PHP proc_open无法与裂土器John一起正常工作

PHP proc_open无法与裂土器John一起正常工作,php,process,exec,Php,Process,Exec,我正在尝试从PHP脚本运行John the Ripper。我想运行它,然后监视它的输出,并做出相应的反应。然而,事情并没有按预期的那样进行,我得到的结果(据我所知)是随机的。我可以想象我错过了什么 问题是输出流不产生任何输出。这对John来说有点正常——当用户使用键盘键入字符时会产生输出。因此,我向我设置的stdin管道写信。然而,这并不会导致约翰产生产出。有什么建议吗 代码: <?php $descriptorspec = array ( 0 => array("pipe

我正在尝试从PHP脚本运行John the Ripper。我想运行它,然后监视它的输出,并做出相应的反应。然而,事情并没有按预期的那样进行,我得到的结果(据我所知)是随机的。我可以想象我错过了什么

问题是输出流不产生任何输出。这对John来说有点正常——当用户使用键盘键入字符时会产生输出。因此,我向我设置的stdin管道写信。然而,这并不会导致约翰产生产出。有什么建议吗

代码:


<?php

$descriptorspec = array (
   0 => array("pipe", "r"),  // stdin is a pipe that the child will read from
   1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
   2 => array("file", "/tmp/error-output.txt", "w")   // stderr is a file to write to
);

// JOHN is the full path to the john executable
$command = JOHN . " --nolog --config=" . dirname (JOHN) . "/john.conf working/hashes-job-{$_POST['id']} --pot=working/hashes-job-{$_POST['id']}.pot";// --format=raw-md5";
$process = proc_open ($command, $descriptorspec, $pipes);

if (is_resource ($process)) {
    sleep(5);
    fwrite ($pipes[0], "a\n");
    fflush ($pipes[0]);
    while (!feof ($pipes[1])) {
            // I have tried with the following uncommented as well
            // That led to the while loop exiting prematurely for some reason...
        // stream_set_blocking($pipes[1], false);
        $output = fread ($pipes[1], 4096);
        // stream_set_blocking($pipes[1], true);

        file_put_contents ('/tmp/dpcp-tool-' . time (), $output);
        fwrite ($pipes[0], 'a');
        fflush ($pipes[0]);
        file_put_contents ('/tmp/publishOutcome-' . time (), $reply);
        sleep(5);
    }

    file_put_contents('/tmp/died-' . time(), $entered);
    fclose ($pipes[0]);
    fclose ($pipes[1]);
    $return_value = proc_close ($process);
}