Skip to content

Instantly share code, notes, and snippets.

@waderwu
Created May 9, 2020 09:05
Show Gist options
  • Save waderwu/12606262f42d70ff08a37f7f3ebbbc74 to your computer and use it in GitHub Desktop.
Save waderwu/12606262f42d70ff08a37f7f3ebbbc74 to your computer and use it in GitHub Desktop.
ping icmp shell
#!/usr/bin/env python3
import socket
def listen():
s = socket.socket(socket.AF_INET,socket.SOCK_RAW,socket.IPPROTO_ICMP)
s.setsockopt(socket.SOL_IP, socket.IP_HDRINCL, 1)
res = b""
while 1:
data, addr = s.recvfrom(1508)
#print(data)
#print("Packet from %r: %r" % (addr,data))
if addr[0] == '134.175.230.10' or addr[0] == '116.228.202.178':
#print(data)
#print(addr[0])
res += data[44:60]
print(res)
if __name__ == "__main__":
listen()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment