Compare commits

...

2 Commits

Author SHA1 Message Date
b6900bc76a templates 2024-10-18 15:08:49 +02:00
c3ed9f9fc2 reorg 2024-10-18 14:47:02 +02:00
12 changed files with 82 additions and 71 deletions

View File

@ -3,14 +3,14 @@
$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

@ -397,10 +397,10 @@ Exemples: <?= $_SERVER['REMOTE_ADDR']; ?>/24 <?= $_SERVER['SERVER_NAME']; ?> 10.
<label for="stylesheetSelect" title="--stylesheet">Feuille de style</label> <label for="stylesheetSelect" title="--stylesheet">Feuille de style</label>
<select class="ui dropdown" id="stylesheetSelect" name="--stylesheet" value="<?= $options["--stylesheet"] ?? ""?>"> <select class="ui dropdown" id="stylesheetSelect" name="--stylesheet" value="<?= $options["--stylesheet"] ?? ""?>">
<?php <?php
foreach (scandir('xslt') as $filename) { foreach (scandir('templates') as $filename) {
if (substr($filename, -4) === '.xsl') { if (substr($filename, -4) === '.xsl') {
$name = substr($filename, 0, -4); $name = substr($filename, 0, -4);
$URL = htmlentities("$BASEDIR/xslt/$filename", ENT_QUOTES); $URL = htmlentities("$BASEDIR/templates/$filename", ENT_QUOTES);
if (isset($options["--stylesheet"]) && $URL == $options["--stylesheet"]) { if (isset($options["--stylesheet"]) && $URL == $options["--stylesheet"]) {
echo " <option value='$URL' selected>$name</option>\n"; echo " <option value='$URL' selected>$name</option>\n";
} else { } else {
@ -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 ([$DATADIR, $NMAPDIR] as $dir) {
echo "<!-- $nmap_services -->\n";
if (file_exists("$dir/nmap-services")) {
$nmap_services = file("$dir/nmap-services");
foreach ($nmap_services as $service) { foreach ($nmap_services as $service) {
if (0 !== strpos($service, '#')) { if (0 !== strpos($service, '#')) {
[$name, $port] = explode("\t", $service); [$name, $port] = explode("\t", $service);
$services[$name] = explode("/", $port); $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>
@ -310,8 +310,8 @@ function hostScanning(link) {
<xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=400">orange</xsl:when> <xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=400">orange</xsl:when>
<xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=200">green</xsl:when> <xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=200">green</xsl:when>
<xsl:when test="$currentPort/state/@state='open'">green</xsl:when> <xsl:when test="$currentPort/state/@state='open'">green</xsl:when>
<xsl:when test="$currentPort/state/@state='filtered'">orange disabled</xsl:when> <xsl:when test="$currentPort/state/@state='filtered'">orange</xsl:when>
<xsl:otherwise>red disabled</xsl:otherwise> <xsl:otherwise>red</xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:choose> <xsl:choose>
<xsl:when test="(service/@name='microsoft-ds' or service/@name='netbios-ssn') and ../../hostscript/script[@id='smb-shares-size']/table"> mini dropdown button share-size</xsl:when> <xsl:when test="(service/@name='microsoft-ds' or service/@name='netbios-ssn') and ../../hostscript/script[@id='smb-shares-size']/table"> mini dropdown button share-size</xsl:when>
@ -327,22 +327,21 @@ function hostScanning(link) {
<xsl:value-of select="@portid"/> <xsl:value-of select="@portid"/>
</xsl:attribute> </xsl:attribute>
</xsl:if> </xsl:if>
<xsl:if test="service/@name='ms-wbt-server'"> <xsl:attribute name="title">
<xsl:attribute name="href"> <xsl:value-of select="@portid"/>/<xsl:value-of select="@protocol"/>
<xsl:text>rdp.php?v=</xsl:text>
<xsl:value-of select="$hostAddress"/>
<xsl:text>&amp;p=</xsl:text>
<xsl:value-of select="@portid"/>
</xsl:attribute> </xsl:attribute>
</xsl:if> <xsl:choose>
<xsl:value-of select="service/@name"/> <xsl:when test="service/@name='unknown'">
<div class="detail">
<xsl:choose> <xsl:choose>
<xsl:when test="@protocol='tcp'">:</xsl:when> <xsl:when test="@protocol='tcp'">:</xsl:when>
<xsl:otherwise><xsl:value-of select="substring(@protocol, 1, 1)"/>:</xsl:otherwise> <xsl:otherwise><xsl:value-of select="substring(@protocol, 1, 1)"/>:</xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:value-of select="@portid"/> <xsl:value-of select="@portid"/>
</div> </xsl:when>
<xsl:otherwise>
<xsl:value-of select="service/@name"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="(service/@name='microsoft-ds' or service/@name='netbios-ssn') and ../../hostscript/script[@id='smb-shares-size']/table"> <xsl:if test="(service/@name='microsoft-ds' or service/@name='netbios-ssn') and ../../hostscript/script[@id='smb-shares-size']/table">
<xsl:attribute name="style"> <xsl:attribute name="style">
<xsl:for-each select="$currentHost/hostscript/script[@id='smb-shares-size']/table"> <xsl:for-each select="$currentHost/hostscript/script[@id='smb-shares-size']/table">

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>
@ -301,27 +301,11 @@ function hostScanning(link) {
<xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=400">orange</xsl:when> <xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=400">orange</xsl:when>
<xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=200">green</xsl:when> <xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=200">green</xsl:when>
<xsl:when test="$currentPort/state/@state='open'">green</xsl:when> <xsl:when test="$currentPort/state/@state='open'">green</xsl:when>
<xsl:when test="$currentPort/state/@state='filtered'">orange disabled</xsl:when> <xsl:when test="$currentPort/state/@state='filtered'">orange</xsl:when>
<xsl:otherwise>red disabled</xsl:otherwise> <xsl:otherwise>red</xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:if test="(service/@name='microsoft-ds' or service/@name='netbios-ssn') and ../../hostscript/script[@id='smb-shares-size']/table"> dropdown share-size</xsl:if> <xsl:if test="(service/@name='microsoft-ds' or service/@name='netbios-ssn') and ../../hostscript/script[@id='smb-shares-size']/table"> dropdown share-size</xsl:if>
</xsl:attribute> </xsl:attribute>
<xsl:attribute name="title">
<xsl:choose>
<xsl:when test="@protocol='tcp'">:</xsl:when>
<xsl:otherwise><xsl:value-of select="substring(@protocol, 1, 1)"/>:</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="@portid"/>
</xsl:attribute>
<xsl:if test="service/@name='ftp' or service/@name='ssh' or service/@name='http' or service/@name='https'">
<xsl:attribute name="href">
<xsl:value-of select="service/@name"/>
<xsl:text>://</xsl:text>
<xsl:value-of select="$hostAddress"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="@portid"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="service/@name='ms-wbt-server'"> <xsl:if test="service/@name='ms-wbt-server'">
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:text>rdp.php?v=</xsl:text> <xsl:text>rdp.php?v=</xsl:text>
@ -330,7 +314,21 @@ function hostScanning(link) {
<xsl:value-of select="@portid"/> <xsl:value-of select="@portid"/>
</xsl:attribute> </xsl:attribute>
</xsl:if> </xsl:if>
<xsl:attribute name="title">
<xsl:value-of select="@portid"/>/<xsl:value-of select="@protocol"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="service/@name='unknown'">
<xsl:choose>
<xsl:when test="@protocol='tcp'">:</xsl:when>
<xsl:otherwise><xsl:value-of select="substring(@protocol, 1, 1)"/>:</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="@portid"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="service/@name"/> <xsl:value-of select="service/@name"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="(service/@name='microsoft-ds' or service/@name='netbios-ssn') and ../../hostscript/script[@id='smb-shares-size']/table"> <xsl:if test="(service/@name='microsoft-ds' or service/@name='netbios-ssn') and ../../hostscript/script[@id='smb-shares-size']/table">
<xsl:attribute name="style"> <xsl:attribute name="style">
<xsl:for-each select="$currentHost/hostscript/script[@id='smb-shares-size']/table"> <xsl:for-each select="$currentHost/hostscript/script[@id='smb-shares-size']/table">

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>
@ -330,8 +330,8 @@ function hostScanning(link) {
<xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=400">orange</xsl:when> <xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=400">orange</xsl:when>
<xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=200">green</xsl:when> <xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=200">green</xsl:when>
<xsl:when test="$currentPort/state/@state='open'">green</xsl:when> <xsl:when test="$currentPort/state/@state='open'">green</xsl:when>
<xsl:when test="$currentPort/state/@state='filtered'">orange disabled</xsl:when> <xsl:when test="$currentPort/state/@state='filtered'">orange</xsl:when>
<xsl:otherwise>red disabled</xsl:otherwise> <xsl:otherwise>red</xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:choose> <xsl:choose>
<xsl:when test="(service/@name='microsoft-ds' or service/@name='netbios-ssn') and ../../hostscript/script[@id='smb-shares-size']/table"> mini dropdown button share-size</xsl:when> <xsl:when test="(service/@name='microsoft-ds' or service/@name='netbios-ssn') and ../../hostscript/script[@id='smb-shares-size']/table"> mini dropdown button share-size</xsl:when>
@ -355,14 +355,21 @@ function hostScanning(link) {
<xsl:value-of select="@portid"/> <xsl:value-of select="@portid"/>
</xsl:attribute> </xsl:attribute>
</xsl:if> </xsl:if>
<xsl:value-of select="service/@name"/> <xsl:attribute name="title">
<div class="detail" style=""> <xsl:value-of select="@portid"/>/<xsl:value-of select="@protocol"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="service/@name='unknown'">
<xsl:choose> <xsl:choose>
<xsl:when test="@protocol='tcp'">:</xsl:when> <xsl:when test="@protocol='tcp'">:</xsl:when>
<xsl:otherwise><xsl:value-of select="substring(@protocol, 1, 1)"/>:</xsl:otherwise> <xsl:otherwise><xsl:value-of select="substring(@protocol, 1, 1)"/>:</xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:value-of select="@portid"/> <xsl:value-of select="@portid"/>
</div> </xsl:when>
<xsl:otherwise>
<xsl:value-of select="service/@name"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="(service/@name='microsoft-ds' or service/@name='netbios-ssn') and ../../hostscript/script[@id='smb-shares-size']/table"> <xsl:if test="(service/@name='microsoft-ds' or service/@name='netbios-ssn') and ../../hostscript/script[@id='smb-shares-size']/table">
<xsl:attribute name="style"> <xsl:attribute name="style">
<xsl:for-each select="$currentHost/hostscript/script[@id='smb-shares-size']/table"> <xsl:for-each select="$currentHost/hostscript/script[@id='smb-shares-size']/table">

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>