nmap command path is now computed at runtime

This commit is contained in:
Luca Deri 2023-11-03 21:30:22 +01:00
parent c86a2ecec7
commit df3b2f1d69
5 changed files with 31 additions and 16 deletions

View file

@ -96,30 +96,40 @@ vs_utils.ports_diff_case = {
-- **********************************************************
function vs_utils.is_nmap_installed()
function vs_utils.get_nmap_path()
local path = {
"/usr/bin/nmap",
"/usr/local/bin/nmap",
"/opt/homebrew/bin/nmap"
}
for _,p in pairs(path) do
if(ntop.exists(p)) then
return(p)
end
end
return(nil)
end
-- **********************************************************
function vs_utils.is_nmap_installed()
local module_path = {
"/usr/share/nmap/scripts/",
"/opt/homebrew/share/nmap/scripts/vulscan/",
"/usr/local/share/nmap/scripts/vulscan",
}
for _,p in pairs(path) do
if(ntop.exists(p)) then
-- nmap is present. Now check if vulscan is present
for _,m in pairs(module_path) do
if(ntop.exists(m)) then
return true
end
local path = vs_utils.get_nmap_path()
if(path ~= nil) then
for _,m in pairs(module_path) do
if(ntop.exists(m)) then
return true
end
end
end
return false
end
@ -1550,7 +1560,7 @@ end
-- **********************************************************
function vs_utils.schedule_ondemand_single_host_scan(scan_type, host, ports, scan_id, is_periodicity, is_all)
function vs_utils.schedule_host_scan(scan_type, host, ports, scan_id, is_periodicity, is_all)
local scan = { scan_type = scan_type, host = host, ports = ports, id= scan_id}
vs_utils.set_status_scan(scan_type, host, ports, scan_id, is_periodicity, is_all, vs_utils.scan_status.scheduled)
@ -1746,7 +1756,8 @@ function vs_utils.get_active_hosts(host, cidr)
else
local s = string.split(host, '%.')
local net = s[1].."."..s[2].."."..s[3].."."
local command = 'nmap -sP -n ' .. net .. '1-254 | grep "Nmap scan report for" | cut -d " " -f 5'
local nmap = vs_utils.get_nmap_path()
local command = nmap..' -sP -n ' .. net .. '1-254 | grep "Nmap scan report for" | cut -d " " -f 5'
local out = ntop.execCmd(command)
local l = lines(out)