-
Notifications
You must be signed in to change notification settings - Fork 1
/
thievius.py
171 lines (150 loc) · 5.71 KB
/
thievius.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
167
168
169
170
171
#!/usr/bin/env python3
import os
import sys
import argparse
import platform
from colorama import Fore, Style
from prettytable import PrettyTable
err = Fore.RED + '[X]' + Style.RESET_ALL
okay = Fore.GREEN + '[+]' + Style.RESET_ALL
info = Fore.YELLOW + '[!]' + Style.RESET_ALL
# check python version
if sys.version_info.major != 3:
print('\n' + err + ' please run this script with python3!\n')
sys.exit(1)
# clear and banner
def clear():
if platform.system() == 'Linux':
os.system('clear')
else:
print(err, 'non-linux support coming soon... maybe.')
sys.exit(1)
def banner():
print(Fore.LIGHTRED_EX + '''\
|\___/|
/ \ thievius! (username generator) v1.0
/_ ▲ ▲ _\ by cr0w
==\▼/==
''' + Style.RESET_ALL)
# the most unnecessary exit/exception logic
def confirm_exception():
while True:
try:
print('\n\n' + err,
'^C was detected. would you like to exit?' + Fore.LIGHTRED_EX + ' (y/n)' + Style.RESET_ALL)
choice = input('\r\n>> ')
if choice.lower() in ['y']:
print('')
sys.exit(1)
elif choice.lower() in ['n']:
clear()
banner()
print(info, 'getting names...')
print(okay, 'please enter: first name + last name (one name per line)')
print(info, 'if you\'re done entering in names, type'
+ Fore.LIGHTRED_EX + ' "done" ' + Style.RESET_ALL
+ 'or' + Fore.LIGHTRED_EX + ' "exit"\n' + Style.RESET_ALL)
break
else:
clear()
banner()
confirm_exception()
except KeyboardInterrupt:
clear()
sys.exit(1)
# get name from user
names = []
def get_name():
print(info, 'getting names...')
print(okay, 'please enter:' + Fore.LIGHTRED_EX +
' first name' + Style.RESET_ALL + ' + ' + Fore.LIGHTRED_EX + 'last name '
+ Style.RESET_ALL + Fore.YELLOW +
'(one name per line)')
print(info, 'if you\'re done entering in names, type'
+ Fore.LIGHTRED_EX + ' "done" ' + Style.RESET_ALL
+ 'or' + Fore.LIGHTRED_EX + ' "exit"\n' + Style.RESET_ALL)
while True:
try:
name = input('>> ')
names.append(name)
if name.lower() in ['done', 'exit']:
names.pop() # such a cool little function -> deletes last element of an array unless specified
break
elif name in ['',
' ']: # don't let users supply in spaces or nothing, could've done this with filter() too
names.pop()
except KeyboardInterrupt:
confirm_exception()
def display_names():
# names_display = ['names', names]
if len(names) == 0:
print('')
print(err, 'no names supplied.')
print(info, 'exiting...\n')
sys.exit(1)
else:
print('')
print(info, 'captured {} '.format(len(names)) + 'name(s)!')
print(okay, 'here they are:')
table = PrettyTable(border=True, header=False, padding_width=3)
table.title = 'names'
table.add_row(names)
print(Fore.LIGHTRED_EX)
print(table)
print(Style.RESET_ALL)
# put the names into a temporary file for john
def export_names():
print('')
print(info, 'exporting target names into a file for JtR')
with open('names.txt', 'w') as file:
for name in names:
file.write("".join(name) + '\n')
print(okay, 'done! continuing execution...')
# generate usernames from exported names now
def generate_usernames():
print(info, 'time to generate some usernames from the {}'.format(len(names)) + ' name(s)!')
print(info, 'would you like to generate case-sensitive usernames?' + Fore.LIGHTRED_EX + ' (y/n)'
+ Style.RESET_ALL)
while True:
try:
choice = input('\r\n>> ')
print(Fore.LIGHTRED_EX)
if choice.lower() in ['y', 'yes']:
command = 'john --wordlist=names.txt --rules=Login-Generator --stdout > usernames.txt'
os.system(command)
print('')
print(okay, 'finished!')
line_count = sum(1 for line in open('usernames.txt'))
print(info, 'thievius! has generated:' + Fore.LIGHTGREEN_EX,
'{}'.format(line_count), 'usernames!' + Style.RESET_ALL + '\n')
reorder = 'cat usernames.txt | sort > users.txt'
os.system(reorder)
delete_temporary = 'rm names.txt usernames.txt'
os.system(delete_temporary)
break
elif choice.lower() in ['n', 'no']:
command = 'john --wordlist=names.txt --rules=Login-Generator-i --stdout > usernames.txt'
os.system(command)
print('')
print(okay, 'finished!')
line_count = sum(1 for line in open('usernames.txt'))
print(info, 'thievius! has generated:' + Fore.LIGHTGREEN_EX,
'{}'.format(line_count), 'usernames' + Style.RESET_ALL + '!\n')
reorder = 'cat usernames.txt | sort > users.txt'
os.system(reorder)
delete_temporary = 'rm names.txt usernames.txt'
os.system(delete_temporary)
break
else:
clear()
banner()
generate_usernames()
except KeyboardInterrupt:
confirm_exception()
if __name__ == "__main__":
clear()
banner()
get_name()
display_names()
export_names()
generate_usernames()