mirror of
https://github.com/NetsecExplained/Nmap-XML-to-CSV.git
synced 2026-10-27 10:42:33 +02:00
Update nmap_xml_parser.py
This commit is contained in:
parent
e50d6387ca
commit
4563e600fa
@ -54,6 +54,11 @@ def get_host_data(root):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
host_name = ''
|
host_name = ''
|
||||||
|
|
||||||
|
if args.ip_addresses:
|
||||||
|
addr_info.extend((ip_address, host_name))
|
||||||
|
host_data.append(addr_info)
|
||||||
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os_element = host.findall('os')
|
os_element = host.findall('os')
|
||||||
os_name = os_element[0].findall('osmatch')[0].attrib['name']
|
os_name = os_element[0].findall('osmatch')[0].attrib['name']
|
||||||
@ -147,9 +152,13 @@ def list_ip_addresses(data):
|
|||||||
ip_list = []
|
ip_list = []
|
||||||
for item in data:
|
for item in data:
|
||||||
ip_list.append(item[0])
|
ip_list.append(item[0])
|
||||||
|
|
||||||
sorted_set = sorted(set(ip_list))
|
sorted_set = sorted(set(ip_list))
|
||||||
|
addr_list = []
|
||||||
for ip in sorted_set:
|
for ip in sorted_set:
|
||||||
print(ip)
|
addr_list.append(ip)
|
||||||
|
|
||||||
|
return addr_list
|
||||||
|
|
||||||
|
|
||||||
def print_web_ports(data):
|
def print_web_ports(data):
|
||||||
@ -242,7 +251,9 @@ def main():
|
|||||||
if args.csv:
|
if args.csv:
|
||||||
parse_to_csv(data)
|
parse_to_csv(data)
|
||||||
if args.ip_addresses:
|
if args.ip_addresses:
|
||||||
list_ip_addresses(data)
|
addrs = list_ip_addresses(data)
|
||||||
|
for addr in addrs:
|
||||||
|
print(addr)
|
||||||
if args.print_all:
|
if args.print_all:
|
||||||
print_data(data)
|
print_data(data)
|
||||||
if args.filter_by_port:
|
if args.filter_by_port:
|
||||||
@ -282,4 +293,4 @@ if __name__ == '__main__':
|
|||||||
exit()
|
exit()
|
||||||
|
|
||||||
csv_name = args.csv
|
csv_name = args.csv
|
||||||
main()
|
main()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user