🛡️ Methodology Checklist

  • Save all formats at once: nmap -oA [BASENAME] [TARGET]
  • Grepable format for parsing: nmap -oG [FILE] [TARGET]
  • XML for tool import (Metasploit, Faraday): nmap -oX [FILE] [TARGET]
  • Append to existing output: use -oG - and redirect
  • Import XML into Metasploit: db_import [FILE].xml
  • Review saved output before proceeding to exploitation phase

🎯 Operational Context

Think Dumber First: Always use -oA [basename] from the very first scan — you cannot recreate scan results after the engagement. Store scans in organized directories: /root/engagement/[TARGET]/scans/. Grepable format (.gnmap) enables fast grep searches. XML format imports directly into Metasploit with db_import.

When you land here: Starting any scan. The baseline workflow: nmap [FLAGS] -oA /root/[ENGAGEMENT]/scans/[TARGET]-[SCANTYPE]. Never run a scan without output saving — it will be needed for the report, even if you think you won’t use it.


⚡ Tactical Cheatsheet

CommandTactical Outcome
sudo nmap [TARGET_IP] -p- -oA scans/target-fullSave all 3 output formats simultaneously (recommended)
sudo nmap [TARGET_IP] -p- -oN scans/target.nmapSave human-readable normal format only
sudo nmap [TARGET_IP] -p- -oG scans/target.gnmapSave grepable format only
sudo nmap [TARGET_IP] -p- -oX scans/target.xmlSave XML format only
xsltproc target.xml -o report.htmlConvert XML output to HTML report
cat target.gnmap | grep "80/open" | awk '{print $2}'Extract IPs with port 80 open from grepable output

🔬 Deep Dive & Workflow

Output Formats

FlagExtensionUse Case
-oN.nmapHuman-readable, good for quick review and paste into notes
-oG.gnmapOne line per host — easy parsing with grep/awk/cut
-oX.xmlStructured data for importing into Metasploit (db_import), Searchsploit, or converting to HTML
-oAAll 3Best practice — always use this

Why Save All Formats

  • Comparison: Diff results between SYN vs Connect scans.
  • Documentation: Evidence for pentest reports.
  • Tool Import: Metasploit’s db_import requires XML; grepable is needed for scripted pipelines.

HTML Report

xsltproc (pre-installed on Kali/Parrot) converts the XML to a styled browser-viewable table of open ports.


🛠️ Troubleshooting & Edge Cases

ProblemCauseFix
Output files created in wrong directoryRelative path usedAlways use absolute path: -oA /root/htb/[BOX]/scans/initial; verify with ls -la /root/htb/[BOX]/scans/
XML import to MSF fails ‘no services found’Scan run without -sV; no version data in XMLRe-run targeted scan with -sV: nmap -p [OPEN_PORTS] -sV -oX rescan.xml; then db_import rescan.xml
grep on .gnmap returns no resultsWrong field syntaxGrepable format: grep 'open' file.gnmap | awk '{print $2}'; fields are: Host State OpenPorts Hostname
Output file is 0 bytesScan failed immediately (bad target or permission)Check nmap exit code: echo $?; run with -v to see failure reason; confirm target is reachable
Can’t open .xml in browserNo XSLT stylesheet linkedConvert: xsltproc /usr/share/nmap/nmap.xsl result.xml -o result.html; open result.html in browser

📝 Reporting Trigger

Finding Title: (Scan output is evidence — attach relevant nmap output files to findings as supporting evidence. XML output linked to CVE database provides authoritative version-to-vulnerability mapping. Incomplete scan coverage should be disclosed in report limitations.)