[VS] Fix discrepancies check. (#8066)

This commit is contained in:
Nicolo Maio 2023-11-30 09:58:04 +01:00
parent a5a2146cfb
commit ffdff17ebd
3 changed files with 18 additions and 5 deletions

View file

@ -31,8 +31,13 @@ end
function vs_module:scan_host(host_ip, ports, use_coroutines)
local nmap = vs_utils.get_nmap_path()
local command = nmap.." -sV --script=vulscan/vulscan.nse --script-args vulscandb=cve.csv" -- <target> -p 80,233
local now,result,duration,scan_result,num_open_ports,num_vulnerabilities_found, cve, udp_ports, tcp_ports = vs_utils.nmap_scan_host(command, host_ip, ports, use_coroutines, self.name)
return now,result,duration,scan_result,num_open_ports,num_vulnerabilities_found, cve, udp_ports, tcp_ports
-- check if host is up and running before the cve scan
local is_up, scan_duration, start_scan, end_scan = vs_utils.nmap_check_host(host_ip, use_coroutines)
if (is_up) then
local now,result,duration,scan_result,num_open_ports,num_vulnerabilities_found, cve, udp_ports, tcp_ports = vs_utils.nmap_scan_host(command, host_ip, ports, use_coroutines, self.name)
return now,result,duration,scan_result,num_open_ports,num_vulnerabilities_found, cve, udp_ports, tcp_ports
end
return start_scan,i18n("hosts_stats.page_scan_hosts.host_is_not_up_and_running"),scan_duration,vs_utils.scan_status.failed,0,0,{},{},{}
end
-- ##############################################

View file

@ -33,8 +33,13 @@ end
function vs_module:scan_host(host_ip, ports, use_coroutines)
local nmap = vs_utils.get_nmap_path()
local command = nmap.." -sV --script=vulscan/vulscan.nse" -- <target> -p 80,233
local now,result,duration,scan_result,num_open_ports,num_vulnerabilities_found, cve, udp_ports, tcp_ports = vs_utils.nmap_scan_host(command, host_ip, ports, use_coroutines, self.name)
return now,result,duration,scan_result,num_open_ports,num_vulnerabilities_found, cve, udp_ports, tcp_ports
local is_up, scan_duration, start_scan, end_scan = vs_utils.nmap_check_host(host_ip, use_coroutines)
if (is_up) then
local now,result,duration,scan_result,num_open_ports,num_vulnerabilities_found, cve, udp_ports, tcp_ports = vs_utils.nmap_scan_host(command, host_ip, ports, use_coroutines, self.name)
return now,result,duration,scan_result,num_open_ports,num_vulnerabilities_found, cve, udp_ports, tcp_ports
end
return start_scan,i18n("hosts_stats.page_scan_hosts.host_is_not_up_and_running"),scan_duration,vs_utils.scan_status.failed,0,0,{},{},{}
end
-- ##############################################

View file

@ -1231,7 +1231,10 @@ function vs_utils.save_host_to_scan(scan_type, host, scan_result, last_scan_time
end
local host_info_differences
if trigger_alert and old_data and (not is_edit) then
if trigger_alert and old_data and (not is_edit) and
-- old scan and new scan must be successfully to perform discrepancies check
(old_data.is_ok_last_scan == vs_utils.scan_status.ok and new_item.is_ok_last_scan == vs_utils.scan_status.ok)
then
local already_scanned = (old_data.last_scan and old_data.last_scan.epoch)
if already_scanned then