Skip to content

Instantly share code, notes, and snippets.

@opie4624
Created October 6, 2010 15:45
Show Gist options
  • Save opie4624/613550 to your computer and use it in GitHub Desktop.
Save opie4624/613550 to your computer and use it in GitHub Desktop.
Fixes XML files resulting from a resumed NMAP scan
#!/bin/bash
# If you resume an NMAP scan while outputting to XML the file
# becomes malformed. This script will take that file and split
# it into multiple .xml files, one for each run.
#
# Files without the .xml extension didn't lint and couldn't be fixed.
#
# It will try to lint the file twice, and add </nmaprun> if needed.
# If that doesn't work, pay attention to the xmllint errors and
# fix it your damn self.
split -p '^<\?xml version' NMAP_Output_File.xml NMAP_Output-
for i in `ls NMAP_Output-??`
do
xmllint --output $i.xml $i 2>/dev/null
if test $? -eq 0
then
rm $i
else
echo "</nmaprun>">>$i
xmllint --output $i.xml $i
if test $? -eq 0
then
rm $i
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment