use other stylesheets

This commit is contained in:
2024-10-13 18:07:32 +02:00
parent f7629028f6
commit 76e1832c28
6 changed files with 100 additions and 124 deletions

View File

@ -12,6 +12,11 @@ if (!file_exists($SCANS_DIR)) {
mkdir($SCANS_DIR);
}
if (isset($inputs["stylesheet"])) {
$basedir = "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}" . dirname($_SERVER['REQUEST_URI']);
$inputs["stylesheet"] = "$basedir/{$inputs["stylesheet"]}.xsl";
}
$args = '';
foreach ($inputs as $arg => $value) {
if (is_null($value)) {
@ -19,19 +24,18 @@ foreach ($inputs as $arg => $value) {
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";
else $arg = "--$arg";
if (strlen($arg) <= 2) $args .= " -$arg";
else $args .= " --$arg";
} else {
if (strlen($arg)<=2) $args .= " -$arg" . ($value);
else $arg = "--$arg " . ($value);
if (strlen($arg) <= 2) $args .= " -$arg$value";
else $args .= " --$arg $value";
}
}
}
$basedir = "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}" . dirname($_SERVER['REQUEST_URI']);
$tempPath = tempnam(sys_get_temp_dir(), 'scan_').".xml";
exec("nmap$args --stylesheet $basedir/stylesheet.xsl -oX '$tempPath' $targets 2>&1", $stderr, $code);
exec("nmap$args -oX '$tempPath' $targets 2>&1", $stderr, $code);
if ($code) {
http_response_code(500);
die(implode("<br/>\n", $stderr));