Foro de elhacker.net

Programación => Scripting => Mensaje iniciado por: BigBear en 10 Febrero 2012, 21:04 pm



Título: [Ruby] CrackHash 0.1
Publicado por: BigBear en 10 Febrero 2012, 21:04 pm
Un simple codigo en ruby para crackear un hash md5 con un diccionario.

Código
  1. #!usr/bin/ruby
  2. #CrackHash 0.1
  3. #Coded By Doddy H
  4. #Test with 202cb962ac59075b964b07152d234b70 = 123
  5.  
  6. require "digest/md5"
  7.  
  8. def openwords(file)
  9.  if File.file?(file)
  10.    print "\n[+] Opening file\n\n"
  11.    ar = File.open(file)
  12.    lineas = ar.readlines
  13.    ar.close
  14.    print "[+] Number of words : ",lineas.length,"\n\n"
  15.    return lineas
  16.  else
  17.    print "[-] Error opening file\n"
  18.  end
  19. end
  20.  
  21. def sintax()
  22.  print "\n[+] ruby crack.rb <hash> <wordlist>\n"
  23. end
  24.  
  25. def head()
  26.  print "\n-- == CrackHash 0.1 == --\n\n"
  27. end
  28.  
  29. def copyright()
  30.  print "\n\n(C) Doddy Hackman 2012\n"
  31.  exit(1)
  32. end
  33.  
  34. hash = ARGV[0]
  35. wordlist = ARGV[1]
  36.  
  37. head()
  38.  
  39. if !hash and !wordlist
  40.  sintax()
  41. else
  42.  if hash.length ==32
  43.    words = openwords(wordlist)
  44.    print "\n[+] Cracking hash...\n\n"
  45.    words.each do |word|
  46.      word = word.chomp
  47.      if Digest::MD5.hexdigest(word) == hash
  48.        print "\a\a\n[+] Hash cracked : ",word,"\n"
  49.        copyright()
  50.      end      
  51.    end
  52.    print "\n[-] Hash not found\n\n"
  53.  else
  54.    print "\n[-] Hash invalid\n\n"
  55.    copyright()      
  56.  end
  57. end
  58.  
  59. copyright()
  60.  
  61.  
  62. # The End ?
  63.