Learn How to Crack a Password With Python Programming

Published on . Written by

Password cracker using Python Ethical hacking project

In recent years ethical hacking has gained huge popularity because of its wide applications. It is used by many organizations to prevent their site from hackers. Before discussing ethical hacking first you need to understand what is hacking.


Skyfi Labs Projects
Hacking is the process of performing malicious activities in a device by gaining unauthorized access using the vulnerabilities found in the system. The malicious activities such as deleting a system file or stealing sensitive information. Mostly hacking is performed illegally without taking permission from the user.

Now, will discuss what is ethical hacking. It is the process of finding the vulnerabilities in a system or device by performing various attacks to resolve those vulnerabilities. Ethical hacking is legal and it is performed after taking permission from the user.

In this ethical hacking project, we are going to use python to create a password cracker which uses a dictionary attack to crack passwords.

Passwords are always hashed before storing in the database and the hash is compared for verification purpose.

Read more..

SLNOTE
Project Implementation:

Let’s start coding:

import hashlib

pass_hash = input(“Enter md5 hash:”)

Now we imported the hashlib library and created a variable which takes the input hash. The next step is to import a file which consists of a bunch of words written into it which is going to act as a dictionary file.

You can download the file from Github which contains a bunch of passwords and it is normally used in the dictionary attack.

But we can also do like this to import the file:

wordlist = input(“Filename”:)


SLLATEST
Here we are going to put the file name and open it using some read permissions.

We are going to use try bock. For that, type the following:

try:

            pass_file = open (wordlist, “r”)

Except:

            print(“No file found”)

            quit()

Let’s write the program to compare the hashes of different words which are found in this file.

for word in pass_file:

            enc_wrd = word.encode(‘utf-8’)

            digest = hashlib.md5(wnc-wrd.strip()).hexdigest()

Now the hash is created the next step is to compare it with all the other sort of hashes.

if digest == pass_hash:

            print(“Password found”)

            print(“password is “ + word)

flag=1

break

If the hash matches with the word it will print the password and breaks the loop. This will happen only if the password is found in the list. So for the other way we need to create a flag which says 1.

if flag == 0:

print(“password/passphrase is not in the list”)

If the flag is still set to 0 after checking the whole list the above line will be printed. Now our code is ready. Save the program and run it.

To run the program open command prompt in the file location and start the program give the hash name and the dictionary file name. Now the program will start comparing the list and displays you the password.

Also, try giving the wrong hash file which will give the output as no password found. This project is for learning purpose only never misuse it.


SLDYK
Kit required to develop Learn How to Crack a Password With Python Programming:
Technologies you will learn by working on Learn How to Crack a Password With Python Programming:


Any Questions?


Subscribe for more project ideas