Error creating raw sockets

I am trying to create a packet sniffer and for this I need to create a raw socket first. I run the code to see if I can create a raw socket first.

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_RAW)

      

However, when running the code, my interpreter gets caught in an error.

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    s = socket.socket(socket.AF_INET, socket.SOCK_RAW)
  File "C:\Python\Python35\lib\socket.py", line 134, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

      

It looks like my operating system, which is window 10, will not let me create raw sockets. How can I fix this without using another type of operating system? Note: I am using python 3.6.0

+3


source to share


1 answer


Creating raw sockets requires elevated privileges. On Windows with UAC users enabled, run programs in unprivileged mode by default.



You can grant administrative privileges to your script if you run it from the Windows command prompt and select the "Run as administrator" option.

+1


source







All Articles