-
Notifications
You must be signed in to change notification settings - Fork 7
/
passgen.py
236 lines (179 loc) · 9.67 KB
/
passgen.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
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
# Date: 02/23/2019
# Original passgen author: Mohamed
# Some changed by: UnderMind0x41
# Description: A social engineering password generator
# This script required python version >= 3.0
import argparse
import sys
max_count_default = 1000000
max_count_main_default = 1000
class PassGen:
def __init__(self, max_count=max_count_default, max_count_main=max_count_main_default, silent=False):
self.pet = None
self.child = None
self.spouse = None
self.target = None
self.passwords = []
self.silent = silent
self.max_count = max_count
self.max_count_main = max_count_main
def prompt(self, txt):
return str(input(txt))
def question(self, target):
answers = {}
answers['firstname'] = self.prompt('Enter {}\'s first name: '.format(target))
answers['lastname'] = self.prompt('Enter {}\'s last name: '.format(target))
answers['nickname'] = self.prompt('Enter {}\'s nick name: '.format(target))
while True:
bday = self.prompt('Enter {}\'s birthday (dd.mm.yyyy): '.format(target))
if not len(bday.strip()):
break
if len(bday.split('.')) != 3:
print('Invalid birthday format\n')
continue
for _ in bday.split('.'):
if not _.isdigit():
print('Birthday only requires numbers\n')
continue
dd, mm, yyyy = bday.split('.')
if int(mm) > 12 or int(mm) < 1 \
or int(dd) > 31 or int(dd) < 1 \
or len(yyyy) != 4:
print('Invalid birthday\n')
continue
bday = { 'day': dd, 'month': mm, 'year': int(yyyy) }
break
answers['birthday'] = bday
return answers
def cases(self, word):
return [word.lower(), word.title()]
def fullname(self, fname, lname):
return ['{}{}'.format(a, b) for a in self.cases(fname) for b in self.cases(lname)]
def format_names(self):
for _ in range(self.max_count_main):
if not self.silent:
print(f'Generated: {len(self.passwords)}')
iters = 0
for data in [self.target, self.spouse, self.child, self.pet]:
for n in ['firstname', 'lastname', 'nickname']:
fullname_list = []
name = data[n].strip()
if not len(name):
continue
if not iters:
fullname_list = self.fullname(data['firstname'], data['lastname'])
iters += 1
for word in self.cases(name) + fullname_list:
a, b, c = ('{}{}'.format(word, _),
'{}{}'.format(_, word),
'{0}{1}{0}'.format(_, word)
)
if not word in self.passwords:
self.passwords.append(word)
if not a in self.passwords:
self.passwords.append(a)
if not b in self.passwords:
self.passwords.append(b)
if not c in self.passwords:
self.passwords.append(c)
bday = data['birthday']
if bday:
d, e, f, g, h, i, j, k, l, m, n, o, p, q = (
'{}{}'.format(word, bday['year']),
'{}{}'.format(bday['year'], word),
'{}{}{}{}'.format(word, bday['day'], bday['month'], bday['year']),
'{}{}.{}.{}'.format(word, bday['day'], bday['month'], bday['year']),
'{}{}{}{}'.format(bday['day'], bday['month'], bday['year'], word),
'{}.{}.{}{}'.format(bday['day'], bday['month'], bday['year'], word),
'{}_{}{}{}'.format(word, bday['day'], bday['month'], bday['year']),
'{}_{}.{}.{}'.format(word, bday['day'], bday['month'], bday['year']),
'{}{}{}_{}'.format(bday['day'], bday['month'], bday['year'], word),
'{}.{}.{}_{}'.format(bday['day'], bday['month'], bday['year'], word),
'{}-{}{}{}'.format(word, bday['day'], bday['month'], bday['year']),
'{}-{}.{}.{}'.format(word, bday['day'], bday['month'], bday['year']),
'{}{}{}-{}'.format(bday['day'], bday['month'], bday['year'], word),
'{}.{}.{}-{}'.format(bday['day'], bday['month'], bday['year'], word),
)
if not d in self.passwords:
self.passwords.append(d)
if not e in self.passwords:
self.passwords.append(e)
if not f in self.passwords:
self.passwords.append(f)
if not g in self.passwords:
self.passwords.append(g)
if not h in self.passwords:
self.passwords.append(h)
if not i in self.passwords:
self.passwords.append(i)
if not j in self.passwords:
self.passwords.append(j)
if not k in self.passwords:
self.passwords.append(k)
if not l in self.passwords:
self.passwords.append(l)
if not m in self.passwords:
self.passwords.append(m)
if not n in self.passwords:
self.passwords.append(n)
if not o in self.passwords:
self.passwords.append(o)
if not p in self.passwords:
self.passwords.append(p)
if not q in self.passwords:
self.passwords.append(q)
def generator(self, ignore_additional = True):
self.target = self.question('target')
print('\n')
self.spouse = self.question('spouse')
print('\n')
self.child = self.question('child')
print('\n')
self.pet = self.question('pet')
print('\n')
print('Generating main passwords... \nIt\'s may take a while.')
self.format_names()
if self.silent:
print("...generated {} main passwords".format(len(self.passwords)))
output_file = '{}.txt'.format(self.target['firstname'].lower()
if self.target['firstname'] else 'pass.txt')
with open(output_file, 'wt') as f:
for pwd in self.passwords:
if not self.silent:
print('Writing ...')
f.write('{}\n'.format(pwd))
if not ignore_additional:
print("Generating additionals combinations...")
with open(output_file, 'at') as f:
i = 0
while(i < self.max_count):
if not self.silent:
print('Writing additional combinations ... {}/{}'.format(i*3, self.max_count*3))
f.write('{}{}\n'.format(self.target['firstname'], i))
f.write('{}{}\n'.format(self.target['lastname'], i))
f.write('{}{}\n'.format(self.target['nickname'], i))
i += 1
if self.silent:
print("...generated {} additional combinations".format(self.max_count*3))
print('Passwords Generated in file: {}'.format(output_file))
quit()
def parseCmdArgs(argv):
parser = argparse.ArgumentParser(description='Run password generator')
parser.add_argument('--ignore-additional', dest='ignore_additional', action='store_true',
help='ignore additions combinations')
parser.add_argument('--max-count', dest='max_count', default=max_count_default,
help='maximum count for additional combinations')
parser.add_argument('--max-count-main', dest='max_count_main', default=max_count_main_default,
help='maximum count for main combinations')
parser.add_argument('--silent', dest='silent', action='store_true',
help='no print process (faster)')
parser.set_defaults(ignore_additional=False)
parser.set_defaults(silent=False)
args = parser.parse_args(argv[1:])
return args
if __name__ == '__main__':
args = parseCmdArgs(sys.argv)
PassGen(max_count=int(args.max_count),
max_count_main=int(args.max_count_main),
silent=args.silent
).generator(ignore_additional=args.ignore_additional)