mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 23:49:33 +00:00
Minor strings changes
This commit is contained in:
parent
eb22e3ae9e
commit
7f17a00a15
2 changed files with 48 additions and 50 deletions
|
|
@ -10,7 +10,7 @@
|
|||
-- https://geekflare.com/nmap-vulnerability-scan/
|
||||
-- cd /usr/share/nmap/scripts/
|
||||
-- git clone https://github.com/scipag/vulscan.git
|
||||
-- ln -s `pwd`/scipag_vulscan /usr/share/nmap/scripts/vulscan
|
||||
-- ln -s `pwd`/scipag_vulscan /usr/share/nmap/scripts/vulscan
|
||||
-- cd vulscan/utilities/updater/
|
||||
-- chmod +x updateFiles.sh
|
||||
-- ./updateFiles.sh
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
-- Example:
|
||||
-- nmap -sV --script vulscan --script-args vulscandb=openvas.csv <target> -p 80,233
|
||||
--
|
||||
--
|
||||
--
|
||||
-- exploitdb.csv
|
||||
-- osvdb.csv
|
||||
-- securitytracker.csv
|
||||
|
|
@ -49,7 +49,7 @@ local vs_utils = {}
|
|||
|
||||
-- **********************************************************
|
||||
|
||||
function vs_utils.get_host_hash_key(host, scan_type)
|
||||
function vs_utils.get_host_hash_key(host, scan_type)
|
||||
return string.format("%s-%s",host,scan_type)
|
||||
end
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ function vs_utils.is_nmap_installed()
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ end
|
|||
|
||||
local function lines(str)
|
||||
local result = {}
|
||||
|
||||
|
||||
for line in str:gmatch '[^\n]+' do
|
||||
table.insert(result, line)
|
||||
end
|
||||
|
|
@ -119,7 +119,7 @@ local function check_differences(host, scan_type, old_data, new_data)
|
|||
new_num_ports = new_data.ports or 0
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
local num_cve_solved = 0
|
||||
local num_new_cve_issues = 0
|
||||
local cve_solved = {}
|
||||
|
|
@ -135,7 +135,7 @@ local function check_differences(host, scan_type, old_data, new_data)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Checking the new vulnerabilities
|
||||
for _, cve in ipairs(new_data.cve or {}) do
|
||||
-- If the new table does not contains the cve it means that it is solved
|
||||
|
|
@ -176,12 +176,12 @@ function vs_utils.cleanup_nmap_result(scan_result, scan_type)
|
|||
scan_result = scan_result:gsub("_", "")
|
||||
|
||||
scan_result = lines(scan_result)
|
||||
|
||||
for i=1,4 do
|
||||
|
||||
for i=1,4 do
|
||||
table.remove(scan_result, 1)
|
||||
end
|
||||
|
||||
for i=1,3 do
|
||||
|
||||
for i=1,3 do
|
||||
table.remove(scan_result, #scan_result)
|
||||
end
|
||||
|
||||
|
|
@ -189,24 +189,24 @@ function vs_utils.cleanup_nmap_result(scan_result, scan_type)
|
|||
local num_vulnerabilities = 0
|
||||
local cve = {}
|
||||
local scan_out = {}
|
||||
|
||||
|
||||
for _,l in pairs(scan_result) do
|
||||
local t = string.find(l, "/tcp ") or 0
|
||||
local u = string.find(l, "/udp ") or 0
|
||||
|
||||
|
||||
if((t > 0) or (u > 0)) then
|
||||
num_open_ports = num_open_ports + 1
|
||||
end
|
||||
|
||||
if(string.sub(l, 1, 2) == " [") then
|
||||
local c = string.split(string.sub(l,3), "]")
|
||||
|
||||
|
||||
if(scan_type == "cve") then
|
||||
l = '[<A HREF="https://nvd.nist.gov/vuln/detail/'..c[1]..'">'..c[1]..'</A>]'..c[2]
|
||||
elseif(scan_type == "openvas") then
|
||||
l = '[<A HREF="https://vulners.com/openvas/OPENVAS:'..c[1]..'">'..c[1]..'</A>]'..c[2]
|
||||
end
|
||||
|
||||
|
||||
table.insert(cve, c[1])
|
||||
num_vulnerabilities = num_vulnerabilities + 1
|
||||
end
|
||||
|
|
@ -266,8 +266,6 @@ function vs_utils.save_host_to_scan(scan_type, host, scan_result, last_scan_time
|
|||
ntop.rpushCache(scanned_hosts_changes_key, json.encode(host_info_to_cache))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
local new_item = {
|
||||
host = host,
|
||||
|
|
@ -280,18 +278,18 @@ function vs_utils.save_host_to_scan(scan_type, host, scan_result, last_scan_time
|
|||
|
||||
if last_scan_time or last_duration then
|
||||
local time_formatted = format_utils.formatPastEpochShort(last_scan_time)
|
||||
|
||||
|
||||
if last_duration <= 0 then
|
||||
last_duration = 1
|
||||
end
|
||||
|
||||
|
||||
last_duration = secondsToTime(last_duration)
|
||||
new_item.last_scan = {
|
||||
epoch = last_scan_time,
|
||||
time = time_formatted,
|
||||
duration = last_duration
|
||||
}
|
||||
|
||||
|
||||
if is_ok_last_scan then
|
||||
new_item.is_ok_last_scan = is_ok_last_scan
|
||||
end
|
||||
|
|
@ -306,10 +304,10 @@ function vs_utils.save_host_to_scan(scan_type, host, scan_result, last_scan_time
|
|||
local result = handle:write(scan_result)
|
||||
handle:close()
|
||||
end
|
||||
|
||||
|
||||
--saved_hosts[#saved_hosts+1] = new_item
|
||||
ntop.setHashCache(host_to_scan_key, host_hash_key, json.encode(new_item))
|
||||
|
||||
|
||||
--ntop.setCache(host_to_scan_key, json.encode(saved_hosts))
|
||||
return 1
|
||||
end
|
||||
|
|
@ -338,7 +336,7 @@ end
|
|||
|
||||
-- Function to retrieve hosts list to scan just for status_info
|
||||
function vs_utils.check_in_progress_status()
|
||||
|
||||
|
||||
local hash_keys = ntop.getHashKeysCache(host_to_scan_key)
|
||||
|
||||
if hash_keys then
|
||||
|
|
@ -350,7 +348,7 @@ function vs_utils.check_in_progress_status()
|
|||
-- Check IN PROGRESS --> FIX ME with enums
|
||||
if hash_value and hash_value.is_ok_last_scan == 4 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -368,7 +366,7 @@ function vs_utils.retrieve_hosts_scan_result(scan_type, host)
|
|||
local handle = io.open(path, "r")
|
||||
local result = handle:read("*a")
|
||||
handle:close()
|
||||
|
||||
|
||||
return result
|
||||
else
|
||||
return ""
|
||||
|
|
@ -383,7 +381,7 @@ function vs_utils.delete_host_to_scan(host, scan_type, all)
|
|||
|
||||
ntop.delCache(host_to_scan_key)
|
||||
else
|
||||
|
||||
|
||||
local host_hash_key = vs_utils.get_host_hash_key(host, scan_type)
|
||||
ntop.delHashCache(host_to_scan_key, host_hash_key)
|
||||
end
|
||||
|
|
@ -397,11 +395,11 @@ end
|
|||
function vs_utils.retrieve_scan_types()
|
||||
local scan_types = vs_utils.list_scan_modules()
|
||||
local ret = {}
|
||||
|
||||
|
||||
for _,scan_type in ipairs(scan_types) do
|
||||
table.insert(ret, { id = scan_type, label = i18n("hosts_stats.page_scan_hosts.scan_type_list."..scan_type) })
|
||||
end
|
||||
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
|
|
@ -411,7 +409,7 @@ function vs_utils.list_scan_modules()
|
|||
local dirs = ntop.getDirs()
|
||||
local basedir = dirs.scriptdir .. "/lua/modules/vulnerability_scan/modules"
|
||||
local modules = {}
|
||||
|
||||
|
||||
for name in pairs(ntop.readdir(basedir)) do
|
||||
if(ends(name, ".lua")) then
|
||||
name = string.sub(name, 1, string.len(name)-4) -- remove .lua trailer
|
||||
|
|
@ -472,7 +470,7 @@ function vs_utils.schedule_host_scan(scan_type, host, ports)
|
|||
vs_utils.set_status_scan(scan_type, host, ports)
|
||||
|
||||
ntop.rpushCache(host_scan_queue_key, json.encode(scan))
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
@ -486,7 +484,7 @@ function vs_utils.schedule_all_hosts_scan(scan_type, host, ports)
|
|||
vs_utils.schedule_host_scan(scan_info.scan_type, scan_info.host, scan_info.ports)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
@ -505,7 +503,7 @@ function vs_utils.schedule_periodic_scan(periodicity)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
@ -524,7 +522,7 @@ function vs_utils.process_oldest_scheduled_scan()
|
|||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- **********************************************************
|
||||
|
|
@ -534,10 +532,10 @@ function vs_utils.process_all_scheduled_scans(max_num_scans)
|
|||
local num = 0
|
||||
|
||||
if(max_num_scans == nil) then max_num_scans = 9999 end
|
||||
|
||||
|
||||
while(max_num_scans > 0) do
|
||||
local res = vs_utils.process_oldest_scheduled_scan()
|
||||
|
||||
|
||||
if(res == false) then
|
||||
break
|
||||
else
|
||||
|
|
@ -556,7 +554,7 @@ function vs_utils.get_active_hosts(host, cidr)
|
|||
local result = {}
|
||||
|
||||
cidr = tonumber(cidr)
|
||||
|
||||
|
||||
if((cidr == 32) or (cidr == 128)
|
||||
or (host:find('.') == nil) -- not dots in IP, it looks symbolic
|
||||
or (string.sub(host, -1) ~= "0") -- last digit is not 0, so let's assume /32
|
||||
|
|
@ -565,18 +563,18 @@ 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 command = 'nmap -sP -n ' .. net .. '1-254 | grep "Nmap scan report for" | cut -d " " -f 5'
|
||||
local handle = io.popen(command)
|
||||
local out = handle:read("*a")
|
||||
local l = lines(out)
|
||||
|
||||
handle:close()
|
||||
|
||||
|
||||
for _,h in pairs(l) do
|
||||
result[#result+1] = h
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue