-
Notifications
You must be signed in to change notification settings - Fork 3
/
wordlist_gen.py
59 lines (40 loc) · 1.78 KB
/
wordlist_gen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import os
import sys
import string
import argparse
import itertools
from datetime import datetime
def wordlist(chrs, min_length, max_length, output):
if min_length > max_length:
print("[+] min_length value Should be small or same as max_length")
sys.exit()
if os.path.exists(os.path.dirname(output)) == False:
os.makedirs(os.path.dirname(output))
print("\n")
print("[+] creating a wordist at %s " %output)
start_time = datetime.now()
print ('[+] Starting at : %s' % start_time)
output = open(output,'w')
for n in range(min_length, max_length+1):
for xs in itertools.product(chrs, repeat=n):
chars = ''.join(xs)
output.write("%s\n" % chars)
sys.stdout.write('\r[+] saving character `%s`' % chars)
sys.stdout.flush()
output.close()
end_time = datetime.now()
print ('\n[+] Ended at : %s' % end_time )
print ('\n[+] Total Duration : {}\n'.format(end_time - start_time))
def main():
parser = argparse.ArgumentParser(description='Python Wordlist Generator')
parser.add_argument('-chr','--chars',default=None, help='characters to iterate')
parser.add_argument('-min','--min_length', type=int,default=1, help='minimum length of characters')
parser.add_argument('-max','--max_length', type=int,default=2, help='maximum length of characters')
parser.add_argument('-out','--output',default='output/wordlist.txt', help='output of wordlist file.')
args = parser.parse_args()
if args.chars is None:
os.system('python wordlist_gen.py -h')
else:
wordlist(args.chars, args.min_length, args.max_length, args.output)
if __name__ == "__main__":
main()