Coder Social home page Coder Social logo

vdjagilev / nmap-formatter Goto Github PK

View Code? Open in Web Editor NEW
602.0 6.0 47.0 428 KB

A tool that allows you to convert NMAP results to html, csv, json, markdown, graphviz (dot) or sqlite. Simply put it's nmap converter.

License: MIT License

Go 99.87% Dockerfile 0.13%
xml xml-parsing json markdown html csv security security-tools nmap scan

nmap-formatter's People

Contributors

au-top avatar dependabot[bot] avatar vdjagilev avatar veids avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nmap-formatter's Issues

CSV skips hosts that are down

Currently CSV outputs only hosts that have some ports opened. If there is none, there is no record for that.

The host record look like this:

[IP], "-", "-", "-", "-" ...

Move types package

It's better to move types closer to the package where they belong. Types package stands out in this case and needs to be moved to formatter package.

Remove heavy dependencies

Currently spf13/cobra is used as a dependency, however app is quite simple and requires only a few features that are used.

Remove blank space in markdown output

Due to the nature of go text templates, there is a lot of blank space in markdown output. There should be way to filter output and remove unneeded spaces/newlines.

Cleanup

  • Fix the issues reported by golint (mostly warnings about missing comments for exported structs, et cetera)
  • Remove remaining TODO's
  • Check for variable name consistency (config & Config in formatter structs)

Move scan summary `Services` field under the table

Services field often contains a big list of ports which is problematic to display in markdown table (it has to be hidden using <details><summary>... html tags). Move this part in a sub-chapter, enclosing it in ``` would be better.

Implement floating table of contents

If there is huge output, it's better to navigate on a page using floating table of contents with anchor links.

Also add new option:

--html-floating-index, true by default.

JSON: output numbers as numbers instead of strings

Great project to get the data into Elastic :) One thing is bothering ES, everything is a string in the json output, even stuff like port numbers. This makes it difficult to filter stuff. Could the numeric stuff be parsed that way?

Thanks!

Wiki

Create a wiki with more in-depth topics.

  • More screenshots
  • More examples where nmap-formatter is combined with tools like jq and etc.
  • Custom templates
  • More automation topics?
    • nse-scripts?
    • combine tools? nmap -> nmap-formatter -> jq (exctract 'http' service ports) -> nikto?
  • Use as a library:
    • Simple output to stdin
    • Output as a string
    • Work with struct (based on parsed data: filter entries/do something with the data)
  • Simplify readme as much as possible and add links to wiki there

Alternative golangci-lint

  golangci-lint:
    name: golangci-lint
    runs-on: ubuntu-latest
    steps:
      - name: Set up Go
        uses: actions/setup-go@v3
        with:
          go-version: 1.18
      - uses: actions/checkout@v3
      - name: Run golangci-lint
        uses: golangci/golangci-lint-action@v3
        with:
          version: latest

Add options to skip some parts of scan output

It would be good if it would be possible to skip certain parts of scan output, for example:

  • Summary --skip-summary=false
  • Traceroute --skip-traceroute=false
  • Metrics --skip-metrics=false
  • Port-scripts --skip-port-scripts=false

Available only for HTML & Markdown

OSMatch can have multiple values

There might be more than 1 osmatch nodes.

<osmatch name="Some Linux Example" accuracy="94" line="1234"/>
<osmatch name="Another Linux Example" accuracy="89" line="4321"/>

Add codecov

  • Add code coverage workflow
  • Add badge to the readme

NMAP output

when running nmap-formatter nmap.xml md > nmap.md, it generates 8 columns when only 7 are identified, you can find below the output :

Port State Service Reason Product Version Extra Info
22 tcp open ssh syn-ack OpenSSH 7.4

This will generate rendering issues when viewing mardown because tcp (protocol) would be in the state column.
You could either add protocol column or merge tcp with port like this 22/tcp

Add option to read xml content from stdin

Add a possibility to read XML content from stdin. This would allow much easier piping.

nmap -A -T4 -oX - 10.10.10.100 | nmap-formatter json

TODO

  • Implement support for stdin read
  • Update documentation examples
  • Change places for file & format arguments? (Breaking change)

Add option to pretty print

Add possibility to pretty-print JSON, example:

json.MarshalIndent(struct, "", "    ") //  3-th = 4 spaces

Increase test coverage

Those parts needs to be covered with tests:

  • Formatter package
    • Workflow
    • HTML
      • check if HTML is valid (parse without error)
      • validate if all parts exist in HTML
        • hosts
        • ports
      • check --skip* output options
    • Markdown
      • parses without error
      • hosts
      • ports
    • JSON
    • CSV
      • Check if hosts that are down skipped by default
      • Check with --skip-down-hosts=false if down hosts are not skipped
  • cmd
    • arguments check
    • run
    • validation
  • Fix github actions workflow (run all tests via: go test ./... -count=1 -v)

Add more use-cases with jq

How to use this tool with jq (show hosts that are up, show only http service ports, show only filtered ports, count ports for each host, et cetera)

Custom variables for custom templates

Add a possibility to pass custom variables for custom templates.

Example:

--x-opt "foo=${bar}"

Then this value can be used in a custom template like this:

Some custom variables:

<ul>
  <li><b>Foo value:</b> {{.custom.foo}}</li>
</ul>

This could be used in automated environments (pipelines?) to pass some values to the custom templates.

Can be implemented only after #23

Make it possible to use as a library

It would be good if this repository could be used as a library to parse nmap xml output. For this purpose 2 things must be accomplished:

  • Create examples in readme on how to use the library
  • Refactor the code in a way that allows easily to use the library

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.