File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,50 @@ or Markdown
39
39
nmap-formatter [path-to-nmap.xml] md > some-markdown.md
40
40
```
41
41
42
+ or JSON
43
+
44
+ ```
45
+ nmap-formatter [path-to-nmap.xml] json
46
+ ```
47
+
48
+ it can be also combined with a ` jq ` tool, for example, list all the found ports and count them:
49
+
50
+ ```
51
+ nmap-formatter [nmap.xml] json | jq -r '.Host[]?.Ports?.Port[]?.PortID' | sort | uniq -c
52
+ ```
53
+
54
+ ```
55
+ 1 "22"
56
+ 2 "80"
57
+ 1 "8080"
58
+ ```
59
+
60
+ another example where only those hosts are selected, which have port where some http service is running:
61
+
62
+ ```
63
+ nmap-formatter [nmap.xml] json | jq '.Host[]? | . as $host | .Ports?.Port[]? | select(.Service.Name== "http") | $host.HostAddress.Address' | uniq -c
64
+ ```
65
+
66
+ ```
67
+ 1 "192.168.1.1"
68
+ 1 "192.168.1.2"
69
+ 2 "192.168.1.3"
70
+ ```
71
+
72
+ In this case ` 192.168.1.3 ` has 2 http services running (for example on ports 80 and 8080)`.
73
+
74
+ Another example where it is needed to display only filtered ports:
75
+
76
+ ```
77
+ nmap-formatter [nmap.xml] json | jq '.Host[]?.Ports?.Port[]? | select(.State.State == "filtered") | .PortID'
78
+ ```
79
+
80
+ Display host IP addresses that have filtered ports:
81
+
82
+ ```
83
+ nmap-formatter [nmap.xml] json | jq '.Host[]? | . as $host | .Ports?.Port[]? | select(.State.State == "filtered") | .PortID | $host.HostAddress.Address'
84
+ ```
85
+
42
86
### Flags
43
87
44
88
* ` -f, --file [filename] ` outputs result to the file (by default output goes to STDOUT)
You can’t perform that action at this time.
0 commit comments