Jump to content

exec(), system(), shell_exec(), etc + nmap


Recommended Posts

hi

 

i'm trying to create a script that executes nmap from my server, then displays the output.

 

i've tried:

 

$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);

echo "(pre)$result(/pre)";

 

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 :)

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/67441-exec-system-shell_exec-etc-nmap/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.