import pyshark
pkts = pyshark.FileCapture("test.pcap")
for p in pkts:
print
I am trying to print all destination ports and source ports in the PCAP file. How could I do it?
import pyshark
pkts = pyshark.FileCapture('cap.pcap')
for p in pkts:
if hasattr(p, 'tcp'):
print(p.tcp.srcport + ' -- ' + p.tcp.dstport)
if hasattr(p, 'udp'):
print(p.udp.srcport + ' -- ' + p.udp.dstport)