Skip to content

Instantly share code, notes, and snippets.

@cldrn
Created December 18, 2015 14:22
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cldrn/be95a50fcffeb199b716 to your computer and use it in GitHub Desktop.
Save cldrn/be95a50fcffeb199b716 to your computer and use it in GitHub Desktop.
XMLStarlet command to convert Nmap's XML output to JSON. (Works on portrule scripts)
xmlstarlet sel -t -m "//host/ports/port/script" -o "{ip:'" -v "ancestor::host/address[@addrtype='ipv4']/@addr" -o "', hostname:'" -v "concat(ancestor::host/hostnames/hostname/@name,'')" -o "', proto:'" -v "../@protocol" -o "', port:" -v "../@portid" -o ", service:'" -v "../service/@name" -o "', script:'" -v "@id" -o "', script-output:'" -v "@output" -o "'}" -n <XML INPUT FILE>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment