The lip adresses and the lines in format "22/tcp open ssh" are those which have importance to me
Code: Select all
Starting Nmap 5.00 ( http://nmap.org ) at 2012-04-19 20:08 CEST
Interesting ports on 192.168.70.6:
Not shown: 1022 closed ports
PORT STATE SERVICE
22/tcp open ssh
23/tcp open telnet
Interesting ports on 192.168.70.25:
Not shown: 1021 closed ports
PORT STATE SERVICE
21/tcp open ftp
80/tcp open http
443/tcp open https
Nmap done: 256 IP addresses (2 hosts up) scanned in 7.27 secondsI need to get IP adresses and their corresponding Port_number protocol, state and name of service
My code which take care of parsing "Port_number protocol, state and name of service" is>
Code: Select all
$port_mappings = preg_grep('!^\d+/\S+ +\S+ !', $lines); // get the interesting lines
$parsed_port_mappings = array();
foreach($port_mappings as $port_mapping)
{
preg_match('!^(?P<port>\d+)/(?P<protocol>\S+) +(?P<state>\S+) +(?P<service>\S+)!', $port_mapping, $parsed_port_mappings[]);
} The problem is i need to make som adjustment which provide me some machanism to parse also IP addresses and their coresponding "Port_number protocol, state and name of service" best would be multiarray like "$parsed_port_mappings[X][Y]['service']" probably, where X will be the IP address and Y will be the corresponding lines or any other solution which will fit here. Thanks for your help.