Programming¶
If command-line tool interface is not enough for you or you want to build your own solution you can use nessus file reader (NFR) as a python module:
Import nessus-file-reader module.
import nessus_file_reader as nfr
File functions¶
Use file functions to get details about provided file, e.g., root, file name, file size.
1import nessus_file_reader as nfr
2
3nessus_scan_file = './your_nessus_file.nessus'
4
5root = nfr.file.nessus_scan_file_root_element(nessus_scan_file)
6
7file_name = nfr.file.nessus_scan_file_name_with_path(nessus_scan_file)
8file_size = nfr.file.nessus_scan_file_size_human(nessus_scan_file)
9
10print(f'File name: {file_name}')
11print(f'File size: {file_size}')
Scan functions¶
Use scan functions to get details about provided scan, e.g., report name, number of target/scanned/credentialed hosts, scan time start/end/elapsed and more.
1import nessus_file_reader as nfr
2
3nessus_scan_file = './your_nessus_file.nessus'
4
5root = nfr.file.nessus_scan_file_root_element(nessus_scan_file)
6
7report_name = nfr.scan.report_name(root)
8number_of_target_hosts = nfr.scan.number_of_target_hosts(root)
9number_of_scanned_hosts = nfr.scan.number_of_scanned_hosts(root)
10number_of_scanned_hosts_with_credentialed_checks_yes = nfr.scan.number_of_scanned_hosts_with_credentialed_checks_yes(root)
11scan_time_start = nfr.scan.scan_time_start(root)
12scan_time_end = nfr.scan.scan_time_end(root)
13scan_time_elapsed = nfr.scan.scan_time_elapsed(root)
14
15print(f' Report name: {report_name}')
16print(f' Number of target/scanned/credentialed hosts: {number_of_target_hosts}/{number_of_scanned_hosts}/{number_of_scanned_hosts_with_credentialed_checks_yes}')
17print(f' Scan time START - END (ELAPSED): {scan_time_start} - {scan_time_end} ({scan_time_elapsed})')
Host functions¶
Use host functions to get details about hosts from provided scan, e.g., report hosts names, operating system, hosts scan time start/end/elapsed, number of Critical/High/Medium/Low/None findings and more.
1import nessus_file_reader as nfr
2
3nessus_scan_file = './your_nessus_file.nessus'
4
5root = nfr.file.nessus_scan_file_root_element(nessus_scan_file)
6
7for report_host in nfr.scan.report_hosts(root):
8 report_host_name = nfr.host.report_host_name(report_host)
9 report_host_os = nfr.host.detected_os(report_host)
10 report_host_scan_time_start = nfr.host.host_time_start(report_host)
11 report_host_scan_time_end = nfr.host.host_time_end(report_host)
12 report_host_scan_time_elapsed = nfr.host.host_time_elapsed(report_host)
13 report_host_critical = nfr.host.number_of_plugins_per_risk_factor(report_host, 'Critical')
14 report_host_high = nfr.host.number_of_plugins_per_risk_factor(report_host, 'High')
15 report_host_medium = nfr.host.number_of_plugins_per_risk_factor(report_host, 'Medium')
16 report_host_low = nfr.host.number_of_plugins_per_risk_factor(report_host, 'Low')
17 report_host_none = nfr.host.number_of_plugins_per_risk_factor(report_host, 'None')
18
19 print(f' Report host name: {report_host_name}')
20 print(f' Report host OS: {report_host_os}')
21 print(f' Host scan time START - END (ELAPSED): {report_host_scan_time_start} - {report_host_scan_time_end} ({report_host_scan_time_elapsed})')
22 print(f' Critical/High/Medium/Low/None findings: {report_host_critical}/{report_host_high}/{report_host_medium}/{report_host_low}/{report_host_none}')
Plugin functions¶
Use plugin functions to get details about plugins reported in provided scan, e.g., plugins ID, plugins risk factor, plugins name.
1import nessus_file_reader as nfr
2
3nessus_scan_file = './your_nessus_file.nessus'
4
5root = nfr.file.nessus_scan_file_root_element(nessus_scan_file)
6
7for report_host in nfr.scan.report_hosts(root):
8 report_items_per_host = nfr.host.report_items(report_host)
9 for report_item in report_items_per_host:
10 plugin_id = int(nfr.plugin.report_item_value(report_item, 'pluginID'))
11 risk_factor = nfr.plugin.report_item_value(report_item, 'risk_factor')
12 plugin_name = nfr.plugin.report_item_value(report_item, 'pluginName')
13
14 print('\t', plugin_id, ' \t\t\t', risk_factor, ' \t\t\t', plugin_name)
If you want to get output for interesting you plugin, e.g., “Nessus Scan Information” use below function
1import nessus_file_reader as nfr
2
3nessus_scan_file = './your_nessus_file.nessus'
4
5root = nfr.file.nessus_scan_file_root_element(nessus_scan_file)
6
7for report_host in nfr.scan.report_hosts(root):
8 pido_19506 = nfr.plugin.plugin_output(root, report_host, '19506')
9
10 print(f'Nessus Scan Information Plugin Output:\n{pido_19506}')
If you know that interesting you plugin occurs more than ones for particular host, e.g., “Netstat Portscanner (SSH)” use below function
1import nessus_file_reader as nfr
2
3nessus_scan_file = './your_nessus_file.nessus'
4
5root = nfr.file.nessus_scan_file_root_element(nessus_scan_file)
6
7for report_host in nfr.scan.report_hosts(root):
8 pidos_14272 = nfr.plugin.plugin_outputs(root, report_host, '14272')
9
10 print(f'All findings for Netstat Portscanner (SSH): \n{pidos_14272}')