Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #Name: mt5crack.py
- #Version: 1.0
- #Author: s3my0n
- #Website: py1337.22web.net
- #########################################################################
- # mt5crack performs a multi-threaded dictionary attack against multiple #
- # md5 hashes, and dumps all cracked hashes to a file. #
- # #
- # Copyright (C) 2010 s3my0n #
- # #
- # 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, see <http://www.gnu.org/licenses/>. #
- #########################################################################
- import sys, threading
- from time import ctime
- from hashlib import md5
- class MD5Cracker(object):
- def __init__(self, dictionary):
- self.dic = dictionary
- self.cracked = 0
- self.lhashes = None
- def findMatch(self, thash, fresult):
- try:
- for word in self.dic:
- # converting word to md5 hash
- m = md5()
- m.update(word)
- hashword = m.hexdigest()
- # matching hash to word
- if thash == hashword:
- toappend = '%s:%s\n' % (thash, word)
- fresult.write(toappend) # writing successful match
- self.cracked += 1
- else:
- continue
- except KeyboardInterrupt:
- print '\n [*] Aborted: exiting'
- sys.exit(1)
- def about():
- usage = '''
- ##########################################
- # #
- # Name: md5crack.py #
- # Version: 1.0 #
- # Author: s3my0n #
- # Email: RuSH4ck3R[at]gmail[dot]com #
- # #
- # Kalimantan Cyber Hacked #
- # #
- ##########################################
- Usage: mt5crack.py <hashes_file> <dictionary_file> <cracked_file>
- Example: mt5crack.py hashes.txt dic.txt cracked.txt'''
- return usage
- def main(hashfile, mt5, filetoappendto):
- try:
- fappend = open(filetoappendto, 'a')
- except IOError:
- print '\n [-] Error opening %s to append to' % (filetoappend)
- sys.exit()
- try:
- ofile = open(hashfile).readlines()
- mt5.lhashes = len(ofile) # number of hashes
- print '\n [+] Loaded %d hashes' % (mt5.lhashes)
- except IOError:
- print '\n [-] Error opening %s to read from' % (hashfile)
- sys.exit(1)
- hashes = [i.strip() for i in ofile] # storing hashes to crack here
- threads = [] # all our threads will be stored in here
- nhashes = range(len(hashes))
- print '\n [*] Checking for valid md5 hashes...'
- validhashes = 0 # variable to test for number of valid hashes
- for h in hashes:
- if len(h) == 32:
- validhashes += 1
- t = threading.Thread(target=mt5.findMatch, args=(h, fappend)) # making threads
- threads.append(t)
- if validhashes == 0:
- print '\n [-] File %s doesn\'t contain valid md5 hashes' % (hashfile)
- sys.exit(1)
- print '\n [*] Starting cracking at [%s] ...' % (ctime())
- for t in nhashes:
- try:
- threads[t].start() # starting threads
- except KeyboardInterrupt:
- print '\n [*] Aborted: exiting'
- sys.exit(1)
- print '\n [+] Cracked %d out of %d hashes at [%s]' % (mt5.cracked, mt5.lhashes, ctime())
- if __name__=='__main__':
- if len(sys.argv) != 4:
- print about()
- sys.exit(1)
- try:
- ofile = open(sys.argv[2]).readlines() # opening dictionary file
- except IOError:
- print '\n [-] Error opening %s to read from' % (sys.argv[2])
- sys.exit(1)
- dic = [i.strip() for i in ofile] # storing dictionary words here
- afile = sys.argv[3] # file to append cracked hashes to
- md5cracker = MD5Cracker(dic) # passing dictionary to md5cracker
- print '\n [+] Loaded %d words from dictionary file' % (len(dic))
- main(sys.argv[1], md5cracker, afile)
Advertisement
Add Comment
Please, Sign In to add comment