shell_exec not working with nmap command

后端 未结 2 906
栀梦
栀梦 2021-01-07 11:11

I got a problem with the shell_exec php function, here is a example code:

$output = shell_exec(\'nmap -PS80 -n -oG - --send-ip 11.11.11.11\         


        
相关标签:
2条回答
  • 2021-01-07 11:42

    You might want to resort to exec() instead, which gives you greater error diagnostics:

    // Capture outout from STDERR as well
    $command = "nmap ... 2>&1";
    
    exec($command, $output, $return_var);
    
    // If return code is not zero, the command failed
    if ($return_var != 0) 
    {
        // dump all output, including error messages
        var_dump($output);
    }
    
    0 讨论(0)
  • 2021-01-07 12:01

    Try to specify full path to nmap like /usr/local/bin/nmap. PHP might not know about nmap location. Enjoy!

    0 讨论(0)
提交回复
热议问题