Fixed wrongly named alert definitions

This commit is contained in:
Matteo Biscosi 2021-01-28 19:14:02 +01:00
parent 10a78cdca9
commit d42e34359e
6 changed files with 366 additions and 0 deletions

View file

@ -0,0 +1,77 @@
--
-- (C) 2019-20 - ntop.org
--
local alert_keys = require "alert_keys"
local status_keys = require "status_keys"
-- Import the classes library.
local classes = require "classes"
-- Make sure to import the Superclass!
local alert = require "alert"
-- ##############################################
local external_alert = classes.class(alert)
-- ##############################################
external_alert.meta = {
alert_key = alert_keys.ntopng.alert_external,
status_key = status_keys.ntopng.status_external_alert,
i18n_title = "alerts_dashboard.external_alert",
icon = "fas fa-eye",
}
-- #######################################################
-- @brief Prepare an alert table used to generate the alert
-- @param info A generic table decoded from a JSON originated at the external alert source
-- @return A table with the alert built
function external_alert:init(info)
-- Call the parent constructor
self.super:init()
self.alert_type_params = info
end
-- #######################################################
local function formatIDSAlert(alert)
local alert_consts = require "alert_consts"
local signature = (alert and alert.signature)
local category = (alert and alert.category)
local signature_info = (signature and signature:split(" "));
local maker = (signature_info and table.remove(signature_info, 1))
local scope = (signature_info and table.remove(signature_info, 1))
local msg = (signature_info and table.concat(signature_info, " "))
if maker and alert_consts.ids_rule_maker[maker] then
maker = alert_consts.ids_rule_maker[maker]
end
return i18n("flow_details.ids_alert", { scope=scope, msg=msg, maker=maker })
end
-- #######################################################
function external_alert.format(ifid, alert, alert_type_params)
local res = i18n("alerts_dashboard.external_alert")
if not alert_type_params then
return res
end
-- Available fields:
-- alert_type_params.source (e.g. suricata)
-- alert_type_params.severity_id (custom severity)
-- alert_type_params.alert (alert metadata)
if alert_type_params.source == "suricata" then
res = formatIDSAlert(alert_type_params.alert)
end
return res
end
-- #######################################################
return external_alert

View file

@ -0,0 +1,66 @@
--
-- (C) 2019-21 - ntop.org
--
-- ##############################################
local alert_keys = require "alert_keys"
local status_keys = require "status_keys"
-- Import the classes library.
local classes = require "classes"
-- Make sure to import the Superclass!
local alert = require "alert"
-- ##############################################
local alert_tls_old_version = classes.class(alert)
-- ##############################################
alert_tls_old_version.meta = {
status_key = status_keys.ntopng.status_tls_old_protocol_version,
alert_key = alert_keys.ntopng.alert_tls_old_protocol_version,
i18n_title = "flow_details.tls_old_protocol_version",
icon = "fas fa-exclamation",
}
-- ##############################################
-- @brief Prepare an alert table used to generate the alert
-- @param tls_version A number indicating the TLS version detected, or nil when version is not available
-- @return A table with the alert built
function alert_tls_old_version:init(tls_version)
-- Call the parent constructor
self.super:init()
self.alert_type_params = {
tls_version = tls_version,
}
end
-- #######################################################
-- @brief Format an alert into a human-readable string
-- @param ifid The integer interface id of the generated alert
-- @param alert The alert description table, including alert data such as the generating entity, timestamp, granularity, type
-- @param alert_type_params Table `alert_type_params` as built in the `:init` method
-- @return A human-readable string
function alert_tls_old_version.format(ifid, alert, alert_type_params)
local msg = i18n("flow_details.tls_old_protocol_version")
if(alert_type_params and alert_type_params.tls_version) then
local ver_str = ntop.getTLSVersionName(alert_type_params.tls_version)
if(ver_str == nil) then
ver_str = string.format("%u", alert_type_params.tls_version)
end
msg = msg .. " (" .. ver_str .. ")"
end
return(msg)
end
-- #######################################################
return alert_tls_old_version

View file

@ -0,0 +1,58 @@
--
-- (C) 2019-21 - ntop.org
--
-- ##############################################
local alert_keys = require "alert_keys"
local status_keys = require "status_keys"
-- Import the classes library.
local classes = require "classes"
-- Make sure to import the Superclass!
local alert = require "alert"
-- ##############################################
local alert_unexpected_dhcp_server = classes.class(alert)
-- ##############################################
alert_unexpected_dhcp_server.meta = {
status_key = status_keys.ntopng.status_unexpected_dhcp_server,
alert_key = alert_keys.ntopng.alert_unexpected_dhcp_server,
i18n_title = "unexpected_dhcp.alert_unexpected_dhcp_title",
icon = "fas fa-exclamation",
has_victim = true,
has_attacker = true,
}
-- ##############################################
-- @brief Prepare an alert table used to generate the alert
-- @param one_flow_param The first alert param
-- @param another_flow_param The second alert param
-- @return A table with the alert built
function alert_unexpected_dhcp_server:init(client_ip, server_ip)
-- Call the parent constructor
self.super:init()
self.alert_type_params = {
client_ip = client_ip,
server_ip = server_ip
}
end
-- #######################################################
-- @brief Format an alert into a human-readable string
-- @param ifid The integer interface id of the generated alert
-- @param alert The alert description table, including alert data such as the generating entity, timestamp, granularity, type
-- @param alert_type_params Table `alert_type_params` as built in the `:init` method
-- @return A human-readable string
function alert_unexpected_dhcp_server.format(ifid, alert, alert_type_params)
return(i18n("unexpected_dhcp.status_unexpected_dhcp_description", { server=alert_type_params.server_ip} ))
end
-- #######################################################
return alert_unexpected_dhcp_server

View file

@ -0,0 +1,58 @@
--
-- (C) 2019-21 - ntop.org
--
-- ##############################################
local alert_keys = require "alert_keys"
local status_keys = require "status_keys"
-- Import the classes library.
local classes = require "classes"
-- Make sure to import the Superclass!
local alert = require "alert"
-- ##############################################
local alert_unexpected_dns_server = classes.class(alert)
-- ##############################################
alert_unexpected_dns_server.meta = {
status_key = status_keys.ntopng.status_unexpected_dns_server,
alert_key = alert_keys.ntopng.alert_unexpected_dns_server,
i18n_title = "unexpected_dns.alert_unexpected_dns_title",
icon = "fas fa-exclamation",
has_victim = true,
has_attacker = true,
}
-- ##############################################
-- @brief Prepare an alert table used to generate the alert
-- @param one_flow_param The first alert param
-- @param another_flow_param The second alert param
-- @return A table with the alert built
function alert_unexpected_dns_server:init(client_ip, server_ip)
-- Call the parent constructor
self.super:init()
self.alert_type_params = {
client_ip = client_ip,
server_ip = server_ip
}
end
-- #######################################################
-- @brief Format an alert into a human-readable string
-- @param ifid The integer interface id of the generated alert
-- @param alert The alert description table, including alert data such as the generating entity, timestamp, granularity, type
-- @param alert_type_params Table `alert_type_params` as built in the `:init` method
-- @return A human-readable string
function alert_unexpected_dns_server.format(ifid, alert, alert_type_params)
return(i18n("unexpected_dns.status_unexpected_dns_description", { server=alert_type_params.server_ip} ))
end
-- #######################################################
return alert_unexpected_dns_server

View file

@ -0,0 +1,58 @@
--
-- (C) 2019-21 - ntop.org
--
-- ##############################################
local alert_keys = require "alert_keys"
local status_keys = require "status_keys"
-- Import the classes library.
local classes = require "classes"
-- Make sure to import the Superclass!
local alert = require "alert"
-- ##############################################
local alert_unexpected_ntp_server = classes.class(alert)
-- ##############################################
alert_unexpected_ntp_server.meta = {
status_key = status_keys.ntopng.status_unexpected_ntp_server,
alert_key = alert_keys.ntopng.alert_unexpected_ntp_server,
i18n_title = "unexpected_ntp.alert_unexpected_ntp_title",
icon = "fas fa-exclamation",
has_victim = true,
has_attacker = true,
}
-- ##############################################
-- @brief Prepare an alert table used to generate the alert
-- @param one_flow_param The first alert param
-- @param another_flow_param The second alert param
-- @return A table with the alert built
function alert_unexpected_ntp_server:init(client_ip, server_ip)
-- Call the parent constructor
self.super:init()
self.alert_type_params = {
client_ip = client_ip,
server_ip = server_ip
}
end
-- #######################################################
-- @brief Format an alert into a human-readable string
-- @param ifid The integer interface id of the generated alert
-- @param alert The alert description table, including alert data such as the generating entity, timestamp, granularity, type
-- @param alert_type_params Table `alert_type_params` as built in the `:init` method
-- @return A human-readable string
function alert_unexpected_ntp_server.format(ifid, alert, alert_type_params)
return(i18n("unexpected_ntp.status_unexpected_ntp_description", { server=alert_type_params.server_ip} ))
end
-- #######################################################
return alert_unexpected_ntp_server

View file

@ -0,0 +1,49 @@
--
-- (C) 2019-21 - ntop.org
--
-- ##############################################
local alert_keys = require "alert_keys"
local status_keys = require "status_keys"
-- Import the classes library.
local classes = require "classes"
-- Make sure to import the Superclass!
local alert = require "alert"
-- ##############################################
local alert_unexpected_smtp_server = classes.class(alert)
-- ##############################################
alert_unexpected_smtp_server.meta = {
status_key = status_keys.ntopng.status_unexpected_smtp_server,
alert_key = alert_keys.ntopng.alert_unexpected_smtp_server,
i18n_title = "unexpected_smtp.alert_unexpected_smtp_title",
icon = "fas fa-exclamation",
has_victim = true,
has_attacker = true,
}
-- ##############################################
function alert_unexpected_smtp_server:init(client_ip, server_ip)
-- Call the parent constructor
self.super:init()
self.alert_type_params = {
client_ip = client_ip,
server_ip = server_ip
}
end
-- #######################################################
function alert_unexpected_smtp_server.format(ifid, alert, alert_type_params)
return(i18n("unexpected_smtp.status_unexpected_smtp_description", { server=alert_type_params.server_ip} ))
end
-- #######################################################
return alert_unexpected_smtp_server