pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg/55446 (scapy function send() does not work)



On 07/06/20 01:25, David H. Gutteridge wrote:
> The following reply was made to PR pkg/55446; it has been noted by GNATS.
>
> From: "David H. Gutteridge" <david%gutteridge.ca@localhost>
> To: gnats-bugs%netbsd.org@localhost
> Cc: 
> Subject: Re: pkg/55446 (scapy function send() does not work)
> Date: Sun, 05 Jul 2020 18:24:07 -0400
>
>  I hadn't had occasion to try interacting with a loopback device with
>  Scapy before, but I borrowed that example from the Scapy test suite
>  (where it recorded a pass for me on NetBSD 8.1 when I ran it while
>  doing the last package update), but, the difference is, their test
>  example targets the IP address "8.8.8.8".

I tried "8.8.8.8", the result was:

# scapy 
INFO: Can't import matplotlib. Won't be able to plot.
INFO: Can't import PyX. Won't be able to use psdump() or pdfdump().
INFO: No IPv6 support in kernel
WARNING: No route found for IPv6 destination :: (no default route?)
INFO: Can't import python-cryptography v1.7+. Disabled WEP decryption/encryption. (Dot11)
INFO: Can't import python-cryptography v1.7+. Disabled IPsec encryption/authentication.
WARNING: IPython not available. Using standard Python shell instead.
AutoCompletion, History are disabled.
                                      
                     aSPY//YASa       
             apyyyyCY//////////YCa       |
            sY//////YSpcs  scpCY//Pp     | Welcome to Scapy
 ayp ayyyyyyySCP//Pp           syY//C    | Version git-archive.dev304758016
 AYAsAYYYYYYYY///Ps              cY//S   |
         pCCCCY//p          cSSps y//Y   | https://github.com/secdev/scapy
         SPPPP///a          pP///AC//Y   |
              A//A            cyP////C   | Have fun!
              p///Ac            sC///a   |
              P////YCpc           A//A   | Craft me if you can.
       scccccp///pSP///p          p//Y   |                   -- IPv6 layer
      sY/////////y  caa           S//P   |
       cayCyayP//Ya              pY/Ya
        sY/PsY////YCc          aC//Yp 
         sc  sccaCY//PCypaapyCP//YSs  
                  spCPY//////YPSps    
                       ccaacs         
                                      
>>> sendp(IP(dst="8.8.8.8")/ICMP()/"test"
... help
  File "<console>", line 2
    help
       ^
SyntaxError: invalid syntax
>>> 

I realized that something went wrong.

> Anyway, you'll want to have a
>  look at the following link in the Scapy documentation:
>  
>  https://scapy.readthedocs.io/en/latest/troubleshooting.html#i-can-t-ping-127-0-0-1-scapy-does-not-work-with-127-0-0-1-or-on-the-loopback-interface

I tried the above, the result was:

# scapy
INFO: Can't import matplotlib. Won't be able to plot.
INFO: Can't import PyX. Won't be able to use psdump() or pdfdump().
INFO: No IPv6 support in kernel
WARNING: No route found for IPv6 destination :: (no default route?)
INFO: Can't import python-cryptography v1.7+. Disabled WEP decryption/encryption. (Dot11)
INFO: Can't import python-cryptography v1.7+. Disabled IPsec encryption/authentication.
WARNING: IPython not available. Using standard Python shell instead.
AutoCompletion, History are disabled.
                                      
                     aSPY//YASa       
             apyyyyCY//////////YCa       |
            sY//////YSpcs  scpCY//Pp     | Welcome to Scapy
 ayp ayyyyyyySCP//Pp           syY//C    | Version git-archive.dev304758016
 AYAsAYYYYYYYY///Ps              cY//S   |
         pCCCCY//p          cSSps y//Y   | https://github.com/secdev/scapy
         SPPPP///a          pP///AC//Y   |
              A//A            cyP////C   | Have fun!
              p///Ac            sC///a   |
              P////YCpc           A//A   | Wanna support scapy? Rate it on
       scccccp///pSP///p          p//Y   | sectools!
      sY/////////y  caa           S//P   | http://sectools.org/tool/scapy/
       cayCyayP//Ya              pY/Ya   |             -- Satoshi Nakamoto
        sY/PsY////YCc          aC//Yp    |
         sc  sccaCY//PCypaapyCP//YSs  
                  spCPY//////YPSps    
                       ccaacs         
                                      
>>> conf.L3socket
<L3bpfSocket: read/write packets using BPF>
>>> conf.L3socket=L3RawSocket
>>> conf.L3socket
<L3RawSocket: Layer 3 using Raw sockets (PF_INET/SOCK_RAW)>
>>> p=IP(dst="127.0.0.1")/ICMP()/"test"
>>> p.show2()
###[ IP ]### 
  version= 4
  ihl= 5
  tos= 0x0
  len= 32
  id= 1
  flags= 
  frag= 0
  ttl= 64
  proto= icmp
  chksum= 0x7cda
  src= 127.0.0.1
  dst= 127.0.0.1
  \options\
###[ ICMP ]### 
     type= echo-request
     code= 0
     chksum= 0x1026
     id= 0x0
     seq= 0x0
###[ Raw ]### 
        load= 'test'

>>> send(p)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/pkg/lib/python3.7/site-packages/scapy/sendrecv.py", line 316, in send
    socket = socket or conf.L3socket(*args, **kargs)
  File "/usr/pkg/lib/python3.7/site-packages/scapy/supersocket.py", line 150, in __init__
    self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(type))  # noqa: E501
AttributeError: module 'socket' has no attribute 'AF_PACKET'

>  Separately...
>  
>  >I'd like to clarify the environment of the bug:
>  >(1) I have no active Ethernet or SLIP interfaces;
>  >(2) I have active Wi-Fi and tun interfaces.
>  >
>  >According to the "man 4 bpf": "A packet can be sent out on the network
>  >by writing to a bpf file descriptor. The writes are unbuffered, meaning
>  >only one packet can be processed per write. Currently, only writes to
>  >Ethernets and SLIP links are supported."
>  
>  I think there may be a documentation issue or two there. That last
>  statement is perhaps outdated (I haven't checked in detail), and refers
>  to writes to a link layer which Wi-Fi devices also use. (Note your
>  tcpdump output states your iwi0 device's "link-type" is "Ethernet".)
>  
>  From looking at Scapy commits, it seems NetBSD 8 was the release they
>  developed against. So generally we should expect at minimum it's more
>  likely to work on 8.x than newer releases.
>  
>  I don't use Scapy much; I was using bits of it before for specific
>  purposes, but not most of its functionality, so issues with it haven't
>  been a priority for me to chase. I think in this case some of this
>  issue is better directed to the Scapy project. (I will look into the
>  bpf documentation aspect.)
>  
>  Dave

OK. I'll write to the Scapy project.


--
Alexei


Home | Main Index | Thread Index | Old Index