Refactorised code

This commit is contained in:
Luca Deri 2023-10-22 08:23:46 +02:00
parent 0fe08f4848
commit 616682496a
7 changed files with 43 additions and 167 deletions

View file

@ -1716,7 +1716,8 @@ end
function vs_utils.runCommand(scan_command, use_coroutines)
local result
local debug_me = true
if ntop.isWindows() then
local handle = io.popen(scan_command)
result = handle:read("*a")
@ -1748,6 +1749,34 @@ function vs_utils.runCommand(scan_command, use_coroutines)
return result
end
-- **********************************************************
function vs_utils.nmap_scan_host(command, host_ip, ports, use_coroutines)
local scan_command
local debug_me = false
-- IPv6 check
if(string.contains(host_ip, ':')) then command = command .. " -6 " end
if(not(isEmptyString(ports))) then command = command .. " -p " .. ports end
scan_command = string.format("%s %s", command, host_ip)
-- io.write("[UDP] "..scan_command.."\n")
local begin_epoch = os.time()
local result = vs_utils.runCommand(scan_command, use_coroutines)
local duration = os.time() - begin_epoch
local scan_ok = true
local num_open_ports
local num_vulnerabilities_found
local cve
local tcp_ports
local udp_ports
result, num_open_ports, num_vulnerabilities_found, cve, udp_ports, tcp_ports = vs_utils.cleanup_nmap_result(result, self.name)
return begin_epoch, result, duration, scan_ok, num_open_ports, num_vulnerabilities_found, cve, udp_ports, tcp_ports
end
-- **********************************************************