How To: Create a Password Dictionary Generating Script with Python

Create a Password Dictionary Generating Script with Python

First of all, I hope the title makes sense. :D Well, this is basically creating a program that can help with dictionary attacks. Generate possible passwords. It pretty much lies in you knowing the person you want to hack.

Story Time

I just like stories :D

Well, I heard about the new series, Mr. Robot from my friend and after seeing 5 minutes of the pilot. I loved it. Stuff he said that I was unfamiliar with or was just rusty with I paused and googled it right away.

Some may not enjoy it that way, but I did, and it was awesome.

Well if you have seen the pilot, you know most of the time he is hacking someone, he uses a dictionary of common things about them. I figured cool, I want one of those, so then I went about my script kiddie-ing and checked online, didn't really find much, and I figured lemme go semi - script kiddie and get someone's code and just copy it and understand it later, that way I can write it myself any time...still nothing.

And that was just getting annoying so I figured I will just have to learn something new and write it myself. I started this as a small project, but then I got carried away(too much actually). The first version is really simple but then the final one I have done is not difficult just a bunch of copy and paste of the

So this version is kinda long but not will try and explain everything as best as i can. If you get bored at some point, sorry...but I think if you stick to the end, it will be worth it. :D

So well here goes...

Step 1: Basic Stuff

Well, this part just imports the modules and defines the arguments for it. I wanted it to look so I decided to use arguments. No more rawinput ...hehehe!!

Image via

So well, the first 2 lines just import the modules obviously.

And now for the long explanation.
Line 4: creates and object of the argparse module(kinda)

Line 5-8: create arguments to receive from the command-line. (I'm sure we have all used arguments before so I won't go much into that!!)

Line 11-13: is a different kinda parser arguments. It lets you choose one out of the group. (You know like if you running a script you can either choose verbose or quiet but not both). Something like that. And the action="store_true" is to show that it contains no data.

Step 2: The Real Code - NoRepeat

This section will contain only the code on the norepeat section, this is where in the code the characters in the passwords do not repeat each other.

Image via

This is not complicated, just a lot of stupid ifs and elses it shouldn't be hard to comprehend. the only part I think I should explain is the itertools.permutations() function(or method or whatever) what it does is make sure that the characters don't repeat(duh!)..well it takes two parameters(or arguments..i got bad programming grammar people!!)

so the first one is the characters themselves and the second one is the length of the characters that will be provided. as you can see the for loop makes it either print or save it in a possible passwords by getting the data in the res(that's where the characters are saved-ish)

Step 3: The Real Code - Repeat

This is the same thing as the NoRepeat except it so a lot more words in your dictionary file hence a better chance of finding the password.

Image via

Pretty much the same as itertools.permutations except with itertools.product it repeats that's all hence therepeat=i and parameters(or arguments..shame on me!!) are the same thing!!

Step 4: Conclusion

I just realized it's a lot like cupp but I didn't like cupp very much. I mean how many people you gonna hack are married...right?! Well I hope this helps. When I was writing this. I was completely tired, so you have to forgive me for been sloppy or for any mistakes both in the code and in the English as well. Also don't forget to ask questions if you got any. And I didn't test it, but it should work all the same. Check out your indentation(those things can be a pain in the ass!)..That's it for now!!!

Happy hacking!!

Romans 6:12 Therefore do not let sin reign in your mortal body,
that you should obey it in its lusts.

Just updated your iPhone? You'll find new features for Podcasts, News, Books, and TV, as well as important security improvements and fresh wallpapers. Find out what's new and changed on your iPhone with the iOS 17.5 update.


So... where is the code? Pastebin?

No, I did it on my computer and just snipped it. But since you asked I can put it on pastebin and upload the link

Thanks you :)

You welcome. Hope it worked for you!

Just a suggestion. Test and debug your code before posting it here.


Hi there, great post Man Wuzi, I was looking for something like this. Maybe you can help me (please).

If I needed the chars to repeat at mostly only 3 times in a row, what would be needed to change in the code?

Or the "- R" option you developed can determine the times a char can be repeted? ("-R 3" for 3 times?)

Just you give you the main idea, I'm trying to make an hex dictionary with a lenght of 10 chars but the words can't have more than 3 equal chars in a row.

For example:
BB2354B976A --- is acceptable
BB2354BB76A --- is acceptable
BBB354B976A --- is acceptable
BBBB54B976A --- not acceptable

Can you (or anyone else) help me out or point in the right direction?

I get what you mean...I think(and I haven't tested this) you can make some kind of a nested for-loop so that it runs through the 3 and you can append that to the rest of it...For example

for alpha in "A", "AA", "AAA":
->for rest in res:
->->print alpha+rest

this is just an example....I hope you understand what I mean. sorry if am not clear enough..and sorry if I took so long.


Ty Man Wuzi, :)

Glad you happy about it :D

I'm ask, if I make wordlist like this 33443344 33445566

Share Your Thoughts

  • Hot
  • Latest