By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,450 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Parse nmap XML output using tinyxml

P: 1
The following is the nmap xml output. Can someone help me to parse it using tinyxml library.

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE nmaprun>
  3. <?xml-stylesheet href="file:///C:/Program Files (x86)/Nmap/nmap.xsl" type="text/xsl"?>
  4. <!-- Nmap 7.40 scan initiated Thu Mar 16 11:09:08 2017 as: nmap -oX opt.xml -v -sS -O -pT:80,22 192.16.112.27 -->
  5. <nmaprun scanner="nmap" args="nmap -oX opt.xml -v -sS -O -pT:80,22 192.16.112.27" start="1489642748" startstr="Thu Mar 16 11:09:08 2017" version="7.40" xmloutputversion="1.04">
  6. <scaninfo type="syn" protocol="tcp" numservices="2" services="22,80"/>
  7. <verbose level="1"/>
  8. <debugging level="0"/>
  9. <taskbegin task="Ping Scan" time="1489642748"/>
  10. <taskend task="Ping Scan" time="1489642748" extrainfo="1 total hosts"/>
  11. <taskbegin task="Parallel DNS resolution of 1 host." time="1489642748"/>
  12. <taskend task="Parallel DNS resolution of 1 host." time="1489642748"/>
  13. <taskbegin task="SYN Stealth Scan" time="1489642748"/>
  14. <taskend task="SYN Stealth Scan" time="1489642748" extrainfo="2 total ports"/>
  15. <host starttime="1489642748" endtime="1489642750"><status state="up" reason="echo-reply" reason_ttl="63"/>
  16. <address addr="192.16.112.27" addrtype="ipv4"/>
  17. <hostnames>
  18. </hostnames>
  19. <ports><port protocol="tcp" portid="22"><state state="open" reason="syn-ack" reason_ttl="63"/><service name="ssh" method="table" conf="3"/></port>
  20. <port protocol="tcp" portid="80"><state state="closed" reason="reset" reason_ttl="63"/><service name="http" method="table" conf="3"/></port>
  21. </ports>
  22. <os><portused state="open" proto="tcp" portid="22"/>
  23. <portused state="closed" proto="tcp" portid="80"/>
  24. <portused state="closed" proto="udp" portid="35303"/>
  25. <osmatch name="Apple Mac OS X 10.7.0 (Lion) - 10.11 (El Capitan) or iOS 4.1 - 9.3.3 (Darwin 10.0.0 - 15.6.0)" accuracy="100" line="6233">
  26. <osclass type="general purpose" vendor="Apple" osfamily="Mac OS X" osgen="10.7.X" accuracy="100"><cpe>cpe:/o:apple:mac_os_x:10.7</cpe></osclass>
  27. <osclass type="general purpose" vendor="Apple" osfamily="OS X" osgen="10.8.X" accuracy="100"><cpe>cpe:/o:apple:mac_os_x:10.8</cpe></osclass>
  28. <osclass type="general purpose" vendor="Apple" osfamily="OS X" osgen="10.9.X" accuracy="100"><cpe>cpe:/o:apple:mac_os_x:10.9</cpe></osclass>
  29. <osclass type="general purpose" vendor="Apple" osfamily="OS X" osgen="10.10.X" accuracy="100"><cpe>cpe:/o:apple:mac_os_x:10.10</cpe></osclass>
  30. <osclass type="general purpose" vendor="Apple" osfamily="OS X" osgen="10.11.X" accuracy="100"><cpe>cpe:/o:apple:mac_os_x:10.11</cpe></osclass>
  31. <osclass type="media device" vendor="Apple" osfamily="iOS" osgen="4.X" accuracy="100"><cpe>cpe:/o:apple:iphone_os:4</cpe><cpe>cpe:/a:apple:apple_tv:4</cpe></osclass>
  32. <osclass type="phone" vendor="Apple" osfamily="iOS" osgen="4.X" accuracy="100"><cpe>cpe:/o:apple:iphone_os:4</cpe></osclass>
  33. <osclass type="phone" vendor="Apple" osfamily="iOS" osgen="5.X" accuracy="100"><cpe>cpe:/o:apple:iphone_os:5</cpe></osclass>
  34. <osclass type="phone" vendor="Apple" osfamily="iOS" osgen="6.X" accuracy="100"><cpe>cpe:/o:apple:iphone_os:6</cpe></osclass>
  35. <osclass type="phone" vendor="Apple" osfamily="iOS" osgen="7.X" accuracy="100"><cpe>cpe:/o:apple:iphone_os:7</cpe></osclass>
  36. <osclass type="phone" vendor="Apple" osfamily="iOS" osgen="8.X" accuracy="100"><cpe>cpe:/o:apple:iphone_os:8</cpe></osclass>
  37. <osclass type="phone" vendor="Apple" osfamily="iOS" osgen="9.X" accuracy="100"><cpe>cpe:/o:apple:iphone_os:9</cpe></osclass>
  38. </osmatch>
  39. </os>
  40. <uptime seconds="3410036" lastboot="Sat Feb 04 23:55:14 2017"/>
  41. <distance value="2"/>
  42. <tcpsequence index="256" difficulty="Good luck!" values="B5EF23AF,CD041F8E,81EBD9FE,E469975C,94BA072B,C9470524"/>
  43. <ipidsequence class="Randomized" values="5EC0,5EA7,DB6F,CD28,7415,7D9A"/>
  44. <tcptssequence class="1000HZ" values="CB410263,CB4102C6,CB410329,CB410398,CB4103FC,CB41045F"/>
  45. <times srtt="2217" rttvar="1576" to="100000"/>
  46. </host>
  47. <runstats><finished time="1489642750" timestr="Thu Mar 16 11:09:10 2017" elapsed="2.42" summary="Nmap done at Thu Mar 16 11:09:10 2017; 1 IP address (1 host up) scanned in 2.42 seconds" exit="success"/><hosts up="1" down="0" total="1"/>
  48. </runstats>
  49. </nmaprun>
  50.  
Thanks,
Arnav
Mar 28 '17 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.