simbha

MD5 Encryption and Decryption Python

Dec 8th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.46 KB | None | 0 0
  1. #!/usr/bin/python {http://pastebin.com/hwck1Wa3}
  2.  
  3. import hashlib
  4. import sys
  5. import os
  6. import time
  7. import urllib2
  8. import urllib
  9. import re
  10.  
  11. def banner():
  12.     print """
  13.     ****************************************************************
  14.     \tMD5 AND SHA1 ENCRYTION PYTHON SCRIPT \t
  15.     \tWRITTEN BY : TEJASH PATEL \t
  16.     \tFACEBOOK : https://www.facebook.com/tejash1991\t
  17.     \tYOUTUBE CHANNEL : https://www.youtube.com/user/tejash1991\t
  18.     ****************************************************************
  19.     """
  20. banner()
  21. def main():
  22.     os.system("clear")
  23.     print ("MD5 and SHA1 ENCRYTION AND DECRYTION SCRIPT"); print
  24.     print '1 - ENCRYTION USING MD5 AND SHA1'
  25.     print '2 - MD5 DECRYTION'
  26.     select = input("select option :")
  27.  
  28.    
  29.     if select == 1:
  30.         encrytion()
  31.     elif select == 2:
  32.         decrytion()
  33.  
  34. def encrytion():
  35.     os.system("clear")
  36.     print ("MD5 and SHA1 ENCRYTION SCRIPT"); print
  37.     print '1 - ENCRYTION USING MD5'
  38.     print '2 - ENCRYTION USING SHA1'
  39.     select = input("select option :")
  40.  
  41.    
  42.     if select == 1:
  43.         md5encrytion()
  44.     elif select == 2:
  45.         sha1encrytion()
  46.  
  47.  
  48. def md5encrytion():
  49.     os.system("clear")
  50.     string=raw_input("string you want to convert to MD5 >")
  51.     algorithim=hashlib.md5()
  52.     algorithim.update(string)
  53.     encrypted=algorithim.hexdigest()
  54.     print'%s to MD5 hash %s' %(string,encrypted)
  55.     mainmenu=raw_input("Press [ENTER] to go to main menu.")
  56.     main()
  57.  
  58. def sha1encrytion():
  59.     os.system("clear")
  60.     string=raw_input("string you want to convert to SHA1 > ")
  61.     algorithim=hashlib.sha1()
  62.     algorithim.update(string)
  63.     encrypted=algorithim.hexdigest()
  64.     print'%s to MD5 hash %s' %(string,encrypted)
  65.     mainmenu=raw_input("Press [ENTER] to go to main menu.")
  66.     main()
  67. def decrytion():
  68.     os.system("clear")
  69.     print ("MD5 DECRYTION"); print
  70.     print '1 - MD5 ONLINE DECRYTION '
  71.     print '2 - MD5 OFFLINE DECRYTION '
  72.     select = input("select option :")
  73.  
  74.     if select == 1:
  75.         md5onlinedecrytion()
  76.     elif select == 2:
  77.         md5offlinedecrytion()
  78.  
  79. def md5onlinedecrytion():
  80.     os.system("clear")
  81.     string=raw_input("paste MD5 Hash > ")
  82.     website = 'http://md5decryption.com/'
  83.         weburl = urllib.urlencode({'hash':string,'submit':'Decrypt+It!'})
  84.         req = urllib2.Request(website)
  85.         try:
  86.           fd = urllib2.urlopen(req, weburl)
  87.           data = fd.read()
  88.           match = re.search(r'(Decrypted Text: </b>)(.+[^>])(</font><br/><center>)', data)
  89.           if match: print '[-] site: %s\t\t\tPassword: %s' % (website, match.group(2))
  90.           else: print '[-] site: %s\t\t\tPassword: Not found' % website
  91.         except urllib2.URLError: print '[+] site: %s \t\t\t[+] Error: seems to be down' % website
  92. def md5offlinedecrytion():
  93.     os.system("clear")
  94.     counter = 0
  95.     lines = 0
  96.     string=raw_input("paste MD5 Hash > ")
  97.     wordList = raw_input("Dictionary path > ")
  98.     try:
  99.         wordlistfile = open(wordList)
  100.         for line in open(wordList):
  101.             lines += 1
  102.     except IoError:
  103.         print'Dictionary is not valid'
  104.         raw_input("Press [ENTER] to try Again")    
  105.         main()
  106.     else:
  107.         pass
  108.     for line in wordlistfile:
  109.         algorithim = hashlib.md5()
  110.         line = line.replace("\n","")
  111.         algorithim.update(line)
  112.         wordlistdecrypted = algorithim.hexdigest()
  113.         counter += 1
  114.         percentage_raw = float(counter) / float(lines) * 100
  115.         percentage_raw ="%.0f" % percentage_raw; percentage = str(percentage_raw) + " " + "%"
  116.         os.system("clear")
  117.         print(percentage)
  118.         if wordlistdecrypted == string:
  119.             print'Hash Crackrd - %s' % line
  120.             mainmenu = raw_input("Press [ENTER] to go to main menu")
  121.             main()
  122. main()
Advertisement
Add Comment
Please, Sign In to add comment