mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-06 03:45:26 +00:00
64 lines
No EOL
1.7 KiB
Lua
64 lines
No EOL
1.7 KiB
Lua
--
|
|
-- (C) 2013-23 - ntop.org
|
|
--
|
|
|
|
--
|
|
-- Module used to build exec vulnerability scan
|
|
--
|
|
|
|
dirs = ntop.getDirs()
|
|
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
|
package.path = dirs.installdir .. "/scripts/lua/modules/host/?.lua;" .. package.path
|
|
package.path = dirs.installdir .. "/scripts/lua/pro/modules/?.lua;" .. package.path
|
|
|
|
local vulnerability_scan = {}
|
|
local scan_utils = require "scan_utils"
|
|
|
|
local debug = false
|
|
|
|
debug = true
|
|
|
|
function vulnerability_scan.scan_host(scan_type, scan_params, ip, save_on_redis)
|
|
|
|
local scan_command = string.format("%s %s %s",scan_type, scan_params, ip)
|
|
local handle = io.popen(scan_command)
|
|
local result = handle:read("*a")
|
|
handle:close()
|
|
local now = os.time()
|
|
if result then
|
|
if debug then
|
|
end
|
|
if save_on_redis then
|
|
scan_utils.save_host_to_scan(scan_type, scan_params, ip, result, now)
|
|
end
|
|
end
|
|
|
|
return 1
|
|
end
|
|
|
|
|
|
function vulnerability_scan.scan_all_host(save_on_redis)
|
|
local host_to_scan_list = scan_utils.retrieve_hosts_to_scan()
|
|
|
|
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 ip = scan_info.host
|
|
local scan_params = scan_info.scan_params
|
|
local scan_command = string.format("%s %s %s",scan_type, scan_params, ip)
|
|
local handle = io.popen(scan_command)
|
|
local result = handle:read("*a")
|
|
handle:close()
|
|
if result then
|
|
if save_on_redis then
|
|
scan_utils.save_host_to_scan(scan_type, scan_params, ip, result, now)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return 1
|
|
end
|
|
|
|
return vulnerability_scan |