acav9
acav9

Reputation: 31

Can't import layer xxx: name arp_display is not defined Python

I have a problem this simple code that one day stopped working and any other scapy involved code brings me a similar error(cant import layer(the layer im trying to use,arp,tcp..) and the function name)

this is the code:

from scapy.all import *
def arp_display(pkt):
    if pkt[ARP].op == 1: #who-has (request)
        return "Request: " + pkt[ARP].psrc + " is asking about " + pkt[ARP].pdst
    if pkt[ARP].op == 2: #is-at (response)
        return "*Response: " + pkt[ARP].hwsrc + " has address " + pkt[ARP].psrc
print sniff(prn=arp_display, filter="arp", store=0, count=1500)

this is the error:

WARNING: No route found for IPv6 destination :: (no default route?)

WARNING: can't import layer inet: name 'arp_display' is not defined

WARNING: can't import layer dhcp: name 'arp_display' is not defined

WARNING: can't import layer dns: name 'arp_display' is not defined

WARNING: can't import layer gprs: name 'arp_display' is not defined

WARNING: can't import layer hsrp: name 'arp_display' is not defined

WARNING: can't import layer inet6: name 'arp_display' is not defined

WARNING: can't import layer isakmp: name 'arp_display' is not defined

WARNING: can't import layer l2tp: name 'arp_display' is not defined

WARNING: can't import layer mgcp: name 'arp_display' is not defined

WARNING: can't import layer mobileip: name 'arp_display' is not defined

WARNING: can't import layer netbios: name 'arp_display' is not defined

WARNING: can't import layer ntp: name 'arp_display' is not defined

WARNING: can't import layer ppp: name 'arp_display' is not defined

WARNING: can't import layer rip: name 'arp_display' is not defined

WARNING: can't import layer sebek: name 'arp_display' is not defined

WARNING: can't import layer skinny: name 'arp_display' is not defined

WARNING: can't import layer smb: name 'arp_display' is not defined

WARNING: can't import layer snmp: name 'arp_display' is not defined

WARNING: can't import layer tftp: name 'arp_display' is not defined

WARNING: can't import layer dhcp6: name 'arp_display' is not defined

WARNING: can't import layer llmnr: name 'arp_display' is not defined

WARNING: can't import layer sctp: name 'arp_display' is not defined

WARNING: can't import layer vrrp: name 'arp_display' is not defined

Upvotes: 2

Views: 993

Answers (2)

Yunari
Yunari

Reputation: 1

  1. Go to C:\Python27\Lib\site-packages\scapy\layers and open all.py
  2. Add "from layer-that-you-need-to-add import *" ex) from inet import *

Upvotes: 0

Bob Ebert
Bob Ebert

Reputation: 1401

I just had that problem. I had a few python scripts on my desktop which were about DNS (dns request and dns redirection). When running those, there was a new script with the same name but with the extention pyx (I believe) that was created when running the script. The solution? I deleted the scripts and the ones that were created afterwards (dns_request.py and dns_request.pyx). When running other scripts, the Warnings were gone!

Upvotes: 1

Related Questions