Search code examples
phpperlsystem

Calling a Perl program from PHP and printing the output


For a school project I want to try scanning websites for vulnerabilities, and show the responds on a page.

For this I am trying to use Uniscan.

I tried a lot of ways to get any responds but it isn't working out.

This is what I have right now:

   <?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;
?>

This is the responds, the only thing you see is the responds of the 'ls' command.

Responds

I hope someone can help me.


Solution

  • The problem was that the www-data user didn't had rights to run that script.

    So when I gave him right in the sudoers file like this:

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

    everything works perfectly!