-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhcx-genlst
executable file
·259 lines (214 loc) · 7.45 KB
/
hcx-genlst
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#!/usr/bin/env python3
import sys
import argparse
import itertools
import time
from threading import Thread
parser = argparse.ArgumentParser(description='generate a password wordlist from strings (words)')
parser.add_argument('-s', '--string', metavar='word', action="append", type=str, help="append word to word set for generation (can have multiple -s)")
parser.add_argument('-i', '--input', metavar='infile', type=str, help="append every line in file to word set")
parser.add_argument('-o', '--output', metavar='outfile', type=str, help="file to write to (default: stdout)")
parser.add_argument('-v', '--verbose', action='store_true', help="print status")
parser.add_argument('-l', '--lower', action='store_true', help="add lowercase word variation to word set")
parser.add_argument('-u', '--upper', action='store_true', help="add UPPERCASE word variation to word set")
parser.add_argument('-t', '--title', action='store_true', help="add Title word variation to word set")
parser.add_argument('-r', '--reverse', action='store_true', help="reverse string")
parser.add_argument("-1", '--wordint', action='store_true', help="word + int")
parser.add_argument("-2", '--intword', action='store_true', help="int + word")
parser.add_argument("-3", '--intwordint', action='store_true', help="int + word + int")
parser.add_argument('-y', '--year', action='store_true', help="just generate [0](0-100) and years 1800-2025")
parser.add_argument('-m', '--min', metavar='number', default=8, type=int, help="min password len (default: 8)")
parser.add_argument('-c', '--check', action="store_true", help="check if output is unique, don't generate dupes, slower")
parser.add_argument('-d', '--double', action="store_true", help="double mode -- permutate every word in word set len 2 (<str><str>)")
parser.add_argument('-z', '--double_small', action='store_true', help="double mode -- just do (<str1><str1>)")
parser.add_argument('-j', '--double_join', metavar='string', type=str, default="", help="double mode -- join string (<str><join><str>)")
args = parser.parse_args()
if args.verbose:
sys.stderr.write(f"{args}\n")
class Progress:
def __init__(self, current, total, length=25):
self.current = current
self.total = total
self.length = length
self.running = True
self.start_time = time.time()
self.prev_time = self.start_time
self.prev_processed = 0
# Start the thread to display the progress
self.thread = Thread(target=self.run)
self.thread.start()
def run(self):
while self.running:
self.display(self.current)
time.sleep(0.05)
def display(self, current):
elapsed_time = time.time() - self.start_time
time_delta = time.time() - self.prev_time
if elapsed_time == 0:
words_per_sec = 0
else:
words_per_sec = (current - self.prev_processed) / time_delta
# Prevent division by zero
if self.total > 0:
percent_complete = (current / self.total) * 100
else:
percent_complete = 100 # Set to 100% if total is 0
filled_length = int(self.length * percent_complete // 100)
bar = '#' * filled_length + '-' * (self.length - filled_length)
sys.stderr.write(f'\r[{bar}] {percent_complete:.0f}% ({current}/{self.total}) {words_per_sec:.1f} w/s ')
sys.stderr.flush()
self.prev_time = time.time() # Update the time for the next calculation
self.prev_processed = current # Track the last processed word count
def update(self, current):
self.current = current
def stop(self):
self.running = False
self.thread.join()
sys.stderr.write('\n')
def finish(self):
self.current = self.total
self.display(self.current)
self.stop()
#
# get input
#
words = set()
def addword(word):
words.add(word)
# add word variations to list
def wordvari(word):
addword(word)
if args.lower: addword(word.lower())
if args.upper: addword(word.upper())
if args.title: addword(word.title())
if args.reverse: addword(word[::-1].lower())
#addword(word[::-1].upper())
#addword(word[::-1].title())
if args.string:
for i in args.string:
wordvari(i)
if args.input:
if args.verbose:
sys.stderr.write(f"loading file... ")
sys.stderr.flush()
with open(args.input, 'r') as file:
for line in file:
wordvari(line.strip())
words_n = len(words)
if args.verbose:
sys.stderr.write(f"word set length: {words_n}\n")
sys.stderr.flush()
#
# define output
#
if args.output:
out_file = open(args.output, "w")
def write(i):
out_file.write(f"{i}\n")
else:
def write(i):
print(i)
output_uniq = set()
def out_minlen_uniq(i):
if len(i) < args.min:
return
if args.check:
if i in output_uniq:
return
output_uniq.add(i)
write(i)
#
# generation
#
def genlst(word, callback):
# common sufix
sufix = [
"!",
"!!",
"!!!",
".",
"..",
"...",
"@",
"@@",
"@@@",
"#",
"12345",
"123456",
"1234567",
"12345678",
"123456789",
"1234567890",
"12345678910",
"012345",
"0123456",
"01234567",
"012345678",
"0123456789",
"01234567890",
"012345678910",
]
for i in sufix:
callback(word, i)
r = i[::-1]
if r != i:
callback(word, r)
for i in range(0, 10):
callback(word, f"00{i}")
if args.year:
special = [
"123",
"1234",
"31337",
"1337",
"1312",
"3112",
"403",
]
for i in special:
callback(word, i)
r = i[::-1]
if r != i:
callback(word, r)
for i in range(0, 101):
callback(word, str(i))
callback(word, f"0{i}")
for i in range(1800, 2025): #2024
callback(word, str(i))
else:
for i in range(0, 10001): #10000
callback(word, str(i))
callback(word, f"0{i}")
def wordnum():
# just print word variations
for i in words:
out_minlen_uniq(i)
if args.verbose:
progress = Progress(current=1, total=words_n)
# word + nums
for x, i in enumerate(words):
if args.verbose: progress.update(x+1)
if args.wordint: genlst(i, lambda w, n: out_minlen_uniq(w + n))
if args.intword: genlst(i, lambda w, n: out_minlen_uniq(n + w))
if args.intwordint: genlst(i, lambda w, n: out_minlen_uniq(n + w + n))
if args.verbose:
progress.finish()
def namename():
for i in words:
out_minlen_uniq(i + args.double_join + i)
if not args.double_small:
if args.verbose:
l = words_n * (words_n - 1)
progress = Progress(current=1, total=l)
for x, (str1, str2) in enumerate(itertools.permutations(words, 2)):
if args.verbose: progress.update(x+1)
out_minlen_uniq(str1 + args.double_join + str2)
if args.verbose:
progress.finish()
if args.double:
namename()
else:
wordnum()
# close output if any
if args.output:
out_file.close()