Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

#78: Make struct field Ports to be singular #93

Merged
merged 2 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ cat nmap.xml | nmap-formatter json | jq
List all the found ports and count them:

```bash
nmap-formatter json [nmap.xml] | jq -r '.Host[]?.Ports?.Port[]?.PortID' | sort | uniq -c
nmap-formatter json [nmap.xml] | jq -r '.Host[]?.Port[]?.PortID' | sort | uniq -c
```

```
Expand All @@ -76,7 +76,7 @@ nmap-formatter json [nmap.xml] | jq -r '.Host[]?.Ports?.Port[]?.PortID' | sort |
another example where only those hosts are selected, which have port where some http service is running:

```bash
nmap-formatter json [nmap.xml] | jq '.Host[]? | . as $host | .Ports?.Port[]? | select(.Service.Name== "http") | $host.HostAddress.Address' | uniq -c
nmap-formatter json [nmap.xml] | jq '.Host[]? | . as $host | .Port[]? | select(.Service.Name== "http") | $host.HostAddress.Address' | uniq -c
```

```
Expand All @@ -89,14 +89,14 @@ In this case `192.168.1.3` has 2 http services running (for example on ports 80

Another example where it is needed to display only filtered ports:

```
nmap-formatter json [nmap.xml] | jq '.Host[]?.Ports?.Port[]? | select(.State.State == "filtered") | .PortID'
```bash
nmap-formatter json [nmap.xml] | jq '.Host[]?.Port[]? | select(.State.State == "filtered") | .PortID'
```

Display host IP addresses that have filtered ports:

```bash
nmap-formatter json [nmap.xml] | jq '.Host[]? | . as $host | .Ports?.Port[]? | select(.State.State == "filtered") | .PortID | $host.HostAddress.Address'
nmap-formatter json [nmap.xml] | jq '.Host[]? | . as $host | .Port[]? | select(.State.State == "filtered") | .PortID | $host.HostAddress.Address'
```

### Flags
Expand Down
4 changes: 2 additions & 2 deletions formatter/formatter_csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func (f *CSVFormatter) convert(td *TemplateData) (data [][]string) {
}
address := fmt.Sprintf("%s (%s)", host.HostAddress.Address, host.Status.State)
data = append(data, []string{address, "", "", "", "", "", "", "", ""})
for j := range host.Ports.Port {
var port *Port = &host.Ports.Port[j]
for j := range host.Port {
var port *Port = &host.Port[j]
data = append(
data,
[]string{
Expand Down
Loading