简体   繁体   中英

Passing arguments to John the Ripper during session using Java ProcessBuilder

i am trying to run John the Ripper with the Java ProcessBuilder. Everything is working so far.

My problem is regarding the John the Ripper Status information. While a cracking session is running in a Bash, you can press any key to display status information like this one:

guesses: 0 time: 51:06:37:19 0.00% (3) c/s: 4466 trying: shs1geO - shs1god

What i am not able to achieve is to pass the "any key" to the Process during execution so that status line is returned.

I have tried the BufferedWriter and passed all kinds of Strings, line separators and backslash n. Nothing has worked so far, my write(x) just gets ignored. The process terminates normally and returns the normal process output.

Here is some code to illustrate:

        long lastStatusTime = System.nanoTime();
        long interval = 5 * 1000L * 1000 * 1000;
        int counter = 0;

        while(!(proM.isComplete())){
            if((lastStatusTime + interval) <= System.nanoTime()){
                bw.write("q");
                bw.flush();

                line = br.readLine();
                System.out.println(line);
                lastStatusTime = System.nanoTime();

            }
        }

        //Proc output
        while ((line = br.readLine()) != null) {
            System.out.println(line);
        }

the first while is executed as long as the process didnt finish and writes the "q" (or any key other key) to the BufferedWriter every 5 seconds (or at least it is supposed to).

When the Process is terminated the while stops and the second while captures the normal process output.

Unfortunately the write is completely ignored and the readLine inside the if-statement blocks until the first Line of the normal termination output is received.

Building of the BufferedWriter:

        OutputStream os = process.getOutputStream();
        OutputStreamWriter osw = new OutputStreamWriter(os);
        BufferedWriter bw = new BufferedWriter(osw);

Is anyone able to help resolve this issue? i am trying for hours

Thanks in advance for any help

You don't show us how you construct your BufferedWriter. When you create your Process, are you getting the Streams associated with the process, ie, the InputStream, OutputStream and ErrorStreams? You should, and then you should try to send a new line char to the OutputStream.

Myself, I'd wrap the OutputStream in a PrintStream, and simply call println() on it.


Edit
Note that I am not familiar with the program that you are trying to control. If it is not a console program, then writing to the OutputStream will not help. Instead you would need to send key strokes to the game's window, perhaps via the Robot class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM