Generate Custom Combos Wordlist in Python

2022-05-18

When we need to fuzz or brute force the website (of course you must have the authority for that…), we should use some wordlists or combos.

Regarding wordlists, it is enough to use SecLists in most cases.
But when combolists like “username:password” are required at time, we may have to create them ourselves.

That’s why I write how to generate the custom combolist you want in thie post.

If you would like to generate it quickly, please use my combo generator.


Prepare two wordlists

First, create a new directory and prepare two wordlists, usernames.txt and passwords.txt.

1
2
3
mkdir combo_generator
cd combo_generator
touch usernames.txt passwords.txt

For example, here are the contents of each wordlist.

usernames.txt:

1
2
3
admin
bob
john

passwords.txt:

1
2
3
4
0123456
password
pass1
apple

Create a generator

Next, create a Python file for generating a combolist from two wordlists, usernames.txt and passwords.txt.

1
touch generator.py

generator.py:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
WORDLIST_1 = "usernames.txt"
WORDLIST_2 = "passwords.txt"
OUTPUT = "combolist.txt"

# Read the contents of the given wordlists
with open(WORDLIST_1, 'r', errors='replace') as w1:
wordlist_1 = w1.read().splitlines()
with open(WORDLIST_2, 'r', errors='replace') as w2:
wordlist_2 = w2.read().splitlines()

# Generate the custom combos and write it
with open(OUTPUT, 'a') as output:
for a in wordlist_1:
for b in wordlist_2:
combo = a + ':' + b
output.write(combo + "\n")

  • WORDLIST_1, WORDLIST_2: The two wordlists you created.
  • OUTPUT: The name of the output file to be generated as a result.

Run

Check if three files exist in the directory.

1
generator.py    passwords.txt   usernames.txt

If OK, run the generator.py.

1
python3 generator.py

Then, you should see the combolist.txt generated.

combolist.txt:

1
2
3
4
5
6
7
8
9
10
11
12
admin:0123456
admin:password
admin:pass1
admin:apple
bob:0123456
bob:password
bob:pass1
bob:apple
john:0123456
john:password
john:pass1
john:apple