I'm trying to parse XML information from an Nmap scan, but I'm a little stuck. What I'd like to get is the IP address, open port, and OS. I know a fair amount of bash scripting as well as Java (although I really am not a fan) but am unsure how to go about tackling this project.
Accomplishing this in bash looks like hell. Some research shows Perl would probably do what I want. How relatively difficult would this be for someone with intermediate programming skills?
Here's an example of the XML output:
Accomplishing this in bash looks like hell. Some research shows Perl would probably do what I want. How relatively difficult would this be for someone with intermediate programming skills?
Here's an example of the XML output:
Code:
<host starttime="1363325770" endtime="1363325790"><status state="up" reason="syn-ack"/>
<address addr="192.168.1.78" addrtype="ipv4"/>
<hostnames>
</hostnames>
<ports><extraports state="closed" count="995">
<extrareasons reason="conn-refused" count="995"/>
</extraports>
<port protocol="tcp" portid="80"><state state="open" reason="syn-ack" reason_ttl="0"/><service name="http" product="Apache httpd" version="2.2.22" extrainfo="(Ubuntu)" method="probed" conf="10"><cpe>cpe:/a:apache:http_server:2.2.22</cpe></service><script id="http-title" output="Site doesn't have a title (text/html)."/><script id="http-methods" output="No Allow or Public header in OPTIONS response (status code 200)"/></port>
<port protocol="tcp" portid="139"><state state="open" reason="syn-ack" reason_ttl="0"/><service name="netbios-ssn" product="Samba smbd" version="3.X" extrainfo="workgroup: WORKGROUP" method="probed" conf="10"/></port>
<port protocol="tcp" portid="443"><state state="open" reason="syn-ack" reason_ttl="0"/><service name="ssh" product="OpenSSH" version="5.9p1 Debian 5ubuntu1" extrainfo="protocol 2.0" ostype="Linux" method="probed" conf="10"><cpe>cpe:/a:openbsd:openssh:5.9p1</cpe><cpe>cpe:/o:linux:kernel</cpe></service></port>
<port protocol="tcp" portid="445"><state state="open" reason="syn-ack" reason_ttl="0"/><service name="netbios-ssn" product="Samba smbd" version="3.X" extrainfo="workgroup: WORKGROUP" method="probed" conf="10"/></port>
<port protocol="tcp" portid="5800"><state state="open" reason="syn-ack" reason_ttl="0"/><service name="vnc-http" product="x11vnc" method="probed" conf="10"/><script id="http-methods" output="No Allow or Public header in OPTIONS response (status code 400)"/></port>
</ports>
<hostscript><script id="nbstat" output="NetBIOS name: UBUNTU1204, NetBIOS user: <unknown>, NetBIOS MAC: <unknown>"/><script id="smbv2-enabled" output="Server doesn't support SMBv2 protocol"/><script id="smb-security-mode" output="
 Account that was used for smb scripts: guest
 User-level authentication
 SMB Security: Challenge/response passwords supported
 Message signing disabled (dangerous, but default)
"/><script id="smb-os-discovery" output="
 OS: Unix (Samba 3.6.3)
 Computer name: Ubuntu1204
 Domain name: 
 FQDN: Ubuntu1204
 NetBIOS computer name: 
 System time: 2013-03-14 22:36:28 UTC-7
"/></hostscript><times srtt="1981" rttvar="3130" to="100000"/>
</host>