Skip to content

Templates

Vsevolod Djagilev edited this page May 2, 2022 · 3 revisions

You can use your own custom templates (HTML or Markdown) for the output. Basic example is shown here:

Markdown

Template:

# Scanning

{{ range .NMAPRun.Host }}
{{ if eq .Status.State "up" }}
## {{ .HostAddress.Address }}
---
{{ range .Port }}
* {{ .PortID }} ({{ .Protocol }})
{{ end }}
{{ end }}
{{ end }}

Command:

nmap-formatter md example.xml --md-use-template example.md

Output:

# Scanning

## 74.207.244.221
---
* 22 (tcp)
* 80 (tcp)

HTML

Template:

<!DOCTYPE html>
<html>
    <head>
        <title>Test</title>
    </head>
    <body>
        {{ range .NMAPRun.Host }}
            {{ if eq .Status.State "up" -}}
            <h2>{{ .HostAddress.Address }}</h2>
            <hr />
            <ul>
                {{ range .Port -}}
                <li>{{ .PortID }} ({{ .Protocol }})</li>
                {{ end }}
            </ul>
            {{- end }}
        {{- end }}
    </body>
</html>

Command:

nmap-formatter html example.xml --html-use-template template.html > example.html

Output:

<!DOCTYPE html>
<html>
    <head>
        <title>Test</title>
    </head>
    <body>
        
            <h2>74.207.244.221</h2>
            <hr />
            <ul>
                <li>22 (tcp)</li>
                <li>80 (tcp)</li>
                
            </ul>
    </body>
</html>

Clone this wiki locally