每次写博客都是源于纳闷,python解析pcap这么常用的例子网上竟然没有,全是一堆命令行执行的python,能用吗?玩呢?
pip安装scapy,然后解析pcap:
import scapy
from scapy.all import *
from scapy.utils import PcapReader
packets=rdpcap(./test.pcap)
for data in packets:
if 'UDP' in data:
s = repr(data)
print(s)
print(data['UDP'].sport)
break
打