HakTip 103 – NMap 101: How to Output to a File

NMap delivers your output in several ways, including as a text file, an XML file, a grepable file and even more.

Download HD  |   Download MP4

Welcome to HakTip — the show where we breakdown concepts, tools and techniques for hackers, gurus and IT ninjas. I’m Shannon Morse and I think it’s time we talked about some of the output options you have in NMap, since we’ve pretty much seen the same output for all of our commands.

You can output your info into an XMl file, a text file or even a grep file. This may be helpful if you need to scan a network with thousands of systems on it. That way you’d be able to scan all of these into a file you can then review later.

We’ll start with the -oN option. Type: nmap -oN test.txt Now if you cat test.txt, it’ll show you the output in a text file. Make sure if you want to use the same name for a file, you change the name of the text file or use the command option –append-output.

You can also output to an XML file by typing: nmap -oX test.xml Then you can type: cat test.xml.

To do the same thing for a grepable file, use: nmap -oG test.txt Now if I want to pull up the text from that file, I can use: grep “Windows 8” test.txt. This will search that file for the words “Windows 8” and output to me the results.

Now, what if you want to output the scan to all of those formats? XML, text, and grepable? Simple! Use: nmap -oA test Now if I use ls -l test.* I’ll see all of the newly created files. gnmap is Grep, XML is XML, and .nmap is a text file.

There are also a couple of other cool and useful output types. Type: nmap –stats-every 5s to show me the statistical information every 5 seconds during a scan. You can use s for seconds, m for minutes, or h for hours for this scan.

And lastly, we have creating a script kiddie or a 1337 output with -oS. This is just a cute little easter egg in NMap you can play with. Type nmap -oS test.txt to save it, then type cat test.txt to view the output. It’s sorta written in 1337speak instead of in actual English.

What would you like to see next about NMAP? Send me a comment below or email us at [email protected]. And be sure to check out our sister show, Hak5 for more great stuff just like this. I’ll be there, reminding you to trust your technolust.

1 Comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>