Skip to content

Instantly share code, notes, and snippets.

@numanturle
Created March 24, 2022 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save numanturle/26544d7ff22d1c52599b8cacfbd69402 to your computer and use it in GitHub Desktop.
Save numanturle/26544d7ff22d1c52599b8cacfbd69402 to your computer and use it in GitHub Desktop.
nmap terminal parser
<?php
$ac = file(trim($argv[1]));
$start = 0;
$sonuc = [];
$son_ip = "";
foreach($ac as $satir){
if(strstr($satir, "Nmap scan report for")){
$start = 1;
$ip = explode("Nmap scan report for",$satir);
$ip = trim(end($ip));
$son_ip = $ip;
}else if(strstr($satir, "tcp open")){
$parca = explode(" ",$satir);
$parca = array_map("trim",$parca);
$sonuc[] = [
"port" => $parca[0],
"ip" => $son_ip
];
}
}
echo "ip,port".PHP_EOL;
foreach($sonuc as $son){
echo $son["ip"].",".$son["port"].PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment