Python is a very powerful language. It is very effective for testing, so Python is becoming more and more popular.
So in this tutorial I'll talk about how to build a dictionary in Python and use it for whatever purpose you want.
Prerequisite Requirements
1,python 2.7 (for Python 3.x version basically the same, you just need to make some minor adjustments)
2,peace of mine (the author of a joke, this is a song name)
If you use virtualenv to build a python development environment, make sure that you have installed Itertools. Because we're going to use Itertools to generate a dictionary. We'll show you the whole process step-by-step, so follow this article and don't just copy and paste all the code.
Generating dictionaries
Create a new file named "dicgen.py" and open it with your most handy text editor.
First we're going to call Itertools.
I used the itertools as ITR, so I can play less words. After calling the Itertools, we go to the next step.
We need to select some keywords to form some combination to generate the desired dictionary. Give these keywords to the method provided by Itertools to generate the dictionary.
Finding the right keyword requires some tips. For example, I forgot a file password (. php) used to manage the server. I need to enter a user name and password to open this file before I can make changes to my server. I also forgot the login information for cpanel. So I decided to brute force password. I remember the user name, but the password was not very clear, and I tried all the combinations manually but were not correct. So I wrote a script in Python to generate a password and log in. I have some clues to the password on hand, such as it is six bits in length, is only a combination of letters, does not contain numbers or special symbols.
Let's go back to the tutorial. Suppose you want to generate a six-bit length with a letter-only password (mixed case).
We'll explain this code at 1.1.
The words variable is the character we want to try in the password. In this case, these characters are uppercase and lowercase letters in the alphabet. So we've added all the uppercase and lowercase letters here.
Itr.product (words, repeat=6) is the most important part of this code, returning the selected list from the given alphabet. Because the password length in this example is six bits, it is set to repeat 6 times (repeat=6) here.
We loop through the process 6 times to make sure that each alphabetical list is added to the master list.
Let's put all the generated passwords into a list and see how many combinations we can have. But don't run it now, or your computer may crash.
We recommend that you use it immediately after the password is generated, or store it in a document. It's just a basic. In the next tutorial, we will learn more about how to generate passwords more efficiently based on our needs.
The following is the complete code.
Reference URL: python.freelycode.com
Use Python to automatically generate brute-force dictionary