I'm trying to write to a pcap file once I filter out all NBNS traffic. This is giving me a syntax error.
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)
I found the answer for the syntax error was just a missing parenthesis at the end of ...str(ports))))
but now I have a different error.
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 left operand, not Packet_metaclass