Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error creating raw sockets

I'm trying to create a packet sniffer and in order to do that I need to first create a raw socket. 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 upon running the code my interpreter hits 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

So apparently my operating system which is a windows 10 wont allow me to create raw sockets.How do I fix this without using another type of operating system?Note: I'm using python 3.6.0


1 Answers

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

You can give administrative privileges to your script if you run it on windows command prompt and select the "Run as administrator" option.

like image 57
t.m.adam Avatar answered Nov 26 '25 11:11

t.m.adam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!