mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 15:39:33 +00:00
Added script for triggering periodic scans
This commit is contained in:
parent
ce19759f53
commit
82b3c2faeb
4 changed files with 65 additions and 21 deletions
|
|
@ -55,11 +55,23 @@ function vs_utils.is_nmap_installed()
|
|||
"/usr/local/bin/nmap",
|
||||
"/opt/homebrew/bin/nmap"
|
||||
}
|
||||
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 return true end
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
|
@ -371,19 +383,33 @@ function vs_utils.schedule_all_hosts_scan(scan_type, host, ports)
|
|||
|
||||
if #host_to_scan_list > 0 then
|
||||
for _,scan_info in ipairs(host_to_scan_list) do
|
||||
local scan_type = scan_info.scan_type
|
||||
local host = scan_info.host
|
||||
local ports = scan_info.ports
|
||||
local scan = { scan_type = scan_type, host = host, ports = ports }
|
||||
vs_utils.set_status_scan(scan_type, host, ports)
|
||||
|
||||
ntop.rpushCache(host_scan_queue_key, json.encode(scan))
|
||||
vs_utils.schedule_host_scan(scan_info.scan_type, scan_info.host, scan_info.ports)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- **********************************************************
|
||||
|
||||
-- periodicity can be set to "1day" "1week" "disabled"
|
||||
function vs_utils.schedule_periodic_scan(periodicity)
|
||||
local host_to_scan_list = vs_utils.retrieve_hosts_to_scan()
|
||||
|
||||
if #host_to_scan_list > 0 then
|
||||
for _,scan_info in ipairs(host_to_scan_list) do
|
||||
local frequency = scan_info.scan_frequency
|
||||
|
||||
if(frequency == periodicity) then
|
||||
vs_utils.schedule_host_scan(scan_info.scan_type, scan_info.host, scan_info.ports)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
-- **********************************************************
|
||||
|
||||
-- Process a single host scan request that has been queued
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue