forked from tuwid/darkc0de-old-stuff
-
Notifications
You must be signed in to change notification settings - Fork 7
/
MySQL_double_SHA1_brute.py
127 lines (98 loc) · 3.97 KB
/
MySQL_double_SHA1_brute.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
#!/usr/bin/env python
import sys
try:
import hashlib
except ImportError:
print '''
You need hashlib.
Update your python to version 2.5\n'''
sys.exit(1)
def license():
'''Print the usage license to this software, yeah, it's the same as above'''
print '''
%s - MySQL double SHA1 hash wordlist brute forcer. This cracker works against
hash created by MySQL to store passwords.
Copyright (c) 2009 Ulisses "thebug" Castro <uss.thebug@nospam@gmail.com>
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
(at your option) 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, see <http://www.gnu.org/licenses/>
''' % sys.argv[0]
def makelist(file):
'''
Make word list
'''
items = []
try:
fd = open(file, 'r')
for line in fd.readlines():
item = line.replace('\n', '').replace('\r', '')
items.append(item)
return items
except IOError:
print 'unable to read file \'%s\'' % file
pass
except Exception, e:
print 'unknown error'
pass
def testword(text):
"""
Hash string twice with SHA1 (double SHA1), make UPPER and add an asterix.
"""
pazz = hashlib.sha1(text).digest()
pazz2 = hashlib.sha1(pazz).hexdigest()
return "*" + pazz2.upper()
if __name__ == '__main__':
from optparse import OptionError
from optparse import OptionParser
version = '''----------------------------------------------------------------------
MySQL double SHA1 hash brute force
version 0.1 uss.thebug[at]gmail.com
----------------------------------------------------------------------'''
usage = '%s [-H hash] [-w wordlist] [-t word-to-hash] [-v]' % sys.argv[0]
parser = OptionParser(version=version, usage=usage)
parser.add_option('-H', dest='hash', help='hash. (format: *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9)')
parser.add_option('-w', dest='wordlist', help='wordlist to run against hash')
parser.add_option('-t', dest='wordtohash', help='transform word to hash')
parser.add_option('-v', '--verbose', action='store_true', dest='verbose', help='verbose')
parser.add_option('-l', '--license', action='store_true', dest='license', help='license')
(options, args) = parser.parse_args()
hash = options.hash
wordlist = options.wordlist
wordtohash = options.wordtohash
if options.license:
license()
sys.exit(0)
if options.wordtohash:
print "[*] MySQL double SHA1 hasher (by thebug)"
print "[*] word: %s" % wordtohash
print "[*] hash: %s" % testword(wordtohash)
sys.exit(0)
if not options.wordlist:
parser.print_help()
sys.exit(1)
if int(len(hash)) != 41 or hash[:1] != "*":
print "Improper hash format. Format: *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9\n"
sys.exit(1)
words = makelist(wordlist)
print "[*] MySQL double SHA1 hash brute force (by thebug)"
print "[*] hash: %s" % hash
print "[*] %s word(s) loaded." % str(len(words))
print "[*] brute force started."
for word in words:
if options.verbose:
print "[+] word: %s" % word
if hash == testword(word):
print "\n[*] got it!"
print "[*] password is: %s\n" % word
sys.exit(0)
else:
pass
print "[*] Done.\n"
sys.exit(0)