2017-03-07 54 views

回答

5
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)