Skip to content

AttributeError: 'L3WinSocket' object has no attribute 'ins' #4795

Open
@Dobatymo

Description

@Dobatymo

Brief description

Only a minor issue, but it could be confusing for users.

Running the script under Windows without admin raises an exception (as expected) but also has a different problem from a AttributeError in __del__ which make the real problem harder to see (since it's not at the bottom anymore).

Scapy version

2.6.1

Python version

3.13

Operating system

Windows 11 x64

Additional environment information

No response

How to reproduce

Run on Windows without admin

from scapy.all import IP, ICMP, sr1
s = IP(dst="google.com")/ICMP()/"asd"
p = sr1(s)

Actual result

WARNING: No libpcap provider available ! pcap won't be used
WARNING: Dropping unsupported option: filter
WARNING: Dropping unsupported option: nofilter
Traceback (most recent call last):
  File "...\Python313\Lib\site-packages\scapy\arch\windows\native.py", line 100, in __init__
    self.outs = self.ins = socket.socket(
                           ~~~~~~~~~~~~~^
        af,
        ^^^
        socket.SOCK_RAW,
        ^^^^^^^^^^^^^^^^
        socket.IPPROTO_IP,
        ^^^^^^^^^^^^^^^^^^
    )
    ^
  File "...\Python313\Lib\socket.py", line 233, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "...\scapy-no-admin.py", line 3, in <module>
    p = sr1(s)
  File "...\Python313\Lib\site-packages\scapy\sendrecv.py", line 732, in sr1
    ans, _ = sr(*args, **kargs)
             ~~^^^^^^^^^^^^^^^^
  File "...\Python313\Lib\site-packages\scapy\sendrecv.py", line 706, in sr
    s = iface.l3socket(ipv6)(
        promisc=promisc, filter=filter,
        iface=iface, nofilter=nofilter,
    )
  File "...\Python313\Lib\site-packages\scapy\arch\windows\native.py", line 107, in __init__
    raise OSError("Windows native L3 Raw sockets are only "
                  "usable as administrator ! "
                  "Please install Npcap to workaround !")
OSError: Windows native L3 Raw sockets are only usable as administrator ! Please install Npcap to workaround !
Exception ignored in: <function SuperSocket.__del__ at 0x0000046425AF7760>
Traceback (most recent call last):
  File "...\Python313\Lib\site-packages\scapy\supersocket.py", line 305, in __del__
    self.close()
  File "...\Python313\Lib\site-packages\scapy\arch\windows\native.py", line 226, in close
    self.ins.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)
AttributeError: 'L3WinSocket' object has no attribute 'ins'

Expected result

Same traceback but without the lowest Exception ignored in part.

Related resources

Similar older issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions