Created
July 26, 2016 06:43
-
-
Save Yi-Tseng/6434e34d3d0f2883b5c508e279a0a88d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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