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文件?