Write-up Generator with Nmap Integration
Introduction
Recently I made a python tool to automate my write-up templates, start filling out some simple sections (ie nmap output, open ports etc), and perform a few additional Web Enumeration tasks such as grabbing html comments and the robots.txt file if it exists. I built it because I wanted to learn basic nmap output parsing, and save time during my weekly write-ups.This tool should save me time creating a skeleton of the write-up. It should also prevent accidentally leaving old data in new write-ups, and standardize my formatting for every write-up.
The Problem
I am currently studying for the Certified Penetration Testing Specialist certification from Hack the Box. This certification heavily emphasizes documentation and report writing. This makes sense as this is the product a penetration tester is selling. To improve my reporting skills I created a schedule where every weekend I complete a box on Hack the Box, then the following Monday I complete a professional write-up. While doing this, I noticed that for nearly every box I was running the same Nmap scan to identify ports and services, then manually copying that information into my write-up, all before I even started writing. Typically I would reuse old write-ups and replace the existing data with the results from the new target. This is prone to a major error. Because there was existing data in the write-up I was using as a template, I might occasionally rush and forget to replace data appropriately. By using this tool, that problem is solved, and I was able to successfully automate an existing workflow. As I mapped the output to the appropriate sections of the write-up, I found a few other small tasks I could quickly and easily integrate into the program as well, namely grabbing any homepage HTML comments, and grabbing the if the robots.txt page if it exists.
Project Goals
The goals of this project were:
- Standardize my reporting template
- Automate some basic tasks I do on every Box I complete
- Save time and energy when completing write-ups
- Become familiar with xml parsing, in particular xml output from nmap
This project was NOT meant to:
- Automate a full box write-up
- Replace any existing tools
- Make me an expert in XML
How it Works
- Run Nmap scan against user provided IP and save output as .xml, .gnmap, and .nmap
- Parse the .xml output to extract open ports, protocols, services, and versions
- Generate a write-up in markdown with the nmap scan output, and a table of ports services and versions pre-populated
- If http(s) was detected perform additional Web Enumeration
- Extract any HTML comments from the home page
- Retrieve and display the contents of robots.txt if present
Future Improvements
At this point this tool is still relatively breakable, as time goes on I will add more error handling etc to ensure that it works even when things do not behave as expected. Eventually I will also create a functionality to perform an optional Gobuster scan, which will then be parsed and auto-populated into the generated write-up.