-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNumNinja (CUI).py
166 lines (135 loc) · 6.33 KB
/
NumNinja (CUI).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
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
import time; import os
from tqdm import tqdm
from termcolor import colored
import colorama
colorama.init()
BANNER1 = colored('''
███▄ █ █ ██ ███▄ ▄███▓ ███▄ █ ██▓ ███▄ █ ▄▄▄██▀▀▀▄▄▄
██ ▀█ █ ██ ▓██▒▓██▒▀█▀ ██▒ ██ ▀█ █ ▓██▒ ██ ▀█ █ ▒██ ▒████▄
▓██ ▀█ ██▒▓██ ▒██░▓██ ▓██░▓██ ▀█ ██▒▒██▒▓██ ▀█ ██▒ ░██ ▒██ ▀█▄
▓██▒ ▐▌██▒▓▓█ ░██░▒██ ▒██ ▓██▒ ▐▌██▒░██░▓██▒ ▐▌██▒▓██▄██▓ ░██▄▄▄▄██
▒██░ ▓██░▒▒█████▓ ▒██▒ ░██▒▒██░ ▓██░░██░▒██░ ▓██░ ▓███▒ ▓█ ▓██▒
░ ▒░ ▒ ▒ ░▒▓▒ ▒ ▒ ░ ▒░ ░ ░░ ▒░ ▒ ▒ ░▓ ░ ▒░ ▒ ▒ ▒▓▒▒░ ▒▒ ▓▒█░
░ ░░ ░ ▒░░░▒░ ░ ░ ░ ░ ░░ ░░ ░ ▒░ ▒ ░░ ░░ ░ ▒░ ▒ ░▒░ ▒ ▒▒ ░
░ ░ ░ ░░░ ░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ▒
░ ░ ░ ░ ░ ░ ░ ░ ░ ░''', 'blue')
BANNER2 = colored(''' ----------------------------------------------''', 'blue')
BANNER3 = colored(''' || NumNinja: The Numeric Wordlist Generator ||''', 'red')
BANNER4 = colored(''' ----------------------------------------------''', 'blue')
def printBanner():
print(BANNER1), print(BANNER2), print(BANNER3), print(BANNER4)
########## Method Elements ###########
def zeros():
if (progressBar == "1"):
for number in tqdm(range(minunit, maxunit + 1), desc="Progress", unit=" lines", unit_scale=1):
file.write((digitStr + "\n") % number)
elif (progressBar == "2"):
for number in range(minunit, maxunit + 1):
file.write((digitStr + "\n") % number)
def straight():
if (progressBar == "1"):
for number in tqdm(range(minunit, maxunit + 1), desc="Progress", unit=" lines", unit_scale=1):
file.write(f"{number}\n")
elif (progressBar == "2"):
for number in range(minunit, maxunit + 1):
file.write(f"{number}\n")
def clrscr():
if os.name == 'posix':
_ = os.system('clear')
else:
_ = os.system('cls')
printBanner()
############### Main ###############
if __name__ == "__main__":
printBanner()
try:
while (True):
try:
minunit = int(input("\nEnter the minimum value (Default = zero): ") or 0)
maxunit = int(input("Enter the maximum value: "))
if maxunit > minunit:
break
elif (minunit == maxunit):
clrscr()
print("\nThe minimum value cannot be equal to the maximum value. Please try again.\n")
continue
elif (minunit > maxunit):
clrscr()
print("\nThe minimum value cannot be greater than the maximum value. Please try again.\n")
continue
except KeyboardInterrupt:
raise KeyboardInterrupt
except:
clrscr()
print("\nInvalid entry (not an integer). Please try again.\n")
continue
while (True):
print("\n\nMethods:-")
print("1. Leading Zeros\n2. Staightforward")
method = input("\nSelect method number (Default = Straightforward): ") or "2"
print("")
if (method == "1"):
digits = int(input("Enter the number of digits: "))
digitStr = (f"%0{digits}d")
break
elif (method == "2"):
break
else:
clrscr()
print("\nInvalid entry. Choose either option 1 or 2. Try again.\n")
continue
while (True):
print("\nShow progress?")
print("1. Yes (slower)\n2. No (faster)")
progressBar = input("\nSelect option number (Default = No): ") or "2"
if (progressBar == "1" or progressBar == "2"):
break
else:
clrscr()
print("\nInvalid entry. Choose either option 1 or 2. Try again.\n")
continue
while (True):
output = input("\nEnter output folder (Default = working folder):") or "./"
output += "/"
if (os.path.exists(output) is True):
break
else:
clrscr()
print("\nEither path does not exist or invalid path entered. Try again.\n")
continue
clrscr()
genunit = maxunit - minunit + 1
print(f"\nNumber of lines that will be generated: {genunit}")
print("\nWorking...", end='')
if (method == "1"):
output += ((digitStr) % minunit) + " to " + ((digitStr) % maxunit) + ".txt"
with open(output, 'w') as file:
start = time.time()
zeros()
completionTime = time.time() - start
elif (method == "2"):
output += f"{minunit} to {maxunit}.txt"
with open(output, 'w') as file:
start = time.time()
straight()
completionTime = time.time() - start
try:
rate = genunit // completionTime
clrscr()
print(f"\n\nThe task completed successfully in {completionTime} seconds. (at ~{rate} lines/sec)")
print("Press Enter to exit.")
input()
except ZeroDivisionError:
clrscr()
print("\n\nThe task completed successfully in zero seconds.")
print("Press Enter to exit.")
input()
except KeyboardInterrupt:
clrscr()
try:
file.close()
except:
pass
print("\nCTRL ^C\n\nThrew a wrench in the works.")
print("Press Enter to exit.")
input()