From 7d753e816de1581e60ee49e0b973666f45e009c4 Mon Sep 17 00:00:00 2001 From: Damian Krawczyk Date: Sat, 25 Jul 2020 14:54:09 +0200 Subject: [PATCH] v. 0.3.0 --- .gitignore | 2 ++ CHANGELOG.md | 33 +++++++++++++++++++++++++++++++++ CHANGELOG.rst | 19 ------------------- nessus_file_reader/file/file.py | 4 ++-- nessus_file_reader/host/host.py | 23 +++++++++++++++++++++++ nessus_file_reader/scan/scan.py | 4 ++++ nessus_file_reader/utilities.py | 8 ++++++++ nfr_example_script.py | 3 +++ setup.py | 4 ++-- 9 files changed, 77 insertions(+), 23 deletions(-) create mode 100644 CHANGELOG.md delete mode 100644 CHANGELOG.rst diff --git a/.gitignore b/.gitignore index 339b07c..20a5745 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ __pycache__ build dist nessus_file_reader.egg-info +test_files +.vscode \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..dd0d462 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,33 @@ +# Change Log + +This document records all notable changes to [nessus file reader by LimberDuck][1]. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.3.0] - 2020-07-25 + +### Added + +- new function host.netbios_network_name - to get NetBIOS Computer Name, Workgroup / Domain name for given target. + +### Changed + +- possibility to pars network address with mask in target + +## [0.2.0] - 2019-09-09 + +### Added + +- new function plugin.report_item_values - to get list of values for all items with given name e.g. 'cve' + + +## [0.1.0] - 2019-06-23 + +- Initial release + +[0.3.0]: https://github.com/LimberDuck/nessus-file-reader/compare/v0.2.0...v0.3.0 +[0.2.0]: https://github.com/LimberDuck/nessus-file-reader/compare/v0.1.0...v0.2.0 +[0.1.0]: https://github.com/LimberDuck/nessus-file-reader/releases/tag/v0.1.0 + +[1]: https://github.com/LimberDuck/nessus-file-reader \ No newline at end of file diff --git a/CHANGELOG.rst b/CHANGELOG.rst deleted file mode 100644 index 5cfdef0..0000000 --- a/CHANGELOG.rst +++ /dev/null @@ -1,19 +0,0 @@ -========== -Change Log -========== - -This document records all notable changes to `nessus file reader by LimberDuck `_. -This project adheres to `Semantic Versioning `_. - - -0.2.0 (2019-09-09) ---------------------- - -New Features - - new function plugin.report_item_values - to get list of values for all items with given name e.g. 'cve' - - -0.1.0 (2019-06-23) ---------------------- - -* Initial release \ No newline at end of file diff --git a/nessus_file_reader/file/file.py b/nessus_file_reader/file/file.py index 52059fc..529ae7b 100644 --- a/nessus_file_reader/file/file.py +++ b/nessus_file_reader/file/file.py @@ -64,7 +64,7 @@ def nessus_scan_file_root_element(file): :param file: given nessus file :return: root element for this tree. """ - nessus_scan_file = nessus_scan_file_name_with_path(file) - nessus_scan_file_parsed = parse(nessus_scan_file) + + nessus_scan_file_parsed = parse(file) root = nessus_scan_file_parsed.getroot() return root diff --git a/nessus_file_reader/host/host.py b/nessus_file_reader/host/host.py index 37ca0fe..3906725 100644 --- a/nessus_file_reader/host/host.py +++ b/nessus_file_reader/host/host.py @@ -86,6 +86,29 @@ def resolved_fqdn(report_host): return host_fqdn +def netbios_network_name(root, report_host): + """ + Function returns information about NetBIOS Computer Name, Workgroup / Domain name for given target. + :param root: root element of scan file tree + :param report_host: report host element + :return: os for given target + """ + pido_10150 = plugin.plugin_output(root, report_host, '10150') + pido_10150_split = pido_10150.split('\n') + + netbios_computer_name = '' + netbios_domain_name = '' + for netbios_data_split_entry in pido_10150_split: + if 'Computer name' in netbios_data_split_entry: + netbios_computer_name = netbios_data_split_entry.split('=')[0].strip().lower() + + if 'Workgroup / Domain name' in netbios_data_split_entry: + netbios_domain_name = netbios_data_split_entry.split('=')[0].strip().lower() + + return {'netbios_computer_name': netbios_computer_name, + 'netbios_domain_name': netbios_domain_name} + + def detected_os(report_host): """ Function returns information about Operating System for given target. diff --git a/nessus_file_reader/scan/scan.py b/nessus_file_reader/scan/scan.py index 6893d3c..20edbed 100644 --- a/nessus_file_reader/scan/scan.py +++ b/nessus_file_reader/scan/scan.py @@ -242,6 +242,10 @@ def list_of_target_hosts(root): address_range = utilities.ip_range_split(target) for address in address_range: target_hosts_final_list.append(str(address)) + elif re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/\d{1,2}', target): + address_range = utilities.ip_range_split(target) + for address in address_range: + target_hosts_final_list.append(str(address)) else: target_hosts_final_list.append(target) else: diff --git a/nessus_file_reader/utilities.py b/nessus_file_reader/utilities.py index d291e13..2139c20 100644 --- a/nessus_file_reader/utilities.py +++ b/nessus_file_reader/utilities.py @@ -39,4 +39,12 @@ def ip_range_split(ip_range): ip_addresses.append(first_address) first_address += 1 + elif re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/\d{1,2}', ip_range): + ip_network_hosts = ipaddress.ip_network(ip_range).hosts() + ip_network_hosts_list = list(ip_network_hosts) + + for ip in ip_network_hosts_list: + # print(ip) + ip_addresses.append(ip) + return ip_addresses diff --git a/nfr_example_script.py b/nfr_example_script.py index 2cf81fc..63c04d7 100644 --- a/nfr_example_script.py +++ b/nfr_example_script.py @@ -124,6 +124,9 @@ def nfr_example_simple(): pidos_14272 = nfr.plugin.plugin_outputs(root, report_host, '14272') print(f'All findings for Netstat Portscanner (SSH): \n{pidos_14272}') + netbios_network_name = nfr.host.netbios_network_name(root, report_host) + print(f'Netbios network name {netbios_network_name}') + except Exception as e: print(f'\nUps... ERROR occurred. \n\n {str(e)}') traceback.print_exc() diff --git a/setup.py b/setup.py index ed8f69f..a1fd64c 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="nessus_file_reader", - version="0.2.0", + version="0.3.0", author="Damian Krawczyk", author_email="damian.krawczyk@limberduck.org", description="nessus file reader by LimberDuck (pronounced *ˈlɪm.bɚ dʌk*) is a python module " @@ -16,7 +16,7 @@ url="https://github.com/LimberDuck/nessus-file-reader", packages=setuptools.find_packages(), classifiers=[ - "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Development Status :: 4 - Beta",