mirror of
https://github.com/NetsecExplained/Nmap-XML-to-CSV.git
synced 2026-08-27 08:20:12 +03: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:
|
||||
host_name = ''
|
||||
|
||||
if args.ip_addresses:
|
||||
addr_info.extend((ip_address, host_name))
|
||||
host_data.append(addr_info)
|
||||
continue
|
||||
|
||||
try:
|
||||
os_element = host.findall('os')
|
||||
os_name = os_element[0].findall('osmatch')[0].attrib['name']
|
||||
@ -147,9 +152,13 @@ def list_ip_addresses(data):
|
||||
ip_list = []
|
||||
for item in data:
|
||||
ip_list.append(item[0])
|
||||
|
||||
sorted_set = sorted(set(ip_list))
|
||||
addr_list = []
|
||||
for ip in sorted_set:
|
||||
print(ip)
|
||||
addr_list.append(ip)
|
||||
|
||||
return addr_list
|
||||
|
||||
|
||||
def print_web_ports(data):
|
||||
@ -242,7 +251,9 @@ def main():
|
||||
if args.csv:
|
||||
parse_to_csv(data)
|
||||
if args.ip_addresses:
|
||||
list_ip_addresses(data)
|
||||
addrs = list_ip_addresses(data)
|
||||
for addr in addrs:
|
||||
print(addr)
|
||||
if args.print_all:
|
||||
print_data(data)
|
||||
if args.filter_by_port:
|
||||
@ -282,4 +293,4 @@ if __name__ == '__main__':
|
||||
exit()
|
||||
|
||||
csv_name = args.csv
|
||||
main()
|
||||
main()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user