-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_password_spray.py
More file actions
executable file
·179 lines (161 loc) · 6.55 KB
/
generate_password_spray.py
File metadata and controls
executable file
·179 lines (161 loc) · 6.55 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
#!/usr/bin/python3
# Tool used to generate a password spray wordlist
# Also usefull to crack hashes
import argparse
import os
import csv
parser = argparse.ArgumentParser(description="Password spray tool")
parser.add_argument("-c", "--company-name", help="Target company", type=str, required=True)
parser.add_argument("-j", "--job", help="Main job in the company", type=str, required=True)
parser.add_argument("-k", "--country", help="Target country", type=str, required=True)
parser.add_argument("-l", "--location", help="Target location", type=str, required=True)
parser.add_argument("-a", "--area-code", help="Target area code", type=str, required=True)
parser.add_argument("-y", "--year", help="Current year", type=str, required=True)
parser.add_argument("-p", "--password-min-length", help="Password minimum length", type=int, required=True)
parser.add_argument("-s", "--special-char", help="Special char, e.g. '!' or '*'", type=str)
parser.add_argument("-w", "--words", help="List of key words : word1,word2,word3", type=str)
args = parser.parse_args()
company = args.company_name
job = args.job
country = args.country
location = args.location
area_code = args.area_code
year = args.year
min_length = args.password_min_length
special_char = args.special_char
if args.words:
words = args.words.split(',')
# List of +1 and -3 years based on user input
years = [year]
years.append(str(int(year)+1))
years.append(str(int(year)-1))
years.append(str(int(year)-2))
years.append(str(int(year)-3))
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
# Generate months
def generate_months():
with open(company + '.txt', 'a') as file:
for month in months:
file.write(month + year + '\n')
# Generate seasons passwords
def generate_seasons():
"""
Autumn and fall are used interchangeably as words for the season between summer and winter.
Both are used in American and British English, but fall occurs more often in American English.
Autumn is considered the more formal name for the season.
"""
with open(company + '.txt', 'a') as file:
for year in years[0:3]:
file.write('Winter' + year + '\n')
file.write('Spring' + year + '\n')
file.write('Summer' + year + '\n')
file.write('Autumn' + year + '\n')
file.write('Fall' + year + '\n')
if special_char:
file.write('Winter' + year + special_char + '\n')
file.write('Spring' + year + special_char + '\n')
file.write('Summer' + year + special_char + '\n')
file.write('Autumn' + year + special_char + '\n')
file.write('Fall' + year + special_char + '\n')
# Generate company related passwords
def generate_company():
with open(company + '.txt', 'a') as file:
file.write(company + '123' + '\n')
file.write(company + '1' + '\n')
file.write(company + area_code + '\n')
if special_char:
file.write(company + '123' + special_char + '\n')
file.write(company + '1' + special_char + '\n')
file.write(company + area_code + special_char + '\n')
for year in years:
file.write(company + year + '\n')
if special_char:
file.write(company + year + special_char + '\n')
# Generate country related passwords
def generate_country():
with open(company + '.txt', 'a') as file:
file.write(country + '123' + '\n')
file.write(country + '1' + '\n')
file.write(country + year + '\n')
file.write(country + area_code + '\n')
if special_char:
file.write(country + '123' + special_char + '\n')
file.write(country + '1' + special_char + '\n')
file.write(country + year + special_char + '\n')
file.write(country + area_code + special_char + '\n')
# Generate passwords based on bordering countries
# CSV from : https://github.com/geodatasource/country-borders
countries = []
csv_file = csv.reader(open('country_borders.csv', "r"), delimiter=",")
for row in csv_file:
if country == row[-1]:
countries.append(row[1])
for bordering_country in countries:
file.write(bordering_country + '123' + '\n')
file.write(bordering_country + '1' + '\n')
file.write(bordering_country + year + '\n')
if special_char:
file.write(bordering_country + '123' + special_char + '\n')
file.write(bordering_country + '1' + special_char + '\n')
file.write(bordering_country + year + special_char + '\n')
# Generate location related passwords
def generate_location():
with open(company + '.txt', 'a') as file:
file.write(location + '123' + '\n')
file.write(location + '1' + '\n')
file.write(location + year + '\n')
file.write(location + area_code + '\n')
if special_char:
file.write(location + '123' + special_char + '\n')
file.write(location + '1' + special_char + '\n')
file.write(location + year + special_char + '\n')
file.write(location + area_code + special_char + '\n')
# Generate job related passwords
def generate_job():
with open(company + '.txt', 'a') as file:
file.write(job + '123' + '\n')
file.write(job + '1' + '\n')
file.write(job + year + '\n')
file.write(job + area_code + '\n')
if special_char:
file.write(job + '123' + special_char + '\n')
file.write(job + '1' + special_char + '\n')
file.write(job + year + special_char + '\n')
file.write(job + area_code + special_char + '\n')
# Generate key words related passwords
def generate_words():
if args.words:
with open(company + '.txt', 'a') as file:
for word in words:
file.write(word + '123' + '\n')
file.write(word + '1' + '\n')
file.write(word + year + '\n')
file.write(word + area_code + '\n')
if special_char:
file.write(word + '123' + special_char + '\n')
file.write(word + '1' + special_char + '\n')
file.write(word + year + special_char + '\n')
file.write(word + area_code + special_char + '\n')
# Apply the password policy
def apply_password_min_length_and_best_passwords():
with open('best_passwords.txt','r') as filebp, open(company + '.txt', 'r') as filein, open(company + '_wordlist.txt', 'w') as fileout:
fileout.write('[empty password]\n')
fileout.write('[username as password]\n')
for line in filebp:
fileout.write(line)
for line in filein:
if len(line) > min_length:
fileout.write(line)
os.remove(company + '.txt')
if __name__ == "__main__":
print("[+] Generating wordlist...")
generate_company()
generate_job()
generate_location()
generate_words()
generate_seasons()
generate_months()
generate_country()
apply_password_min_length_and_best_passwords()
print("[+] " + company + "_wordlist.txt generated !\n")
print("/!\ Don't forget to spray with the username as password, an empty password and the best passwords.\n Even if the passwords don't match the password policy.")