【发布时间】:2016-05-25 23:29:20
【问题描述】:
我找到了很多示例来捕获数据包并从 pcap 文件中读取。但是根本没有示例来捕获数据包并将它们转储到 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
有什么想法可以将捕获的数据包转储到 pcap 文件中吗?
【问题讨论】: