Created
March 24, 2022 14:29
-
-
Save numanturle/26544d7ff22d1c52599b8cacfbd69402 to your computer and use it in GitHub Desktop.
nmap terminal parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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