import os
from scapy.utils import PcapWriter
from scapy.all import *
pktdump = PcapWriter("./result/test.pcap", append=True, sync=True)
for files in os.listdir('.'):
if files.endswith('.pcap'):
pkts = rdpcap('/root/pcap/'+str(files))
ports = [68]
filtered = (pkt for pkt in pkts if UDP in pkt and (pkt[UDP].sport in ports or pkt[UDP].dport in ports))
pktdump.write(filtered)
结果贼尴尬, Out of memory: Kill process 9889 (python) score 782 or sacrifice child Killed process 9889 (python) total-vm:1650728kB, anon-rss:1514964kB, file-rss:0kB
其中有个pcap文件的大小是200M