1
我发现了很多捕获数据包并从pcap文件中读取数据的例子。但没有任何例子可以捕获数据包并将其转储到pcap中。使用Pcapy将数据包保存到pcap文件
我用下面的代码here:
import pcapy
from impacket.ImpactDecoder import *
# list all the network devices
pcapy.findalldevs()
max_bytes = 1024
promiscuous = False
read_timeout = 100 # in milliseconds
pc = pcapy.open_live("name of network device to capture from", max_bytes, promiscuous, read_timeout)
pc.setfilter('tcp')
# callback for received packets
def recv_pkts(hdr, data):
packet = EthDecoder().decode(data)
print packet
packet_limit = -1 # infinite
pc.loop(packet_limit, recv_pkts) # capture packets
任何IDEIA转储捕获的数据包到一个PCAP文件?