Skip to content

Commit 4de417c

Browse files
author
dreizehnutters
committed
added QoL features
1 parent ac13103 commit 4de417c

7 files changed

Lines changed: 979 additions & 166 deletions

File tree

xsl/helpers.xsl

Lines changed: 3 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -158,24 +158,6 @@
158158
</xsl:template>
159159

160160
<xsl:template name="resolve-inferred-hostname">
161-
<xsl:variable name="cert-san" select="ancestor-or-self::host[1]/ports/port[script[@id='ssl-cert']][1]/script/table[@key='extensions']/table[elem[@key='name']='X509v3 Subject Alternative Name'][1]/elem[@key='value']"/>
162-
<xsl:variable name="cert-san-output">
163-
<xsl:choose>
164-
<xsl:when test="string($cert-san) != ''">
165-
<xsl:value-of select="$cert-san"/>
166-
</xsl:when>
167-
<xsl:otherwise>
168-
<xsl:value-of select="substring-before(substring-after(ancestor-or-self::host[1]/ports/port[script[@id='ssl-cert']][1]/script[@id='ssl-cert']/@output, 'Subject Alternative Name:'), '&#xA;')"/>
169-
</xsl:otherwise>
170-
</xsl:choose>
171-
</xsl:variable>
172-
<xsl:variable name="cert-dns">
173-
<xsl:call-template name="extract-first-dns-name">
174-
<xsl:with-param name="text" select="$cert-san-output"/>
175-
</xsl:call-template>
176-
</xsl:variable>
177-
<xsl:variable name="cert-cn" select="normalize-space(ancestor-or-self::host[1]/ports/port[script[@id='ssl-cert']][1]/script/table[@key='subject']/elem[@key='commonName'])"/>
178-
<xsl:variable name="cert-cn-output" select="normalize-space(substring-before(substring-after(ancestor-or-self::host[1]/ports/port[script[@id='ssl-cert']][1]/script[@id='ssl-cert']/@output, 'Subject: commonName='), '/'))"/>
179161
<xsl:variable name="location-url">
180162
<xsl:choose>
181163
<xsl:when test="string(ancestor-or-self::host[1]/ports/port[script[@id='http-title']/elem[@key='redirect_url']][1]/script[@id='http-title']/elem[@key='redirect_url']) != ''">
@@ -213,41 +195,10 @@
213195
<xsl:with-param name="url" select="$location-url"/>
214196
</xsl:call-template>
215197
</xsl:variable>
216-
<xsl:choose>
217-
<xsl:when test="string($cert-dns) != ''">
218-
<xsl:value-of select="$cert-dns"/>
219-
</xsl:when>
220-
<xsl:when test="string($cert-cn) != '' and $cert-cn != 'localhost' and string(translate($cert-cn, '0123456789.:-[]', '')) != ''">
221-
<xsl:value-of select="$cert-cn"/>
222-
</xsl:when>
223-
<xsl:when test="string($cert-cn-output) != '' and $cert-cn-output != 'localhost' and string(translate($cert-cn-output, '0123456789.:-[]', '')) != ''">
224-
<xsl:value-of select="$cert-cn-output"/>
225-
</xsl:when>
226-
<xsl:otherwise>
227-
<xsl:value-of select="$location-host"/>
228-
</xsl:otherwise>
229-
</xsl:choose>
198+
<xsl:value-of select="$location-host"/>
230199
</xsl:template>
231200

232201
<xsl:template name="resolve-inferred-hostname-source">
233-
<xsl:variable name="cert-san" select="ancestor-or-self::host[1]/ports/port[script[@id='ssl-cert']][1]/script/table[@key='extensions']/table[elem[@key='name']='X509v3 Subject Alternative Name'][1]/elem[@key='value']"/>
234-
<xsl:variable name="cert-san-output">
235-
<xsl:choose>
236-
<xsl:when test="string($cert-san) != ''">
237-
<xsl:value-of select="$cert-san"/>
238-
</xsl:when>
239-
<xsl:otherwise>
240-
<xsl:value-of select="substring-before(substring-after(ancestor-or-self::host[1]/ports/port[script[@id='ssl-cert']][1]/script[@id='ssl-cert']/@output, 'Subject Alternative Name:'), '&#xA;')"/>
241-
</xsl:otherwise>
242-
</xsl:choose>
243-
</xsl:variable>
244-
<xsl:variable name="cert-dns">
245-
<xsl:call-template name="extract-first-dns-name">
246-
<xsl:with-param name="text" select="$cert-san-output"/>
247-
</xsl:call-template>
248-
</xsl:variable>
249-
<xsl:variable name="cert-cn" select="normalize-space(ancestor-or-self::host[1]/ports/port[script[@id='ssl-cert']][1]/script/table[@key='subject']/elem[@key='commonName'])"/>
250-
<xsl:variable name="cert-cn-output" select="normalize-space(substring-before(substring-after(ancestor-or-self::host[1]/ports/port[script[@id='ssl-cert']][1]/script[@id='ssl-cert']/@output, 'Subject: commonName='), '/'))"/>
251202
<xsl:variable name="location-url">
252203
<xsl:choose>
253204
<xsl:when test="string(ancestor-or-self::host[1]/ports/port[script[@id='http-title']/elem[@key='redirect_url']][1]/script[@id='http-title']/elem[@key='redirect_url']) != ''">
@@ -257,9 +208,6 @@
257208
</xsl:choose>
258209
</xsl:variable>
259210
<xsl:choose>
260-
<xsl:when test="string($cert-dns) != '' or (string($cert-cn) != '' and $cert-cn != 'localhost' and string(translate($cert-cn, '0123456789.:-[]', '')) != '') or (string($cert-cn-output) != '' and $cert-cn-output != 'localhost' and string(translate($cert-cn-output, '0123456789.:-[]', '')) != '')">
261-
<xsl:text>inferred-cert</xsl:text>
262-
</xsl:when>
263211
<xsl:when test="string($location-url) != ''">
264212
<xsl:text>inferred-location</xsl:text>
265213
</xsl:when>
@@ -268,26 +216,11 @@
268216
</xsl:template>
269217

270218
<xsl:template name="resolve-effective-hostname">
271-
<xsl:choose>
272-
<xsl:when test="string(normalize-space(ancestor-or-self::host[1]/hostnames/hostname[1]/@name)) != ''">
273-
<xsl:value-of select="normalize-space(ancestor-or-self::host[1]/hostnames/hostname[1]/@name)"/>
274-
</xsl:when>
275-
<xsl:otherwise>
276-
<xsl:call-template name="resolve-inferred-hostname"/>
277-
</xsl:otherwise>
278-
</xsl:choose>
219+
<xsl:value-of select="normalize-space(ancestor-or-self::host[1]/hostnames/hostname[1]/@name)"/>
279220
</xsl:template>
280221

281222
<xsl:template name="resolve-effective-hostname-source">
282-
<xsl:choose>
283-
<xsl:when test="string(normalize-space(ancestor-or-self::host[1]/hostnames/hostname[1]/@name)) != ''">
284-
<xsl:value-of select="normalize-space(ancestor-or-self::host[1]/hostnames/hostname[1]/@type)"/>
285-
</xsl:when>
286-
<xsl:when test="string(normalize-space(ancestor-or-self::host[1]/hostnames/hostname[1]/@name)) = '' and string(normalize-space(ancestor-or-self::host[1])) != ''">
287-
<xsl:call-template name="resolve-inferred-hostname-source"/>
288-
</xsl:when>
289-
<xsl:otherwise/>
290-
</xsl:choose>
223+
<xsl:value-of select="normalize-space(ancestor-or-self::host[1]/hostnames/hostname[1]/@type)"/>
291224
</xsl:template>
292225

293226
<xsl:template name="extract-last-token">

xsl/hosts.xsl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<th scope="col">State</th>
1414
<th scope="col">Mac</th>
1515
<th scope="col">Vendor</th>
16-
<th scope="col">OS</th>
16+
<th scope="col">OS (est.)</th>
1717
<th scope="col">Address</th>
1818
<th scope="col">Hostname</th>
1919
<th scope="col">Open TCP Ports</th>
@@ -25,10 +25,10 @@
2525
<span title="Approximate hop distance from the scanner, as reported by Nmap.">Hops</span>
2626
</th>
2727
<th scope="col">
28-
<span title="Aggregate count of Vulners matches across this host's open services. Treat as a rough indicator only; it can include false positives.">Pot. Issues</span>
28+
<span title="Aggregate count of Vulners matches across this host's open services. Treat as a rough indicator only; it can include false positives.">Issues (est.)</span>
2929
</th>
3030
<th scope="col">
31-
<span title="Relative rarity of this host's open services within this scan. Higher scores indicate hosts with less common service combinations.">Uniqueness</span>
31+
<span title="Relative rarity of this host's open services within this scan. Higher scores indicate hosts with less common service combinations.">Rarity</span>
3232
</th>
3333
</tr>
3434
</thead>
@@ -296,7 +296,7 @@
296296
<th scope="col">State</th>
297297
<th scope="col">Mac</th>
298298
<th scope="col">Vendor</th>
299-
<th scope="col">OS</th>
299+
<th scope="col">OS (est.)</th>
300300
<th scope="col">Address</th>
301301
<th scope="col">Hostname</th>
302302
<th scope="col">Open TCP Ports</th>
@@ -308,10 +308,10 @@
308308
<span title="Approximate hop distance from the scanner, as reported by Nmap.">Hops</span>
309309
</th>
310310
<th scope="col">
311-
<span title="Aggregate count of Vulners matches across this host's open services. Treat as a rough indicator only; it can include false positives.">Pot. Issues</span>
311+
<span title="Aggregate count of Vulners matches across this host's open services. Treat as a rough indicator only; it can include false positives.">Issues (est.)</span>
312312
</th>
313313
<th scope="col">
314-
<span title="Relative rarity of this host's open services within this scan. Higher scores indicate hosts with less common service combinations.">Uniqueness</span>
314+
<span title="Relative rarity of this host's open services within this scan. Higher scores indicate hosts with less common service combinations.">Rarity</span>
315315
</th>
316316
</tr>
317317
</thead>

xsl/inventory.xsl

Lines changed: 36 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2,74 +2,51 @@
22
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
33
<xsl:template name="render-service-inventory">
44
<hr class="my-4"/>
5-
<h2 id="serviceinventory" class="fs-4 mt-5 mb-3 bg-light p-3 rounded"><span class="section-heading-title">Service Summary</span><small class="section-heading-subtitle">See which services are most common, where they appear, and how broadly they are distributed across hosts.</small></h2>
5+
<h2 id="serviceinventory" class="fs-4 mt-5 mb-3 bg-light p-3 rounded"><span class="section-heading-title">Service Summary</span><small class="section-heading-subtitle">Compare service variants by exact detected product and version while preserving host coverage and exposed ports.</small></h2>
66
<xsl:choose>
77
<xsl:when test="count(//host/ports/port[state/@state='open' and service/@name]) &gt; 0">
88
<div class="table-responsive">
9-
<table id="service-inventory" class="table table-striped table-hover table-bordered dataTable align-middle" role="grid">
9+
<table id="service-inventory" class="table table-striped table-hover table-bordered align-middle dataTable" role="grid">
1010
<thead class="table-light">
1111
<tr>
12-
<th scope="col">Service Name</th>
13-
<th scope="col">Ports</th>
14-
<th scope="col">Count</th>
15-
<th scope="col">Hosts</th>
12+
<th scope="col" class="service-inventory-name-column">Service Name</th>
13+
<th scope="col" class="service-inventory-count-column">Host Count</th>
14+
<th scope="col">Host Details</th>
1615
</tr>
1716
</thead>
18-
<tbody>
19-
<xsl:for-each select="//host/ports/port[state/@state='open' and service/@name]
20-
[generate-id() = generate-id(
21-
key('serviceGroup',
22-
concat(
23-
substring('ssl/', 1, (service/@tunnel = 'ssl') * string-length('ssl/')),
24-
service/@name,
25-
'-',
26-
@protocol
27-
)
28-
)[1]
29-
)]">
30-
<xsl:variable name="key" select="concat(
31-
substring('ssl/', 1, (service/@tunnel = 'ssl') * string-length('ssl/')),
32-
service/@name,
33-
'-',
34-
@protocol
35-
)" />
36-
<tr>
37-
<td>
38-
<xsl:value-of select="concat(
39-
substring('ssl/', 1, (service/@tunnel = 'ssl') * string-length('ssl/')),
40-
service/@name
41-
)"/>
42-
</td>
43-
<td class="port-list">
44-
<xsl:attribute name="data-ports">
45-
<xsl:for-each select="key('serviceGroup', $key)">
46-
<xsl:sort select="@portid" data-type="number"/>
47-
<xsl:value-of select="@portid"/>
48-
<xsl:if test="position() != last()">,</xsl:if>
49-
</xsl:for-each>
50-
</xsl:attribute>
51-
<span class="display-ports">Loading...</span>
52-
</td>
53-
<td>
54-
<xsl:value-of select="count(key('serviceGroup', $key))"/>
55-
</td>
56-
<td class="host-list">
57-
<xsl:attribute name="data-hosts">
58-
<xsl:for-each select="key('serviceGroup', $key)">
59-
<xsl:variable name="ip" select="ancestor::host/address[not(@addrtype='mac')]/@addr"/>
60-
<xsl:if test="not(preceding::host/address[not(@addrtype='mac')]/@addr = $ip)">
61-
<xsl:if test="position() != 1">,</xsl:if>
62-
<xsl:value-of select="$ip"/>
63-
</xsl:if>
64-
</xsl:for-each>
65-
</xsl:attribute>
66-
<span class="display-hosts">Loading...</span>
67-
</td>
68-
</tr>
69-
</xsl:for-each>
70-
</tbody>
17+
<tbody id="serviceInventoryTableBody"/>
7118
</table>
7219
</div>
20+
<div id="serviceInventoryData" class="d-none">
21+
<xsl:for-each select="//host/ports/port[state/@state='open' and service/@name]">
22+
<xsl:variable name="effective-hostname">
23+
<xsl:call-template name="resolve-effective-hostname"/>
24+
</xsl:variable>
25+
<span class="service-inventory-entry">
26+
<xsl:attribute name="data-service">
27+
<xsl:call-template name="render-service-name"/>
28+
</xsl:attribute>
29+
<xsl:attribute name="data-product">
30+
<xsl:value-of select="service/@product"/>
31+
</xsl:attribute>
32+
<xsl:attribute name="data-version">
33+
<xsl:value-of select="service/@version"/>
34+
</xsl:attribute>
35+
<xsl:attribute name="data-address">
36+
<xsl:value-of select="ancestor::host[1]/address[not(@addrtype='mac')][1]/@addr"/>
37+
</xsl:attribute>
38+
<xsl:attribute name="data-hostname">
39+
<xsl:value-of select="$effective-hostname"/>
40+
</xsl:attribute>
41+
<xsl:attribute name="data-port">
42+
<xsl:value-of select="@portid"/>
43+
</xsl:attribute>
44+
<xsl:attribute name="data-protocol">
45+
<xsl:value-of select="@protocol"/>
46+
</xsl:attribute>
47+
</span>
48+
</xsl:for-each>
49+
</div>
7350
<xsl:call-template name="render-service-matrix-data"/>
7451
<xsl:call-template name="render-host-port-matrix-card"/>
7552
<xsl:call-template name="render-service-port-heatmap-card"/>

0 commit comments

Comments
 (0)