Loganinit / python-zaid

Ethical hacking python scripts developed based on the course Python & Ethical Hacking From Scratch by Zaid Sabih
129 stars 95 forks source link

Python 3 support #5

Open nikhildr22 opened 3 years ago

nikhildr22 commented 3 years ago

I can contribute in converting these to python 3

red-rhett commented 3 years ago

I can contribute in converting these to python 3

Hi, I need some help with regex in python3 - in python2 I'm getting the right result from code input (e.g. line 53 https://github.com/Loganinit/python-zaid/blob/master/1%20mac_changer/macchanger-9.py)

current_mac = re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w",ifconfig_result)

but I cannot find the correct input for python3. Can you help? I've tried flags options etc

The error includes

TypeError: cannot use a string pattern on a bytes-like object"

Thanks!

nikhildr22 commented 3 years ago

Hey, subprocess.check_output(["ifconfig",interface]) returns raw data in bytes. You can use a byte method called decode( ) to convert the byte to string before using regex. i've made the changes for you in my forked repo.. https://github.com/nikhildr22/python-zaid/blob/master/1%20mac_changer/macchanger-9.py

red-rhett commented 3 years ago

Hey, subprocess.check_output(["ifconfig",interface]) returns raw data in bytes. You can use a byte method called decode( ) to convert the byte to string before using regex. i've made the changes for you in my forked repo.. https://github.com/nikhildr22/python-zaid/blob/master/1%20mac_changer/macchanger-9.py

That's amazing, and such a simple solution. Thank you!

nikhildr22 commented 3 years ago

im rewriting every one of these files for python 3 support, feel free to ping me if something comes up

red-rhett commented 3 years ago

im rewriting every one of these files for python 3 support, feel free to ping me if something comes up

Hello nikhildr22, and thanks again for updating the Ch1 sections. Zaid's videos (Udemy and O'Reilly) and code are really an EXCELLENT source, but the course's reliance on Python 2.7 is no longer relevant, since 2.7 entered end of life this year. It appears that at each step I am encountering issues in conversion. I have an email on which you can contact me (see profile), and that way I can be more specific.

Thanks!

ChongChink commented 2 years ago

use python pip module 2to3 to convert python2 files to python3 files example: suppose the keylogger works with python2 so u run 2to3 -w keylogger.py (this will convert the existing file to python3 and will create a backup file - keylogger.bak)