mirror of
https://github.com/NetsecExplained/Nmap-XML-to-CSV.git
synced 2026-08-27 08:20:12 +03:00
Add files via upload
This commit is contained in:
parent
f10a7d1612
commit
20d25a8d28
@ -38,6 +38,7 @@ def get_host_data(root):
|
||||
host_data = []
|
||||
hosts = root.findall('host')
|
||||
for host in hosts:
|
||||
addr_info = []
|
||||
if not host.findall('status')[0].attrib['state'] == 'up':
|
||||
continue
|
||||
|
||||
@ -55,40 +56,45 @@ def get_host_data(root):
|
||||
except IndexError:
|
||||
os_name = ''
|
||||
|
||||
port_element = host.findall('ports')
|
||||
ports = port_element[0].findall('port')
|
||||
try:
|
||||
port_element = host.findall('ports')
|
||||
ports = port_element[0].findall('port')
|
||||
|
||||
for port in ports:
|
||||
port_data = []
|
||||
if not port.findall('state')[0].attrib['state'] == 'open':
|
||||
continue
|
||||
for port in ports:
|
||||
port_data = []
|
||||
if not port.findall('state')[0].attrib['state'] == 'open':
|
||||
continue
|
||||
|
||||
proto = port.attrib['protocol']
|
||||
port_id = port.attrib['portid']
|
||||
service = port.findall('service')[0].attrib['name']
|
||||
proto = port.attrib['protocol']
|
||||
port_id = port.attrib['portid']
|
||||
service = port.findall('service')[0].attrib['name']
|
||||
|
||||
try:
|
||||
product = port.findall('service')[0].attrib['product']
|
||||
except (IndexError, KeyError):
|
||||
product = ''
|
||||
try:
|
||||
product = port.findall('service')[0].attrib['product']
|
||||
except (IndexError, KeyError):
|
||||
product = ''
|
||||
|
||||
try:
|
||||
servicefp = port.findall('service')[0].attrib['servicefp']
|
||||
except (IndexError, KeyError):
|
||||
servicefp = ''
|
||||
try:
|
||||
servicefp = port.findall('service')[0].attrib['servicefp']
|
||||
except (IndexError, KeyError):
|
||||
servicefp = ''
|
||||
|
||||
try:
|
||||
script_id = port.findall('script')[0].attrib['id']
|
||||
except (IndexError, KeyError):
|
||||
script_id = ''
|
||||
try:
|
||||
script_id = port.findall('script')[0].attrib['id']
|
||||
except (IndexError, KeyError):
|
||||
script_id = ''
|
||||
|
||||
try:
|
||||
script_output = port.findall('script')[0].attrib['output']
|
||||
except (IndexError, KeyError):
|
||||
script_output = ''
|
||||
try:
|
||||
script_output = port.findall('script')[0].attrib['output']
|
||||
except (IndexError, KeyError):
|
||||
script_output = ''
|
||||
|
||||
port_data.extend((ip_address, host_name, os_name, proto, port_id, service, product, servicefp, script_id, script_output))
|
||||
host_data.append(port_data)
|
||||
port_data.extend((ip_address, host_name, os_name, proto, port_id, service, product, servicefp, script_id, script_output))
|
||||
host_data.append(port_data)
|
||||
|
||||
except IndexError:
|
||||
addr_info.extend((ip_address, host_name))
|
||||
host_data.append(addr_info)
|
||||
|
||||
return host_data
|
||||
|
||||
@ -142,7 +148,7 @@ def list_ip_addresses(data):
|
||||
|
||||
def print_web_ports(data):
|
||||
""" Examines the port information and prints out the IP and port
|
||||
info in URL format (https://ipaddr:port/)
|
||||
info in URL format (https://ipaddr:port/)
|
||||
"""
|
||||
# http and https port numbers came from experience as well as
|
||||
# searching for http on th following website:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user