Created
June 30, 2016 19:12
-
-
Save allenluce/f71c89414e4c422102ec5ac8f9c8b966 to your computer and use it in GitHub Desktop.
Simple packet printer for scapy
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
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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment