script-args

This commit is contained in:
2025-02-04 13:35:46 +01:00
parent 13f42cad36
commit ad63f0691b
9 changed files with 467 additions and 165 deletions

View File

@ -11,15 +11,19 @@
<xsl:output indent="yes" />
<xsl:strip-space elements='*' />
<xsl:variable name="stylesheetURL" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href=&quot;'), '&quot;')" />
<xsl:variable name="stylesheetURL"
select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href=&quot;'), '&quot;')" />
<xsl:variable name="base" select="concat($stylesheetURL, '/../../')" />
<xsl:template match="nmaprun">
<xsl:variable name="targets" select="substring-after(@args, '.xsl ')" />
<xsl:variable name="current" select="." />
<xsl:variable name="init" select="document(concat($base, 'scans/', translate($targets,'/', '!'), '.xml'))/nmaprun" />
<xsl:variable
name="current" select="." />
<xsl:variable name="init"
select="document(concat($base, 'scans/', translate($targets,'/', '!'), '.xml'))/nmaprun" />
<html lang="fr">
<html
lang="fr">
<xsl:apply-templates select="." mode="head">
<xsl:with-param name="base" select="$base" />
<xsl:with-param name="targets" select="$targets" />
@ -30,7 +34,8 @@
</xsl:apply-templates>
<main class="ui main container inverted segment">
<xsl:apply-templates select="$current/host | $init/host[not(address/@addr=$current/host/address/@addr)][not(status/@state='down')]">
<xsl:apply-templates
select="$current/host | $init/host[not(address/@addr=$current/host/address/@addr)][not(status/@state='down')]">
<xsl:with-param name="init" select="$init" />
<xsl:with-param name="current" select="$current" />
</xsl:apply-templates>
@ -52,9 +57,12 @@ $('.ui.dropdown').dropdown()
<xsl:template match="host">
<xsl:param name="init" />
<xsl:param name="current" />
<xsl:variable name="addr" select="address/@addr" />
<xsl:variable name="initHost" select="$init/host[address/@addr=$addr]" />
<xsl:variable name="currentHost" select="$current/host[address/@addr=$addr]" />
<xsl:variable name="addr"
select="address/@addr" />
<xsl:variable name="initHost"
select="$init/host[address/@addr=$addr]" />
<xsl:variable name="currentHost"
select="$current/host[address/@addr=$addr]" />
<xsl:variable name="hostAddress">
<xsl:choose>
<xsl:when test="hostnames/hostname/@name">
@ -67,13 +75,13 @@ $('.ui.dropdown').dropdown()
</xsl:variable>
<h1>
<xsl:attribute name="class">
<xsl:text>ui inverted header </xsl:text>
<xsl:attribute name="class">
<xsl:text>ui inverted header </xsl:text>
<xsl:choose>
<xsl:when test="$currentHost/status/@state='up'">green</xsl:when>
<xsl:otherwise>red</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:when test="$currentHost/status/@state='up'">green</xsl:when>
<xsl:otherwise>red</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:choose>
<xsl:when test="hostnames/hostname/@name">
<xsl:value-of select="hostnames/hostname/@name" />
@ -84,7 +92,8 @@ $('.ui.dropdown').dropdown()
</xsl:choose>
</h1>
<table class="ui inverted table" style="width: max-content">
<table
class="ui inverted table" style="width: max-content">
<thead>
<tr>
<xsl:if test="address[@addrtype='ipv4']/@addr">
@ -144,20 +153,23 @@ $('.ui.dropdown').dropdown()
</tbody>
</table>
<div class="ui inverted tree accordion">
<div class="title">
<i class="dropdown icon"></i>
Informations supplémentaires
<xsl:if
test="hostscript/script">
<div class="ui inverted tree accordion">
<div class="title">
<i class="dropdown icon"></i> Informations supplémentaires </div>
<div class="content">
<xsl:apply-templates select="hostscript/script" />
</div>
</div>
<div class="content">
<xsl:apply-templates select="hostscript/script" />
</div>
</div>
</xsl:if>
<h2 class="ui header">Services</h2>
<h2
class="ui header">Services</h2>
<div class="ui cards">
<xsl:apply-templates select="$currentHost/ports/port | $initHost/ports/port[not(@portid=$currentHost/ports/port/@portid)][not(state/@state='closed')]">
<xsl:apply-templates
select="$currentHost/ports/port | $initHost/ports/port[not(@portid=$currentHost/ports/port/@portid)][not(state/@state='closed')]">
<xsl:with-param name="initHost" select="$initHost" />
<xsl:with-param name="currentHost" select="$currentHost" />
<xsl:with-param name="hostAddress" select="$hostAddress" />
@ -170,9 +182,12 @@ $('.ui.dropdown').dropdown()
<xsl:param name="hostAddress" />
<xsl:param name="initHost" />
<xsl:param name="currentHost" />
<xsl:variable name="portid" select="@portid" />
<xsl:variable name="initPort" select="$initHost/ports/port[@portid=$portid]" />
<xsl:variable name="currentPort" select="$currentHost/ports/port[@portid=$portid]" />
<xsl:variable
name="portid" select="@portid" />
<xsl:variable name="initPort"
select="$initHost/ports/port[@portid=$portid]" />
<xsl:variable name="currentPort"
select="$currentHost/ports/port[@portid=$portid]" />
<xsl:variable name="color">
<xsl:choose>
<xsl:when test="$currentPort/script[@id='http-info']/elem[@key='status']>=500">red</xsl:when>
@ -184,7 +199,8 @@ $('.ui.dropdown').dropdown()
</xsl:choose>
</xsl:variable>
<div class="ui inverted card {$color}">
<div
class="ui inverted card {$color}">
<div class="content">
<div class="header">
<div class="ui {$color} ribbon label" style="text-transform: uppercase">
@ -222,9 +238,7 @@ $('.ui.dropdown').dropdown()
<xsl:if test="script">
<div class="ui inverted tree accordion">
<div class="title">
<i class="dropdown icon"></i>
Détails
</div>
<i class="dropdown icon"></i> Détails </div>
<div class="content">
<xsl:apply-templates select="script" />
</div>
@ -233,7 +247,8 @@ $('.ui.dropdown').dropdown()
</div>
</div>
</div>
<xsl:if test="service/@name='ftp' or service/@name='ssh' or service/@name='http' or service/@name='https' or service/@name='ms-wbt-server'">
<xsl:if
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">
<xsl:attribute name="href" target="_blank">
<xsl:choose>
@ -241,7 +256,8 @@ $('.ui.dropdown').dropdown()
<xsl:text>rdp.php?v=</xsl:text>
<xsl:value-of select="$hostAddress" />
<xsl:text>&amp;p=</xsl:text>
<xsl:value-of select="@portid" />
<xsl:value-of
select="@portid" />
</xsl:when>
<xsl:otherwise>
<xsl:choose>
@ -253,15 +269,15 @@ $('.ui.dropdown').dropdown()
</xsl:otherwise>
</xsl:choose>
<xsl:text>://</xsl:text>
<xsl:value-of select="$hostAddress" />
<xsl:value-of
select="$hostAddress" />
<xsl:text>:</xsl:text>
<xsl:value-of select="@portid" />
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<i class="external alternate icon"></i>
Ouvrir
</a>
<i
class="external alternate icon"></i> Ouvrir </a>
</xsl:if>
</div>
@ -277,13 +293,14 @@ $('.ui.dropdown').dropdown()
<xsl:choose>
<xsl:when test="elem or table">
<xsl:if test="elem">
<table class="ui small inverted fixed definition table">
<table class="ui small compact inverted fixed definition table">
<tbody>
<xsl:apply-templates select="elem" />
</tbody>
</table>
</xsl:if>
<xsl:apply-templates select="table" />
<xsl:apply-templates
select="table" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@output" />
@ -303,7 +320,7 @@ $('.ui.dropdown').dropdown()
</div>
<div class="content">
<xsl:if test="elem">
<table class="ui small inverted fixed definition table">
<table class="ui small compact inverted fixed definition table">
<tbody>
<xsl:apply-templates select="elem" />
</tbody>
@ -314,7 +331,7 @@ $('.ui.dropdown').dropdown()
</div>
</xsl:when>
<xsl:when test="elem">
<table class="ui small inverted fixed definition table">
<table class="ui small compact inverted fixed definition table">
<tbody>
<xsl:apply-templates select="elem" />
</tbody>
@ -325,7 +342,7 @@ $('.ui.dropdown').dropdown()
<xsl:template match="elem">
<tr>
<td>
<td style="width: min-content">
<xsl:value-of select="@key" />
</td>
<td>

View File

@ -41,7 +41,7 @@
</h1>
<table id="scanResultsTable" style="width:100%" role="grid"
class="ui sortable small stuck striped table">
class="ui sortable small compact stuck striped table">
<thead>
<tr>
<th style="width: min-width">Etat</th>
@ -54,7 +54,7 @@
</thead>
<tbody>
<xsl:apply-templates
select="$current/host | $init/host[not(address/@addr=$current/host/address/@addr)][not(status/@state='down')]">
select="host | $init/host[not(address/@addr=$current/host/address/@addr)][not(status/@state='down')]">
<xsl:with-param name="init" select="$init" />
<xsl:with-param name="current" select="$current" />
</xsl:apply-templates>
@ -127,7 +127,7 @@ $('.ui.dropdown').dropdown()
<xsl:value-of select="$currentHost/status/@state" />
</div>
</xsl:when>
<xsl:otherwise><div class="ui red circular label">down</div></xsl:otherwise>
<xsl:otherwise><div class="ui mini circular label red">down</div></xsl:otherwise>
</xsl:choose>
</td>
<td>
@ -146,7 +146,7 @@ $('.ui.dropdown').dropdown()
</td>
<td>
<xsl:apply-templates
select="$initHost/ports/port[not(@portid=$currentHost/ports/port/@portid)][not(state/@state='closed')] | $currentHost/ports/port"
select="ports/port | $initHost/ports/port[not(state/@state='closed')][not(@portid=$currentHost/ports/port/@portid)]"
mode="service">
<xsl:with-param name="initHost" select="$initHost" />
<xsl:with-param name="currentHost" select="$currentHost" />
@ -156,7 +156,7 @@ $('.ui.dropdown').dropdown()
</xsl:apply-templates>
</td>
<td>
<a class="ui mini icon teal icon button" target="_blank">
<a class="ui mini icon teal icon button" target="_blank" title="Scan intensif">
<xsl:attribute name="href">scan.php?host=<xsl:value-of select="$hostAddress" /></xsl:attribute>
<i class="search plus icon"></i>
</a>

View File

@ -1,15 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.1">
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.1">
<xsl:template match="nmaprun" mode="nav">
<nav class="ui inverted secondary menu">
<h3>
<a href="." class="button item logo">lan<svg class="logo" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 24 24" xml:space="preserve" width="40" height="40"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<xsl:template match="nmaprun" mode="nav">
<nav class="ui inverted secondary menu">
<a href="." class="ui header button item logo">lan<svg class="logo" version="1.1" id="Layer_1"
x="0px"
y="0px" viewBox="0 0 24 24" xml:space="preserve" width="40" height="40"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs id="defs206"></defs>
<g id="g998" transform="matrix(0,0.04687491,-0.04687491,0,24,2.2682373e-5)">
<g id="g147">
@ -55,7 +56,38 @@
</g>
</svg>
can</a>
</h3>
</nav>
</xsl:template>
</xsl:stylesheet>
<div class="right menu">
<form class="ui right aligned category search item" id="scanForm" action="scan.php"
method="get">
<div class="ui inverted icon input" id="targetsInputDiv">
<input name="lan" class="prompt" type="text" placeholder="Scanner un réseau"
pattern="[a-zA-Z0-9._\/ \-]+"
title="Les cibles peuvent être spécifiées par des noms d'hôtes, des adresses IP, des adresses de réseaux, etc.
Exemples: 192.168.1.0/24 scanme.nmap.org 10.0-255.0-255.1-254" />
<i class="satellite dish icon"></i>
</div>
<a class="button item" href="options.php" title="Actualiser">
<i class="settings icon"></i>
</a>
</form>
</div>
</nav>
<script>
scanForm.onsubmit = function(event) {
if (scanForm.checkValidity()) {
targetsInputDiv.classList.add('loading')
$.toast({
title : 'Scan en cours...',
message : 'Merci de patienter',
class : 'info',
showIcon : 'satellite dish',
displayTime: 0,
closeIcon : true,
position : 'bottom right',
})
}
}
</script>
</xsl:template>
</xsl:stylesheet>