mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 02:16:39 +00:00
[VS] Add IPv4 Network Scan. (#8062)
This commit is contained in:
parent
fd418514d0
commit
d1dc23d23b
7 changed files with 236 additions and 36 deletions
|
|
@ -0,0 +1,58 @@
|
|||
--
|
||||
-- (C) 2020-23 - ntop.org
|
||||
--
|
||||
|
||||
local vs_module = {}
|
||||
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/vulnerability_scan/?.lua;" .. package.path
|
||||
local vs_utils = require("vs_utils")
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function vs_module:new()
|
||||
local obj = { name = "ipv4_netscan", cidr = 24 }
|
||||
|
||||
setmetatable(obj, self)
|
||||
self.__index = self
|
||||
|
||||
return obj
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function vs_module:is_enabled()
|
||||
return(vs_utils.is_nmap_installed())
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- NOTE: ports are comma separated (e.g 80,443)
|
||||
|
||||
function vs_module:scan_host(network_ip, ports, use_coroutines)
|
||||
local secondary_scan_type, scan_frequency = vs_utils.get_network_pref_value(network_ip, self.name)
|
||||
|
||||
local discovered_hosts,scan_out,start_scan,scan_duration,scan_ok = vs_utils.exec_netscan(network_ip, self.cidr)
|
||||
|
||||
for _,host_ip in ipairs(discovered_hosts) do
|
||||
if (vs_utils.isVSConfiguredHost(host_ip)) then
|
||||
------- host aleady configured case -------
|
||||
else
|
||||
------- new host not found case -------
|
||||
|
||||
-- trigger alert host not configured
|
||||
vs_utils.triggerHostNotConfiguredAlert(host_ip)
|
||||
|
||||
-- add and scan new host
|
||||
local result,id = vs_utils.add_host_pref(secondary_scan_type, host_ip, ports, scan_frequency, nil)
|
||||
vs_utils.schedule_ondemand_single_host_scan(secondary_scan_type,host_ip,ports,id,false,false,false)
|
||||
end
|
||||
end
|
||||
|
||||
return start_scan,scan_out,scan_duration,scan_ok,0--[[num_open_ports]],0--[[num_vulnerabilities_found]],{}--[[cve]],{}--[[udp_ports]],{}--[[tcp_ports]]
|
||||
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
return vs_module
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue