Compare commits
No commits in common. "570e8f2252fe980e18c99b090d474a93d630584c" and "6422830783530f66ca412c0851909b4f4beb74ab" have entirely different histories.
570e8f2252
...
6422830783
@ -10,7 +10,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;
|
||||
```
|
||||
|
@ -17,7 +17,6 @@ $HOSTSCAN_OPTIONS = [
|
||||
];
|
||||
|
||||
$refreshPeriod = 60;
|
||||
$use_sudo = false;
|
||||
|
||||
$SCANSDIR = 'scans';
|
||||
$DATADIR = '/usr/share/nmap';
|
||||
|
11
options.php
11
options.php
@ -34,15 +34,6 @@ include_once 'filter_inputs.php';
|
||||
</nav>
|
||||
|
||||
<main class="ui main container">
|
||||
|
||||
<?php if(isset($errorMessage)) { ?>
|
||||
<div class="ui negative message">
|
||||
<i class="close icon"></i>
|
||||
<div class="header">Erreur</div>
|
||||
<p><?=$errorMessage?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<h1 class="header">Scanner un <?=$host? "hôte" : "réseau" ?></h1>
|
||||
|
||||
<form id="newScanForm" class="ui form" method="get" action="scan.php">
|
||||
@ -452,4 +443,4 @@ foreach ($services as $name => [$portid, $protocol]) {
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
20
scan.php
20
scan.php
@ -5,9 +5,7 @@ include_once 'filter_inputs.php';
|
||||
|
||||
if (!$targets) {
|
||||
http_response_code(400);
|
||||
$errorMessage = 'Paramètre manquant : targets, lan ou host';
|
||||
include_once "options.php";
|
||||
die();
|
||||
die('Paramètre manquant : targets, lan ou host');
|
||||
}
|
||||
|
||||
if (!file_exists($SCANSDIR)) mkdir($SCANSDIR);
|
||||
@ -16,9 +14,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);
|
||||
include_once "options.php";
|
||||
die();
|
||||
die("Valeur incorecte pour le paramètre $arg : " . filter_input(INPUT_GET, $arg, FILTER_SANITIZE_FULL_SPECIAL_CHARS));
|
||||
} else if ($value) {
|
||||
if ($value === true) {
|
||||
if (strlen($arg) <= 2) $args .= " -$arg";
|
||||
@ -32,15 +28,19 @@ 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 = "nmap$args -oX '$tempPath' $targets 2>&1";
|
||||
|
||||
exec($command, $stderr, $retcode);
|
||||
|
||||
if ($retcode && strpos(implode($stderr), " root ") !== false) {
|
||||
// Retry with sudo
|
||||
$recode = 0;
|
||||
exec("sudo $command", $stderr, $retcode);
|
||||
}
|
||||
|
||||
if ($retcode) {
|
||||
http_response_code(500);
|
||||
$errorMessage = implode("<br/>\n", $stderr);
|
||||
include_once "options.php";
|
||||
die();
|
||||
die(implode("<br/>\n", $stderr));
|
||||
}
|
||||
|
||||
$xml = new DOMDocument();
|
||||
|
Reference in New Issue
Block a user