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.
|
||||
|
||||
* 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>`.
|
||||
* Scanner avec le script `./scan_all.sh` (utiliser une tâche cron !).
|
||||
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
|
||||
|
@ -3,8 +3,8 @@
|
||||
Scan hosts with `nmap` and display results in webpage.
|
||||
|
||||
* Create a configuration yaml file in ./configs/ subdirectory (see example below).
|
||||
It may be generated by scanning a network with `./discover.sh <CIDR>`.
|
||||
* Scan with `./scan_all.sh` (use a cron task!).
|
||||
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.
|
||||
|
||||
## Example
|
||||
|
@ -19,7 +19,7 @@ site="${network/\//_}"
|
||||
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.yml"
|
||||
php to_XML.php "configs/$site.yml" > "site/$site.xml"
|
||||
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
|
@ -8,7 +8,7 @@
|
||||
<xsl:param name="site"/>
|
||||
|
||||
<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:text> --script nse/ --datadir nse/ --script-args-file script-args.ini -oX "</xsl:text>
|
||||
<xsl:value-of select="@scanpath"/>
|
||||
@ -32,4 +32,4 @@
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
</xsl:stylesheet>
|
@ -20,6 +20,7 @@ license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
|
||||
|
||||
portrule = shortport.service({"http", "https", "ssl"})
|
||||
|
||||
|
||||
local http = require "http"
|
||||
local stdnse = require "stdnse"
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
local stdnse = require "stdnse"
|
||||
local smb = require "smb"
|
||||
local smb2 = require "smb2"
|
||||
local msrpc = require "msrpc"
|
||||
local bin = require "bin"
|
||||
local shortport = require "shortport"
|
||||
local stdnse = require "stdnse"
|
||||
local smb = require "smb"
|
||||
local msrpc = require "msrpc"
|
||||
local bin = require "bin"
|
||||
|
||||
description = [[
|
||||
Return free and total size in octets of each SMB shares
|
||||
@ -27,8 +25,9 @@ categories = {"discovery", "intrusive"}
|
||||
author = "Adrien Malingrey"
|
||||
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)
|
||||
local status, shares, extra
|
||||
@ -147,11 +146,7 @@ function send_transaction2(smbstate, sub_command, function_parameters, function_
|
||||
stdnse.debug2("SMB: Sending SMB_COM_TRANSACTION2")
|
||||
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
|
||||
return false, err
|
||||
end
|
||||
return false, err
|
||||
end
|
||||
|
||||
return true
|
||||
@ -162,11 +157,7 @@ function receive_transaction2(smbstate)
|
||||
-- Read the result
|
||||
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
|
||||
return false, header
|
||||
end
|
||||
return false, header
|
||||
end
|
||||
|
||||
-- Check if it worked
|
||||
|
62
results.xsl
62
results.xsl
@ -10,7 +10,7 @@
|
||||
<xsl:template match="lanScan">
|
||||
<html lang="fr">
|
||||
<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>
|
||||
<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>
|
||||
@ -34,11 +34,19 @@
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.button.share-size {
|
||||
--bg: #21ba45;
|
||||
}
|
||||
|
||||
.item.share-size {
|
||||
--bg: white;
|
||||
}
|
||||
|
||||
.share-size {
|
||||
--free-ratio: calc(var(--free) / var(--total));
|
||||
--used-percent: calc(100% - 100%*var(--free-ratio));
|
||||
--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>
|
||||
<meta http-equiv="refresh" content="60"/>
|
||||
@ -69,7 +77,7 @@
|
||||
</div>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:apply-templates select="group"/>
|
||||
<xsl:apply-templates select="hosts"/>
|
||||
</div>
|
||||
<script>
|
||||
$('.ui.dropdown').dropdown()
|
||||
@ -78,9 +86,9 @@
|
||||
</html>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="group">
|
||||
<xsl:template match="hosts">
|
||||
<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"/>
|
||||
</div>
|
||||
</xsl:template>
|
||||
@ -142,8 +150,10 @@
|
||||
<xsl:variable name="scannedPort" select="$scannedHost/ports/port[service/@name=$serviceName or @portid=$serviceName][1]"/>
|
||||
<xsl:variable name="state">
|
||||
<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='open'">green</xsl:when>
|
||||
<xsl:otherwise>red</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
@ -155,49 +165,29 @@
|
||||
<xsl:value-of select="$scannedPort/state/@state"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<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:choose>
|
||||
<xsl:when test="$scannedPort/script[@id='smb-shares-size']/table">
|
||||
<div class="ui {$state} dropdown mini button share-size" title="{$title}">
|
||||
<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: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}" 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:value-of select="$serviceName"/>
|
||||
<i class="dropdown icon"></i>
|
||||
<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:apply-templates>
|
||||
</div>
|
||||
</div>
|
||||
</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}">
|
||||
<xsl:value-of select="$serviceName"/>
|
||||
</a>
|
||||
</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'">
|
||||
<a class="ui {$state} mini button" href="{$scannedPort/service/@name}://{$scannedHostAddress}:{$scannedPort/@portid}" target="_blank" title="{$title}">
|
||||
<xsl:value-of select="$serviceName"/>
|
||||
@ -214,7 +204,7 @@
|
||||
|
||||
<xsl:template match="table">
|
||||
<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"/>
|
||||
</a>
|
||||
</xsl:template>
|
||||
|
@ -6,9 +6,9 @@ if [ "$#" -ne 1 ]; then
|
||||
fi
|
||||
|
||||
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") \
|
||||
&& mv "scans/$site.xml.tmp" "scans/$site.xml"
|
||||
|
@ -5,11 +5,11 @@ pushd "$(dirname -- $0)" > /dev/null
|
||||
mkdir -p scans
|
||||
mkdir -p site
|
||||
|
||||
for config in configs/*.yml
|
||||
for config in configs/*.yaml
|
||||
do
|
||||
site="$(basename ${config/.yml/})"
|
||||
site="$(basename ${config/.yaml/})"
|
||||
echo "Scan $site"
|
||||
./scan.sh "$site"
|
||||
./scan "$site"
|
||||
done
|
||||
|
||||
popd > /dev/null
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
$file = $argv[1];
|
||||
$site = basename($file, ".yml");
|
||||
$site = basename($file, ".yaml");
|
||||
$__DIR__ = __DIR__;
|
||||
|
||||
$conf = yaml_parse_file($file);
|
||||
|
@ -11,12 +11,11 @@
|
||||
<xsl:text>---
|
||||
site: Nom du site
|
||||
|
||||
group:
|
||||
hosts:
|
||||
- name: Réseau </xsl:text><xsl:value-of select="$network"/><xsl:text>
|
||||
host:
|
||||
</xsl:text>
|
||||
<xsl:apply-templates select="host"/>
|
||||
<xsl:text>...</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="host">
|
||||
|
Loading…
x
Reference in New Issue
Block a user