Python for ethical hacking: Develop Pentesting Tools

AB

[!!] 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 .

https://raw.githubusercontent.com/Biddy79/eclipse_python/master/sniffers_flooders_spoofers/mac_sniffer.py

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:
https://stackoverflow.com/questions/39103164/ord-function-in-python2-7-and-python-3-4-are-different

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

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

Now all works well.

Thanks Hackerspolit