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) {
-
-
-Scans enregistrés
+
+ $name\n";
+ }
}
}
-arsort($scans);
-foreach ($scans as $filename => $date) {
- $name = str_replace('!', '/', substr_replace($filename, '', -4));
- echo "
".date(DATE_RFC7231, $date)."
\n";
-}
?>
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);