forked from WangYihang/ccupp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchinese-weak-password-generator.py
More file actions
192 lines (169 loc) · 6.26 KB
/
chinese-weak-password-generator.py
File metadata and controls
192 lines (169 loc) · 6.26 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
#!/usr/bin/env python
#coding:utf-8
from pypinyin import lazy_pinyin, Style
import hashlib
import sys
class Person:
FAMILY_NAME = u"李"
GIVEN_NAME = u"二狗"
PHONE = ["13512345678",]
CARD = "220281198309243953"
BIRTHDAY = ("1983", "09", "24")
HOMETOWN = (u"四川", u"成都", u"高新区")
PLACE = [(u"河北", u"秦皇岛", u"北戴河"),]
QQ = ["987654321",]
COMPANY = [(u"腾讯", "tencent"),]
SCHOOL = [(u"清华大学", u"清华", "tsinghua")]
ACCOUNT = ["twodog",]
PASSWORD = ["old_password",]
delimiters = ["", "-", ".", "|", "_", "+", "#", "@"]
Prefix = ["",]
Suffix = ["","123","@","abc",".","123.","!!!",]
def get_md5(password):
return hashlib.md5(password).hexdigest()
def get_pinyin(word):
return lazy_pinyin(word)
def get_pinyin_first_letter(word):
return lazy_pinyin(word, style=Style.FIRST_LETTER)
def get_full_pinyin(word):
return get_pinyin(word)
def get_title(word):
result = list(word)
result[0] = result[0].upper()
return "".join(i for i in result)
def get_name_component(person):
print(person.NAME, get_pinyin(person.NAME))
result = []
result.append(get_pinyin(person.NAME))
result.append(get_pinyin(person.NAME[0]))
result.append(get_pinyin(person.NAME[1:]))
result.append(get_title(get_pinyin(person.NAME)))
result.append(get_title(get_pinyin(person.NAME[0])))
result.append(get_title(get_pinyin(person.NAME[1:])))
return result
def get_phone_component(person):
result = []
for phone in person.PHONE:
result.append(phone)
result.append(phone[-4:])
return result
def get_card_component(person):
result = []
result.append(person.CARD)
result.append(person.CARD[-6:])
result.append(person.CARD[0:6])
return result
def get_birthday_component(person):
result = []
year = person.BIRTHDAY[0]
month = person.BIRTHDAY[1]
day = person.BIRTHDAY[2]
result.append(year)
result.append(year[2:])
result.append(month+day)
result.append(year+month+day)
return result
def get_hometown_component(person):
result = []
result.append(get_pinyin(person.HOMETOWN[0]))
result.append(get_pinyin(person.HOMETOWN[1]))
result.append(get_pinyin(person.HOMETOWN[2]))
result.append(get_title(get_pinyin(person.HOMETOWN[0])))
result.append(get_title(get_pinyin(person.HOMETOWN[1])))
result.append(get_title(get_pinyin(person.HOMETOWN[2])))
result.append(get_abbreviation(person.HOMETOWN[0]))
result.append(get_abbreviation(person.HOMETOWN[1]))
result.append(get_abbreviation(person.HOMETOWN[2]))
return result
def get_place_component(person):
result = []
for place in person.PLACE:
result.append(get_pinyin(place[0]))
result.append(get_pinyin(place[1]))
result.append(get_pinyin(place[2]))
result.append(get_title(get_pinyin(place[0])))
result.append(get_title(get_pinyin(place[1])))
result.append(get_title(get_pinyin(place[2])))
result.append(get_abbreviation(place[0]))
result.append(get_abbreviation(place[1]))
result.append(get_abbreviation(place[2]))
return result
def get_qq_component(person):
result = []
for qq in person.QQ:
result.append(qq)
return result
def get_company_component(person):
result = []
for company in person.COMPANY:
for name in company:
result.append(get_pinyin(name))
result.append(get_title(get_pinyin(name)))
result.append(get_abbreviation(name))
return result
def get_school_component(person):
result = []
for school in person.SCHOOL:
for name in school:
result.append(get_pinyin(name))
result.append(get_title(get_pinyin(name)))
result.append(get_abbreviation(name))
return result
def get_account_component(person):
result = []
for account in person.ACCOUNT:
result.append(get_pinyin(account))
result.append(get_title(get_pinyin(account)))
result.append(get_abbreviation(account))
return result
def get_all_component(person):
result = []
result.append(get_name_component(person))
result.append(get_phone_component(person))
result.append(get_card_component(person))
result.append(get_birthday_component(person))
result.append(get_hometown_component(person))
result.append(get_place_component(person))
result.append(get_qq_component(person))
result.append(get_company_component(person))
result.append(get_school_component(person))
result.append(get_account_component(person))
return result
def store_password(password, filename):
md5 = get_md5(password)
print("[+] %s => %s" % (password, md5))
with open(filename, "a+") as f:
f.write("%s\t%s\n" % (password, md5))
def main():
compents = get_all_component(Person)
filename = "password.list"
# 单组件密码
for delimiter in delimiters:
for prefix in Prefix:
for suffix in Suffix:
for compent in compents:
for i in compent:
if delimiter == "":
password = prefix + i + delimiter + suffix
if len(password) > 6 and len(password) < 16:
store_password(password, filename)
continue
password = prefix + i + delimiter + suffix
if len(password) > 6 and len(password) < 16:
store_password(password, filename)
password = prefix + delimiter + i + suffix
if len(password) > 6 and len(password) < 16:
store_password(password, filename)
# 两组件密码
for delimiter in delimiters:
for prefix in Prefix:
for suffix in Suffix:
for compent_a in compents:
for compent_b in compents:
for i in compent_a:
for j in compent_b:
password = prefix + i + delimiter + j + suffix
if len(password) > 6 and len(password) < 16:
store_password(password, filename)
if __name__ == "__main__":
main()