[VS] Add the commonly used subnets. (#7943)

This commit is contained in:
Nicolo Maio 2024-03-25 11:41:17 +01:00
parent 06af740b92
commit 0aa1cacb71
6 changed files with 88 additions and 24 deletions

View file

@ -2567,10 +2567,25 @@ function vs_utils.exec_netscan(host, cidr)
) then
result[#result+1] = host -- return it as is
else
local net_range = '1-254'
if (cidr == 25) then
net_range = '1-127'
elseif (cidr == 26) then
net_range = '1-63'
elseif (cidr == 27) then
net_range = '1-31'
elseif (cidr == 28) then
net_range = '1-15'
elseif (cidr == 29) then
net_range = '1-7'
elseif (cidr == 30) then
net_range = '1-3'
end
local s = string.split(host, '%.')
local net = s[1].."."..s[2].."."..s[3].."."
local nmap = vs_utils.get_nmap_path()
local command = nmap..' -sP -n ' .. net .. '1-254'
local command = nmap..' -sP -n ' .. net .. net_range
begin_epoch = os.time()
out = ntop.execCmd(command)