其他分享
首页 > 其他分享> > nmap xml处理

nmap xml处理

作者:互联网

<?php
$file_path = "xiamen_scan_ok.xml";
$file = fopen($file_path, "r");

//输出文本中所有的行,直到文件结束为止。
global $ip;
while(!feof($file))
{
    $line= fgets($file);//fgets()函数从文件指针中读取一行'
    //echo $line;
    preg_match("/address addr=\"(.+)\" addrtype=\"ipv4\"/", $line,$ips);//匹配IP
    preg_match("/<port protocol=\"tcp\" portid=\"(.+)\"><state state=\"open\".+<service name=\"(\S+)\" /", $line,$port);//匹配端口

    if ($ips) {
        $ip = $ips;
    }
    if ($port) {
        echo $ip[1].":".$port[1].":".$port[2];
        echo '<br>';
    }
}
fclose($file);
?>

 

标签:nmap,xml,fclose,file,处理
来源: https://www.cnblogs.com/nul1/p/13954039.html