small fixes
This commit is contained in:
parent
e1bde27789
commit
c3082c9442
28
LISEZMOI.md
Normal file
28
LISEZMOI.md
Normal file
@ -0,0 +1,28 @@
|
||||
# lanScan
|
||||
|
||||
Scanne des hôtes avec `nmap`
|
||||
et affiche le résultat dans une page web.
|
||||
|
||||
* Créer un fichier de configuration YAML dans un sous-dossier ./configs/ (voir l'exemple ci-dessous).
|
||||
Il peut être généré en scannant un réseau avec : `./discover <CIDR>`.
|
||||
* Scanner avec le script `./scan_all` (utiliser une tâche cron !).
|
||||
* Voir les résultats en ouvrant `.\index.php` dans le navigateur web.
|
||||
|
||||
## Exemple
|
||||
```yaml
|
||||
---
|
||||
site: Nom du site
|
||||
|
||||
hosts:
|
||||
- name: Nom du premier groupe
|
||||
host:
|
||||
- address: host1.local
|
||||
services: [ssh, http]
|
||||
- address: 192.168.1.100
|
||||
services: [ftp, https, 5432]
|
||||
- name: Nom du 2ème groupe
|
||||
host:
|
||||
- adress: host3.local
|
||||
services: [ssh, ftp, 8006]
|
||||
```
|
||||
|
13
README.md
13
README.md
@ -1,14 +1,13 @@
|
||||
# lanScan
|
||||
|
||||
Scanne des hôtes spécifiées avec un fichier de configuration en YAML
|
||||
et affiche le résultat dans une page web.
|
||||
Scan hosts with `nmap` and display results in webpage.
|
||||
|
||||
* Créer un fichier de configuration YAML dans un sous-dossier ./configs/ (voir l'exemple ci-dessous).
|
||||
Il peut être généré en scannant un réseau (en notation CIDR) avec : `./discover XXX.XXX.XXX.XXX/XX`.
|
||||
* Scanner avec le script `./scan_all` (utiliser une tâche cron !).
|
||||
* Voir les résultats dans le navigateur web.
|
||||
* Create a configuration yaml file in ./configs/ subdirectory (see example below).
|
||||
It may be generated by scanning a network with `./discover <CIDR>`.
|
||||
* Scan with `./scan_all` (use a cron task!).
|
||||
* Open `.\index.php` in web browser to see results.
|
||||
|
||||
## Exemple
|
||||
## Example
|
||||
```yaml
|
||||
---
|
||||
site: Nom du site
|
||||
|
22
discover
22
discover
@ -3,17 +3,23 @@
|
||||
###
|
||||
#
|
||||
# Scan un réseau avec nmap pour créer un fichier de configuration
|
||||
# Usage : ./discover <network> avec network en notation CIDR XXX.XXX.XXX.XXX/XX
|
||||
# Usage : ./discover <reseau> avec reseau en notation CIDR XXX.XXX.XXX.XXX/XX
|
||||
#
|
||||
###
|
||||
|
||||
DIR="$(dirname -- "$0")"
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo -e "Usage : ./discover <CIDR>\navec <CIDR> l'adresse réseau en notation CIDR (XXX.XXX.XXX.XXX/XX)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pushd "$(dirname -- "$0")" > /dev/null
|
||||
network="$1"
|
||||
filename="${network/\//_}"
|
||||
site="${network/\//_}"
|
||||
|
||||
mkdir -p "$DIR/scans"
|
||||
nmap -F -oX "$DIR/scans/$filename.xml" $network
|
||||
mkdir -p "$DIR/configs"
|
||||
xsltproc --stringparam network "$network" to_config.xsl "$DIR/scans/$filename.xml" > "$DIR/configs/$filename.yaml"
|
||||
php to_XML.php "$DIR/configs/$filename.yaml" > "$DIR/site/$site.xml"
|
||||
mkdir -p "scans"
|
||||
nmap -F -oX "scans/$site.xml" $network
|
||||
mkdir -p "configs"
|
||||
xsltproc --stringparam network "$network" to_config.xsl "scans/$site.xml" > "configs/$site.yaml"
|
||||
php to_XML.php "configs/$site.yaml" > "site/$site.xml"
|
||||
|
||||
popd > /dev/null
|
43
nmap_cmd.php
43
nmap_cmd.php
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
$file = $argv[1];
|
||||
$site = basename($file, ".yaml");
|
||||
$__DIR__ = __DIR__;
|
||||
|
||||
$conf = yaml_parse_file($file);
|
||||
|
||||
$xml = new SimpleXMLElement(<<<XML
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href='../results.xsl' type='text/xsl'?>
|
||||
<lanScanConf scanpath="scans/$site.xml"/>
|
||||
XML
|
||||
);
|
||||
|
||||
$targets = [];
|
||||
$services = [];
|
||||
|
||||
foreach ($conf as $key => $value) {
|
||||
if ($key == "site") {
|
||||
$xml->addAttribute("site", $value);
|
||||
} else {
|
||||
$xmlGroup = $xml->addChild("group");
|
||||
$xmlGroup->addAttribute("name", $key);
|
||||
foreach($value as $hostaddress => $servicesList) {
|
||||
$xmlHost = $xmlGroup->addChild("host");
|
||||
$xmlHost->addAttribute("address", $hostaddress);
|
||||
$targets[$hostaddress] = true;
|
||||
if ($servicesList) foreach ($servicesList as $service) {
|
||||
$xmlService = $xmlHost->addChild("service");
|
||||
$xmlService->addAttribute("name", $service);
|
||||
$services[$service] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$xml->asXML("site/$site.xml");
|
||||
|
||||
$targets = join(array_keys($targets), " ");
|
||||
$services = join(array_keys($services), ",");
|
||||
|
||||
echo ("nmap -v -T4 -p $services --script $__DIR__/http-info.nse -oX $__DIR__/scans/.~$site.xml $targets");
|
||||
?>
|
@ -10,7 +10,7 @@
|
||||
<xsl:template match="lanScan">
|
||||
<xsl:text>nmap -v -T4 -p </xsl:text>
|
||||
<xsl:apply-templates select="//service[not(.=preceding::*)]" />
|
||||
<xsl:text> --script "$DIR/http-info.nse" -oX "$DIR/</xsl:text>
|
||||
<xsl:text> --script "http-info.nse" -oX "</xsl:text>
|
||||
<xsl:value-of select="@scanpath"/>
|
||||
<xsl:text>.tmp" </xsl:text>
|
||||
<xsl:apply-templates select="//host"/>
|
||||
|
18
scan
18
scan
@ -1,9 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export DIR="$(dirname -- "$0")"
|
||||
config="$1"
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: ./scan <config>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
site="$(basename ${config/.yaml/})"
|
||||
php to_XML.php "$config" > "$DIR/site/$site.xml"
|
||||
xsltproc nmap_cmd.xsl "$DIR/site/$site.xml" | sh
|
||||
mv "$DIR/scans/$site.xml.tmp" "$DIR/scans/$site.xml"
|
||||
pushd "$(dirname -- "$0")" > /dev/null
|
||||
site="$(basename ${1/.yaml/})"
|
||||
|
||||
php "to_XML.php" "configs/$site.yaml" > "site/$site.xml"
|
||||
eval $(xsltproc "nmap_cmd.xsl" "site/$site.xml")
|
||||
mv "scans/$site.xml.tmp" "scans/$site.xml"
|
||||
|
||||
popd > /dev/null
|
15
scan_all
15
scan_all
@ -1,12 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
DIR="$(dirname -- $0)"
|
||||
pushd "$(dirname -- $0)" > /dev/null
|
||||
|
||||
mkdir -p "$DIR"/scans
|
||||
mkdir -p "$DIR"/site
|
||||
mkdir -p scans
|
||||
mkdir -p site
|
||||
|
||||
for config in "$DIR"/configs/*.yaml
|
||||
for config in configs/*.yaml
|
||||
do
|
||||
echo $config
|
||||
./scan "$config" &
|
||||
site="$(basename ${config/.yaml/})"
|
||||
echo "Scan $site"
|
||||
./scan "$site" &
|
||||
done
|
||||
|
||||
popd > /dev/null
|
@ -5,10 +5,12 @@ $__DIR__ = __DIR__;
|
||||
|
||||
$conf = yaml_parse_file($file);
|
||||
|
||||
$xml = new DomDocument("1.0");
|
||||
$xml = new DomDocument("1.0", "utf-8");
|
||||
$xml->preserveWhiteSpace = false;
|
||||
$xml->formatOutput = true;
|
||||
$xml->appendChild($xml->createProcessingInstruction("xml-stylesheet", "href='../results.xsl' type='text/xsl'"));
|
||||
$root = $xml->appendChild($xml->createElement("lanScan"));
|
||||
$root->setAttribute("scanpath", "scans/$site.xml");
|
||||
$root->setAttribute("scanpath", "./scans/$site.xml");
|
||||
|
||||
function appendArray($document, $node, $array) {
|
||||
foreach ($array as $key => $value) {
|
||||
|
Reference in New Issue
Block a user