$value) { if (is_null($value)) { http_response_code(400); 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"; } else { if (strlen($arg)<=2) $args .= " -$arg" . ($value); else $arg = "--$arg " . ($value); } } } $basedir = "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}" . dirname($_SERVER['REQUEST_URI']); exec("nmap$args --stylesheet $basedir/stylesheet.xsl -oX $SCANS_DIR/.tmp $targets 2>&1", $stderr, $code); if ($code) { http_response_code(500); die(implode("
\n", $stderr)); } $xml = new DOMDocument(); $xml->load("$SCANS_DIR/.tmp"); $xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='saveAs' value='".htmlentities($saveAs, ENT_QUOTES)."'"), $xml->documentElement); $xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='scansDir' value='".htmlentities($SCANS_DIR, ENT_QUOTES)."'"), $xml->documentElement); $xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='compareWith' value='".htmlentities($compareWith, ENT_QUOTES)."'"), $xml->documentElement); if ($saveAs) { if (!file_exists($SCANS_DIR)) mkdir($SCANS_DIR); $path = "$SCANS_DIR/$saveAs.xml"; $xml->save($path); header("Location: $path"); exit(); } else { header('Content-type: text/xml'); exit($xml->saveXML()); }