Skip to content

Commit 3095c3c

Browse files
authored
Create nmap-bootstrap.xsl
1 parent 10e1052 commit 3095c3c

File tree

1 file changed

+259
-0
lines changed

1 file changed

+259
-0
lines changed

nmap-bootstrap.xsl

Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Nmap Bootstrap XSL
4+
Creative Commons BY-SA
5+
Andreas Hontzia (@honze_net)
6+
-->
7+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
8+
<xsl:output method="html" encoding="utf-8" indent="yes" doctype-system="about:legacy-compat"/>
9+
<xsl:template match="/">
10+
<html lang="en">
11+
<head>
12+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"/>
13+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"/>
14+
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap.min.css"/>
15+
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
16+
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
17+
<script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap.min.js"></script>
18+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
19+
<style>
20+
.target:before {
21+
content: "";
22+
display: block;
23+
height: 50px;
24+
margin: -20px 0 0;
25+
}
26+
@media only screen and (min-width:1900px) {
27+
.container {
28+
width: 1800px;
29+
}
30+
}
31+
.footer {
32+
margin-top:60px;
33+
padding-top:60px;
34+
width: 100%;
35+
height: 180px;
36+
background-color: #f5f5f5;
37+
}
38+
</style>
39+
<title>Scan Report Nmap <xsl:value-of select="/nmaprun/@version"/></title>
40+
</head>
41+
<body>
42+
<nav class="navbar navbar-default navbar-fixed-top">
43+
<div class="container-fluid">
44+
<div class="navbar-header">
45+
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
46+
<span class="sr-only">Toggle navigation</span>
47+
<span class="icon-bar"></span>
48+
<span class="icon-bar"></span>
49+
<span class="icon-bar"></span>
50+
</button>
51+
<a class="navbar-brand" href="#"><span class="glyphicon glyphicon-home"></span></a>
52+
</div>
53+
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
54+
<ul class="nav navbar-nav">
55+
<li><a href="#scannedhosts">Scanned Hosts</a></li>
56+
<li><a href="#onlinehosts">Online Hosts</a></li>
57+
<li><a href="#openservices">Open Services</a></li>
58+
</ul>
59+
</div>
60+
</div>
61+
</nav>
62+
<div class="container">
63+
<div class="jumbotron">
64+
<h1>Scan Report<br/><small>Nmap <xsl:value-of select="/nmaprun/@version"/></small></h1>
65+
<pre style="white-space:pre-wrap; word-wrap:break-word;"><xsl:value-of select="/nmaprun/@args"/></pre>
66+
<p class="lead">
67+
<xsl:value-of select="/nmaprun/@startstr"/> – <xsl:value-of select="/nmaprun/runstats/finished/@timestr"/><br/>
68+
<xsl:value-of select="/nmaprun/runstats/hosts/@total"/> hosts scanned.
69+
<xsl:value-of select="/nmaprun/runstats/hosts/@up"/> hosts up.
70+
<xsl:value-of select="/nmaprun/runstats/hosts/@down"/> hosts down.
71+
</p>
72+
<div class="progress">
73+
<div class="progress-bar progress-bar-success" style="width: 0%">
74+
<xsl:attribute name="style">width:<xsl:value-of select="/nmaprun/runstats/hosts/@up div /nmaprun/runstats/hosts/@total * 100"/>%;</xsl:attribute>
75+
<xsl:value-of select="/nmaprun/runstats/hosts/@up"/>
76+
<span class="sr-only"></span>
77+
</div>
78+
<div class="progress-bar progress-bar-danger" style="width: 0%">
79+
<xsl:attribute name="style">width:<xsl:value-of select="/nmaprun/runstats/hosts/@down div /nmaprun/runstats/hosts/@total * 100"/>%;</xsl:attribute>
80+
<xsl:value-of select="/nmaprun/runstats/hosts/@down"/>
81+
<span class="sr-only"></span>
82+
</div>
83+
</div>
84+
</div>
85+
<h2 id="scannedhosts" class="target">Scanned Hosts</h2>
86+
<div class="table-responsive">
87+
<table id="table-overview" class="table table-striped dataTable" role="grid">
88+
<thead>
89+
<tr>
90+
<th>State</th>
91+
<th>Address</th>
92+
<th>Hostname</th>
93+
<th>TCP (open)</th>
94+
<th>UDP (open)</th>
95+
</tr>
96+
</thead>
97+
<tbody>
98+
<xsl:for-each select="/nmaprun/host">
99+
<tr>
100+
<td><span class="label label-danger"><xsl:if test="status/@state='up'"><xsl:attribute name="class">label label-success</xsl:attribute></xsl:if><xsl:value-of select="status/@state"/></span></td>
101+
<td><xsl:value-of select="address/@addr"/></td>
102+
<td><xsl:value-of select="hostnames/hostname/@name"/></td>
103+
<td><xsl:value-of select="count(ports/port[state/@state='open' and @protocol='tcp'])"/></td>
104+
<td><xsl:value-of select="count(ports/port[state/@state='open' and @protocol='udp'])"/></td>
105+
</tr>
106+
</xsl:for-each>
107+
</tbody>
108+
</table>
109+
</div>
110+
<script>
111+
$(document).ready(function() {
112+
$('#table-overview').DataTable();
113+
});
114+
</script>
115+
<h2 id="onlinehosts" class="target">Online Hosts</h2>
116+
<xsl:for-each select="/nmaprun/host[status/@state='up']">
117+
<div class="panel panel-default">
118+
<div class="panel-heading">
119+
<h3 class="panel-title"><xsl:value-of select="address/@addr"/><xsl:if test="count(hostnames/hostname) > 0"> - <xsl:value-of select="hostnames/hostname/@name"/></xsl:if></h3>
120+
</div>
121+
<div class="panel-body">
122+
<xsl:if test="count(hostnames/hostname) > 0">
123+
<h4>Hostnames</h4>
124+
<ul>
125+
<xsl:for-each select="hostnames/hostname">
126+
<li><xsl:value-of select="@name"/> (<xsl:value-of select="@type"/>)</li>
127+
</xsl:for-each>
128+
</ul>
129+
</xsl:if>
130+
<h4>Ports</h4>
131+
<div class="table-responsive">
132+
<table class="table table-bordered">
133+
<thead>
134+
<tr>
135+
<th>Port</th>
136+
<th>Protocol</th>
137+
<th>State<br/>Reason</th>
138+
<th>Service</th>
139+
<th>Product</th>
140+
<th>Version</th>
141+
<th>Extra Info</th>
142+
</tr>
143+
</thead>
144+
<tbody>
145+
<xsl:for-each select="ports/port">
146+
<xsl:choose>
147+
<xsl:when test="state/@state = 'open'">
148+
<tr class="success">
149+
<td title="Port"><xsl:value-of select="@portid"/></td>
150+
<td title="Protocol"><xsl:value-of select="@protocol"/></td>
151+
<td title="State / Reason"><xsl:value-of select="state/@state"/><br/><xsl:value-of select="state/@reason"/></td>
152+
<td title="Service"><xsl:value-of select="service/@name"/></td>
153+
<td title="Product"><xsl:value-of select="service/@product"/></td>
154+
<td title="Version"><xsl:value-of select="service/@version"/></td>
155+
<td title="Extra Info"><xsl:value-of select="service/@extrainfo"/></td>
156+
</tr>
157+
<tr>
158+
<td colspan="7">
159+
<a><xsl:attribute name="href">https://nvd.nist.gov/vuln/search/results?form_type=Advanced&amp;cves=on&amp;cpe_version=<xsl:value-of select="service/cpe"/></xsl:attribute><xsl:value-of select="service/cpe"/></a>
160+
<xsl:for-each select="script">
161+
<h5><xsl:value-of select="@id"/></h5>
162+
<pre style="white-space:pre-wrap; word-wrap:break-word;"><xsl:value-of select="@output"/></pre>
163+
</xsl:for-each>
164+
</td>
165+
</tr>
166+
</xsl:when>
167+
<xsl:when test="state/@state = 'filtered'">
168+
<tr class="warning">
169+
<td><xsl:value-of select="@portid"/></td>
170+
<td><xsl:value-of select="@protocol"/></td>
171+
<td><xsl:value-of select="state/@state"/><br/><xsl:value-of select="state/@reason"/></td>
172+
<td><xsl:value-of select="service/@name"/></td>
173+
<td><xsl:value-of select="service/@product"/></td>
174+
<td><xsl:value-of select="service/@version"/></td>
175+
<td><xsl:value-of select="service/@extrainfo"/></td>
176+
</tr>
177+
</xsl:when>
178+
<xsl:when test="state/@state = 'closed'">
179+
<tr class="active">
180+
<td><xsl:value-of select="@portid"/></td>
181+
<td><xsl:value-of select="@protocol"/></td>
182+
<td><xsl:value-of select="state/@state"/><br/><xsl:value-of select="state/@reason"/></td>
183+
<td><xsl:value-of select="service/@name"/></td>
184+
<td><xsl:value-of select="service/@product"/></td>
185+
<td><xsl:value-of select="service/@version"/></td>
186+
<td><xsl:value-of select="service/@extrainfo"/></td>
187+
</tr>
188+
</xsl:when>
189+
<xsl:otherwise>
190+
<tr class="info">
191+
<td><xsl:value-of select="@portid"/></td>
192+
<td><xsl:value-of select="@protocol"/></td>
193+
<td><xsl:value-of select="state/@state"/><br/><xsl:value-of select="state/@reason"/></td>
194+
<td><xsl:value-of select="service/@name"/></td>
195+
<td><xsl:value-of select="service/@product"/></td>
196+
<td><xsl:value-of select="service/@version"/></td>
197+
<td><xsl:value-of select="service/@extrainfo"/></td>
198+
</tr>
199+
</xsl:otherwise>
200+
</xsl:choose>
201+
</xsl:for-each>
202+
</tbody>
203+
</table>
204+
</div>
205+
</div>
206+
</div>
207+
</xsl:for-each>
208+
<h2 id="openservices" class="target">Open Services</h2>
209+
<div class="table-responsive">
210+
<table id="table-services" class="table table-striped dataTable" role="grid">
211+
<thead>
212+
<tr>
213+
<th>Address</th>
214+
<th>Port</th>
215+
<th>Protocol</th>
216+
<th>Service</th>
217+
<th>Product</th>
218+
<th>Version</th>
219+
<th>CPE</th>
220+
<th>Extra info</th>
221+
</tr>
222+
</thead>
223+
<tbody>
224+
<xsl:for-each select="/nmaprun/host">
225+
<xsl:for-each select="ports/port[state/@state='open']">
226+
<tr>
227+
<td><xsl:value-of select="../../address/@addr"/><xsl:if test="count(../../hostnames/hostname) > 0"> - <xsl:value-of select="../../hostnames/hostname/@name"/></xsl:if></td>
228+
<td><xsl:value-of select="@portid"/></td>
229+
<td><xsl:value-of select="@protocol"/></td>
230+
<td><xsl:value-of select="service/@name"/></td>
231+
<td><xsl:value-of select="service/@product"/></td>
232+
<td><xsl:value-of select="service/@version"/></td>
233+
<td><xsl:value-of select="service/cpe"/></td>
234+
<td><xsl:value-of select="service/@extrainfo"/></td>
235+
</tr>
236+
</xsl:for-each>
237+
</xsl:for-each>
238+
</tbody>
239+
</table>
240+
</div>
241+
<script>
242+
$(document).ready(function() {
243+
$('#table-services').DataTable();
244+
});
245+
</script>
246+
</div>
247+
<footer class="footer">
248+
<div class="container">
249+
<p class="text-muted">
250+
This report was generated with <a href="https://github.com/honze-net/nmap-bootstrap-xsl">Nmap Bootstrap XSL</a>.<br/>
251+
Licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons BY-SA</a>.<br/>
252+
Designed and built by Andreas Hontzia (<a href="https://www.twitter.com/honze_net">@honze_net</a>).<br/>
253+
</p>
254+
</div>
255+
</footer>
256+
</body>
257+
</html>
258+
</xsl:template>
259+
</xsl:stylesheet>

0 commit comments

Comments
 (0)