From e4232737521d8e59f1c703570323916615017512 Mon Sep 17 00:00:00 2001 From: adrien Date: Tue, 26 Nov 2024 15:15:12 +0100 Subject: [PATCH] save if name only --- filter_inputs.php | 5 ++++- index.php | 24 +++++++++--------------- scan.php | 14 ++++++++------ 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/filter_inputs.php b/filter_inputs.php index ebea65a..624a645 100644 --- a/filter_inputs.php +++ b/filter_inputs.php @@ -10,7 +10,7 @@ $tempoRegex = '/^\d+[smh]?$/'; $fileNameRegex = '/^[^<>:\/|?]+$/'; $targets = filter_input(INPUT_GET, 'targets', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex], "flags" => FILTER_NULL_ON_FAILURE]); -$preset = filter_input(INPUT_GET, "preset"); +$preset = filter_input(INPUT_GET, "preset", FILTER_SANITIZE_STRING); if ($preset && isset($presets[$preset])) { $options = $presets[$preset]; @@ -116,6 +116,9 @@ if ($preset && isset($presets[$preset])) { ], false) ?: $presets["default"]; } +$options["--datadir"] = $DATADIR; +$options["--script-args-file"] = $SCRIPTARGS; + /*echo "\n";*/ \ No newline at end of file diff --git a/index.php b/index.php index 3e7e426..1705edd 100755 --- a/index.php +++ b/index.php @@ -641,23 +641,17 @@ foreach (scandir($SCANSDIR) as $filename) { -

Derniers scans

-
-Scans enregistrés + diff --git a/scan.php b/scan.php index f3a6029..a089b27 100755 --- a/scan.php +++ b/scan.php @@ -3,14 +3,10 @@ include_once 'config.php'; include_once 'filter_inputs.php'; -$options["--datadir"] = $DATADIR; -$options["--script-args-file"] = $SCRIPTARGS; - if (!file_exists($SCANSDIR)) mkdir($SCANSDIR); if (!$options["name"]) $options["name"] = str_replace('/', '!', $targets); -//$command = ($options["sudo"]?? false ? "sudo " : "") . "nmap"; $args = ""; foreach ($options as $option => $value) { if (substr($option, 0, 1) == '-') { @@ -30,9 +26,15 @@ foreach ($options as $option => $value) { } } -$path = "$SCANSDIR/{$options["name"]}.xml"; -$command = "nmap $args -oX - $targets | tee '$path'"; +$command = "nmap $args -oX - $targets"; + +if (isset($options["sudo"])) $command = "sudo $command"; + +if (isset($options["name"])) { + $path = "$SCANSDIR/{$options["name"]}.xml"; + $command .= " | tee '$path'" +} header('Content-type: text/xml'); system($command, $retcode);