diff --git a/README.md b/README.md index 400f181..10105d9 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,3 @@ Pour donner les droits à lanScan sous Linux, installer `sudo` au besoin, puis c ``` www-data ALL = NOPASSWD: /usr/bin/nmap ```` -et modifier le fichier `config.php` avec : -```php -$use_sudo = true; -``` diff --git a/config.php b/config.php index e30194f..3a4bf70 100644 --- a/config.php +++ b/config.php @@ -13,12 +13,10 @@ $HOSTSCAN_OPTIONS = [ 'Pn' => true, 'F' => true, 'sV' => true, + 'T5' => true, 'stylesheet' => "$BASEDIR/hostScan.xsl" ]; -$refreshPeriod = 60; -$use_sudo = false; - $SCANSDIR = 'scans'; $DATADIR = '/usr/share/nmap'; diff --git a/filter_inputs.php b/filter_inputs.php index 72912a0..42cfda4 100644 --- a/filter_inputs.php +++ b/filter_inputs.php @@ -1,5 +1,7 @@ :"\/|?]+$/'; -$targets = filter_input(INPUT_GET, 'targets', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex]]); -$lan = filter_input(INPUT_GET, 'lan', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex]]); -$host = filter_input(INPUT_GET, 'host', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex]]); +$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]); $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]]) ?? $refreshPeriod; +$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); if ($lan) { $targets = $lan; diff --git a/options.php b/options.php index e4049c8..5022bf2 100755 --- a/options.php +++ b/options.php @@ -363,6 +363,13 @@ foreach (scandir($SCANSDIR) as $filename) {
secondes
+ +
+
+ /> + +
+
diff --git a/scan.php b/scan.php index dcc0c12..c315760 100755 --- a/scan.php +++ b/scan.php @@ -1,11 +1,10 @@ targets : " . filter_input(INPUT_GET, "targets", FILTER_SANITIZE_FULL_SPECIAL_CHARS); include_once "options.php"; die(); } @@ -16,7 +15,7 @@ $args = ''; foreach ($inputs 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); + $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) { @@ -32,7 +31,7 @@ foreach ($inputs as $arg => $value) { $tempPath = tempnam(sys_get_temp_dir(), 'scan_').".xml"; -$command = ($use_sudo? "sudo " : "") . "nmap$args -oX '$tempPath' $targets 2>&1"; +$command = ($sudo? "sudo " : "") . "nmap$args -oX '$tempPath' $targets 2>&1"; exec($command, $stderr, $retcode);