lot of stuff

This commit is contained in:
2024-10-12 19:10:50 +02:00
parent 8a9b822cf6
commit 97a4c5801b
7 changed files with 505 additions and 409 deletions

View File

@ -15,40 +15,42 @@ if (!file_exists($SCANS_DIR)) {
$basedir = "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}" . dirname($_SERVER['REQUEST_URI']);
$args = '';
foreach ($inputs as $name => $value) {
foreach ($inputs as $arg => $value) {
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));
die("Valeur incorecte pour le paramètre $arg : " . filter_input(INPUT_GET, $arg, FILTER_SANITIZE_FULL_SPECIAL_CHARS));
} else if ($value) {
if ($value === true) {
$args .= " -$name";
if (strlen($arg)<=2) $args .= " -$arg";
else $arg = "--$arg";
} else {
$args .= " -$name " . ($value);
if (strlen($arg)<=2) $args .= " -$arg" . ($value);
else $arg = "--$arg " . ($value);
}
}
}
$result = `nmap$args --stylesheet $basedir/stylesheet.xsl -oX - $targets`;
if (!$result) {
exec("nmap$args --stylesheet $basedir/stylesheet.xsl -oX - $targets 2>&1", $result, $code);
if ($code) {
http_response_code(500);
exit();
die(implode("<br/>\n", $result));
}
$xml = new DOMDocument();
$xml->loadXML($result);
$xml->loadXML(implode("\n", $result));
$dir = $SCANS_DIR;
if (!file_exists($SCANS_DIR)) {
mkdir($SCANS_DIR);
}
$xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='name' value='$name'"), $xml->documentElement);
$xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='scansDir' value='$SCANS_DIR'"), $xml->documentElement);
$xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='compareWith' value='$compareWith'"), $xml->documentElement);
$path = "$SCANS_DIR/" . str_replace('/', '!', $targets) . '.xml';
if (!file_exists($path)) {
$xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='compareWith' value=''"), $xml->documentElement);
if ($name) {
if (!file_exists($SCANS_DIR)) mkdir($SCANS_DIR);
$path = "$SCANS_DIR/$name.xml";
$xml->save($path);
} else {
$xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='compareWith' value='$path'"), $xml->documentElement);
}
header('Content-type: text/xml');
exit($xml->saveXML());
header("Location: $path");
exit();
} else {
header('Content-type: text/xml');
exit($xml->saveXML());
}