From f5a0cffc055e5696da1deead3ba4def77198274e Mon Sep 17 00:00:00 2001 From: adrien Date: Sun, 13 Oct 2024 15:04:58 +0200 Subject: [PATCH] temp file --- index.php | 9 ++++++++- scan.php | 8 +++++--- stylesheet.xsl | 13 ++++++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/index.php b/index.php index e733b94..949c6c5 100755 --- a/index.php +++ b/index.php @@ -21,7 +21,7 @@ include_once 'filter_inputs.php';
diff --git a/scan.php b/scan.php index 878b201..9a8b644 100755 --- a/scan.php +++ b/scan.php @@ -29,21 +29,23 @@ foreach ($inputs as $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); + +$tempPath = tempnam(sys_get_temp_dir(), 'scan_').".xml"; +exec("nmap$args --stylesheet $basedir/stylesheet.xsl -oX '$tempPath' $targets 2>&1", $stderr, $code); if ($code) { http_response_code(500); die(implode("
\n", $stderr)); } $xml = new DOMDocument(); -$xml->load("$SCANS_DIR/.tmp"); +$xml->load($tempPath); +`rm "$tempPath"`; $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); diff --git a/stylesheet.xsl b/stylesheet.xsl index d71f739..47f7cef 100755 --- a/stylesheet.xsl +++ b/stylesheet.xsl @@ -23,7 +23,7 @@ - + @@ -67,7 +67,7 @@