• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Parse XML data from a Nmap scan?

00PS

[H]ard|Gawd
Joined
May 5, 2009
Messages
1,798
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:

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&apos;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: &lt;unknown&gt;, NetBIOS MAC: &lt;unknown&gt;"/><script id="smbv2-enabled" output="Server doesn&apos;t support SMBv2 protocol"/><script id="smb-security-mode" output="&#xa;  Account that was used for smb scripts: guest&#xa;  User-level authentication&#xa;  SMB Security: Challenge/response passwords supported&#xa;  Message signing disabled (dangerous, but default)&#xa;"/><script id="smb-os-discovery" output="&#xa;  OS: Unix (Samba 3.6.3)&#xa;  Computer name: Ubuntu1204&#xa;  Domain name: &#xa;  FQDN: Ubuntu1204&#xa;  NetBIOS computer name: &#xa;  System time: 2013-03-14 22:36:28 UTC-7&#xa;"/></hostscript><times srtt="1981" rttvar="3130" to="100000"/>
</host>
 
Back
Top