LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 01-24-2008, 08:04 AM   #1
shourya21
LQ Newbie
 
Registered: Jan 2008
Posts: 3

Rep: Reputation: 0
generate xml from nmap output


Hi all,
I ran an nmap command with the following options:
$NMAP -A -oX $SCAN_REPORT --host_timeout $TIMEOUT --stylesheet $NMAPXSL $IPRANGE

where $SCAN_REPORT is the path of the xml file it stores the output into.

Now I want to run the nmap command with another set of ip addresses let's say $IPRANGE2 and want to append the output to the same xml $SCAN_REPORT. How do I achieve this?
For your reference the xml format is like this:

<?xml version="1.0" ?>
<?xml-stylesheet href="nmap.xsl" type="text/xsl"?>
<!-- Nmap 4.20 scan initiated Wed Dec 5 13:51:34 2007 as: /usr/bin/nmap -A -oX ./scan/05-Dec-2007-01_51-PM.xml -&#45;host_timeout 600000 -&#45;stylesheet nmap.xsl -->
<nmaprun scanner="nmap" args="/usr/bin/nmap -A -oX ./scan/05-Dec-2007-01_51-PM.xml --host_timeout 600000 --stylesheet nmap.xsl" start="1196842894" startstr="Wed Dec 5 13:51:34 2007" version="4.20" xmloutputversion="1.01">
<scaninfo type="syn" protocol="tcp" numservices="1697" services="1-1027,1029-1033,1040,1043,1050,1058-1059,1067-1068,1076,1080,1083-1084,1103" />
<verbose level="0" />
<debugging level="0" />


Any pointer would help.
Thanks in advance,
Shourya
 
Old 01-24-2008, 08:54 AM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
You didn't include the closing tag of "<nmaprun ...>". The line above it is a comment. The next line starts the body of the xml document. The "xmlrun" is equivalent to "body" in an html document and the information is included in the elements inside the tag instead of using more tags for them. This xml document isn't designed to include other runs.

Here is a truncated example from mysql.
Code:
<?xml version="1.0"?>

<dataytypes>

  <datatype>
    <name>BOOLEAN</name>
    <group>0</group>
    <synonym_group>0</synonym_group>
    <params_optional>Yes</params_optional>
    <has_length_param>No</has_length_param>
    <flag>UNSIGNED</flag>
  </datatype>

  <datatype>
    <name>BOOL</name>
    <group>0</group>
    <synonym_group>0</synonym_group>
    <params_optional>Yes</params_optional>
    <has_length_param>No</has_length_param>
    <flag>UNSIGNED</flag>
  </datatype>
</datatypes>
Perhaps like:
Code:
<?xml version="1.0" ?>
<?xml-stylesheet href="nmap.xsl" type="text/xsl"?>
<nmapruns>
   <!-- Nmap 4.20 scan initiated Wed Dec 5 13:51:34 2007 as: /usr/bin/nmap -A -oX ./scan/05-Dec-2007-01_51-PM.xml  --host_timeout 600000 --stylesheet nmap.xsl -->
   <nmaprun scanner="nmap" args="/usr/bin/nmap -A -oX ./scan/05-Dec-2007-01_51-PM.xml --host_timeout 600000 --stylesheet nmap.xsl" start="1196842894" startstr="Wed Dec 5 13:51:34 2007" version="4.20" xmloutputversion="1.01">
   <scaninfo type="syn" protocol="tcp" numservices="1697" services="1-1027,1029-1033,1040,1043,1050,1058-1059,1067-1068,1076,1080,1083-1084,1103" />
   <verbose level="0" />
   <debugging level="0" />
   </nmaprun>

   <!-- Nmap 4.20 scan initiated Wed Dec 6 13:51:17 2007 as: /usr/bin/nmap -A -oX ./scan/06-Dec-2007-01_51-PM.xml  --host_timeout 600000 --stylesheet nmap.xsl -->
   <nmaprun scanner="nmap" args="/usr/bin/nmap -A -oX ./scan/06-Dec-2007-01_51-PM.xml --host_timeout 600000 --stylesheet nmap.xsl" start="1196842894" startstr="Wed Dec 6 13:51:34 2007" version="4.20" xmloutputversion="1.01">
   <scaninfo type="syn" protocol="tcp" numservices="1697" services="1-1027,1029-1033,1040,1043,1050,1058-1059,1067-1068,1076,1080,1083-1084,1103" />
   <verbose level="0" />
   <debugging level="0" />
   </nmaprun>
</nmapruns>
If you were to merge two or more xml documents, you would have to reinvent your own xml document making "nmaprun" an element.
You would need to rewrite the "nmap.xsl" file as well so that your new xml documents can be displayed in the web browser or translated to html documents.

----

Taking a peek at nmap.xsl and nmap.dtd, it looks like your posted sample is oversimplified. There should be items for each host. If you wish to display the results in browser, displaying each .xml document separately may be a lot easier.

Last edited by jschiwal; 01-24-2008 at 09:15 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
nmap xml stylesheet lord-fu Linux - Software 1 08-06-2007 10:08 PM
Trying to generate resource information and email the output. bebeslb Programming 1 10-11-2006 09:51 AM
RSS XML File to be read and generate HTML page redhatrosh General 10 02-15-2006 02:16 AM
What packages are needed to generate lib-javox-xml-transform-2.4.1.so, etc. satimis Fedora 0 09-25-2004 09:51 AM
Foomatic: How to generate ppd drivers from xml files? johnny1959 Linux - Newbie 0 02-17-2004 04:27 AM


All times are GMT -5. The time now is 08:20 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration