Commits

Tim Tomes  committed 878e2fc

minor bug fixes to the nmap xml parser.

  • Participants
  • Parent commits 91385bd

Comments (0)

Files changed (1)

File peepingtom.py

         else:
             # parse nessus file
             targets = parseNessus(root)
+        print '[*] Parsed targets:'
+        for x in targets: print x
     elif opts.target:
         targets = [opts.target]
     else:
 
 def parseNmap(root):
     targets = []
+    # iterate through all host nodes
     for host in root.iter('host'):
         hostname = host.find('address').get('addr')
+        # hostname node doesn't always exist. when it does, overwrite address previosuly assigned to hostanme
         hostname_node = host.find('hostnames').find('hostname')
-        if hostname_node is not None:
-            hostname = hostname_node.get('name')
+        if hostname_node is not None: hostname = hostname_node.get('name')
+        # iterate through all port nodes reported for the current host
         for item in host.iter('port'):
             state = item.find('state').get('state')
-            service = item.find('service').get('name')
+            service_node = item.find('service')
+            # service node doesn't always exist when a port is open. assume not http if no service is found
+            if service_node is None: continue
+            service = service_node.get('name')
+            # if the service is unknown, then use the fingerprint
+            if service.lower() == 'unknown': service = item.find('service').get('servicefp')
             if (state.lower() == 'open' and 'http' in service.lower()):
                 port = item.get('portid')
                 proto = 'http'