Skip to content

Instantly share code, notes, and snippets.

@Yi-Tseng
Created July 26, 2016 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yi-Tseng/6434e34d3d0f2883b5c508e279a0a88d to your computer and use it in GitHub Desktop.
Save Yi-Tseng/6434e34d3d0f2883b5c508e279a0a88d to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import struct
from scapy.all import sniff
to_hex = lambda x:" ".join([hex(ord(c)) for c in x])
def handle_pkt(pkt):
pkt = str(pkt)
if(len(pkt) > 30): return
raw_hex = to_hex(pkt)
print "Received %d bytes" % (len(pkt), )
print "Hex data: %s" % (raw_hex, )
print "%s" % (pkt[4:])
print ""
sys.stdout.flush()
def main():
sniff(iface = "eth0", prn = lambda x: handle_pkt(x))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment