Skip to content

Commit a9899a0

Browse files
committed
Merge branch 'master' into 'master'
v1.4.5 See merge request github/nmap-parse-output-github!10
2 parents ecfaec1 + 01b9640 commit a9899a0

File tree

6 files changed

+76
-8
lines changed

6 files changed

+76
-8
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,24 @@ Remove all ports found in `scan-before.xml` from `scan-after.xml` and write the
113113
Extracts a list of extra information about the given port in the following format:
114114
port;service name;http title
115115
116+
ports-reachable
117+
Generates a comma-separated list of all reachable ports (open and closed, unfiltered). Can be used to verify if ports reachable from another host or generate port lists for specific environments.
118+
116119
ports
117-
Generates a comma-separated list of all ports. Can be used to verify if open/closed ports reachable from another host or generate port lists for specific environments. Filter closed/filtered ports.
120+
Generates a comma-separated list of all open ports. Can be used to verify if open ports reachable from another host or generate port lists for specific environments. Closed/filtered ports are not shown in the list.
118121
119122
product
120123
Extracts all detected product names.
121124
122125
service-names
123-
Extracts all detected service names.
126+
Extracts all detected service names (on open ports).
124127
125128
service [service-name]
126129
Extracts a list of all *open* ports with a specific service (e.g. http, ms-wbt-server, smtp) in host:port format.
127130
131+
show-comments
132+
Shows comments added by the comment-* commands.
133+
128134
ssl-common-name
129135
Extracts a list of TLS/SSL ports with the commonName and Subject Alternative Name in the following format:
130136
host:port commonName X509v3 Subject Alternative Name
@@ -196,10 +202,14 @@ Remove all ports found in `scan-before.xml` from `scan-after.xml` and write the
196202
197203
Misc Commands:
198204
199-
[v1.4.4]
205+
[v1.4.5]
200206

201207
## Changelog
202208

209+
* v1.4.5
210+
* Show only service-names of open ports
211+
* Splitted ports command in: ports and ports-reachable
212+
* Added show-comments command
203213
* v1.4.4
204214
* Fixed bug in [bash completion](_nmap-parse-output) when installed system-wide
205215
* Improved documentation

nmap-parse-output

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
NPO_VERSION=1.4.4
2+
NPO_VERSION=1.4.5
33

44
# get script path
55
SOURCE="${BASH_SOURCE[0]}"
@@ -106,4 +106,4 @@ done
106106
# process command on scan XML output
107107
{ cat "$NMAP_XML_OUTPUT"; echo "$UNFINISHED_SCAN"; } | \
108108
xsltproc "${EXTRA_PARAMS[@]}" "$XSLT" - | \
109-
bash -c "$POST_PIPE"
109+
bash -c "$POST_PIPE"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:npo="http://xmlns.sven.to/npo">
2+
<npo:comment>
3+
Generates a comma-separated list of all reachable ports (open and closed, unfiltered). Can be used to verify if ports reachable from another host or generate port lists for specific environments.
4+
</npo:comment>
5+
<npo:category>extract</npo:category>
6+
7+
<xsl:output method="text" />
8+
<xsl:strip-space elements="*" />
9+
10+
<xsl:key name="portid" match="/nmaprun/host/ports/port/state[@state = 'open' or @state = 'closed' or @state = 'unfiltered']/../@portid" use="." />
11+
12+
<xsl:template match="/">
13+
<!-- distinct port numbers, see https://stackoverflow.com/questions/2291567/how-to-use-xslt-to-create-distinct-values -->
14+
<xsl:for-each select="/nmaprun/host/ports/port/state[@state = 'open' or @state = 'closed' or @state = 'unfiltered']/../@portid[generate-id() = generate-id(key('portid',.)[1])]">
15+
<xsl:if test="position() != 1">
16+
<xsl:text>,</xsl:text>
17+
</xsl:if>
18+
<xsl:value-of select="."/>
19+
</xsl:for-each>
20+
21+
<!-- TODO: filter for filtered ports? <xsl:if test="state[@state != 'filtered']"> -->
22+
</xsl:template>
23+
24+
<xsl:template match="text()" />
25+
</xsl:stylesheet>

nmap-parse-output-xslt/ports.xslt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:npo="http://xmlns.sven.to/npo">
22
<npo:comment>
3-
Generates a comma-separated list of all ports. Can be used to verify if open/closed ports reachable from another host or generate port lists for specific environments. Filter closed/filtered ports.
3+
Generates a comma-separated list of all open ports. Can be used to verify if open ports reachable from another host or generate port lists for specific environments. Closed/filtered ports are not shown in the list.
44
</npo:comment>
55
<npo:category>extract</npo:category>
66

nmap-parse-output-xslt/service-names.xslt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:npo="http://xmlns.sven.to/npo">
22
<npo:comment>
3-
Extracts all detected service names.
3+
Extracts all detected service names (on open ports).
44
</npo:comment>
55
<npo:category>extract</npo:category>
66

@@ -11,7 +11,7 @@
1111

1212
<xsl:template match="/">
1313
<!-- distinct port numbers, see https://stackoverflow.com/questions/2291567/how-to-use-xslt-to-create-distinct-values -->
14-
<xsl:for-each select="/nmaprun/host/ports/port/service/@name[generate-id() = generate-id(key('serviceid',.)[1])]">
14+
<xsl:for-each select="/nmaprun/host/ports/port[state/@state='open']/service/@name[generate-id() = generate-id(key('serviceid',.)[1])]">
1515
<xsl:value-of select="."/>
1616
<xsl:text>
1717
</xsl:text>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<xsl:stylesheet version="1.0"
2+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3+
xmlns:npo="http://xmlns.sven.to/npo"
4+
xmlns:str="http://exslt.org/strings"
5+
extension-element-prefixes="str npo">
6+
<npo:comment>
7+
Shows comments added by the comment-* commands.
8+
</npo:comment>
9+
<npo:category>extract</npo:category>
10+
<!-- see http://exslt.org/str/index.html -->
11+
12+
<xsl:output method="text" />
13+
<xsl:strip-space elements="*" />
14+
<xsl:template match="/nmaprun/host/npo-comment">
15+
<xsl:value-of select="../address/@addr"/>
16+
<xsl:text> </xsl:text>
17+
<xsl:value-of select="."/>
18+
<xsl:text>
19+
</xsl:text>
20+
<xsl:apply-templates/>
21+
</xsl:template>
22+
<xsl:template match="/nmaprun/host/ports/port/npo-comment">
23+
<xsl:value-of select="../../../address/@addr"/>
24+
<xsl:text>:</xsl:text>
25+
<xsl:value-of select="../@portid"/>
26+
<xsl:text> </xsl:text>
27+
<xsl:value-of select="."/>
28+
<xsl:text>
29+
</xsl:text>
30+
<xsl:apply-templates/>
31+
</xsl:template>
32+
<xsl:template match="text()" />
33+
</xsl:stylesheet>

0 commit comments

Comments
 (0)