10 lines
486 B
Python
10 lines
486 B
Python
|
|
import socket,struct
|
||
|
|
f=bytearray(180); f[0:4]=b"ENet"
|
||
|
|
struct.pack_into("<I",f,4,1); struct.pack_into("<H",f,0x0A,31772)
|
||
|
|
f[0x12]=1; struct.pack_into("<H",f,0x14,180); struct.pack_into("<H",f,0x18,1)
|
||
|
|
s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM); s.settimeout(5); s.bind(("192.168.58.7",0))
|
||
|
|
s.sendto(bytes(f),("192.168.58.7",31772))
|
||
|
|
try:
|
||
|
|
d,a=s.recvfrom(2048); print("REPLY",len(d),"from",a,"ip_rev",d[0x41:0x45].hex(),"name",d[0x1A:0x29])
|
||
|
|
except socket.timeout: print("TIMEOUT")
|