From 6c33080785fda6f68e2545b28c245148a926ffb8 Mon Sep 17 00:00:00 2001 From: adrien Date: Wed, 16 Oct 2024 20:55:43 +0200 Subject: [PATCH] presets --- config.php | 33 ++++++++++++++++++--------------- filter_inputs.php | 15 +++++---------- hostScan.xsl | 4 ++-- index.php | 12 +++++------- lanScan.xsl | 6 +++--- options.php | 2 +- 6 files changed, 34 insertions(+), 38 deletions(-) diff --git a/config.php b/config.php index 4bb24d8..00b0047 100644 --- a/config.php +++ b/config.php @@ -1,24 +1,27 @@ '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'; diff --git a/filter_inputs.php b/filter_inputs.php index 90595c3..6781444 100644 --- a/filter_inputs.php +++ b/filter_inputs.php @@ -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); diff --git a/hostScan.xsl b/hostScan.xsl index 49bfef3..f3d0b9d 100755 --- a/hostScan.xsl +++ b/hostScan.xsl @@ -169,7 +169,7 @@ $.toast({ 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) { - ui mini button + ui mini fluid button red orange diff --git a/index.php b/index.php index 5727bd1..7cec758 100755 --- a/index.php +++ b/index.php @@ -1,7 +1,4 @@ - + @@ -24,10 +21,11 @@ include_once 'filter_inputs.php'; lancan