Advertisement
Driverfury

Basi Di Crittografia #6 - Bruteforce MD5

Mar 12th, 2016
797
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.90 KB | None | 0 0
  1. import hashlib
  2.  
  3. # Stringa da decriptare, puoi inserire qualsiasi hash MD5 tu voglia
  4. hashDaDecriptare = "74efb8aac68e37c289dfcf260e19ab25"
  5.  
  6. # Lista dei caratteri possibili in una password.
  7. listaCaratteri = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ".", ",", "-", "_", "@", "+"]
  8.  
  9. # Funzione che verifica se la password passata come parametro
  10. # e' quella corretta e di conseguenza e' stata indovinata.
  11. def testaPassword(password):
  12.     m = hashlib.md5()
  13.     m.update(password)
  14.     if (m.hexdigest() == hashDaDecriptare):
  15.         print "Password trovata:", password
  16.         exit()
  17.    
  18. # Qui bisogna supporre una lunghezza massima della password,
  19. # ipotizziamo 12 caratteri.
  20. # Stabiliamo anche una lunghezza minima: 4 caratteri. Di conseguenza
  21. # da 4 caratteri in poi verra' testata la password (attraverso
  22. # la funzione testaPassword).
  23. for c1 in listaCaratteri:
  24.     for c2 in listaCaratteri:
  25.         for c3 in listaCaratteri:
  26.             for c4 in listaCaratteri:
  27.                 psw = c1+c2+c3+c4   # La password da testare sara' composta dai caratteri
  28.                                     # correnti ovvero c1, c2, c3, c4
  29.                 testaPassword(psw)
  30.                 for c5 in listaCaratteri:
  31.                     psw = c1+c2+c3+c4+c5    # La password da testare sara' composta dai
  32.                                             # caratteri correntiovvero c1, c2, c3, c4
  33.                     testaPassword(psw)
  34.                     for c6 in listaCaratteri:
  35.                         psw = c1+c2+c3+c4+c5+c6
  36.                         testaPassword(psw)
  37.                         for c7 in listaCaratteri:
  38.                             psw = c1+c2+c3+c4+c5+c6+c7
  39.                             testaPassword(psw)
  40.                             for c8 in listaCaratteri:
  41.                                 psw = c1+c2+c3+c4+c5+c6+c7+c8
  42.                                 testaPassword(psw)
  43.                                 for c9 in listaCaratteri:
  44.                                     psw = c1+c2+c3+c4+c5+c6+c7+c8+c9
  45.                                     testaPassword(psw)
  46.                                     for c10 in listaCaratteri:
  47.                                         psw = c1+c2+c3+c4+c5+c6+c7+c8+c9+c10
  48.                                         testaPassword(psw)
  49.                                         for c11 in listaCaratteri:
  50.                                             psw = c1+c2+c3+c4+c5+c6+c7+c8+c9+c10+c11
  51.                                             testaPassword(psw)
  52.                                             for c12 in listaCaratteri:
  53.                                                 psw = c1+c2+c3+c4+c5+c6+c7+c8+c9+c10+c11+c12
  54.                                                 testaPassword(psw)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement