从PHP调用Perl程序并打印输出

时间:2017-05-09 09:10:32

标签: php perl system

对于学校项目,我想尝试扫描网站的漏洞,并在页面上显示响应。

为此,我尝试使用Uniscan。

我尝试了很多方法来获得任何响应,但它没有成功。

这就是我现在所拥有的:

   <?php
echo '<pre>';

// Outputs all the result of shellcommand "ls", and returns
// the last output line into $last_line. Stores the return value
// of the shell command in $retval.
$last_line = system('perl uniscan.pl -u https://domain.nl/ -qweds;ls', $ret$

// Printing additional info
echo '</pre>
<hr />Last line of the output: ' . $last_line . '
<hr />Return value: ' . $retval;
?>

这是回应,你看到的唯一一件事就是回应了这些回应。命令。

Responds

我希望有人可以帮助我。

2 个答案:

答案 0 :(得分:0)

我认为您从http://php.net/manual/en/function.system.php复制了很差的代码。

除此之外,您的代码还存在语法错误。您已将$ret传递给系统但尝试打印$retval。还缺少右括号。

试试这个:

$last_line = system('/usr/bin/perl uniscan.pl -u https://domain.nl/ -qweds', $retval);

请注意,我提供了perl解释器的绝对路径。

答案 1 :(得分:0)

问题是www-data用户没有权限运行该脚本。

所以当我在sudoers文件中给他正确的时候:

www-data ALL = NOPASSWD: /var/www/html/Uniscan/uniscan.pl

一切都很完美!