-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
13 changed files
with
267 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* | ||
* (C) 2013-23 - ntop.org | ||
* | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
* | ||
*/ | ||
|
||
#ifndef _RARE_DESTINATION_FLOW_ALERT_H_ | ||
#define _RARE_DESTINATION_FLOW_ALERT_H_ | ||
|
||
#include "ntop_includes.h" | ||
|
||
class RareDestinationAlert : public FlowAlert { | ||
private: | ||
ndpi_serializer *getAlertJSON(ndpi_serializer* serializer); | ||
|
||
public: | ||
static FlowAlertType getClassType() { return { flow_alert_rare_destination, alert_category_network }; } | ||
static u_int8_t getDefaultScore() { return SCORE_LEVEL_NOTICE; }; | ||
|
||
RareDestinationAlert(FlowCheck *c, Flow *f) : FlowAlert(c, f) {}; | ||
~RareDestinationAlert() {}; | ||
|
||
FlowAlertType getAlertType() const { return getClassType(); } | ||
}; | ||
|
||
#endif /* _RARE_DESTINATION_FLOW_ALERT_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* | ||
* (C) 2013-23 - ntop.org | ||
* | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
* | ||
*/ | ||
|
||
#ifndef _RARE_DESTINATION_H_ | ||
#define _RARE_DESTINATION_H_ | ||
|
||
#include "ntop_includes.h" | ||
|
||
|
||
class RareDestination : public FlowCheck { | ||
public: | ||
RareDestination() : FlowCheck(ntopng_edition_community, | ||
true /* Packet Interfaces only */, true /* Exclude for nEdge */, false /* Only for nEdge */, | ||
true /* has_protocol_detected */, false /* has_periodic_update */, false /* has_flow_end */) {}; | ||
virtual ~RareDestination() {}; | ||
|
||
void protocolDetected(Flow *f); | ||
FlowAlert *buildAlert(Flow *f); | ||
|
||
std::string getName() const { return(std::string("rare_destination")); } | ||
}; | ||
|
||
#endif /* _RARE_DESTINATION_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
scripts/lua/modules/alert_definitions/flow/alert_rare_destination.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
-- | ||
-- (C) 2019-23 - ntop.org | ||
-- | ||
|
||
-- ############################################## | ||
|
||
local flow_alert_keys = require "flow_alert_keys" | ||
-- Import the classes library. | ||
local classes = require "classes" | ||
-- Make sure to import the Superclass! | ||
local alert = require "alert" | ||
|
||
-- ############################################## | ||
|
||
local alert_rare_destination = classes.class(alert) | ||
|
||
-- ############################################## | ||
|
||
alert_rare_destination.meta = { | ||
alert_key = flow_alert_keys.flow_alert_rare_destination, | ||
i18n_title = "flow_checks_config.rare_destination", | ||
icon = "fas fa-fw fa-exclamation", | ||
} | ||
|
||
-- ############################################## | ||
|
||
-- @brief Prepare an alert table used to generate the alert | ||
-- @return A table with the alert built | ||
function alert_rare_destination:init() | ||
-- Call the parent constructor | ||
self.super:init() | ||
end | ||
|
||
-- ####################################################### | ||
|
||
function alert_rare_destination.format(ifid, alert, alert_type_params) | ||
if not alert_type_params then | ||
tprint("-1-") | ||
return i18n("alerts_dashboard.rare_destination_description", {destination = ""}) | ||
else | ||
local ret = i18n("alerts_dashboard.rare_destination_description", {destination = alert_type_params["destination"]}) | ||
tprint("-2->"..ret) | ||
return(ret) | ||
end | ||
end | ||
|
||
-- ####################################################### | ||
|
||
return alert_rare_destination |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
scripts/lua/modules/check_definitions/flow/rare_destination.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
-- | ||
-- (C) 2019-22 - ntop.org | ||
-- | ||
|
||
local checks = require("checks") | ||
local alerts_api = require "alerts_api" | ||
local alert_consts = require "alert_consts" | ||
local flow_alert_keys = require "flow_alert_keys" | ||
|
||
-- ################################################################# | ||
|
||
local script = { | ||
packet_interface_only = true, | ||
|
||
-- Script category | ||
category = checks.check_categories.network, | ||
|
||
packet_interface_only = true, | ||
nedge_exclude = true, | ||
|
||
-- This script is only for alerts generation | ||
alert_id = flow_alert_keys.flow_alert_low_goodput, | ||
|
||
default_value = { | ||
|
||
}, | ||
|
||
gui = { | ||
i18n_title = "flow_checks.rare_destination_title", | ||
i18n_description = "flow_checks.rare_destination_description", | ||
} | ||
} | ||
|
||
-- ################################################################# | ||
|
||
return script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* | ||
* (C) 2013-23 - ntop.org | ||
* | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
* | ||
*/ | ||
|
||
#include "flow_alerts_includes.h" | ||
|
||
ndpi_serializer* RareDestinationAlert::getAlertJSON(ndpi_serializer* serializer) { | ||
Flow *f = getFlow(); | ||
|
||
if(serializer) | ||
ndpi_serialize_string_string(serializer, "destination", f->getFlowServerInfo()); | ||
|
||
return serializer; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* | ||
* (C) 2013-23 - ntop.org | ||
* | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
* | ||
*/ | ||
|
||
#include "ntop_includes.h" | ||
#include "flow_checks_includes.h" | ||
|
||
/* ***************************************************** */ | ||
|
||
void RareDestination::protocolDetected(Flow *f) { | ||
bool is_rare_destination = false; | ||
|
||
/* TODO: check if this is a real rare destination */ | ||
if(f->getFlowServerInfo() != NULL) { | ||
#ifdef TODO_HERE | ||
ntop->getTrace()->traceEvent(TRACE_NORMAL, "*** Rare destination %s", f->getFlowServerInfo()); | ||
is_rare_destination = true; | ||
#endif | ||
} | ||
|
||
if(is_rare_destination) { | ||
FlowAlertType alert_type = RareDestinationAlert::getClassType(); | ||
u_int8_t c_score, s_score; | ||
risk_percentage cli_score_pctg = CLIENT_FAIR_RISK_PERCENTAGE; | ||
|
||
computeCliSrvScore(alert_type, cli_score_pctg, &c_score, &s_score); | ||
|
||
f->triggerAlertAsync(alert_type, c_score, s_score); | ||
} | ||
} | ||
|
||
/* ***************************************************** */ | ||
|
||
FlowAlert* RareDestination::buildAlert(Flow *f) { | ||
return new RareDestinationAlert(this, f); | ||
} | ||
|
||
/* ***************************************************** */ |