Last active
September 14, 2016 17:10
-
-
Save dwallraff/0100efe2f3004498bfd9b37b8b737ba8 to your computer and use it in GitHub Desktop.
Use python to tcpump (outputs PCAP)
This file contains hidden or 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,socket,struct,time | |
sys.stdout.write(struct.pack('!IHHIIII',0xa1b2c3d4,2,4,0,0,65535,1)) | |
s=socket.socket(socket.PF_PACKET, socket.SOCK_RAW, socket.htons(0x3)) | |
while True: | |
t,p=time.time(),s.recvfrom(65535) | |
ts=int(t) | |
tu=int((t-ts)*1000000) | |
sys.stdout.write(struct.pack('!IIII',ts,tu,len(p[0]),len(p[0]))+p[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment