Aug 31, 2007
i'm trying to create a script that executes nmap from my server, then displays the output.
View 1 Replies
$output = passthru('nmap -v -A'.' $ip');
$output = shell_exec('nmap -v -A'.' $ip');
system('nmap -v -A'.' $ip');
the problem i'm having is that using the above methods i only get the first line of output, ie.
Starting Nmap 4.20 ( http://insecure.org ) at 2007-08-31 21:46 CST
and nothing else. i've managed to find a way around it by sending the nmap output to a textfile, the using file_get_contents() to pull the data back in:
exec('nmap -v -A '.$ip.' > /usr/local/www/apache22/data/nmap/'.$ip.'.html');
$file = "/usr/local/www/apache22/data/nmap/$ip.html";
$result = file_get_contents($file);
that works perfectly, but i'd rather not be writing anything to the drive. i guess the problem might be that nmap takes about 5-10 seconds to do its scan, and for some reason php doesn't want to wait that long, i really have no idea. can it be made to work without needing to write to files?
and for the curious minds, i'm not doing anything dodgy, i just wanted an online tool i could access from any computer to test networks i support .