Python for ethical hacking: Develop Pentesting Tools


[!!] Error on creating socket object PLEASE HELP !!!

I am working through the Python for ethical hacking course on udemy
The tutorial is to create a mac sniffer (section 6 tutorial 35)

I am receiving [!!] Error on creating socket object from the try: except: statement within my code each time I run ./

I have chmod+x to make it an executable and am running this with sudo privileges.

Below is a link to my code. I have heavily commented it to help me understand it better but please do correct me if I have misunderstood .

Thank you.

This issue as bee resolved by Hackerspolit on udemy.
It seems I had made rookie mistake and need to install full socket module
with pip3 install sockets.
I still had further problems when running this script due to ord() function.
I believe this was due to:

Python 3 the sock.recvfrom(...) call returns bytes while Python 2.7 recvfrom returns a string. So ord did not change but what is being passed to ord has changed.

More on this here:

I removed ord() function in eth_addr() and printed like this:

mac_address = “%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:” % ((mac_char[0]),

Now all works well.

Thanks Hackerspolit