-
Crack MD5
This is a little script that I made to crack MD5 password with dictionary.
Code:
#!/usr/bin/env python
#-*- encoding: iso-8859-1 -*-
###########################################################################
# 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 2 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
############################################################################
# Autor: MrMaX
############################################################################
import md5, sys, getopt
ver= "0.1"
a=0
def run():
if len(sys.argv) == 1 or sys.argv[1]=="-h" or sys.argv[1]=="--help":
print "Usage: pymd5 [md5hash] [wordlist]\r\n"
print "-h --help This Screen"
print "-v --version Version"
print "Example: ./pymd5.py d79096188b670c2f81b7001f73801117 wordlist.txt"
print "\r"
else:
if sys.argv[1]=="-v" or sys.argv[1]=="--version":
print "pymd5 version: " + ver + "\nAutor: MrMaX"
if len(sys.argv) == 3:
md5crack(sys.argv[1],sys.argv[2],)
def md5crack(hash,word):
try:
wordlist = open(word,"r")
except IOError:
print "File " + word + " doesnt exists"
sys.exit(0)
global a
for line in wordlist.xreadlines():
word= line.replace("\n","")
passw = md5.new(word)
if (hash == passw.hexdigest()):
print '\033[1;32mBINGO: ' + passw.hexdigest() + ' = ' + word+'\033[0'
a = 1
sys.exit(0)
if ( a == 0):
print '\033[1;31mSorry no match found\033[0'
wordlist.close()
def main():
run()
if __name__ == "__main__":
main()
Feel free to improve the code, hope that helps