This commit is contained in:
Adrien MALINGREY 2025-01-24 17:38:33 +01:00
parent a593148c38
commit e2c1c6604e
12 changed files with 42 additions and 30 deletions

View File

@ -1,29 +1,31 @@
<?php <?php
$port = (($_SERVER['REQUEST_SCHEME'] == "http" && $_SERVER['SERVER_PORT'] == 80) || ($_SERVER['REQUEST_SCHEME'] == "https" && $_SERVER['SERVER_PORT'] == 443)) ? "" : ":{$_SERVER['SERVER_PORT']}"; $port = (($_SERVER['REQUEST_SCHEME'] == "http" && $_SERVER['SERVER_PORT'] == 80) || ($_SERVER['REQUEST_SCHEME'] == "https" && $_SERVER['SERVER_PORT'] == 443)) ? "" : ":{$_SERVER['SERVER_PORT']}";
$BASEDIR = "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}$port" . dirname($_SERVER['SCRIPT_NAME']); $BASEDIR = "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}$port" . dirname($_SERVER['SCRIPT_NAME']);
$SCANSDIR = 'scans'; $SCANSDIR = 'scans';
$NMAPDIR = dirname(`which nmap`) . "/../share/nmap"; $TEMPLATESDIR = "templates";
$DATADIR = "datadir"; $NMAP = 'sudo nmap'; # nmap command, E.g. 'nmap', 'sudo nmap' for root privileges or '/usr/bin/nmap' if not in PATH
$SCRIPTARGS = "script-args.ini"; $NMAPDIR = dirname(`which nmap`) . "/../share/nmap";
$DATADIR = ".";
$SCRIPTARGS = "script-args.ini";
$presets = [ $presets = [
"default" => [ "default" => [
'-PS' => 'microsoft-ds', '-PS' => 'microsoft-ds',
'-F' => true, '-F' => true,
'-T' => 5, '-T' => 5,
'--stylesheet' => "$BASEDIR/templates/lanScan.xsl", '--stylesheet' => "lanScan.xsl",
'refreshPeriod' => 60, 'refreshPeriod' => 60,
'sudo' => false, 'sudo' => false,
], ],
"host" => [ "host" => [
'-Pn' => true, '-Pn' => true,
'-F' => true, '-F' => true,
'-sV' => true, '-sV' => true,
'-T' => 5, '-T' => 5,
'--script' => "http-info,smb-shares-size", '--script' => "http-info,smb-shares-size",
'--stylesheet' => "$BASEDIR/templates/hostScan.xsl", '--stylesheet' => "hostScan.xsl",
'refreshPeriod' => 60, 'refreshPeriod' => 60,
'sudo' => true, 'sudo' => true,
], ],
]; ];

View File

@ -107,7 +107,7 @@ if ($preset && isset($presets[$preset])) {
'-V' => FILTER_VALIDATE_BOOLEAN, '-V' => FILTER_VALIDATE_BOOLEAN,
'--unprivileged' => FILTER_VALIDATE_BOOLEAN, '--unprivileged' => FILTER_VALIDATE_BOOLEAN,
'-h' => FILTER_VALIDATE_BOOLEAN, '-h' => FILTER_VALIDATE_BOOLEAN,
'--stylesheet' => FILTER_VALIDATE_URL, '--stylesheet' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $fileNameRegex]],
// lanScan // lanScan
'name' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $fileNameRegex]], 'name' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $fileNameRegex]],
'originalURL' => FILTER_VALIDATE_URL, 'originalURL' => FILTER_VALIDATE_URL,

View File

@ -583,10 +583,10 @@ Exemples: <?= $_SERVER['REMOTE_ADDR']; ?>/24 <?= $_SERVER['SERVER_NAME']; ?> 10.
<label for="stylesheetSelect" title="--stylesheet">Feuille de style</label> <label for="stylesheetSelect" title="--stylesheet">Feuille de style</label>
<select id="stylesheetSelect" class="ui dropdown" name="--stylesheet" value="<?= $options["--stylesheet"] ?? ""?>"> <select id="stylesheetSelect" class="ui dropdown" name="--stylesheet" value="<?= $options["--stylesheet"] ?? ""?>">
<?php <?php
foreach (scandir('templates') as $filename) { foreach (scandir($TEMPLATESDIR) as $filename) {
if (substr($filename, -4) === '.xsl') { if (substr($filename, -4) === '.xsl') {
$name = substr($filename, 0, -4); $name = substr($filename, 0, -4);
$URL = "$BASEDIR/templates/".rawurlencode($filename); $URL = rawurlencode($filename);
if (isset($options["--stylesheet"]) && $URL == $options["--stylesheet"]) { if (isset($options["--stylesheet"]) && $URL == $options["--stylesheet"]) {
echo " <option value='$URL' selected>$name</option>\n"; echo " <option value='$URL' selected>$name</option>\n";
} else { } else {
@ -627,13 +627,14 @@ foreach (scandir($SCANSDIR) as $filename) {
<div class="ui label">secondes</div> <div class="ui label">secondes</div>
</div> </div>
</div> </div>
<!--
<div class="inline field"> <div class="inline field">
<div class="ui toggle checkbox"> <div class="ui toggle checkbox">
<input id="sudoCheckbox" type="checkbox" name="sudo" <?= $options["sudo"] ?? false ? 'checked' : ''; ?>/> <input id="sudoCheckbox" type="checkbox" name="sudo" <?= $options["sudo"] ?? false ? 'checked' : ''; ?>/>
<label for="sudoCheckbox" title="sudo">Exécuter en tant qu'administrateur</label> <label for="sudoCheckbox" title="sudo">Exécuter en tant qu'administrateur</label>
</div> </div>
</div> </div>
-->
</div> </div>
</div> </div>
@ -768,6 +769,15 @@ foreach ([$DATADIR, $NMAPDIR] as $dir) {
newScanForm.onsubmit = function(event) { newScanForm.onsubmit = function(event) {
if (this.checkValidity()) { if (this.checkValidity()) {
newScanForm.classList.add("loading") newScanForm.classList.add("loading")
$.toast({
title : 'Scan en cours...',
message : 'Merci de patienter',
class : 'info',
showIcon : 'satellite dish',
displayTime: 0,
closeIcon : true,
position : 'bottom right',
})
return true return true
} else { } else {
event.preventDefault() event.preventDefault()

View File

@ -3,9 +3,10 @@
include_once 'config.php'; include_once 'config.php';
include_once 'filter_inputs.php'; include_once 'filter_inputs.php';
if (!file_exists($SCANSDIR)) mkdir($SCANSDIR); $options["--stylesheet"] = "$BASEDIR/$TEMPLATESDIR/${options["--stylesheet"]}?";
if (isset($options["name"])) {
if (!$options["name"]) $options["name"] = str_replace('/', '!', $targets); $options["--stylesheet"] .= "name=" . rawurlencode($options["name"]) . "&";
}
$args = ""; $args = "";
foreach ($options as $option => $value) { foreach ($options as $option => $value) {
@ -27,11 +28,10 @@ foreach ($options as $option => $value) {
} }
$command = "nmap $args -oX - $targets"; $command = "$NMAP $args -oX - $targets";
if (isset($options["sudo"])) $command = "sudo $command";
if (isset($options["name"])) { if (isset($options["name"])) {
if (!file_exists($SCANSDIR)) mkdir($SCANSDIR);
$path = "$SCANSDIR/{$options["name"]}.xml"; $path = "$SCANSDIR/{$options["name"]}.xml";
$command .= " | tee '$path'"; $command .= " | tee '$path'";
} }

0
script-args.ini Normal file
View File

View File

@ -19,7 +19,7 @@
<xsl:param name="sudo" select="false"/> <xsl:param name="sudo" select="false"/>
<xsl:variable name="current" select="./nmaprun"/> <xsl:variable name="current" select="./nmaprun"/>
<xsl:variable name="stylesheetURL" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href=&quot;'),'&quot;')"/> <xsl:variable name="stylesheetURL" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href=&quot;'), '?')"/>
<xsl:variable name="basedir" select="concat($stylesheetURL, '/../..')"/> <xsl:variable name="basedir" select="concat($stylesheetURL, '/../..')"/>
<xsl:variable name="init" select="document($originalURL)/nmaprun"/> <xsl:variable name="init" select="document($originalURL)/nmaprun"/>
<xsl:variable name="nextComparison"> <xsl:variable name="nextComparison">

View File

@ -19,7 +19,7 @@
<xsl:param name="sudo" select="false"/> <xsl:param name="sudo" select="false"/>
<xsl:variable name="current" select="./nmaprun"/> <xsl:variable name="current" select="./nmaprun"/>
<xsl:variable name="stylesheetURL" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href=&quot;'),'&quot;')"/> <xsl:variable name="stylesheetURL" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href=&quot;'), '?')"/>
<xsl:variable name="basedir" select="concat($stylesheetURL, '/../..')"/> <xsl:variable name="basedir" select="concat($stylesheetURL, '/../..')"/>
<xsl:variable name="init" select="document($originalURL)/nmaprun"/> <xsl:variable name="init" select="document($originalURL)/nmaprun"/>
<xsl:variable name="nextComparison"> <xsl:variable name="nextComparison">
@ -51,7 +51,7 @@
<xsl:with-param name="sudo" select="$sudo"/> <xsl:with-param name="sudo" select="$sudo"/>
</xsl:apply-templates> </xsl:apply-templates>
<main class="ui container"> <main class="ui wide container">
<h1 class="ui header"><xsl:value-of select="$targets"/></h1> <h1 class="ui header"><xsl:value-of select="$targets"/></h1>
<div class="form"> <div class="form">

View File

@ -19,7 +19,7 @@
<xsl:param name="sudo" select="false"/> <xsl:param name="sudo" select="false"/>
<xsl:variable name="current" select="./nmaprun"/> <xsl:variable name="current" select="./nmaprun"/>
<xsl:variable name="stylesheetURL" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href=&quot;'),'&quot;')"/> <xsl:variable name="stylesheetURL" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href=&quot;'), '?')"/>
<xsl:variable name="basedir" select="concat($stylesheetURL, '/../..')"/> <xsl:variable name="basedir" select="concat($stylesheetURL, '/../..')"/>
<xsl:variable name="init" select="document($originalURL)/nmaprun"/> <xsl:variable name="init" select="document($originalURL)/nmaprun"/>
<xsl:variable name="nextComparison"> <xsl:variable name="nextComparison">

View File

@ -19,7 +19,7 @@
<xsl:param name="sudo" select="false"/> <xsl:param name="sudo" select="false"/>
<xsl:variable name="current" select="./nmaprun"/> <xsl:variable name="current" select="./nmaprun"/>
<xsl:variable name="stylesheetURL" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href=&quot;'),'&quot;')"/> <xsl:variable name="stylesheetURL" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href=&quot;'), '?')"/>
<xsl:variable name="basedir" select="concat($stylesheetURL, '/../..')"/> <xsl:variable name="basedir" select="concat($stylesheetURL, '/../..')"/>
<xsl:variable name="init" select="document($originalURL)/nmaprun"/> <xsl:variable name="init" select="document($originalURL)/nmaprun"/>
<xsl:variable name="nextComparison"> <xsl:variable name="nextComparison">