aaveg
aaveg

Reputation: 1874

scapy: error sending packets

I am new to scapy and I am following some online tutorial, but I am stuck at this problem. I am able to send packets through a wired connection but when I try this with wireless, I face this error. I tried searching google but it was of no help. I hope to find a solution. Thanks in advance.

I am using windows 8.1, python 2.7

>>> p=IP(dst="192.168.1.1")/ICMP()
>>> sr1(p)
Begin emission:
ERROR: --- Error sending packets
Traceback (most recent call last):
  File "c:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 374,
 in sndrcv
    pks.send(p)
  File "c:\Python27\lib\site-packages\scapy\arch\pcapdnet.py", line 257, in send

    sx = str(cls()/x)
  File "c:\Python27\lib\site-packages\scapy\packet.py", line 268, in __str__
    return self.build()
  File "c:\Python27\lib\site-packages\scapy\packet.py", line 330, in build
    p = self.do_build()
  File "c:\Python27\lib\site-packages\scapy\packet.py", line 319, in do_build
    pkt = self.self_build()
  File "c:\Python27\lib\site-packages\scapy\packet.py", line 310, in self_build
    p = f.addfield(self, p, val)
  File "c:\Python27\lib\site-packages\scapy\fields.py", line 70, in addfield
    return s+struct.pack(self.fmt, self.i2m(pkt,val))
  File "c:\Python27\lib\site-packages\scapy\layers\l2.py", line 95, in i2m
    return MACField.i2m(self, pkt, self.i2h(pkt, x))
  File "c:\Python27\lib\site-packages\scapy\layers\l2.py", line 89, in i2h
    x = conf.neighbor.resolve(pkt,pkt.payload)
  File "c:\Python27\lib\site-packages\scapy\layers\l2.py", line 38, in resolve
    return self.resolvers[k](l2inst,l3inst)
  File "c:\Python27\lib\site-packages\scapy\layers\inet.py", line 732, in <lambd
a>
    conf.neighbor.register_l3(Ether, IP, lambda l2,l3: getmacbyip(l3.dst))
  File "c:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 292,
 in getmacbyip
    ifip = str(pcapdnet.dnet.intf().get(iff)['addr'])
KeyError: 'addr'
INFO: --- Error sending packets
.........................
Received 25 packets, got 0 answers, remaining 1 packets
WARNING: __del__: don't know how to close the file descriptor. Bugs ahead ! Plea
se report this bug.

Upvotes: 2

Views: 5619

Answers (4)

CyTex
CyTex

Reputation: 119

I've update my scapy to the dev version (https://github.com/secdev/scapy/), and then it's working properly.

Upvotes: 0

multithr3at3d
multithr3at3d

Reputation: 548

In case anybody else has issues with getmacbyip() timing out before it can resolve a MAC, here's a band-aid fix that works:

mac = None
while not mac:
    mac = getmacbyip(ipaddr)

getmacbyip() will return None if it doesn't resolve. This works, but it will still take a few seconds. I wish this wasn't necessary to make it work.

Upvotes: 0

lukas kiss
lukas kiss

Reputation: 392

I find solution ;}

Just edit c:\Python27\lib\site-packages\scapy\arch\windows__init__.py Like this:

  1. Delete c:\Python27\lib\site-packages\scapy\arch\windows__init__.pyc
  2. Change line get(iff)['addr']) to get(iff)['link_addr'])

Upvotes: 2

FitzChivalry
FitzChivalry

Reputation: 339

Slightly late, but:

I ran into the same problem a few months ago, and what worked for me eventually was to tunnel the WiFi through another network interface. It seems that the problem is in the IP obtaining process; Maybe you should try to run as administrator, and set the features of both Python and the Scapy files so that they have full control (right click->Properties->Security).

Do you encounter the same problem while using other methods like send/sr/srp?

Upvotes: 3

Related Questions