ERROR 10043 - Protocol not configured in system

Asked

Viewed 64 times

0

Hello! I’m trying to create a script that monitors the network, I’m trying to learn so if there’s something wrong I’m sorry.

The code I have

import socket
import struct
import binascii

s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.htonl(3))

while True:
    packet = s.recvfrom(2048)
    ethernet_header = packet[0][0:14]
    eth_header = struct.unpack('!6s6s2s', ethernet_header)
    print('Mac de Destino: ', binascii.hexlify(eth_header[0]), ' Source Mac: ', binascii.hexlify(eth_header[1]), ' Type: ', binascii.hexlify(eth_header[2]))
    ipheader = packet[0][14:34]
    ip_header = struct.unpack('!12s4s4s', ipheader)
    print('Source IP: ', socket.inet_ntoa(ip_header[1]), ' IP de Destino: ', socket.inet_ntoa(ip_header[2]))

The error I’m getting is:

Oserror: [Winerror 10043] The requested protocol was not configured in the system or there is no implementation for it

  • 1

    Ped, good morning! It looks like you’re trying to access something that doesn’t exist for S.What you’re using. Do a search on Npcap and Scapy. Ncap gives Windows the ability to sniffing packages and scapy is used to work with ncap + python. Hug!

1 answer

1

Expensive,

By mistake [WinError 10043], I believe you are running the code on Windows.

See in the source code of socket.py line 133 refers to this error. It is within the if that checks if the system is Windows (line 111).

It is possible that it is not possible to "sniff" the network with the socket using Windows, but I am sure it is possible to do it with Linux.

Your code seems correct, but before testing it on Linux, I suggest running it as an administrator on Windows.

Note: The @Imonferrari suggestion is good and can save you a headache.

I hope it helps.

  • I managed to fix it, vlw!! And sorry for the delay to answer.

  • Oops! Nice of you. Put the solution here to help other people.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.