Skip to content

Exception: tcpdump is not available #2223

@imperio-wxm

Description

@imperio-wxm

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions