This commit is contained in:
Adrien MALINGREY 2024-10-16 20:55:43 +02:00
parent a1aeefee47
commit 6c33080785
6 changed files with 34 additions and 38 deletions

View File

@ -1,24 +1,27 @@
<?php
$BASEDIR = "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}" . dirname($_SERVER['REQUEST_URI']);
$SCANSDIR = 'scans';
$DATADIR = '/usr/share/nmap';
$LANSCAN_OPTIONS = [
'PS' => 'microsoft-ds',
'F' => true,
'T5' => true,
'stylesheet' => "$BASEDIR/lanScan.xsl"
];
$HOSTSCAN_OPTIONS = [
'Pn' => true,
'F' => true,
'sV' => true,
'T5' => true,
'stylesheet' => "$BASEDIR/hostScan.xsl"
$presets = [
"lan" => [
'PS' => 'microsoft-ds',
'F' => true,
'T5' => true,
'stylesheet' => "$BASEDIR/lanScan.xsl"
],
"host" => [
'Pn' => true,
'F' => true,
'sV' => true,
'T5' => true,
'stylesheet' => "$BASEDIR/hostScan.xsl"
],
];
$saveAs = null;
$compareWith = null;
$refreshPeriod = 60;
$sudo = true;
$SCANSDIR = 'scans';
$DATADIR = '/usr/share/nmap';

View File

@ -9,16 +9,11 @@ $portsListRegex = "/^([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*$/";
$tempoRegex = "/^\d+[smh]?$/";
$fileNameRegex = '/^[^<>:"\/|?]+$/';
$targets = filter_input(INPUT_GET, 'targets', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex], "flags" => FILTER_NULL_ON_FAILURE]);
$lan = filter_input(INPUT_GET, 'lan', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex], "flags" => FILTER_NULL_ON_FAILURE]);
$host = filter_input(INPUT_GET, 'host', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex], "flags" => FILTER_NULL_ON_FAILURE]);
$targets = filter_input(INPUT_GET, 'targets', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex], "flags" => FILTER_NULL_ON_FAILURE]);
$preset = filter_input(INPUT_GET, "preset");
if ($lan) {
$targets = $lan;
$args = $LANSCAN_OPTIONS;
} else if ($host) {
$targets = $host;
$args = $HOSTSCAN_OPTIONS;
if ($preset && isset($presets[$preset])) {
$args = $presets[$preset];
} else {
$args = filter_input_array(INPUT_GET, [
'iR' => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 0]],
@ -111,7 +106,7 @@ if ($lan) {
'unprivileged' => FILTER_VALIDATE_BOOLEAN,
'h' => FILTER_VALIDATE_BOOLEAN,
'stylesheet' => FILTER_VALIDATE_URL,
], false) ?: $LANSCAN_OPTIONS;
], false) ?: $presets["lan"];
$saveAs = filter_input(INPUT_GET, 'saveAs', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $fileNameRegex]]);
$compareWith = filter_input(INPUT_GET, 'compareWith', FILTER_VALIDATE_URL);

View File

@ -169,7 +169,7 @@ $.toast({
</xsl:if>
hiddenButton.onclick = function(event) {
if (lanScanForm.form.checkValidity()) {
if (lanScanForm.checkValidity()) {
targetsInputDiv.classList.add('loading')
$.toast({
title : 'Scan en cours...',
@ -308,7 +308,7 @@ function hostScanning(link) {
<td>
<a>
<xsl:attribute name="class">
<xsl:text>ui mini button </xsl:text>
<xsl:text>ui mini fluid button </xsl:text>
<xsl:choose>
<xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=500">red</xsl:when>
<xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=400">orange</xsl:when>

View File

@ -1,7 +1,4 @@
<?php
include_once 'config.php';
include_once 'filter_inputs.php';
?>
<?php include_once "config.php"; ?>
<!DOCTYPE html>
<html lang="fr">
@ -24,10 +21,11 @@ include_once 'filter_inputs.php';
lan<?php include 'logo.svg'; ?>can
</a>
<form id="lanScanForm" class="right menu">
<input type="hidden" name="preset" value="lan"/>
<div class="ui category search item">
<div id="targetsInputDiv" class="ui icon input">
<input class="prompt" type="text" id="targetsInput" name="lan"
pattern="[a-zA-Z0-9._\/ \-]+" value="<?= $targets; ?>" placeholder="Scanner un réseau..."
<input class="prompt" type="text" id="targetsInput" name="targets"
pattern="[a-zA-Z0-9._\/ \-]+" placeholder="Scanner un réseau..."
title="Les cibles peuvent être spécifiées par des noms d'hôtes, des adresses IP, des adresses de réseaux, etc.
Exemples: <?= $_SERVER['REMOTE_ADDR']; ?>/24 <?= $_SERVER['SERVER_NAME']; ?> 10.0-255.0-255.1-254" />
<i class="satellite dish icon"></i>
@ -64,7 +62,7 @@ foreach (scandir($SCANSDIR) as $filename) {
</div>
<script>
hiddenButton.onclick = (event) => {
if (lanScanForm.form.checkValidity()) {
if (lanScanForm.checkValidity()) {
targetsInputDiv.classList.add('loading')
$.toast({
title: 'Scan en cours...',

View File

@ -189,7 +189,7 @@ $.toast({
</xsl:if>
hiddenButton.onclick = function(event) {
if (lanScanForm.form.checkValidity()) {
if (lanScanForm.checkValidity()) {
targetsInputDiv.classList.add('loading')
$.toast({
title : 'Scan en cours...',
@ -292,7 +292,7 @@ function hostScanning(link) {
<a class="ui mini icon teal button" onclick="hostScanning(this)">
<xsl:attribute name="href">
<xsl:value-of select="$basedir"/>
<xsl:text>/scan.php?host=</xsl:text>
<xsl:text>/scan.php?preset=host&amp;targets=</xsl:text>
<xsl:value-of select="$hostAddress"/>
</xsl:attribute>
<i class="satellite dish icon"></i>
@ -301,7 +301,7 @@ function hostScanning(link) {
<a class="ui mini icon teal label">
<xsl:attribute name="href">
<xsl:value-of select="$basedir"/>
<xsl:text>/options.php?host=</xsl:text>
<xsl:text>/options.php?preset=host&amp;targets=</xsl:text>
<xsl:value-of select="$hostAddress"/>
</xsl:attribute>
<i class="sliders horizontal icon"></i>

View File

@ -43,7 +43,7 @@ include_once 'filter_inputs.php';
</div>
<?php } ?>
<h1 class="header">Scanner un <?=$host? "hôte" : "réseau" ?></h1>
<h1 class="header">Scanner un <?=$preset == "host"? "hôte" : "réseau" ?></h1>
<form id="newScanForm" class="ui form" method="get" action="scan.php">
<div class="field">