Compare commits
No commits in common. "9df3ae155a3268e4e3e44832669852636128de34" and "c85c175416dc525f1cfd7d853438c69e322af0a4" have entirely different histories.
9df3ae155a
...
c85c175416
@ -4,8 +4,8 @@ Scanne des hôtes avec `nmap`
|
|||||||
et affiche le résultat dans une page web.
|
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).
|
* 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.sh <CIDR>`.
|
Il peut être généré en scannant un réseau avec : `./discover <CIDR>`.
|
||||||
* Scanner avec le script `./scan_all.sh` (utiliser une tâche cron !).
|
* Scanner avec le script `./scan_all` (utiliser une tâche cron !).
|
||||||
* Voir les résultats en ouvrant `.\index.php` dans le navigateur web.
|
* Voir les résultats en ouvrant `.\index.php` dans le navigateur web.
|
||||||
|
|
||||||
## Exemple
|
## Exemple
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
Scan hosts with `nmap` and display results in webpage.
|
Scan hosts with `nmap` and display results in webpage.
|
||||||
|
|
||||||
* Create a configuration yaml file in ./configs/ subdirectory (see example below).
|
* Create a configuration yaml file in ./configs/ subdirectory (see example below).
|
||||||
It may be generated by scanning a network with `./discover.sh <CIDR>`.
|
It may be generated by scanning a network with `./discover <CIDR>`.
|
||||||
* Scan with `./scan_all.sh` (use a cron task!).
|
* Scan with `./scan_all` (use a cron task!).
|
||||||
* Open `.\index.php` in web browser to see results.
|
* Open `.\index.php` in web browser to see results.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
@ -19,7 +19,7 @@ site="${network/\//_}"
|
|||||||
mkdir -p "scans"
|
mkdir -p "scans"
|
||||||
nmap -F -oX "scans/$site.xml" $network
|
nmap -F -oX "scans/$site.xml" $network
|
||||||
mkdir -p "configs"
|
mkdir -p "configs"
|
||||||
xsltproc --stringparam network "$network" to_config.xsl "scans/$site.xml" > "configs/$site.yml"
|
xsltproc --stringparam network "$network" to_config.xsl "scans/$site.xml" > "configs/$site.yaml"
|
||||||
php to_XML.php "configs/$site.yml" > "site/$site.xml"
|
php to_XML.php "configs/$site.yaml" > "site/$site.xml"
|
||||||
|
|
||||||
popd > /dev/null
|
popd > /dev/null
|
@ -8,7 +8,7 @@
|
|||||||
<xsl:param name="site"/>
|
<xsl:param name="site"/>
|
||||||
|
|
||||||
<xsl:template match="lanScan">
|
<xsl:template match="lanScan">
|
||||||
<xsl:text>nmap -v -T4 -Pn -p </xsl:text>
|
<xsl:text>nmap -v -T4 -p </xsl:text>
|
||||||
<xsl:apply-templates select="//service[not(.=preceding::*)]" />
|
<xsl:apply-templates select="//service[not(.=preceding::*)]" />
|
||||||
<xsl:text> --script nse/ --datadir nse/ --script-args-file script-args.ini -oX "</xsl:text>
|
<xsl:text> --script nse/ --datadir nse/ --script-args-file script-args.ini -oX "</xsl:text>
|
||||||
<xsl:value-of select="@scanpath"/>
|
<xsl:value-of select="@scanpath"/>
|
||||||
|
@ -20,6 +20,7 @@ license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
|
|||||||
|
|
||||||
portrule = shortport.service({"http", "https", "ssl"})
|
portrule = shortport.service({"http", "https", "ssl"})
|
||||||
|
|
||||||
|
|
||||||
local http = require "http"
|
local http = require "http"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local smb = require "smb"
|
local smb = require "smb"
|
||||||
local smb2 = require "smb2"
|
|
||||||
local msrpc = require "msrpc"
|
local msrpc = require "msrpc"
|
||||||
local bin = require "bin"
|
local bin = require "bin"
|
||||||
local shortport = require "shortport"
|
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
Return free and total size in octets of each SMB shares
|
Return free and total size in octets of each SMB shares
|
||||||
@ -27,8 +25,9 @@ categories = {"discovery", "intrusive"}
|
|||||||
author = "Adrien Malingrey"
|
author = "Adrien Malingrey"
|
||||||
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
|
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
|
||||||
|
|
||||||
portrule = shortport.service({"microsoft-ds", "netbios-ssn", "smb"})
|
hostrule = function(host)
|
||||||
|
return smb.get_port(host) ~= nil
|
||||||
|
end
|
||||||
|
|
||||||
action = function(host)
|
action = function(host)
|
||||||
local status, shares, extra
|
local status, shares, extra
|
||||||
@ -146,13 +145,9 @@ function send_transaction2(smbstate, sub_command, function_parameters, function_
|
|||||||
-- Send the transaction request
|
-- Send the transaction request
|
||||||
stdnse.debug2("SMB: Sending SMB_COM_TRANSACTION2")
|
stdnse.debug2("SMB: Sending SMB_COM_TRANSACTION2")
|
||||||
local result, err = smb.smb_send(smbstate, header, parameters, data, overrides)
|
local result, err = smb.smb_send(smbstate, header, parameters, data, overrides)
|
||||||
if(result == false) then
|
|
||||||
stdnse.debug1("SMB: Try SMBv2 connexion")
|
|
||||||
local result, err = smb2.smb2_send(smbstate, header, parameters, data, overrides)
|
|
||||||
if(result == false) then
|
if(result == false) then
|
||||||
return false, err
|
return false, err
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -161,13 +156,9 @@ function receive_transaction2(smbstate)
|
|||||||
|
|
||||||
-- Read the result
|
-- Read the result
|
||||||
local status, header, parameters, data = smb.smb_read(smbstate)
|
local status, header, parameters, data = smb.smb_read(smbstate)
|
||||||
if(status ~= true) then
|
|
||||||
stdnse.debug1("SMB: Try SMBv2 connexion")
|
|
||||||
local status, header, parameters, data = smb2.smb2_read(smbstate)
|
|
||||||
if(status ~= true) then
|
if(status ~= true) then
|
||||||
return false, header
|
return false, header
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- Check if it worked
|
-- Check if it worked
|
||||||
local pos, header1, header2, header3, header4, command, status, flags, flags2, pid_high, signature, unused, tid, pid, uid, mid = bin.unpack("<CCCCCICSSlSSSSS", header)
|
local pos, header1, header2, header3, header4, command, status, flags, flags2, pid_high, signature, unused, tid, pid, uid, mid = bin.unpack("<CCCCCICSSlSSSSS", header)
|
||||||
|
62
results.xsl
62
results.xsl
@ -10,7 +10,7 @@
|
|||||||
<xsl:template match="lanScan">
|
<xsl:template match="lanScan">
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
<head>
|
<head>
|
||||||
<title><xsl:value-of select="@site"/> - lanScan</title>
|
<title>lanScan - <xsl:value-of select="@site"/></title>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.3/dist/jquery.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.3/dist/jquery.min.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/fomantic-ui@2.9.2/dist/semantic.min.css"/>
|
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/fomantic-ui@2.9.2/dist/semantic.min.css"/>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/fomantic-ui@2.9.2/dist/semantic.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/fomantic-ui@2.9.2/dist/semantic.min.js"></script>
|
||||||
@ -34,11 +34,19 @@
|
|||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.button.share-size {
|
||||||
|
--bg: #21ba45;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item.share-size {
|
||||||
|
--bg: white;
|
||||||
|
}
|
||||||
|
|
||||||
.share-size {
|
.share-size {
|
||||||
--free-ratio: calc(var(--free) / var(--total));
|
--free-ratio: calc(var(--free) / var(--total));
|
||||||
--used-percent: calc(100% - 100%*var(--free-ratio));
|
--used-percent: calc(100% - 100%*var(--free-ratio));
|
||||||
--color: hsl(calc(120*var(--free-ratio)) 100% 50%);
|
--color: hsl(calc(120*var(--free-ratio)) 100% 50%);
|
||||||
background-image: linear-gradient(to right, var(--color) var(--used-percent), transparent var(--used-percent), transparent) !important;
|
background: linear-gradient(to right, var(--color) var(--used-percent), var(--bg) var(--used-percent), var(--bg)) !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<meta http-equiv="refresh" content="60"/>
|
<meta http-equiv="refresh" content="60"/>
|
||||||
@ -69,7 +77,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
<xsl:apply-templates select="group"/>
|
<xsl:apply-templates select="hosts"/>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
$('.ui.dropdown').dropdown()
|
$('.ui.dropdown').dropdown()
|
||||||
@ -78,9 +86,9 @@
|
|||||||
</html>
|
</html>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="group">
|
<xsl:template match="hosts">
|
||||||
<h1 class="ui header"><xsl:value-of select="@name"/></h1>
|
<h1 class="ui header"><xsl:value-of select="@name"/></h1>
|
||||||
<div class="ui doubling stackable five column compact grid">
|
<div class="ui doubling stackable four column compact grid">
|
||||||
<xsl:apply-templates select="host"/>
|
<xsl:apply-templates select="host"/>
|
||||||
</div>
|
</div>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
@ -142,8 +150,10 @@
|
|||||||
<xsl:variable name="scannedPort" select="$scannedHost/ports/port[service/@name=$serviceName or @portid=$serviceName][1]"/>
|
<xsl:variable name="scannedPort" select="$scannedHost/ports/port[service/@name=$serviceName or @portid=$serviceName][1]"/>
|
||||||
<xsl:variable name="state">
|
<xsl:variable name="state">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$scannedPort/state/@state='open'">green</xsl:when>
|
<xsl:when test="$scannedPort/script[@id='http-info']/elem[@key='status']>=500">red</xsl:when>
|
||||||
|
<xsl:when test="$scannedPort/script[@id='http-info']/elem[@key='status']>=400">yellow</xsl:when>
|
||||||
<xsl:when test="$scannedPort/state/@state='filtered'">yellow</xsl:when>
|
<xsl:when test="$scannedPort/state/@state='filtered'">yellow</xsl:when>
|
||||||
|
<xsl:when test="$scannedPort/state/@state='open'">green</xsl:when>
|
||||||
<xsl:otherwise>red</xsl:otherwise>
|
<xsl:otherwise>red</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
@ -155,49 +165,29 @@
|
|||||||
<xsl:value-of select="$scannedPort/state/@state"/>
|
<xsl:value-of select="$scannedPort/state/@state"/>
|
||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:value-of select="$scannedPort/service/@name"/>
|
<xsl:value-of select="$scannedPort/service/@name"/>
|
||||||
|
<xsl:if test="$scannedPort/script[@id='http-info']"><xsl:text>
|
||||||
|
</xsl:text><xsl:value-of select="$scannedPort/script[@id='http-info']/elem[@key='status-line']"/>
|
||||||
|
<xsl:value-of select="$scannedPort/script[@id='http-info']/elem[@key='title']"/>
|
||||||
|
</xsl:if>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$scannedPort/script[@id='smb-shares-size']/table">
|
<xsl:when test="($scannedPort/service/@name='microsoft-ds' or $scannedPort/service/@name='netbios-ssn' or $scannedPort/service/@name='smb') and $scannedHost/hostscript/script[@id='smb-shares-size']">
|
||||||
<div class="ui {$state} dropdown mini button share-size" title="{$title}">
|
<div class="ui {$state} dropdown mini button share-size" title="{$title}" style="--free:{$scannedHost/hostscript/script[@id='smb-shares-size']/table/elem[@key='FreeSize']}; --total:{$scannedHost/hostscript/script[@id='smb-shares-size']/table/elem[@key='TotalSize']}">
|
||||||
<xsl:attribute name="style">
|
|
||||||
<xsl:for-each select="$scannedPort/script[@id='smb-shares-size']/table">
|
|
||||||
<xsl:sort select="elem[@key='FreeSize'] div elem[@key='TotalSize']" order="ascending"/>
|
|
||||||
<xsl:if test="position()=1">
|
|
||||||
<xsl:text>--free: </xsl:text>
|
|
||||||
<xsl:value-of select="elem[@key='FreeSize']"/>
|
|
||||||
<xsl:text>; --total: </xsl:text>
|
|
||||||
<xsl:value-of select="elem[@key='TotalSize']"/>
|
|
||||||
</xsl:if>
|
|
||||||
</xsl:for-each>
|
|
||||||
</xsl:attribute>
|
|
||||||
<xsl:value-of select="$serviceName"/>
|
<xsl:value-of select="$serviceName"/>
|
||||||
<i class="dropdown icon"></i>
|
<i class="dropdown icon"></i>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
<xsl:apply-templates select="$scannedPort/script[@id='smb-shares-size']/table">
|
<!-- xsl:apply-templates select="$scannedHost/hostscript/script[@id='smb-shares-size']/table[not(contains(@key, '$'))]" -->
|
||||||
|
<xsl:apply-templates select="$scannedHost/hostscript/script[@id='smb-shares-size']/table">
|
||||||
<xsl:with-param name="scannedHostAddress" select="$scannedHostAddress"/>
|
<xsl:with-param name="scannedHostAddress" select="$scannedHostAddress"/>
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="$scannedPort/service/@name='ms-wbt-server' or $scannedPort/service/@name='rdp'">
|
<xsl:when test="$scannedPort/service/@name='ms-wbt-server' or $scannedPort/service/@name='msrpc'">
|
||||||
<a class="ui {$state} mini button" href="../rdp.php?v={$scannedHostAddress}:{$scannedPort/@portid}" title="{$title}">
|
<a class="ui {$state} mini button" href="../rdp.php?v={$scannedHostAddress}:{$scannedPort/@portid}" title="{$title}">
|
||||||
<xsl:value-of select="$serviceName"/>
|
<xsl:value-of select="$serviceName"/>
|
||||||
</a>
|
</a>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="$scannedPort/script[@id='http-info']">
|
|
||||||
<xsl:variable name="status">
|
|
||||||
<xsl:choose>
|
|
||||||
<xsl:when test="$scannedPort/script[@id='http-info']/elem[@key='status']>=500">red</xsl:when>
|
|
||||||
<xsl:when test="$scannedPort/script[@id='http-info']/elem[@key='status']>=400">yellow</xsl:when>
|
|
||||||
<xsl:when test="$scannedPort/script[@id='http-info']/elem[@key='status']>=200">green</xsl:when>
|
|
||||||
<xsl:otherwise>red</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:variable>
|
|
||||||
<a class="ui {$status} mini button" href="{$scannedPort/service/@name}://{$scannedHostAddress}:{$scannedPort/@portid}" target="_blank"
|
|
||||||
title="{$scannedPort/script[@id='http-info']/elem[@key='title' or @key='status-line']}">
|
|
||||||
<xsl:value-of select="$serviceName"/>
|
|
||||||
</a>
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:when test="$scannedPort/service/@name='ftp' or $scannedPort/service/@name='ssh' or $scannedPort/service/@name='http' or $scannedPort/service/@name='https'">
|
<xsl:when test="$scannedPort/service/@name='ftp' or $scannedPort/service/@name='ssh' or $scannedPort/service/@name='http' or $scannedPort/service/@name='https'">
|
||||||
<a class="ui {$state} mini button" href="{$scannedPort/service/@name}://{$scannedHostAddress}:{$scannedPort/@portid}" target="_blank" title="{$title}">
|
<a class="ui {$state} mini button" href="{$scannedPort/service/@name}://{$scannedHostAddress}:{$scannedPort/@portid}" target="_blank" title="{$title}">
|
||||||
<xsl:value-of select="$serviceName"/>
|
<xsl:value-of select="$serviceName"/>
|
||||||
@ -214,7 +204,7 @@
|
|||||||
|
|
||||||
<xsl:template match="table">
|
<xsl:template match="table">
|
||||||
<xsl:param name="scannedHostAddress"/>
|
<xsl:param name="scannedHostAddress"/>
|
||||||
<a class="item share-size" href="file://///{$scannedHostAddress}/{@key}" target="_blank" rel="noopener noreferrer" style="--free: {elem[@key='FreeSize']}; --total: {elem[@key='TotalSize']}">
|
<a class="item share-size" href="file://///{$scannedHostAddress}/{@key}" target="_blank" rel="noopener noreferrer" style="--free:{elem[@key='FreeSize']}; --total:{elem[@key='TotalSize']}">
|
||||||
<xsl:value-of select="@key"/>
|
<xsl:value-of select="@key"/>
|
||||||
</a>
|
</a>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
@ -6,9 +6,9 @@ if [ "$#" -ne 1 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
pushd "$(dirname -- "$0")" > /dev/null
|
pushd "$(dirname -- "$0")" > /dev/null
|
||||||
site="$(basename ${1/.yml/})"
|
site="$(basename ${1/.yaml/})"
|
||||||
|
|
||||||
php "to_XML.php" "configs/$site.yml" > "site/$site.xml" \
|
php "to_XML.php" "configs/$site.yaml" > "site/$site.xml" \
|
||||||
&& eval $(xsltproc "nmap_cmd.xsl" "site/$site.xml") \
|
&& eval $(xsltproc "nmap_cmd.xsl" "site/$site.xml") \
|
||||||
&& mv "scans/$site.xml.tmp" "scans/$site.xml"
|
&& mv "scans/$site.xml.tmp" "scans/$site.xml"
|
||||||
|
|
@ -5,11 +5,11 @@ pushd "$(dirname -- $0)" > /dev/null
|
|||||||
mkdir -p scans
|
mkdir -p scans
|
||||||
mkdir -p site
|
mkdir -p site
|
||||||
|
|
||||||
for config in configs/*.yml
|
for config in configs/*.yaml
|
||||||
do
|
do
|
||||||
site="$(basename ${config/.yml/})"
|
site="$(basename ${config/.yaml/})"
|
||||||
echo "Scan $site"
|
echo "Scan $site"
|
||||||
./scan.sh "$site"
|
./scan "$site"
|
||||||
done
|
done
|
||||||
|
|
||||||
popd > /dev/null
|
popd > /dev/null
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
$file = $argv[1];
|
$file = $argv[1];
|
||||||
$site = basename($file, ".yml");
|
$site = basename($file, ".yaml");
|
||||||
$__DIR__ = __DIR__;
|
$__DIR__ = __DIR__;
|
||||||
|
|
||||||
$conf = yaml_parse_file($file);
|
$conf = yaml_parse_file($file);
|
||||||
|
@ -11,12 +11,11 @@
|
|||||||
<xsl:text>---
|
<xsl:text>---
|
||||||
site: Nom du site
|
site: Nom du site
|
||||||
|
|
||||||
group:
|
hosts:
|
||||||
- name: Réseau </xsl:text><xsl:value-of select="$network"/><xsl:text>
|
- name: Réseau </xsl:text><xsl:value-of select="$network"/><xsl:text>
|
||||||
host:
|
host:
|
||||||
</xsl:text>
|
</xsl:text>
|
||||||
<xsl:apply-templates select="host"/>
|
<xsl:apply-templates select="host"/>
|
||||||
<xsl:text>...</xsl:text>
|
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="host">
|
<xsl:template match="host">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user