Skip to content

Instantly share code, notes, and snippets.

@kjseefried
Created July 15, 2014 01:15
Show Gist options
  • Save kjseefried/9a3d0d0dd7428777f9e3 to your computer and use it in GitHub Desktop.
Save kjseefried/9a3d0d0dd7428777f9e3 to your computer and use it in GitHub Desktop.
Example of using scapy+gobject to sniff packets.
import gobject
from scapy.all import *
loop = gobject.MainLoop()
ethernet1 = conf.L2listen(type=ETH_P_ALL, iface='eth0')
def ethernet1_handler(packet):
return packet.summary()
def doTheSniff(source, condition):
print "Worked"
return sniff(prn=ethernet1_handler, store=0, count=1)
gobject.io_add_watch(ethernet1, gobject.IO_IN, doTheSniff or True)
loop.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment