Jump to content

help formating output


DataSpy

Recommended Posts

I'm using system() to run NMAP and then display the output but it's one big string, how can I format it to look like what I see in the command line?

 

web app output:

Starting Nmap 5.00 ( http://nmap.org ) at 2012-03-21 18:44 CDT Interesting ports on localhost (127.0.0.1): Not shown: 993 closed ports PORT STATE SERVICE 80/tcp open http 111/tcp open rpcbind 139/tcp open netbios-ssn 443/tcp open https 445/tcp open microsoft-ds 631/tcp open ipp 3306/tcp open mysql Nmap done: 1 IP address (1 host up) scanned in 0.11 seconds 0

 

command line output:

Starting Nmap 5.00 ( http://nmap.org ) at 2012-03-21 18:48 CDT

Interesting ports on localhost (127.0.0.1):

Not shown: 993 closed ports

PORT    STATE SERVICE

80/tcp  open  http

111/tcp  open  rpcbind

139/tcp  open  netbios-ssn

443/tcp  open  https

445/tcp  open  microsoft-ds

631/tcp  open  ipp

3306/tcp open  mysql

 

Nmap done: 1 IP address (1 host up) scanned in 0.45 seconds

 

<?php
// path to NMAP
$Path = '/usr/bin/nmap';

if(isset($_POST['scan']))
{
$IP = $_POST['IP'];
$ScanType = $_POST['ScanType'];

echo "<br /><u>Results for NMAP Scan</u> <br />";

system("$Path $ScanType $IP 2>&1", $Output);

echo $Output;
}
?>

 

any help would be greatly appreciated, thanks in advance!!

Link to comment
Share on other sites

My PHP regex is shoddy at best, but in bash you would use grep, awk, and sed to cut the line up.  This of course requires there to be some sort of static output.  I've not played with nmap nor php regex, so I can't help you there, but hopefully at least you have some direction to pursue.

Link to comment
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.