Skip to content

Instantly share code, notes, and snippets.

@allenluce
Created June 30, 2016 19:12
Show Gist options
  • Save allenluce/f71c89414e4c422102ec5ac8f9c8b966 to your computer and use it in GitHub Desktop.
Save allenluce/f71c89414e4c422102ec5ac8f9c8b966 to your computer and use it in GitHub Desktop.
Simple packet printer for scapy
from scapy.all import *
INPUTFILE = "rmp.imps"
for pkt in PcapReader(INPUTFILE):
if TCP in pkt:
length = pkt[IP].len-40
if length > 0:
ack = pkt[TCP].ack # Acknowledged sequence number seq = pkt[TCP].seq # Packet sequence number ip_src=pkt[IP].src
ip_dst=pkt[IP].dst
tcp_sport=pkt[TCP].sport
tcp_dport=pkt[TCP].dport
print "%s.%d > %s.%d seq %d ack %d" % (ip_src, tcp_sport, ip_dst, tcp_dport, seq, ack)
print pkt[TCP].payload
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment