Skip to content

Commit

Permalink
Add README content and some comments in code
Browse files Browse the repository at this point in the history
  • Loading branch information
Vsevolod committed Jun 29, 2019
1 parent a70427d commit 42b0d9c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# nmap2md
A little utility to convert nmap xml results to markdown tables

A little utility to convert nmap XML results to markdown tables

## Usage

Example which parses nmap XML and outputs Markdown tables

```
python nmap2md.py /path/to/file/test.xml -c protocol,port,service,product,version --hs 4
```

## Output example

#### 74.207.244.221

| Protocol | Port | Service | Product | Version |
|----------|------|---------|---------|---------|
| tcp | 22 | ssh | OpenSSH | 5.3p1 Debian 3ubuntu7 |
| tcp | 80 | http | Apache httpd | 2.2.14 |
4 changes: 3 additions & 1 deletion nmap2md.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@
md += "%s %s\n\n" % ('#' * options.hs, address)
md += "| %s |" % " | ".join(map(lambda s: s.title(), columns))
md += "\n"

# Adding +2 for 1 space on left and right sides
md += "|%s|" % "|".join(map(lambda s: '-' * (len(s) + 2), columns))
md += "\n"

for port_info in result[address]:
# Calculating
# Calculating correct amount of spaces to add some padding and justify content in the cell
# Currently it does not work if content is bigger that the column, in any case it does not break the Markdown view
md += "| %s |" % " | ".join(map(lambda s: port_info[s] + (' ' * (len(s) - len(port_info[s]))), columns))
md += "\n"

Expand Down

0 comments on commit 42b0d9c

Please sign in to comment.