-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Description
- Linux version 2.6.32-431.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) Windows: use Winpcap, drop DNET dependency #1 SMP Fri Nov 22 03:15:09 UTC 2013
- Python 2.7.11
- scapy 2.4.3
- tcpdump-4.0.0-11.20090921gitdf3cb4.2.el6.x86_64
MyCode:
#!/usr/bin/python
#coding:utf-8
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
from scapy.all import *
def pack_callback(packet):
line = raw(packet[TCP].payload)
if len(line) != 0 and line.strip() != '':
print(line)
if __name__ == '__main__':
dpkt = sniff(filter='ip dst xx.xx.xx.xx and tcp and tcp port xxx',iface='eth1',prn=pack_callback, count=0)
Get Error
File "/usr/local/Python-2.7.11/lib/python2.7/site-packages/scapy/sendrecv.py", line 972, in sniff
sniffer._run(*args, **kwargs)
File "/usr/local/Python-2.7.11/lib/python2.7/site-packages/scapy/sendrecv.py", line 842, in _run
*arg, **karg)] = iface
File "/usr/local/Python-2.7.11/lib/python2.7/site-packages/scapy/arch/linux.py", line 475, in __init__
attach_filter(self.ins, filter, iface)
File "/usr/local/Python-2.7.11/lib/python2.7/site-packages/scapy/arch/linux.py", line 160, in attach_filter
bp = compile_filter(bpf_filter, iface)
File "/usr/local/Python-2.7.11/lib/python2.7/site-packages/scapy/arch/common.py", line 165, in compile_filter
raise Scapy_Exception("tcpdump is not available. Cannot use filter !")
scapy.error.Scapy_Exception: tcpdump is not available. Cannot use filter !
Exception socket.error: error(99, 'Cannot assign requested address') in <bound method L2ListenSocket.__del__ of <scapy.arch.linux.L2ListenSocket object at 0x7f2dec32ef90>> ignored
The exception is: tcpdump is not available. Cannot use filter
However, tcpdump is already installed on the machine.
tcpdump -v
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
6 packets captured
597 packets received by filter
561 packets dropped by kernel