-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwordlistForger.py
More file actions
253 lines (205 loc) · 6.97 KB
/
Copy pathwordlistForger.py
File metadata and controls
253 lines (205 loc) · 6.97 KB
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
#!/usr/bin/env python3
import argparse
import random
import string
import sys
import time
from math import prod
VERSION = "1.0.7"
# =========================
# Colors
# =========================
class C:
GREEN = "\033[92m"
YELLOW = "\033[93m"
RED = "\033[91m"
CYAN = "\033[96m"
RESET = "\033[0m"
DIM = "\033[2m"
# =========================
# Banner
# =========================
BANNER = (
f"{C.CYAN}╔══════════════════════════╗\n"
f"║ wordlistForger by M14R41 ║\n"
f"╚══════════════════════════╝{C.RESET}"
)
# BANNER = f"{C.CYAN}WordlistForge v2 by M14R41{C.RESET}"
# =========================
# Pools
# =========================
LOWER = string.ascii_lowercase
UPPER = string.ascii_uppercase
DIGIT = string.digits
HEX = "0123456789abcdef"
# =========================
# Logger
# =========================
def info(msg): print(f"[+] {msg}")
def ok(msg): print(f"{C.GREEN}[+]{C.RESET} {msg}")
def err(msg): print(f"{C.RED}[-]{C.RESET} {msg}")
# =========================
# Core Logic
# =========================
def get_pool(ch, strict_case, match_pattern=False):
if match_pattern:
if ch == 'x': return HEX
if ch == 'n': return DIGIT
if ch == 'a': return LOWER
if ch == 'A': return UPPER
return ch
if ch.isdigit():
return DIGIT
if ch.isalpha():
return LOWER if strict_case and ch.islower() else (UPPER if strict_case else LOWER + UPPER)
return ch
def count_combinations(pattern, lock, lock_mask, strict_case, match_pattern):
sizes = []
i = 0
while i < len(pattern):
if lock and pattern.startswith(lock, i):
sizes.append(1)
i += len(lock)
continue
if lock_mask and i < len(lock_mask) and lock_mask[i] != "x":
sizes.append(1)
else:
pool = get_pool(pattern[i], strict_case, match_pattern)
sizes.append(len(pool) if isinstance(pool, str) else 1)
i += 1
return prod(sizes)
def generate_word(pattern, lock, lock_mask, strict_case, match_pattern):
out = []
i = 0
while i < len(pattern):
if lock and pattern.startswith(lock, i):
out.append(lock)
i += len(lock)
continue
if lock_mask and i < len(lock_mask) and lock_mask[i] != "x":
out.append(lock_mask[i])
else:
pool = get_pool(pattern[i], strict_case, match_pattern)
out.append(random.choice(pool) if isinstance(pool, str) else str(pool))
i += 1
return "".join(out)
# =========================
# PROGRESS BAR
# =========================
def progress(current, total, start_time):
percent = current / total
bar_len = 25
filled = int(bar_len * percent)
bar = ""
for i in range(bar_len):
if i < filled:
if percent < 0.5:
bar += f"{C.GREEN}▰"
elif percent < 0.8:
bar += f"{C.YELLOW}▰"
else:
bar += f"{C.RED}▰"
else:
bar += f"{C.DIM}▱"
elapsed = time.time() - start_time
speed = current / elapsed if elapsed > 0 else 0
eta = (total - current) / speed if speed > 0 else 0
sys.stdout.write(
f"\r{bar}{C.RESET} "
f"{percent*100:5.1f}% "
f"{current}/{total} "
f"| {speed:,.0f} w/s "
f"| ETA {eta:,.1f}s"
)
sys.stdout.flush()
# =========================
# MAIN
# =========================
def main():
print(BANNER)
parser = argparse.ArgumentParser(
prog="wordlistforger",
add_help=False,
description="WordlistForger - Advanced wordlist generator tool",
epilog="""
\033[96mFull documentation at : \033[92mhttps://github.com/m14r41/WordlistForger\033[0m
Example:
wordlistForger -p api_key7m9xq2kpl4 -l 10 --strict-case
wordlistforger -p pass123 -l 20 --live
wordlistForger -p api_key7m9xq2kpl4 -l 10 --lock api_key --live -o api.list
wordlistForger -p ODER-ID-1943AC -l 10 --lock ODER-ID --strict-case --live
""",
formatter_class=argparse.RawDescriptionHelpFormatter
)
parser.add_argument("-h", "--help", action="help", help="")
parser.add_argument("-p", "--pattern", required=True, help="Pattern to generate wordlist from")
parser.add_argument("-l", "--limit", type=int, required=True, help="Number of words to generate")
parser.add_argument("--lock", help="Lock specific string inside pattern")
parser.add_argument("--lock-mask", help="Mask fixed characters in pattern (use 'x' for free positions)")
parser.add_argument("--strict-case", action="store_true", help="Respect case sensitivity strictly")
parser.add_argument("--match-pattern", action="store_true", help="Use pattern-based character rules")
parser.add_argument("-s", "--seed", type=int, help="Random seed for reproducibility")
parser.add_argument("-o", "--output", default="wordlist.txt", help="Output file name")
parser.add_argument("--live", action="store_true", help="Show generated output in real-time")
parser.add_argument(
"-v", "--version",
action="version",
version=f"wordlistForger {VERSION}"
)
args = parser.parse_args()
start = time.time()
# =========================
# INFO
# =========================
info("starting engine")
if args.seed:
random.seed(args.seed)
if args.lock_mask and len(args.lock_mask) != len(args.pattern):
err("lock-mask mismatch")
sys.exit(1)
info("calculating space...")
max_possible = count_combinations(
args.pattern,
args.lock,
args.lock_mask,
args.strict_case,
args.match_pattern
)
info(f"max possible: {max_possible}")
if args.limit > max_possible:
err("limit exceeds possible combinations")
sys.exit(1)
info("generating...")
results = set()
counter = 0
try:
while len(results) < args.limit:
word = generate_word(
args.pattern,
args.lock,
args.lock_mask,
args.strict_case,
args.match_pattern
)
if word not in results:
results.add(word)
counter += 1
if args.live:
print(word)
else:
progress(counter, args.limit, start)
except KeyboardInterrupt:
print(f"\n{C.RED}[!]{C.RESET} stopped by user")
print(f"{C.YELLOW}[~]{C.RESET} saving...")
print()
with open(args.output, "w") as f:
for w in results:
f.write(w + "\n")
elapsed = time.time() - start
speed = len(results) / elapsed if elapsed > 0 else 0
ok(f"generated: {len(results)}")
ok(f"speed: {speed:,.2f} w/s")
ok(f"time: {elapsed:.2f}s")
ok(f"saved: {args.output}")
if __name__ == "__main__":
main()