Lion Cipher Lab
Turn Nmap XML into an asset inventory with a short Python script
- Penetration Testing / Red Team
- Intermediate
- ~50 min
- Free · no account required
Why it matters
A scan result you cannot sort, count or compare is a wall of text. Every real assessment turns raw scanner output into an inventory first: what exists, what it exposes, what version. It is also the base for everything else in this series: diffing before and after a fix, finding the odd one out, deciding what to test first. Writing the small tool yourself means you understand each column and can trust it.
What you'll learn
- saving scans in Nmap XML with -oX and -oA
- reading the host, address, port, state and service elements
- parsing XML with Python's ElementTree
- writing a CSV asset inventory
- filtering to open ports only
- flagging cleartext services with a lookup table
- merging several scans into one inventory
Steps in this lab
- The rule, and the scan you start from
- Read the XML before you parse it
- Write the script
- Check your tool against the scanner
- Merge more than one scan and sort
- Turn the inventory into a short list to look at next
- The defender's view, and the fix
Open the full interactive lab →