system
This commit is contained in:
parent
dc8fa57c0f
commit
0c72ceb620
17
index.php
17
index.php
@ -641,24 +641,25 @@ foreach (scandir($SCANSDIR) as $filename) {
|
||||
<button type="submit" class="ui teal submit button">Démarrer</button>
|
||||
</form>
|
||||
|
||||
<h2 class="ui header">Scans enregistrés</h1>
|
||||
<div class="ui large relaxed card">
|
||||
<div class="content">
|
||||
<div class="ui divided link list">
|
||||
<h2 class="ui header">Derniers scans</h2>
|
||||
<div class="ui relaxed list">
|
||||
<?php
|
||||
if (!file_exists($SCANSDIR)) {
|
||||
mkdir($SCANSDIR);
|
||||
}
|
||||
$scans = [];
|
||||
foreach (scandir($SCANSDIR) as $filename) {
|
||||
if (substr($filename, -4) == '.xml') {
|
||||
$name = str_replace('!', '/', substr_replace($filename, '', -4));
|
||||
echo "<a class='item' href='$SCANSDIR/".rawurlencode($filename)."'>$name</a>\n";
|
||||
$scans[$filename] = filemtime("$SCANSDIR/$filename");
|
||||
}
|
||||
}
|
||||
arsort($scans);
|
||||
foreach ($scans as $filename => $date) {
|
||||
$name = str_replace('!', '/', substr_replace($filename, '', -4));
|
||||
echo " <div class='item'><a class='header' href='$SCANSDIR/".rawurlencode($filename)."'>$name</a><div class='description'>".date(DATE_RFC7231, $date)."</div></div>\n";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="ui footer segment">
|
||||
|
48
scan.php
48
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("<br/>\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();
|
||||
|
@ -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;
|
||||
|
@ -31,7 +31,7 @@
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:template match="nmaprun">
|
||||
<xsl:variable name="targets" select="substring-after(@args, '.xml ')"/>
|
||||
<xsl:variable name="targets" select="substring-after(@args, '-oX - ')"/>
|
||||
|
||||
<html lang="fr">
|
||||
<xsl:apply-templates select="." mode="head">
|
||||
@ -51,7 +51,7 @@
|
||||
<xsl:with-param name="sudo" select="$sudo"/>
|
||||
</xsl:apply-templates>
|
||||
|
||||
<main class="ui main container">
|
||||
<main class="ui main wide container">
|
||||
<h1 class="ui header"><xsl:value-of select="$targets"/></h1>
|
||||
|
||||
<table id="scanResultsTable" style="width:100%" role="grid" class="ui sortable small table">
|
||||
@ -61,7 +61,7 @@
|
||||
<th>Adresse IP</th>
|
||||
<th>Nom</th>
|
||||
<th>Fabricant</th>
|
||||
<th class="eight wide">Services</th>
|
||||
<th class="six wide">Services</th>
|
||||
<th>Scanner les services</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -177,7 +177,7 @@ function hostScanning(link) {
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="$basedir"/>
|
||||
<xsl:text>/scan.php?preset=host&targets=</xsl:text>
|
||||
<xsl:value-of select="$hostAddress"/>
|
||||
<xsl:value-of select="address/@addr"/>
|
||||
</xsl:attribute>
|
||||
<i class="satellite dish icon"></i>
|
||||
<xsl:text> Services</xsl:text>
|
||||
@ -186,7 +186,7 @@ function hostScanning(link) {
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="$basedir"/>
|
||||
<xsl:text>/?preset=host&targets=</xsl:text>
|
||||
<xsl:value-of select="$hostAddress"/>
|
||||
<xsl:value-of select="address/@addr"/>
|
||||
</xsl:attribute>
|
||||
<i class="settings icon"></i>
|
||||
</a>
|
||||
|
Reference in New Issue
Block a user