Home alone with SED and XML

Thanks to my incredible hardening skills I found myself with a lonely Bash prompt in the company of only the sed stream editor instead of enjoying my Saturday afternoon with some nice ice-cold beers.

All this mayhem while I urgently needed to convert some XML files into a readable common text format file. The XML files contained lists of browser user-agent strings. I needed that to do some really advanced hacking stuff, the kind that separate the men from the boys.

OK, I am lying, it was some kindergarten stuff and I could have opened any XML editor to do some boring XPATH thingie but that would not look so cool when they finally make a realistic hacker movie in a year or twenty or so. Better to have some kiddie typing a list of weird characters to hack into Skynet and extract all those confidential cat pictures stored there.

I found an XML file with user-agent strings on techpatterns.com. To spare the world from more cursing, here is the sed command to convert this XML file into a nice and readable text file:

 sed -n -e 's/.*useragent="//' -e 's/"\{1\} \+appcodename.*//p' useragentswitcher.xml | sed -e '/^$/d' > useragents.txt

Another list was downloaded from user-agents.org. Use this beauty to convert that list into sweet text format:

 sed -n -e 's/.\<String>//' -e 's/<\/String>.*//p' allagents.xml | sed -e '/^$/d' > useragentlist2.txt

The resulting lists can easily be used with the Burp Intruder tool or, for additional bonus points and lost time, with the curl command, but I leave that exercise to the reader.

Herman Stevens

Just some guy on the internet. Loves technology, diving, travelling, photography and Belgian Trappist beers.