lot of stuff
This commit is contained in:
42
scan.php
42
scan.php
@ -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());
|
||||
}
|
||||
|
Reference in New Issue
Block a user