Skip to content

Instantly share code, notes, and snippets.

@anch0vy
Created January 17, 2015 18:49
Show Gist options
  • Select an option

  • Save anch0vy/ebeaf88599c8042ab969 to your computer and use it in GitHub Desktop.

Select an option

Save anch0vy/ebeaf88599c8042ab969 to your computer and use it in GitHub Desktop.
import socket
import os
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP)
if os.name=='nt':
HOST = socket.gethostbyname(socket.gethostname())
s.bind((HOST, 0))
s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
s.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
while True:
RawPacketData,(ip,port)=s.recvfrom(65565)
print ip,port
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment