Mayk0

#; [Python] MD5 Cracker!

Jun 10th, 2013
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.36 KB | None | 0 0
  1. #; [Python] MD5 Cracker!
  2.  
  3. 1.- Fuerza Bruta
  4. 2.- Diccionario
  5. 3.- Con BDs online
  6.  
  7. El menu deberia tener algo como lo siguiente:
  8.  
  9. Menú:
  10.  
  11. 1.- Crackear por fuerza bruta
  12. 2.- Crackear por diccionario
  13. 3.- Crackear por Base de Datos Online (Requiere conexion a internet)
  14. 4.- About
  15. _______________________________________________
  16.  
  17.  
  18. Crackeador por fuerza bruta:
  19.  
  20. Código: Python
  21. python Cracker.py -t md5 -h e10adc3949ba59abbe56e057f20f883e -w 1234567890 -a 9 -i 3 -v
  22.  
  23. Comandos:
  24.  
  25. Código: Text
  26. -t: Tipo de Hash
  27. -h: Hash a Crackear
  28. -w: Teclas a usar
  29. -a: Maximo de Caracteres
  30. -i: Minimo de Caracteres
  31. -v: Modo Hacking
  32. _______________________________________________
  33.  
  34. Codigo:
  35.  
  36. Código: Python
  37.  
  38. import sys , string , time
  39. def main():
  40.     "Main"
  41.     title = "MD5 Cracker Brute Force"
  42.     print "\n" + title.center(45) + "\n"
  43.  
  44. def usage():
  45.     "Usage"
  46.     print "[+] Ejemplo : Cracker.py -t md5 -h e10adc3949ba59abbe56e057f20f883e -w 1234567890 -a 9 -i 3 -v"
  47.  
  48. def usagelarge():
  49.     "Usage Large"
  50.     print "\n  Forma de Uso:"
  51.     print "\n  [+]Ejemplo: Cracker.py -t md5 -h e10adc3949ba59abbe56e057f20f883e -w 1234567890 -a 9 -i 3 -v"
  52.     print ""
  53.     print "\t[Comandos]"
  54.     print "\t   -t: Tipo de Hash"
  55.     print "\t   -h: Hash a Crackear"
  56.     print "\t   -w: Teclas a usar"
  57.     print "\t   -a: Maximo de Caracteres"
  58.     print "\t   -i: Minimo de Caracteres"
  59.     print "\t   -v: Modo Hacking\n"
  60.  
  61. def timer():
  62.     "Time"
  63.     now = time.localtime(time.time())
  64.     return time.asctime(now)
  65.  
  66. if '__main__' == __name__ :
  67.  
  68.     if len(sys.argv) <= 5:
  69.         main()
  70.         usagelarge()
  71.         sys.exit(1)
  72.  
  73.     hhash = words = maxw = minw = typeh = ""
  74.     verbose = 0
  75.  
  76.     for arg in sys.argv[1:]:
  77.         try:
  78.             if arg.lower() == "-v" or arg.lower() == "-verbose":
  79.                     verbose = 1
  80.             if arg.lower() == "-h" or arg.lower() == "-hash":
  81.                     hhash = sys.argv[int(sys.argv[1:].index(arg))+2]
  82.             if arg.lower() == "-a" or arg.lower() == "-max":
  83.                     maxw = sys.argv[int(sys.argv[1:].index(arg))+2]
  84.             if arg.lower() == "-i" or arg.lower() == "-min":
  85.                     minw = sys.argv[int(sys.argv[1:].index(arg))+2]
  86.             if arg.lower() == "-w" or arg.lower() == "-words":
  87.                     words = sys.argv[int(sys.argv[1:].index(arg))+2]
  88.             if arg.lower() == "-t" or arg.lower() == "-type":
  89.                     typeh = sys.argv[int(sys.argv[1:].index(arg))+2]
  90.         except(IndexError):
  91.             print "[+] Comandos Obligatorios -t(Tipo de Hash) -h(Hash) -w(Teclas) -a(Maximo de teclas) -a(Minimo de teclas)"
  92.             usage()
  93.             sys.exit(1)
  94.  
  95.     if minw == "" : minw = '1'
  96.  
  97.     main()
  98.     for args in (typeh, hhash, words, maxw, minw):
  99.         try:
  100.             if args != "":
  101.                 if args == typeh :
  102.                     if typeh.lower() != 'md5' or 'sha':
  103.                         if typeh.lower() == "md5" :
  104.                             typeh = '1'
  105.                             print "[+] Tipo de Hash : MD5"
  106.                         elif typeh.lower() == "sha" :
  107.                             typeh = '2'
  108.                             print "[+] Tipo de Hash : SHA1"
  109.                     else:
  110.                         print "[+] Tipo Invalido de Hash"
  111.                         sys.exit(1)
  112.                 if args == hhash :
  113.                     if typeh == '1' :
  114.                         if len(hhash) == 32 :
  115.                             print "[+] MD5 Hash : " + hhash
  116.                         else:
  117.                             print "[+] Tipo Invalido de Hash"
  118.                             sys.exit(1)
  119.                     if typeh == '2' :
  120.                         if len(hhash) == 40 :
  121.                             print "[+] SHA1 Hash : " + hhash
  122.                         else:
  123.                             print "[+] SHA1 Invalido"
  124.                             sys.exit(1)
  125.                 if args == words :
  126.                     print "[+] Teclas a usar : " + words
  127.                 if args == maxw :
  128.                     if maxw.isdigit() != False :
  129.                         if int(maxw) >= 15 :
  130.                             print "[+] Maximo de Digitos : 15 : " + maxw
  131.                             sys.exit(1)
  132.                         else:
  133.                             if int(maxw) > int(minw):
  134.                                 print "[+] Maximo de Digitos : " + maxw
  135.                             else:
  136.                                 print "[+] El Maximo de Digitos debe ser mayor al Minimo de Digitos"
  137.                                 sys.exit(1)
  138.                     else:
  139.                         print "[+] Maximo de Teclas = Digitos"
  140.                         sys.exit(1)
  141.                 if args == minw :
  142.                         if minw.isdigit() != False :
  143.                             if int(minw) < int(maxw) :
  144.                                 print "[+] Minimo de Digitos : " + minw
  145.                             else:
  146.                                 print "[+] El minimo de Digitos debe ser menor al maximo de Digitos"
  147.                                 sys.exit(1)
  148.                         else:
  149.                             print "[+] Minimo de Teclas = Digitos"
  150.                             sys.exit(1)
  151.             else:
  152.                 print "[+] Comandos Obligatorios -t(Tipo de Hash) -h(Hash) -w(Teclas) -a(Maximo de teclas) -a(Minimo de teclas)"
  153.                 usage()
  154.                 sys.exit(1)
  155.         except(ValueError):
  156.             print "[+] Formato de comandos erroneo"
  157.             sys.exit(1)
  158.  
  159.     f = open("CRACK.py",'w')
  160.     f.write("#!/usr/bin/env python\n")
  161.     if (typeh == '1') : f.write("import sys , md5 , string , time\n")
  162.     if (typeh == '2') : f.write("import sys , sha , string , time\n")
  163.     tab = '\t'
  164.     f.write("def timer():\n")
  165.     f.write(tab + "now = time.localtime(time.time())\n")
  166.     f.write(tab + "return time.asctime(now)\n")
  167.     f.write("def crackhash():\n")
  168.  
  169.     i = 0 ; inwords = ""
  170.     f.write(tab + "hashh = '" + hhash.lower() +"'\n")
  171.     f.write(tab + "try:\n")
  172.  
  173.     #print words
  174.     for i in words:
  175.         if i == str(words[int(len(words)-1)]) :
  176.             inwords += "'" + i + "'"
  177.             break
  178.         inwords += "'" + i + "',"
  179.     #print inwords
  180.  
  181.     i = int(minw) ; iwords = "" ; a = 0
  182.  
  183.     while (int(i) != int(maxw) + 1) :
  184.  
  185.         for a in range(i):
  186.             if int(i) != (int(a) + 1):
  187.                 iwords += "i" + str(i) + str(a) + " + "
  188.             else:
  189.                  iwords += "i" + str(i) + str(a)
  190.  
  191.             data = (int(a + 2) * tab + "for i" + str(i) + str(a) + " in (" + inwords + "):\n")
  192.             f.write(data)
  193.  
  194.         f.write(int(i + 2) * tab + "word = '' ; value = ''\n")
  195.         f.write(int(i + 2) * tab + "word = " + iwords + "\n")
  196.  
  197.         if typeh == '1' : f.write(int(i + 2) * tab + "hash = md5.new()\n")
  198.  
  199.         if typeh == '2' : f.write(int(i + 2) * tab + "hash = sha.new()\n")
  200.  
  201.         f.write(int(i + 2) * tab + "hash.update(str(word))\n")
  202.         f.write(int(i + 2) * tab + "value = hash.hexdigest()\n")
  203.         if verbose == 1 : f.write(int(i + 2) * tab + "print " + iwords + ' + " : " + str(value)\n')
  204.         f.write(int(i + 2) * tab + "if str(hashh) == str(value):\n")
  205.         f.write(int(i + 3) * tab + "raise Exception\n")
  206.         iwords = ""
  207.         i += 1
  208.  
  209.     f.write(tab + "except(Exception):")
  210.     f.write('\n'+ 2 * tab + "print '********************  Hash Crackeado ' + 20 * '*'")
  211.     f.write('\n' + 2 * tab + "print '[+] HASH :', hashh")
  212.     f.write('\n' + 2 * tab + "print '[+] PASS :', str(word)")
  213.     f.write('\n' + 2 * tab + "print '[+] Hora de finalizacion :', timer()")
  214.     f.write('\n' + 2 * tab + "sys.exit(1)")
  215.     f.write('\n' + tab + "except(KeyboardInterrupt):")
  216.     f.write('\n' + 2 * tab + "print '[+] Process Ended ',timer()")
  217.     f.write('\n' + 2 * tab + "sys.exit(1)")
  218.     f.write("\ncrackhash()")
  219.     f.close()
  220.  
  221.     print '[+] Hora de inicio : ', timer()
  222.  
  223.     import CRACK
  224.     CRACK.crackhash()
  225. ============================================================================
  226.  
  227. Crackeador de MD5 por Diccionario:
  228.  
  229. Modo de uso:
  230. Código: Python
  231. python Cracker.py e10adc3949ba59abbe56e057f20f883e diccionario.txt
  232.  
  233. Código: Python
  234.  
  235. import md5, sys, getopt
  236. ver= "1.0"
  237. a=0
  238. def run():
  239.    
  240.  if len(sys.argv) == 1 or sys.argv[1]=="-h" or sys.argv[1]=="--help":
  241.    
  242.    print ""
  243.    print ""
  244.    print "Modo de uso: Cracker.py [HASH (MD5)] [Diccionario]"
  245.    print ""
  246.    print "Ejemplo: Cracker.py e10adc3949ba59abbe56e057f20f883e diccionario.txt"
  247.    print ""
  248.      
  249.  else:
  250.   if sys.argv[1]=="-v" or sys.argv[1]=="--version":
  251.    print "Cracker version: " + ver + "\nAutor: ANTRAX"
  252.    
  253.  
  254.  if len(sys.argv) == 3:
  255.      md5crack(sys.argv[1],sys.argv[2],)
  256.  
  257.    
  258. def md5crack(hash,word):
  259.  try:
  260.   wordlist = open(word,"r")
  261.  except IOError:
  262.   print "Diccionario: " + word + " No Existe"
  263.   sys.exit(0)
  264.  
  265.  global a
  266.    
  267.  for line in wordlist.xreadlines():
  268.   word= line.replace("\n","")
  269.   passw = md5.new(word)
  270.  
  271.   if (hash == passw.hexdigest()):
  272.    print ""
  273.    print "Password Crackeada!"
  274.    print 'MD5: ' + passw.hexdigest() + ' ---> ' + word+''
  275.    print "Visita Underc0de.org"
  276.    a = 1
  277.    sys.exit(0)
  278.    
  279.  if ( a == 0):
  280.   print 'Password no Encontrada en este diccionario'
  281.  wordlist.close()
  282.  
  283. def main():
  284.  run()
  285.  
  286.    
  287. if __name__ == "__main__":
  288.     main()
Add Comment
Please, Sign In to add comment