XML ); $xml->addAttribute("scanpath", "scans/$site.xml"); foreach ($yaml as $key => $value) { if ($key == "site") { $xml->addAttribute("site", $value); } else { $xmlGroup = $xml->addChild("group"); $xmlGroup->addAttribute("name", $key); foreach($value as $hostaddress => $servicesList) { $targets[$hostaddress] = true; $xmlHost = $xmlGroup->addChild("host"); $xmlHost->addAttribute("address", $hostaddress); if ($servicesList) foreach ($servicesList as $service) { $services[$service] = true; $xmlService = $xmlHost->addChild("service"); $xmlService->addAttribute("name", $service); } } } } $targets = join(array_keys($targets), " "); $services = join(array_keys($services), ","); exec("nmap -v -Pn -p $services --script smb-enum-shares,".__DIR__."/nmap -oX '".__DIR__."/scans/tmp.xml' $targets\n"); rename(__DIR__."/scans/tmp.xml", __DIR__."/scans/$site.xml"); $xml->asXML(__DIR__."/site/$site.xml"); } } ?>