一旦我过滤掉所有NBNS流量,我就会尝试写入pcap文件。这给了我一个语法错误。
from scapy.all import *
Capture = raw_input("Enter file path of pcap file: " )
pcap = rdpcap(Capture)
ports=137
filtered = (pkt for pkt in Capture if
(UDP in pkt and
(pkt[UDP].sport in str(ports)))
wrpcap("filtered.pcap",filtered)
Run Code Online (Sandbox Code Playgroud)
我发现语法错误的答案只是结尾处缺少括号,...str(ports))))但现在我遇到了另一个错误。
File "receiver2.py", line 18, in <module>
wrpcap("filtered.pcap",filtered)
File "/usr/lib/python2.7/dist-packages/scapy/utils.py",
line 470, in wrpcap
PcapWriter(filename, *args, **kargs).write(pkt)
File "/usr/lib/python2.7/dist-packages/scapy/utils.py", line 652, in write
for p in pkt:
File "receiver2.py", line 13, in <genexpr>
(UDP in pkt and
TypeError: 'in <string>' requires string as …Run Code Online (Sandbox Code Playgroud)