Advertisement
johnburn

md5 lookup from hashkiller.com

May 20th, 2011
790
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.68 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import urllib2, sys, xml.dom.minidom
  4.  
  5. def getHash(hash):
  6.     page = urllib2.urlopen('http://hashkiller.com/api/api.php?md5=%s' %hash).read()
  7.     xmld = xml.dom.minidom.parseString(page)
  8.     if xmld.getElementsByTagName('error') and xmld.getElementsByTagName('error')[0].firstChild.data == 'Invalid MD5 Hash':
  9.         print hash + ' is not a valid MD5';
  10.         return
  11.     elif xmld.getElementsByTagName('found') and xmld.getElementsByTagName('found')[0].firstChild.data == "true":
  12.         print hash + ' : ' + xmld.getElementsByTagName('plain')[0].firstChild.data
  13.     else:
  14.         print hash + ' : Not Found Yet. Try again latter.'
  15.  
  16. def fromFile(file):
  17.     with open(file,'r') as f:
  18.         for line in f:
  19.             line = line.strip()
  20.             if line.__len__() == 32:
  21.                 getHash(line)
  22.     f.close()
  23.  
  24. if len(sys.argv) <= 1:
  25.     print "\n|--------------------------------------------------|"
  26.     print "|               [email protected]                |"
  27.     print "|                   hashkiller.py                  |"
  28.     print "| Usage: hashkiller.py [options]                   |"
  29.     print "|            -h help                               |"
  30.     print "|--------------------------------------------------|\n"
  31.     sys.exit(1)
  32.        
  33. for arg in sys.argv:
  34.     if arg == "-h" or arg == "--help":
  35.         print "Options:"
  36.         print "  -h, --help                 shows this help message and exits"
  37.         print "  -f <file>, --file=<file>   md5 hash list from file\n"
  38.         print "  -i <md5>, --input=<md5>    direct input of md5 hash\n"
  39.         sys.exit(1)
  40. count = 0
  41. for arg in sys.argv:
  42.     if arg == "-f" or arg == "--file":
  43.         file = sys.argv[count+1]
  44.         fromFile(file)
  45.     elif arg == "-i" or arg == "--input":
  46.         hash = sys.argv[count+1]
  47.         getHash(hash)
  48.     count+=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement