From f413212db9b2bc3a76ec1da3682578b09bc2e46a Mon Sep 17 00:00:00 2001 From: adrien Date: Thu, 10 Oct 2024 18:07:44 +0200 Subject: [PATCH] fix scan args --- filter_inputs.php | 46 ++--- index.php | 108 ++++++------ scan-options.php | 433 +++++++++++++++++++++++----------------------- scan.php | 13 +- 4 files changed, 301 insertions(+), 299 deletions(-) diff --git a/filter_inputs.php b/filter_inputs.php index f8bf6ce..4c81b01 100644 --- a/filter_inputs.php +++ b/filter_inputs.php @@ -15,24 +15,24 @@ $protocolePortsListRegex = "/^(([TU]:)?[0-9\-]+|[a-z\-]+)(,([TU]:)?[0-9\-]+|,[a- $portsListRegex = "/^([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*$/"; $tempoRegex = "/^\d+[smh]?$/"; -$options = filter_input_array(INPUT_GET, [ +$inputs = filter_input_array(INPUT_GET, [ 'iR' => ['filter' => FILTER_VALIDATE_INT], - '-exclude' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]], + '-exclude' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]], - 'sL' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]], + 'sL' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]], 'sP' => ['filter' => FILTER_VALIDATE_BOOLEAN], 'P0' => ['filter' => FILTER_VALIDATE_BOOLEAN], 'Pn' => ['filter' => FILTER_VALIDATE_BOOLEAN], - 'PS' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $portsListRegex]], - 'PA' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $portsListRegex]], - 'PU' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $portsListRegex]], + 'PS' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $portsListRegex]], + 'PA' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $portsListRegex]], + 'PU' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $portsListRegex]], 'PE' => ['filter' => FILTER_VALIDATE_BOOLEAN], 'PP' => ['filter' => FILTER_VALIDATE_BOOLEAN], 'PM' => ['filter' => FILTER_VALIDATE_BOOLEAN], - 'PO' => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 0, 'max_range' => 255]], + 'PO' => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 0, 'max_range' => 255]], 'n' => ['filter' => FILTER_VALIDATE_BOOLEAN], 'R' => ['filter' => FILTER_VALIDATE_BOOLEAN], - '-dns-servers' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]], + '-dns-servers' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]], 'sS' => ['filter' => FILTER_VALIDATE_BOOLEAN], 'sT' => ['filter' => FILTER_VALIDATE_BOOLEAN], @@ -46,22 +46,22 @@ $options = filter_input_array(INPUT_GET, [ 'PM' => ['filter' => FILTER_VALIDATE_BOOLEAN], 'PM' => ['filter' => FILTER_VALIDATE_BOOLEAN], 'PM' => ['filter' => FILTER_VALIDATE_BOOLEAN], - '-scanflags' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => "/^([URG|ACK|PSH|RST|SYN|FIN]+)$|^([0-2]?\d?\d)$/"]], - 'sI' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => "/^[a-zA-Z\d:.-]+(:\d+)?$/"]], + '-scanflags' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => "/^([URG|ACK|PSH|RST|SYN|FIN]+)$|^([0-2]?\d?\d)$/"]], + 'sI' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => "/^[a-zA-Z\d:.-]+(:\d+)?$/"]], 'sO' => ['filter' => FILTER_VALIDATE_BOOLEAN], 'b' => FILTER_VALIDATE_DOMAIN, '-traceroute' => ['filter' => FILTER_VALIDATE_BOOLEAN], '-reason' => ['filter' => FILTER_VALIDATE_BOOLEAN], - 'p' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $portsListRegex]], + 'p' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $portsListRegex]], 'F' => ['filter' => FILTER_VALIDATE_BOOLEAN], 'r' => ['filter' => FILTER_VALIDATE_BOOLEAN], '-top-ports' => FILTER_VALIDATE_INT, - '-port-ratio' => ['filter' => FILTER_VALIDATE_FLOAT, 'options' => ['min_range' => 0, 'max_range' => 1]], + '-port-ratio' => ['filter' => FILTER_VALIDATE_FLOAT, 'options' => ['min_range' => 0, 'max_range' => 1]], 'sV' => ['filter' => FILTER_VALIDATE_BOOLEAN], '-version-light' => ['filter' => FILTER_VALIDATE_BOOLEAN], - '-version-intensity' => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 0, 'max_range' => 9]], + '-version-intensity' => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 0, 'max_range' => 9]], '-version-all' => ['filter' => FILTER_VALIDATE_BOOLEAN], '-version-trace' => ['filter' => FILTER_VALIDATE_BOOLEAN], @@ -79,24 +79,24 @@ $options = filter_input_array(INPUT_GET, [ '-max-hostgroup' => ['filter' => FILTER_VALIDATE_INT], '-min-parallelism' => ['filter' => FILTER_VALIDATE_INT], '-max-parallelism' => ['filter' => FILTER_VALIDATE_INT], - '-min-rtt-timeout' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $tempoRegex]], - '-max-rtt-timeout' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $tempoRegex]], - '-initial-rtt-timeout' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $tempoRegex]], + '-min-rtt-timeout' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $tempoRegex]], + '-max-rtt-timeout' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $tempoRegex]], + '-initial-rtt-timeout' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $tempoRegex]], '-max-retries' => ['filter' => FILTER_VALIDATE_INT], - '-host-timeout' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $tempoRegex]], - '-scan-delay' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $tempoRegex]], - '-max-scan-delay' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $tempoRegex]], + '-host-timeout' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $tempoRegex]], + '-scan-delay' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $tempoRegex]], + '-max-scan-delay' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $tempoRegex]], 'f' => ['filter' => FILTER_VALIDATE_INT], 'mtu' => ['filter' => FILTER_VALIDATE_INT], - 'D' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]], + 'D' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]], 'S' => ['filter' => FILTER_VALIDATE_IP], - 'e' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => "/^[a-z\d]+$/"]], + 'e' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => "/^[a-z\d]+$/"]], 'g' => ['filter' => FILTER_VALIDATE_INT], '-source-port' => ['filter' => FILTER_VALIDATE_INT], '-data-length' => ['filter' => FILTER_VALIDATE_INT], - '-ip-options' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => "/^\"(R|T|U|L [\da-zA-Z-.: ]+|S [\da-zA-Z-.: ]+|\\\\x[\da-fA-F]{1,2}(\*[\d]+)?|\\\\[0-2]?[\d]{1,2}(\*[\d]+)?)\"$/"]], - 'ttl' => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 0, 'max_range' => 255]], + '-ip-options' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => "/^\"(R|T|U|L [\da-zA-Z-.: ]+|S [\da-zA-Z-.: ]+|\\\\x[\da-fA-F]{1,2}(\*[\d]+)?|\\\\[0-2]?[\d]{1,2}(\*[\d]+)?)\"$/"]], + 'ttl' => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 0, 'max_range' => 255]], '-spoof-mac' => ['filter' => FILTER_VALIDATE_MAC], '-badsum' => ['filter' => FILTER_VALIDATE_BOOLEAN], diff --git a/index.php b/index.php index c3b7c2d..9a55bc2 100755 --- a/index.php +++ b/index.php @@ -5,64 +5,64 @@ include_once 'filter_inputs.php'; - - - lanScan - - - - - - - - - + + + lanScan + + + + + + + + + - - -
-
-
-
Précédents scans
- +
+
+
+
Précédents scans
+
-
- +
+
+ \ No newline at end of file diff --git a/scan-options.php b/scan-options.php index 464b2ed..f99fd62 100755 --- a/scan-options.php +++ b/scan-options.php @@ -5,254 +5,255 @@ include_once 'filter_inputs.php'; - - - lanScan - - - - - - - - - + + + lanScan + + + + + + + + + - - + + -
-

Scanner un réseau avec Nmap

+
+

Scanner un réseau avec Nmap

-
+ - -
- - +
+ + +
+ +
+
Spécification des cibles
+
+
+ + " + title="Les cibles peuvent être spécifiées par des noms d'hôtes, des adresses IP, des adresses de réseaux, etc. +Exemples: /24,,10.0-255.0-255.1-254"> +
-
-
Spécification des cibles
-
-
- - " - title="Les cibles peuvent être spécifiées par des noms d'hôtes, des adresses IP, des adresses de réseaux, etc. -Exemples: /24,,10.0-255.0-255.1-254"> +
Découverte des hôtes actifs
+
+
+
+ /> +
-
Découverte des hôtes actifs
-
-
-
- /> - -
-
- -
-
- /> - -
-
- -
-
- - " - title="Liste de ports ex: 22,23,25,80,200-1024,60000-"> -
-
- - " - title="Liste de ports ex: 22,23,25,80,200-1024,60000-"> -
-
- - " - title="Liste de ports ex: 22,23,25,80,200-1024,60000-"> -
+
+
+ /> +
+
+
- -
-
-
- /> - -
-
-
-
- /> - -
-
-
-
- /> - -
-
-
+ + " + title="Liste de ports ex: 22,23,25,80,200-1024,60000-">
-
-
- /> - -
+ + " + title="Liste de ports ex: 22,23,25,80,200-1024,60000-">
-
- - " + + " title="Liste de ports ex: 22,23,25,80,200-1024,60000-">
-
Techniques de scan
-
-
-
- /> - +
+ +
+
+
+ /> + +
-
- -
- - " - title="Liste de ports ex: ssh,ftp,U:53,111,137,T:21-25,80,139,8080"> -
- -
-
- /> - +
+
+ /> + +
+
+
+
+ /> + +
+
+
+ /> + +
+
+ +
+ + " + title="Liste de ports ex: 22,23,25,80,200-1024,60000-"> +
- - - - - - - -\n"; +
Techniques de scan
+
+
+
+ /> + +
+
+ +
+ + " + title="Liste de ports ex: ssh,ftp,U:53,111,137,T:21-25,80,139,8080"> +
+ +
+
+ /> + +
+
+
+ +
+ + + + + + + + + \n"; + } + } + ?> + + + [$portid, $protocol]) { + echo " \n"; + } + ?> + +
+ + -$('.ui.accordion').accordion() - -new Tagify(targetsInput, { - delimiters: " |,", - originalInputValueFormat: joinWithSpaces, - whitelist: targetsWhitelist, -}) - -new Tagify(excludeInput, { - delimiters: " |,", - originalInputValueFormat: joinWithCommas, - whitelist: targetsWhitelist, -}) - -new Tagify(PSInput, { - delimiters: " |,", - originalInputValueFormat: joinWithCommas, - whitelist: servicesWhitelist, -}) - -new Tagify(PAInput, { - delimiters: " |,", - originalInputValueFormat: joinWithCommas, - whitelist: servicesWhitelist, -}) - -new Tagify(PUInput, { - delimiters: " |,", - originalInputValueFormat: joinWithCommas, - whitelist: servicesWhitelist, -}) - -new Tagify(P0Input, { - delimiters: " |,", - originalInputValueFormat: joinWithCommas -}) - -new Tagify(pInput, { - delimiters: " |,", - originalInputValueFormat: joinWithCommas, - whitelist: servicesWhitelist, -}) - -newScanForm.onsubmit = function (event) { - if (this.checkValidity()) { - newScanForm.classList.add("loading") - return true - } else { - event.preventDefault() - this.reportValidity() - } -} - - - - + \ No newline at end of file diff --git a/scan.php b/scan.php index b5fe9cc..c75e372 100755 --- a/scan.php +++ b/scan.php @@ -12,18 +12,19 @@ if (!file_exists($SCANS_DIR)) { mkdir($SCANS_DIR); } -$basedir = "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}".dirname($_SERVER['REQUEST_URI']); +$basedir = "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}" . dirname($_SERVER['REQUEST_URI']); $args = ''; -foreach ($options as $arg => $value) { +foreach ($inputs as $name => $value) { + echo "$name : $value $args
"; if (is_null($value)) { http_response_code(400); - exit("Valeur incorecte pour le paramètre $option : ".filter_input(INPUT_GET, $option, FILTER_SANITIZE_FULL_SPECIAL_CHARS)); + exit("Valeur incorecte pour le paramètre $option : " . filter_input(INPUT_GET, $option, FILTER_SANITIZE_FULL_SPECIAL_CHARS)); } else if ($value) { if ($value === true) { - $args .= " -$arg"; + $args .= " -$name"; } else { - $arg .= " -$arg ".escapeshellarg($value); + $args .= " -$name " . ($value); } } } @@ -42,7 +43,7 @@ if (!file_exists($SCANS_DIR)) { mkdir($SCANS_DIR); } -$path = "$SCANS_DIR/".str_replace('/', '!', $targets).'.xml'; +$path = "$SCANS_DIR/" . str_replace('/', '!', $targets) . '.xml'; if (!file_exists($path)) { $xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='compareWith' value=''"), $xml->documentElement); $xml->save($path);