Python Wordlist for Brute Force Password Cracking
Hi Medium !
Use this only for Education purpose not for harming someone’s privacy.
This article will let you create a General password list which can be used in any password cracking attack .
Lets jump into the code →
Libraries →
itertools → used for efficient and simple looping
string → to use string functions
time → to get time
Function →
def password_wordlist(start_range=8,end_range=10,file_name="brute.txt"):
It takes up 3 arguments →
start_range → Potential length of your password
Now lets assume you are brute forcing for wifi and you know the length can extend from 8 to bigger numbers
end_range → Max potential length the password could have
file_name → file name to save the generated passwords
Above code will create all passwords of length 8 and 9. If you change start_range to 1 it will create password from length 1 to 9.
chars will give you a string of all the characters that have potential to be in password you can increase or decrease according to need and PRE-Knowledge about the target
attempts → Counter for counting attempts/different passwords it has generated
f = open(file_name,'a')
Above code will open file in Append mode. It will also create a file if you don’t have one with that name.
for password_length in range(start_range, end_range):
Loop in range for defining the different password length you want.
for guess in itertools.product(chars,repeat=password_length):
itertools.product → product(A,B) is similar to ((x,y) for x in A for y in B)
product(‘ABCD’ , repeat=2) → AA,AB,AC,AD …. …. … DC , DD
You can read more about it → https://docs.python.org/3/library/itertools.html#itertools.product
f.write(guess)
f.write(“\n”)
f.close()
Above code will
f.write() → write the password to file and with newline character.
All the passwords generated will be in different lines
f.close() → close the open file
start_range = 8
end_range = 10
file_name = "brute_password_list.txt"
Changing start_range and end_range and chars→
Example → Your friend send you a zip file with password in digits of length between 4–5
So you will need to change only these three parameters
For this case →
start_range = 4
end_range = 5+1
chars = string.digits
start_time = time.time()
password_wordlist(start_range,end_range,file_name)
end_time = time.time()
print(end_time-start_time)
end_time — start_time will give you the execution time for password_list function .
So this was all about code.
Your file will look something like this if you implement the code given at the start →
Hope you enjoyed it. In case of any queries ping me on below links.
As this is a brute force method it may take long time to create file depending upon the length of chars and range of password length.
Please Upvote 👍!
Thank You !