diff --git a/.gitignore b/.gitignore
index dc49af4..f5c2be8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,2 @@
-confs/*.yaml
-!confs/example.yaml
+site/
scans/
diff --git a/README.md b/README.md
index b6df430..c691f6c 100644
--- a/README.md
+++ b/README.md
@@ -2,17 +2,18 @@
Scan hosts with nmap and display results in webpage.
-* Create a configuration yaml file in confs/ subdirectory (see example below).
+* Create a configuration yaml file in site/ subdirectory (see example below).
It may be generated by scanning a network with `init.sh`.
* Scan with `php scan_all.php` (use a cron task!).
* Open index.php to see results.
## Example
```yaml
-group1:
- host1.local: [ssh, http]
- host2.local: [ftp, https, 5432]
-group2:
- host3: [ssh, ftp, 8006]
+site:
+ group1:
+ host1.local: [ssh, http]
+ host2.local: [ftp, https, 5432]
+ group2:
+ host3: [ssh, ftp, 8006]
```
diff --git a/index.php b/index.php
index 8ae1edf..1eb8c92 100644
--- a/index.php
+++ b/index.php
@@ -1,12 +1,36 @@
-
+
+
+
+
+
+$site\n";
+ }
+ }
+} ?>
+
+
+
+
\ No newline at end of file
diff --git a/init.sh b/init.sh
old mode 100644
new mode 100755
index 8fef3a0..d4cf77b
--- a/init.sh
+++ b/init.sh
@@ -7,8 +7,8 @@
###
echo "Nom du site ?"
-read name
+read site
echo "Plage IP (xxx.xxx.xxx.xxx/xx) ?"
read network
-nmap --script smb-enum-shares.nse -oX "confs/$name.xml" $network
-xsltproc toyaml.xsl "confs/$name.xml" > "confs/$name.yaml"
+nmap --script smb-enum-shares.nse -oX "scans/$site.xml" $network
+xsltproc --stringparam site "$site" --stringparam network $network toyaml.xsl "scans/$site.xml" > "site/$site.yaml"
diff --git a/ls.php b/ls.php
deleted file mode 100644
index bacfd57..0000000
--- a/ls.php
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-$site\n";
- }
- }
-} ?>
-
-
-
-
\ No newline at end of file
diff --git a/results.php b/results.php
deleted file mode 100644
index 7204082..0000000
--- a/results.php
+++ /dev/null
@@ -1,146 +0,0 @@
-
-
-
-
-
=$scan->runstats->finished["summary"]?>
- $conf_hosts) { ?>
-
-
- $conf_services) {
- echo " \n";
- $scan_host = $scan->xpath("host[hostnames/hostname/@name='$conf_address' or address/@addr='$conf_address']")[0];
- $address = count($scan_host->xpath("hostnames/hostname/@name")) ? $scan_host->xpath("hostnames/hostname/@name")[0] : $scan_host->xpath("address/@addr")[0];
- if ($scan_host->status["state"] =="up") {
-?>
-
-
-
-
=$scan_host->address["addr"]?>
-
-
-
-
-
-
-
-
-
=$scan_host->address["addr"]?>
-
-
-
-
-
-
-
-
diff --git a/results.xsl b/results.xsl
new file mode 100644
index 0000000..2107087
--- /dev/null
+++ b/results.xsl
@@ -0,0 +1,138 @@
+
+
+
+
+
+
+
+
+
+ lanScan -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ,
+
+
+
+
+
+
+
+
+ rdp
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/scan_all.php b/scan_all.php
index d16705c..b2babd2 100644
--- a/scan_all.php
+++ b/scan_all.php
@@ -1,27 +1,44 @@
$hosts) {
- foreach($hosts as $hostaddress => $servicesList) {
- $targets[$hostaddress] = true;
- foreach ($servicesList as $service) {
- $services[$service] = true;
+ $xml = new SimpleXMLElement(<<
+
+
+ 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, " "));
+ //exec("nmap -v -Pn -p ".join($services, ",")." --script smb-enum-shares.nse -oX 'scans/$site.xml' ".join($targets, " "));
}
};
diff --git a/toxml.php b/toxml.php
index 235c80c..9c2ac67 100644
--- a/toxml.php
+++ b/toxml.php
@@ -1,19 +1,29 @@
");
+$site = str_replace(".yaml", "", basename($argv[1]));
-foreach ($yaml as $groupName => $hosts) {
- $xmlGroup = $xml->addChild("group");
- $xmlGroup->addAttribute("name", $groupName);
- if ($hosts) foreach ($hosts as $hostName => $services) {
- $xmlHost = $xmlGroup->addChild("host");
- $xmlHost->addAttribute("name", $hostName);
- if ($services) foreach ($services as $service) {
- $xmlHost->addChild("service");
- $xmlHost->addAttribute("name", $service);
+$xml = new SimpleXMLElement(<<
+
+
+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 $hostName => $services) {
+ $xmlHost = $xmlGroup->addChild("host");
+ $xmlHost->addAttribute("address", $hostName);
+ if ($services) foreach ($services as $service) {
+ $xmlService = $xmlHost->addChild("service");
+ $xmlService->addAttribute("name", $service);
+ }
}
- }
+}
}
-echo $xml->asXML();
+$xml->asXML("site/$site.xml");
?>
diff --git a/toyaml.xsl b/toyaml.xsl
index 7e70130..0315a50 100644
--- a/toyaml.xsl
+++ b/toyaml.xsl
@@ -5,15 +5,19 @@
version="1.1">
+
+
+
---
-:
+:
+ :
-
+