From 0c72ceb620e0b780317d6525f55b309c143cd000 Mon Sep 17 00:00:00 2001 From: adrien Date: Mon, 25 Nov 2024 18:02:54 +0100 Subject: [PATCH] system --- index.php | 17 ++++++++------- scan.php | 48 +++++++++++------------------------------- style.css | 4 ++++ templates/hostScan.xsl | 2 +- templates/lanScan.xsl | 10 ++++----- 5 files changed, 31 insertions(+), 50 deletions(-) diff --git a/index.php b/index.php index e2f3eb6..3e7e426 100755 --- a/index.php +++ b/index.php @@ -641,23 +641,24 @@ foreach (scandir($SCANSDIR) as $filename) { -

Scans enregistrés

-
-
-
diff --git a/scan.php b/scan.php index 83b4f32..f3a6029 100755 --- a/scan.php +++ b/scan.php @@ -8,7 +8,10 @@ $options["--script-args-file"] = $SCRIPTARGS; if (!file_exists($SCANSDIR)) mkdir($SCANSDIR); -$command = ($options["sudo"]?? false ? "sudo " : "") . "nmap"; +if (!$options["name"]) $options["name"] = str_replace('/', '!', $targets); + +//$command = ($options["sudo"]?? false ? "sudo " : "") . "nmap"; +$args = ""; foreach ($options as $option => $value) { if (substr($option, 0, 1) == '-') { if (is_null($value)) { @@ -18,47 +21,20 @@ foreach ($options as $option => $value) { die(); } else if ($value) { if ($value === true) { - $command .= " $option"; + $args .= " $option"; } else { - if (substr($option, 0, 2) == '--') $command .= " $option " . escapeshellarg($value); - else $command .= " $option" . escapeshellarg($value); + if (substr($option, 0, 2) == '--') $args .= " $option " . escapeshellarg($value); + else $args .= " $option" . escapeshellarg($value); } } } } -$tempPath = tempnam(sys_get_temp_dir(), 'scan_').".xml"; +$path = "$SCANSDIR/{$options["name"]}.xml"; -$command .= " -oX '$tempPath' $targets 2>&1"; +$command = "nmap $args -oX - $targets | tee '$path'"; -exec($command, $stderr, $retcode); +header('Content-type: text/xml'); +system($command, $retcode); -if ($retcode) { - http_response_code(500); - $errorMessage = implode("
\n", $stderr); - include_once "."; - die(); -} - -$xml = new DOMDocument(); -$xml->load($tempPath); -`rm "$tempPath"`; - -$thisURL = $options["name"]?? false ? "$BASEDIR/$SCANSDIR/".rawurlencode($options["name"]).".xml" : ""; -$xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='thisURL' value='".htmlentities($thisURL, ENT_QUOTES)."'"), $xml->documentElement); -foreach ($options as $option => $value) { - if (substr($option, 0, 1) != '-') { - $xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='$option' value='".htmlentities($value, ENT_QUOTES)."'"), $xml->documentElement); - } -} - -if ($options["name"] ?? false) { - $path = "$SCANSDIR/{$options["name"]}.xml"; - $xml->save($path); - - header("Location: $path"); - exit(); -} else { - header('Content-type: text/xml'); - exit($xml->saveXML()); -} +exit(); diff --git a/style.css b/style.css index a2f4b0d..c7e3cda 100644 --- a/style.css +++ b/style.css @@ -12,6 +12,10 @@ main { min-height: calc(100vh - var(--footer-height) - 1rem) } +h1:first-child, h2:first-child, h3:first-child, h4:first-child, h5:first-child, .ui.header:first-child { + margin-top: 1rem; +} + svg { margin: -0.3em -0.5em -0.5em -0.4em; fill: currentColor; diff --git a/templates/hostScan.xsl b/templates/hostScan.xsl index 24c0f5d..63af742 100755 --- a/templates/hostScan.xsl +++ b/templates/hostScan.xsl @@ -75,7 +75,7 @@ table.order([1, 'asc']).draw() $('.ui.dropdown').dropdown() - + diff --git a/templates/lanScan.xsl b/templates/lanScan.xsl index 9daa554..ed8e493 100755 --- a/templates/lanScan.xsl +++ b/templates/lanScan.xsl @@ -31,7 +31,7 @@ - + @@ -51,7 +51,7 @@ -
+

@@ -61,7 +61,7 @@ - + @@ -177,7 +177,7 @@ function hostScanning(link) { /scan.php?preset=host&targets= - + Services @@ -186,7 +186,7 @@ function hostScanning(link) { /?preset=host&targets= - +
Adresse IP Nom FabricantServicesServices Scanner les services