diff --git a/config.php b/config.php
index f0e058d..0246406 100644
--- a/config.php
+++ b/config.php
@@ -9,19 +9,17 @@ $presets = [
'-PS' => 'microsoft-ds',
'-F' => true,
'-T5' => true,
- '--stylesheet' => "$BASEDIR/lanScan.xsl"
+ '--stylesheet' => "$BASEDIR/lanScan.xsl",
+ 'refreshPeriod' => 60,
+ 'sudo' => false,
],
"host" => [
- '-Pn' => true,
- '-F' => true,
- '-sV' => true,
- '-T5' => true,
- '--stylesheet' => "$BASEDIR/hostScan.xsl"
+ '-Pn' => true,
+ '-F' => true,
+ '-sV' => true,
+ '-T5' => true,
+ '--stylesheet' => "$BASEDIR/hostScan.xsl",
+ 'refreshPeriod' => 60,
+ 'sudo' => false,
],
-];
-
-$saveAs = null;
-$compareWith = null;
-$refreshPeriod = 60;
-$sudo = true;
-
+];
\ No newline at end of file
diff --git a/filter_inputs.php b/filter_inputs.php
index b9f2612..8a45552 100644
--- a/filter_inputs.php
+++ b/filter_inputs.php
@@ -13,9 +13,9 @@ $targets = filter_input(INPUT_GET, 'targets', FILTER_VALIDATE_REGEXP, ['options'
$preset = filter_input(INPUT_GET, "preset");
if ($preset && isset($presets[$preset])) {
- $args = $presets[$preset];
+ $options = $presets[$preset];
} else {
- $args = filter_input_array(INPUT_GET, [
+ $options = filter_input_array(INPUT_GET, [
// TARGET SPECIFICATION:
'-iR' => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 0]],
'--exclude' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]],
@@ -107,10 +107,10 @@ if ($preset && isset($presets[$preset])) {
'--unprivileged' => FILTER_VALIDATE_BOOLEAN,
'-h' => FILTER_VALIDATE_BOOLEAN,
'--stylesheet' => FILTER_VALIDATE_URL,
+// lanScan
+ 'saveAs' => ["filter" => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $fileNameRegex]],
+ 'compareWith' => FILTER_VALIDATE_URL,
+ 'refreshPeriod' => ["filter" => FILTER_VALIDATE_INT, 'options' => ['min_range' => 0]],
+ 'sudo' => FILTER_VALIDATE_BOOLEAN,
], false) ?: $presets["lan"];
-
- $saveAs = filter_input(INPUT_GET, 'saveAs', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $fileNameRegex]]);
- $compareWith = filter_input(INPUT_GET, 'compareWith', FILTER_VALIDATE_URL);
- $refreshPeriod = filter_input(INPUT_GET, 'refreshPeriod', FILTER_VALIDATE_INT, ['options' => ['min_range' => 0]]);
- $sudo = filter_input(INPUT_GET, 'sudo', FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
}
\ No newline at end of file
diff --git a/options.php b/options.php
index 19afb7f..d52f64f 100755
--- a/options.php
+++ b/options.php
@@ -64,13 +64,13 @@ Exemples: = $_SERVER['REMOTE_ADDR']; ?>/24 = $_SERVER['SERVER_NAME']; ?> 10.
">
+ pattern="[a-zA-Z0-9._\/,\-]*" value="= $options['--exclude'] ?? "" ?>">
">
+ value="= $options['-iR'] ?? "" ?>">
@@ -81,7 +81,7 @@ Exemples: = $_SERVER['REMOTE_ADDR']; ?>/24 = $_SERVER['SERVER_NAME']; ?> 10.
@@ -89,21 +89,21 @@ Exemples: = $_SERVER['REMOTE_ADDR']; ?>/24 = $_SERVER['SERVER_NAME']; ?> 10.
"
+ pattern="([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*" value="= $options['-PS'] ?? "" ?>"
title="Liste de ports ex: 22,23,25,80,200-1024,60000-">
"
+ pattern="([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*" value="= $options['-PA'] ?? "" ?>"
title="Liste de ports ex: 22,23,25,80,200-1024,60000-">
"
+ pattern="([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*" value="= $options['-PU'] ?? "" ?>"
title="Liste de ports ex: 22,23,25,80,200-1024,60000-">
@@ -112,19 +112,19 @@ Exemples: = $_SERVER['REMOTE_ADDR']; ?>/24 = $_SERVER['SERVER_NAME']; ?> 10.
@@ -134,20 +134,20 @@ Exemples: = $_SERVER['REMOTE_ADDR']; ?>/24 = $_SERVER['SERVER_NAME']; ?> 10.
"
+ pattern="[0-9,\-]+" value="= $options['-PO'] ?? "" ?>"
title="[num de protocole]">
@@ -156,13 +156,13 @@ Exemples: = $_SERVER['REMOTE_ADDR']; ?>/24 = $_SERVER['SERVER_NAME']; ?> 10.
@@ -185,19 +185,19 @@ Exemples: = $_SERVER['REMOTE_ADDR']; ?>/24 = $_SERVER['SERVER_NAME']; ?> 10.
@@ -206,19 +206,19 @@ Exemples: = $_SERVER['REMOTE_ADDR']; ?>/24 = $_SERVER['SERVER_NAME']; ?> 10.
@@ -227,19 +227,19 @@ Exemples: = $_SERVER['REMOTE_ADDR']; ?>/24 = $_SERVER['SERVER_NAME']; ?> 10.
@@ -248,27 +248,27 @@ Exemples: = $_SERVER['REMOTE_ADDR']; ?>/24 = $_SERVER['SERVER_NAME']; ?> 10.
"
+ pattern="(URG|ACK|PSH|RST|SYN|FIN|,)+|[1-9]?[0-9]|[1-2][0-9][0-9]" value="= $options['--scanflags'] ?? "" ?>"
title="Mélanger simplement les drapeaux URG, ACK, PSH, RST, SYN et FIN.">
"
+ pattern="[a-zA-Z0-9._\-]+(:[0-9]+)?" value="= $options['-sI'] ?? "" ?>"
title="zombie host[:probeport]">
@@ -282,14 +282,14 @@ Exemples: = $_SERVER['REMOTE_ADDR']; ?>/24 = $_SERVER['SERVER_NAME']; ?> 10.
-
+
onchange="pInput.disabled = FCheckbox.checked" />
@@ -297,14 +297,14 @@ Exemples: = $_SERVER['REMOTE_ADDR']; ?>/24 = $_SERVER['SERVER_NAME']; ?> 10.
-
- pattern="(([TU]:)?[0-9\-]+|[a-z\-]+)(,([TU]:)?[0-9\-]+|,[a-z\-]+)*" value="= $args['-p'] ?? "" ?>"
+
+ pattern="(([TU]:)?[0-9\-]+|[a-z\-]+)(,([TU]:)?[0-9\-]+|,[a-z\-]+)*" value="= $options['-p'] ?? "" ?>"
title="Liste de ports ex: ssh,ftp,U:53,111,137,T:21-25,80,139,8080">
@@ -317,13 +317,13 @@ Exemples: = $_SERVER['REMOTE_ADDR']; ?>/24 = $_SERVER['SERVER_NAME']; ?> 10.
diff --git a/scan.php b/scan.php
index 5d6a5dd..3cd999a 100755
--- a/scan.php
+++ b/scan.php
@@ -4,19 +4,21 @@ include_once 'filter_inputs.php';
if (!file_exists($SCANSDIR)) mkdir($SCANSDIR);
-$command = ($sudo? "sudo " : "") . "nmap";
-foreach ($args as $arg => $value) {
- if (is_null($value)) {
- http_response_code(400);
- $errorMessage = "Valeur incorecte pour le paramètre
$arg : " . filter_input(INPUT_GET, $arg, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
- include_once "options.php";
- die();
- } else if ($value) {
- if ($value === true) {
- $command .= " $arg";
- } else {
- if (substr($arg, 0, 2) == '--') $command .= " $arg $value";
- else $command .= " $arg$value";
+$command = ($options["sudo"]?? false ? "sudo " : "") . "nmap";
+foreach ($options as $arg => $value) {
+ if (substr($arg, 0, 1) == '-') {
+ if (is_null($value)) {
+ http_response_code(400);
+ $errorMessage = "Valeur incorecte pour le paramètre
$arg : " . filter_input(INPUT_GET, $arg, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
+ include_once "options.php";
+ die();
+ } else if ($value) {
+ if ($value === true) {
+ $command .= " $arg";
+ } else {
+ if (substr($arg, 0, 2) == '--') $command .= " $arg $value";
+ else $command .= " $arg$value";
+ }
}
}
}
@@ -38,13 +40,13 @@ $xml = new DOMDocument();
$xml->load($tempPath);
`rm "$tempPath"`;
-$saveAsURL = $saveAs? "$BASEDIR/$SCANSDIR/$saveAs.xml" : "";
+$saveAsURL = isset($options["saveAs"])? "$BASEDIR/$SCANSDIR/{$options["saveAs"]}.xml" : "";
$xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='savedAs' value='".htmlentities($saveAsURL, ENT_QUOTES)."'"), $xml->documentElement);
-$xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='compareWith' value='".htmlentities($compareWith, ENT_QUOTES)."'"), $xml->documentElement);
-$xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='refreshPeriod' value='".htmlentities($refreshPeriod, ENT_QUOTES)."'"), $xml->documentElement);
+$xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='compareWith' value='".htmlentities($options["compareWith"] ?? "", ENT_QUOTES)."'"), $xml->documentElement);
+$xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='refreshPeriod' value='".htmlentities($options["refreshPeriod"] ?? "", ENT_QUOTES)."'"), $xml->documentElement);
-if ($saveAs) {
- $path = "$SCANSDIR/$saveAs.xml";
+if (isset($options["saveAs"])) {
+ $path = "$SCANSDIR/{$options["saveAs"]}.xml";
$xml->save($path);
header("Location: $path");