Anyone have a solution when using scapy to grab the tcp syn flags and store the source ip, destination ip, port number in a dictionary? I'm trying to build a tool that will take a pcap file and get that
This is what I've tired:
from scapy.all import PcapReader, TCP
from collections import Counter
count = Counter()
for pkt in PcapReader("testcapture.pcapng"):
if TCP in pkt and pkt[TCP].flags & 2: # TCP SYN packet
src = pkt.sprintf('{IP:%IP.src%}')
pkt.sprint
count[src] += 1
print(src)
This finds all the ips with syn flag, but i want to see port number