This commit is contained in:
Adrien MALINGREY 2024-10-18 14:47:02 +02:00
parent a773e8b8d9
commit c3ed9f9fc2
12 changed files with 30 additions and 23 deletions

View File

@ -1,16 +1,16 @@
<?php <?php
$BASEDIR = "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}" . dirname($_SERVER['REQUEST_URI']); $BASEDIR = "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}" . dirname($_SERVER['REQUEST_URI']);
$SCANSDIR = 'scans'; $SCANSDIR = 'scans';
$NMAPDIR = dirname(`which nmap`) . "/../share/nmap"; $NMAPDIR = dirname(`which nmap`) . "/../share/nmap";
$DATADIR = "."; $DATADIR = "datadir";
$presets = [ $presets = [
"lan" => [ "lan" => [
'-PS' => 'microsoft-ds', '-PS' => 'microsoft-ds',
'-F' => true, '-F' => true,
'-T5' => true, '-T5' => true,
'--stylesheet' => "$BASEDIR/xslt/hostsTable.xsl", '--stylesheet' => "$BASEDIR/templates/hostsTable.xsl",
'refreshPeriod' => 60, 'refreshPeriod' => 60,
'sudo' => false, 'sudo' => false,
], ],
@ -19,8 +19,8 @@ $presets = [
'-F' => true, '-F' => true,
'-sV' => true, '-sV' => true,
'-T5' => true, '-T5' => true,
'--datadir' => "$DATADIR", '--script' => "http-info,smb-shares-size",
'--stylesheet' => "$BASEDIR/xslt/servicesTable.xsl", '--stylesheet' => "$BASEDIR/templates/servicesTable.xsl",
'refreshPeriod' => 60, 'refreshPeriod' => 60,
'sudo' => true, 'sudo' => true,
], ],

View File

@ -117,5 +117,7 @@ if ($preset && isset($presets[$preset])) {
'compareWith' => FILTER_VALIDATE_URL, 'compareWith' => FILTER_VALIDATE_URL,
'refreshPeriod' => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 0]], 'refreshPeriod' => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 0]],
'sudo' => FILTER_VALIDATE_BOOLEAN, 'sudo' => FILTER_VALIDATE_BOOLEAN,
], false); ], false) ?: $preset["lan"];
} }
$options["--datadir"] = $DATADIR;

View File

@ -473,16 +473,21 @@ foreach (scandir($SCANSDIR) as $filename) {
<datalist id='servicesList'> <datalist id='servicesList'>
<?php <?php
$nmap_services = file("$NMAPDIR/nmap-services");
$services = []; $services = [];
foreach ($nmap_services as $service) { foreach ([$DATADIR, $NMAPDIR] as $dir) {
if (0 !== strpos($service, '#')) { echo "<!-- $nmap_services -->\n";
[$name, $port] = explode("\t", $service); if (file_exists("$dir/nmap-services")) {
$services[$name] = explode("/", $port); $nmap_services = file("$dir/nmap-services");
foreach ($nmap_services as $service) {
if (0 !== strpos($service, '#')) {
[$name, $port] = explode("\t", $service);
$services[$name] = explode("/", $port);
}
}
} }
} }
foreach ($services as $name => [$portid, $protocol]) { foreach ($services as $name => [$portid, $protocol]) {
echo " <option value='$name'>$portid</option>\n"; echo " <option value='$name'></option>\n";
} }
?> ?>
</datalist> </datalist>
@ -514,7 +519,7 @@ foreach ($services as $name => [$portid, $protocol]) {
<option value="vuln"></option> <option value="vuln"></option>
<!-- names --> <!-- names -->
<?php <?php
foreach ([$NMAPDIR, $DATADIR] as $dir) { foreach ([$DATADIR, $NMAPDIR] as $dir) {
foreach (scandir("$dir/scripts") as $filename) { foreach (scandir("$dir/scripts") as $filename) {
if (substr($filename, -4) === '.nse') { if (substr($filename, -4) === '.nse') {
$name = substr($filename, 0, -4); $name = substr($filename, 0, -4);

View File

@ -41,7 +41,7 @@ main {
margin-top: 0; margin-top: 0;
} }
.ui.header { .toast-container .ui.header {
text-transform: capitalize; text-transform: capitalize;
} }

View File

@ -268,7 +268,7 @@ function hostScanning(link) {
<xsl:with-param name="initHost" select="$initHost"/> <xsl:with-param name="initHost" select="$initHost"/>
<xsl:with-param name="currentHost" select="$currentHost"/> <xsl:with-param name="currentHost" select="$currentHost"/>
<xsl:with-param name="hostAddress" select="$hostAddress"/> <xsl:with-param name="hostAddress" select="$hostAddress"/>
<xsl:sort select="@portid" order="ascending"/> <xsl:sort select="number(@portid)" order="ascending"/>
</xsl:apply-templates> </xsl:apply-templates>
</div> </div>
</div> </div>

View File

@ -272,7 +272,7 @@ function hostScanning(link) {
<xsl:with-param name="initHost" select="$initHost"/> <xsl:with-param name="initHost" select="$initHost"/>
<xsl:with-param name="currentHost" select="$currentHost"/> <xsl:with-param name="currentHost" select="$currentHost"/>
<xsl:with-param name="hostAddress" select="$hostAddress"/> <xsl:with-param name="hostAddress" select="$hostAddress"/>
<xsl:sort select="@portid" order="ascending"/> <xsl:sort select="number(@portid)" order="ascending"/>
</xsl:apply-templates> </xsl:apply-templates>
</div> </div>
</div> </div>

View File

@ -283,11 +283,11 @@ function hostScanning(link) {
<xsl:value-of select="address[@addrtype='mac']/@vendor"/> <xsl:value-of select="address[@addrtype='mac']/@vendor"/>
</td> </td>
<td> <td>
<xsl:apply-templates select="$currentHost/ports/port | $initHost/ports/port[not(@portid=$currentHost/ports/port/@portid)][not(state/@state='closed')]"> <xsl:apply-templates select="$initHost/ports/port[not(@portid=$currentHost/ports/port/@portid)][not(state/@state='closed')] | $currentHost/ports/port">
<xsl:with-param name="initHost" select="$initHost"/> <xsl:with-param name="initHost" select="$initHost"/>
<xsl:with-param name="currentHost" select="$currentHost"/> <xsl:with-param name="currentHost" select="$currentHost"/>
<xsl:with-param name="hostAddress" select="$hostAddress"/> <xsl:with-param name="hostAddress" select="$hostAddress"/>
<xsl:sort select="@portid" order="ascending"/> <xsl:sort select="number(@portid)" order="ascending"/>
</xsl:apply-templates> </xsl:apply-templates>
</td> </td>
<td> <td>

View File

@ -262,7 +262,7 @@ function hostScanning(link) {
<xsl:with-param name="initHost" select="$initHost"/> <xsl:with-param name="initHost" select="$initHost"/>
<xsl:with-param name="currentHost" select="$currentHost"/> <xsl:with-param name="currentHost" select="$currentHost"/>
<xsl:with-param name="hostAddress" select="$hostAddress"/> <xsl:with-param name="hostAddress" select="$hostAddress"/>
<xsl:sort select="@portid" order="ascending"/> <xsl:sort select="number(@portid)" order="ascending"/>
</xsl:apply-templates> </xsl:apply-templates>
</tbody> </tbody>
</table> </table>