This repository has been archived on 2025-02-13. You can view files and clone it, but cannot push or open issues or pull requests.
lanScan2/scan_all.php
2023-04-09 17:28:10 +02:00

46 lines
1.6 KiB
PHP

<?php
if (!file_exists("scans")) mkdir("scans");
foreach (scandir("./site") as $file) {
if (strrpos($file, ".yaml")) {
$site = str_replace(".yaml", "", $file);
$yaml = yaml_parse_file("site/$file");
$targets = [];
$services = [];
$xml = new SimpleXMLElement(<<<XML
<?xml version="1.0"?>
<?xml-stylesheet href='../results.xsl' type='text/xsl'?>
<lanScanConf/>
XML);
$xml->addChild("scan path='scans/$site.xml'");
foreach ($yaml as $siteName => $groups) {
$xml->addAttribute("name", $siteName);
if ($groups) foreach ($groups as $groupName => $hosts) {
$xmlGroup = $xml->addChild("group");
$xmlGroup->addAttribute("name", $groupName);
if ($hosts) foreach($hosts 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 = array_keys($targets);
$services = array_keys($services);
$xml->asXML("site/$site.xml");
exec("nmap -v -Pn -p ".join($services, ",")." --script smb-enum-shares.nse -oX 'scans/$site.xml' ".join($targets, " ")."\n");
}
};
?>