I'm trying to make the output of the nmap result appear in the browser in the form of a table. follow the code below:
<?php
$host = $_POST["host"];
$saida = shell_exec('nmap -P0 ' . $host);
$vetorLinhas = explode("\n", $saida);
echo "<pre>$alinhamento</pre>";
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>tecnologia</title>
</head>
<body>
<table>
<tr>
<td colspan="5">Scanner de Porta TCP/UDP</td>
</tr>
<tr>
<td height="60" colspan="5" align="center">
<form id="form1" name="form1" method="post" action="exemplo.php">
<br/>
Endereço de Host
<label for="textfield">
<input type="text" name="host" id="textfield" />
<input type="submit" name="button" id="button" value="Ir" />
</label>
</form>
</td>
</tr>
<tr>
<td height="60" colspan="5">
<pre>
<?php
echo "<b><center>$host</center></b><br>";
if (count($vetorLinhas)) {
foreach ($vetorLinhas as $indice => $linha) {
echo "<pre>$indice - $linha</pre>";
}
}
?>
</pre>
</td>
</tr>
</table>
</body>
</html>
It's like this in the browser
0 -
1 - Starting Nmap 7.01 ( https://nmap.org ) at 2016-11-20 19:36 BRT
2 - Nmap scan report for localhost (127.0.0.1)
3 - Host is up (0.000088s latency).
4 - Not shown: 994 closed ports
5 - PORT STATE SERVICE
6 - 21/tcp open ftp
7 - 80/tcp open http
8 - 139/tcp open netbios-ssn
9 - 445/tcp open microsoft-ds
10 - 3306/tcp open mysql
11 - 5432/tcp open postgresql
12 -
13 - Nmap done: 1 IP address (1 host up) scanned in 0.07 seconds
14 -
The question is how would this algorithm in PHP go out in table format in html from the line "PORT STATE SERVICE" and stop displaying in line "Nmap done: 1 IP address (1 host up) scanned in 0.07 seconds" ??