share size script

This commit is contained in:
Adrien MALINGREY 2025-02-04 16:44:57 +01:00
parent 6d4c579198
commit d0de27c4a2
6 changed files with 102 additions and 45 deletions

BIN
bg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 KiB

View File

@ -4,5 +4,5 @@ $BASEDIR = "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}$port
$SCANSDIR = "scans"; $SCANSDIR = "scans";
$STYLESHEETSDIR = "stylesheets"; $STYLESHEETSDIR = "stylesheets";
$lanScanCmd = "sudo nmap -PSmicrosoft-ds -F -T5 -oX - --stylesheet $BASEDIR/$STYLESHEETSDIR/lanScan.xsl"; $lanScanCmd = "sudo nmap -PSmicrosoft-ds -F -T5 --datadir . --script http-info,smb-shares-size --script-args-file script-args.ini -oX - --stylesheet $BASEDIR/$STYLESHEETSDIR/lanScan.xsl";
$hostScanCmd = "sudo nmap -A -T5 -oX - --stylesheet $BASEDIR/$STYLESHEETSDIR/hostScan.xsl"; $hostScanCmd = "sudo nmap -A -T5 --datadir . --script http-info,smb-shares-size --script-args-file script-args.ini -oX - --stylesheet $BASEDIR/$STYLESHEETSDIR/hostScan.xsl";

View File

@ -1,3 +1,3 @@
smbdomain = WORKGROUP smbdomain = AUTH
smbuser = smbuser = application.drieat
smbpassword = smbpassword = d+iFiWn4!cAzdr3KopiM>EA

View File

@ -68,7 +68,10 @@ body {
transparent transparent
) !important; ) !important;
text-align: center !important; text-align: center !important;
font-size: .64285714rem !important; }
.mini.share-size {
font-size: 0.64285714rem !important;
} }
.ui.card .table { .ui.card .table {

View File

@ -141,7 +141,7 @@ $('.ui.dropdown').dropdown()
<xsl:if test="distance/@value"> <xsl:if test="distance/@value">
<td> <td>
<xsl:value-of select="distance/@value" /> <xsl:value-of select="distance/@value" />
<xsl:text> rebonds</xsl:text> <xsl:text> rebond(s)</xsl:text>
</td> </td>
</xsl:if> </xsl:if>
<xsl:if test="uptime/@lastboot"> <xsl:if test="uptime/@lastboot">
@ -203,9 +203,11 @@ $('.ui.dropdown').dropdown()
class="ui inverted card {$color}"> class="ui inverted card {$color}">
<div class="content"> <div class="content">
<div class="header"> <div class="header">
<div class="ui {$color} ribbon label" style="text-transform: uppercase"> <div class="ui {$color} ribbon label">
<xsl:value-of select="@protocol" /> <div class="detail" style="text-transform: uppercase">
<xsl:text>:</xsl:text> <xsl:value-of select="@protocol" />
<xsl:text>:</xsl:text>
</div>
<xsl:value-of select="@portid" /> <xsl:value-of select="@portid" />
</div> </div>
@ -249,8 +251,8 @@ $('.ui.dropdown').dropdown()
</div> </div>
<xsl:if <xsl:if
test="service/@name='ftp' or service/@name='ssh' or service/@name='http' or service/@name='https' or service/@name='ms-wbt-server'"> test="service/@name='ftp' or service/@name='ssh' or service/@name='http' or service/@name='https' or service/@name='ms-wbt-server'">
<a class="ui {$color} button"> <a class="ui {$color} button" target="_blank">
<xsl:attribute name="href" target="_blank"> <xsl:attribute name="href">
<xsl:choose> <xsl:choose>
<xsl:when test="service/@name='ms-wbt-server'"> <xsl:when test="service/@name='ms-wbt-server'">
<xsl:text>rdp.php?v=</xsl:text> <xsl:text>rdp.php?v=</xsl:text>
@ -276,8 +278,34 @@ $('.ui.dropdown').dropdown()
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:attribute> </xsl:attribute>
<i <i class="external alternate icon"></i>
class="external alternate icon"></i> Ouvrir </a> <xsl:text>Ouvrir</xsl:text>
</a>
</xsl:if>
<xsl:if test="$currentPort/script[@id='smb-shares-size']/table">
<div class="ui {$color} center aligned dropdown share-size button">
<xsl:attribute name="style">
<xsl:for-each select="$currentPort/script[@id='smb-shares-size']/table">
<xsl:sort select="elem[@key='FreeSize'] div elem[@key='TotalSize']"
order="ascending" />
<xsl:if test="position()=1">
<xsl:text>--free: </xsl:text>
<xsl:value-of select="elem[@key='FreeSize']" />
<xsl:text>; --total: </xsl:text>
<xsl:value-of
select="elem[@key='TotalSize']" />
</xsl:if>
</xsl:for-each>
</xsl:attribute>
<i class="external alternate icon"></i>
<xsl:text>Ouvrir</xsl:text>
<i class="dropdown icon"></i>
<div class="menu">
<xsl:apply-templates select="$currentPort/script[@id='smb-shares-size']/table">
<xsl:with-param name="hostAddress" select="$hostAddress" />
</xsl:apply-templates>
</div>
</div>
</xsl:if> </xsl:if>
</div> </div>
@ -351,4 +379,13 @@ $('.ui.dropdown').dropdown()
</tr> </tr>
</xsl:template> </xsl:template>
<xsl:template match="table">
<xsl:param name="hostAddress" />
<a class="item share-size"
href="file://///{$hostAddress}/{@key}" target="_blank" rel="noopener noreferrer"
style="--free: {elem[@key='FreeSize']}; --total: {elem[@key='TotalSize']}">
<xsl:value-of select="@key" />
</a>
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

View File

@ -5,23 +5,32 @@
version="1.1"> version="1.1">
<xsl:template match="port" mode="service"> <xsl:template match="port" mode="service">
<xsl:param name="hostAddress"/> <xsl:param name="hostAddress" />
<xsl:param name="initHost"/> <xsl:param name="initHost" />
<xsl:param name="currentHost"/> <xsl:param name="currentHost" />
<xsl:param name="class"/> <xsl:param
<xsl:variable name="portid" select="@portid"/> name="class" />
<xsl:variable name="initPort" select="$initHost/ports/port[@portid=$portid]"/> <xsl:variable name="portid" select="@portid" />
<xsl:variable name="currentPort" select="$currentHost/ports/port[@portid=$portid]"/> <xsl:variable
name="initPort" select="$initHost/ports/port[@portid=$portid]" />
<xsl:variable
name="currentPort" select="$currentHost/ports/port[@portid=$portid]" />
<a target="_blank"> <a
target="_blank">
<xsl:attribute name="class"> <xsl:attribute name="class">
<xsl:value-of select="$class"/> <xsl:value-of select="$class" />
<xsl:text> </xsl:text> <xsl:text> </xsl:text>
<xsl:if test="$currentPort/script[@id='smb-shares-size']/table">dropdown button share-size</xsl:if> <xsl:if
test="$currentPort/script[@id='smb-shares-size']/table">dropdown button
share-size </xsl:if>
<xsl:choose> <xsl:choose>
<xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=500">red</xsl:when> <xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=500">
<xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=400">orange</xsl:when> red</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']>=400">
orange</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</xsl:when> <xsl:when test="$currentPort/state/@state='filtered'">orange</xsl:when>
<xsl:otherwise>red</xsl:otherwise> <xsl:otherwise>red</xsl:otherwise>
@ -30,60 +39,66 @@
<xsl:if test="$currentPort/script[@id='smb-shares-size']/table"> <xsl:if test="$currentPort/script[@id='smb-shares-size']/table">
<xsl:attribute name="style"> <xsl:attribute name="style">
<xsl:for-each select="$currentPort/script[@id='smb-shares-size']/table"> <xsl:for-each select="$currentPort/script[@id='smb-shares-size']/table">
<xsl:sort select="elem[@key='FreeSize'] div elem[@key='TotalSize']" order="ascending"/> <xsl:sort select="elem[@key='FreeSize'] div elem[@key='TotalSize']"
order="ascending" />
<xsl:if test="position()=1"> <xsl:if test="position()=1">
<xsl:text>--free: </xsl:text> <xsl:text>--free: </xsl:text>
<xsl:value-of select="elem[@key='FreeSize']"/> <xsl:value-of select="elem[@key='FreeSize']" />
<xsl:text>; --total: </xsl:text> <xsl:text>; --total: </xsl:text>
<xsl:value-of select="elem[@key='TotalSize']"/> <xsl:value-of
select="elem[@key='TotalSize']" />
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
</xsl:attribute> </xsl:attribute>
</xsl:if> </xsl:if>
<xsl:if test="service/@name='ftp' or service/@name='ssh' or service/@name='http' or service/@name='https'"> <xsl:if
test="service/@name='ftp' or service/@name='ssh' or service/@name='http' or service/@name='https'">
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:choose> <xsl:choose>
<xsl:when test="service/@name='http' and service/@tunnel='ssl'"> <xsl:when test="service/@name='http' and service/@tunnel='ssl'">
<xsl:text>https</xsl:text> <xsl:text>https</xsl:text>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="service/@name"/> <xsl:value-of select="service/@name" />
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:text>://</xsl:text> <xsl:text>://</xsl:text>
<xsl:value-of select="$hostAddress"/> <xsl:value-of
select="$hostAddress" />
<xsl:text>:</xsl:text> <xsl:text>:</xsl:text>
<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: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>
<xsl:value-of select="$hostAddress"/> <xsl:value-of select="$hostAddress" />
<xsl:text>&amp;p=</xsl:text> <xsl:text>&amp;p=</xsl:text>
<xsl:value-of select="@portid"/> <xsl:value-of
select="@portid" />
</xsl:attribute> </xsl:attribute>
</xsl:if> </xsl:if>
<xsl:attribute name="title"> <xsl:attribute name="title">
<xsl:value-of select="@protocol" />:<xsl:value-of select="@portid"/> <xsl:value-of select="@protocol" />:<xsl:value-of select="@portid" />
</xsl:attribute> </xsl:attribute>
<xsl:choose> <xsl:choose>
<xsl:when test="service/@name='unknown'"> <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" />
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="service/@name"/> <xsl:value-of select="service/@name" />
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:if test="$currentPort/script[@id='smb-shares-size']/table"> <xsl:if test="$currentPort/script[@id='smb-shares-size']/table">
<i class="dropdown icon"></i> <i class="dropdown icon"></i>
<div class="menu"> <div class="menu">
<xsl:apply-templates select="$currentPort/script[@id='smb-shares-size']/table"> <xsl:apply-templates select="$currentPort/script[@id='smb-shares-size']/table">
<xsl:with-param name="hostAddress" select="$hostAddress"/> <xsl:with-param name="hostAddress" select="$hostAddress" />
</xsl:apply-templates> </xsl:apply-templates>
</div> </div>
</xsl:if> </xsl:if>
@ -91,9 +106,11 @@
</xsl:template> </xsl:template>
<xsl:template match="table"> <xsl:template match="table">
<xsl:param name="hostAddress"/> <xsl:param name="hostAddress" />
<a class="item share-size" href="file://///{$hostAddress}/{@key}" target="_blank" rel="noopener noreferrer" style="--free: {elem[@key='FreeSize']}; --total: {elem[@key='TotalSize']}"> <a class="item share-size"
<xsl:value-of select="@key"/> href="file://///{$hostAddress}/{@key}" target="_blank" rel="noopener noreferrer"
style="--free: {elem[@key='FreeSize']}; --total: {elem[@key='TotalSize']}">
<xsl:value-of select="@key" />
</a> </a>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>