How can I generate a wordlist like Crunch using Python? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

How can I generate a wordlist like Crunch using Python?

I would like to generate a wordlist like the ones generated by the Linux app "Crunch" where all the characters in the wordlist are from a character set (eg. "[a-zA-Z0-9]) and ranges from one character word up to n (n is user's input). Example: $ python3 words.py "abc" 3 # words.py is the script, "abc" is the character set, 3 is max character for each word (i.e. n) Expected Output: a aa ab ac aaa aab aac aba abb abc [...] b ba bb bc baa bab bac bba bbb [...] And so on up to 'ccc'....

31st Oct 2017, 5:03 PM
Chuma Umenze
3 Réponses
+ 3
import itertools print(list(map("".join, itertools.product('abc', repeat=3))))
31st Oct 2017, 5:10 PM
Witty Phantom
Witty Phantom - avatar
+ 1
Thanks. This will do fine Marking it as best answer. One more thing... any idea how to implement this in C?
31st Oct 2017, 5:32 PM
Chuma Umenze
0
Sorry man, got 0 experience in C but surely if you search on Google you'll find an answer.
31st Oct 2017, 5:39 PM
Witty Phantom
Witty Phantom - avatar