Checking in the infosecaddicts courses, I found this fantastic python code. We often use tools, but, we do not know how these work, so, in this publication we will analyze a python code to decipher passwords that you can edit according to your needs.
Hackers prefer Python because it’s elementary to learn. We will analyze the following code line by line.
In this line of code we import the modules that we will use.
Then we ask what we are receiving, in case the data is incorrect, we show an example of use in the console.
In the next block of code, we save what we receive.
We perform the validation that we can open the file and open it in read mode.
we read a file line by line and create an empty python dictionary
Finally, we will go through the entire archive looking for our hash.
We have already seen the theory, so we go to practice.
wget https://s3.amazonaws.com/infosecaddicts-files/htcrack.pyvi htcrack.py
Add this above contents, save and exit.
$ htpasswd -nd yourname
Enter yourname as the password
$ python htcrack.py joe:aPWqevyejgfsk list.txt