Added NDPI_ERROR_CODE_DETECTED risk

This commit is contained in:
Luca Deri
2022-02-03 13:20:54 +01:00
parent 0dd5ac89f8
commit 7aef27f85e
10 changed files with 25 additions and 2074 deletions
+8
View File
@@ -259,3 +259,11 @@ The risk is set whenever a TLS certificate is close to the expiration date.
NDPI_PUNYCODE_IDN
===================================
The risk is set whenever a domain name is specified in IDN format as they are sometimes used in `IDN homograph attacks <https://en.wikipedia.org/wiki/IDN_homograph_attack>`_.
.. _Risk 043:
NDPI_ERROR_CODE_DETECTED
===================================
The risk is set whenever an error code is detected in the underlying protocol (e.g. HTTP and DNS).
+1
View File
@@ -334,6 +334,7 @@ typedef enum {
NDPI_POSSIBLE_EXPLOIT,
NDPI_TLS_CERTIFICATE_ABOUT_TO_EXPIRE,
NDPI_PUNYCODE_IDN,
NDPI_ERROR_CODE_DETECTED,
/* Leave this as last member */
NDPI_MAX_RISK
+2 -3
View File
@@ -68,8 +68,6 @@ typedef enum {
1. Add a new flow alert key to the enum FlowAlertTypeEnum in include/ntop_typedefs.h
2. Add the very same flow alert key to the table flow_alert_keys in scripts/lua/modules/alert_keys/flow_alert_keys.lua
3. Add the risk to the array risk_enum_to_alert_type in src/FlowRiskAlerts.cpp
- To initialize .alert_type use the flow alert key added in 1. and an AlertCategory
- To initialize .alert_lua_name use a unique string
Example: https://github.com/ntop/ntopng/commit/aecc1e3e6505a0522439dbb2b295a3703d3d0f9a
*/
@@ -117,7 +115,8 @@ typedef enum {
NDPI_POSSIBLE_EXPLOIT, /* Log4J and other exploits */
NDPI_TLS_CERTIFICATE_ABOUT_TO_EXPIRE,
NDPI_PUNYCODE_IDN, /* https://en.wikipedia.org/wiki/Punycode */
NDPI_ERROR_CODE_DETECTED,
/* Leave this as last member */
NDPI_MAX_RISK /* must be <= 63 due to (**) */
} ndpi_risk_enum;
+2 -1
View File
@@ -111,7 +111,8 @@ static ndpi_risk_info ndpi_known_risks[] = {
{ NDPI_POSSIBLE_EXPLOIT, NDPI_RISK_SEVERE, CLIENT_HIGH_RISK_PERCENTAGE },
{ NDPI_TLS_CERTIFICATE_ABOUT_TO_EXPIRE, NDPI_RISK_MEDIUM, CLIENT_LOW_RISK_PERCENTAGE },
{ NDPI_PUNYCODE_IDN, NDPI_RISK_LOW, CLIENT_LOW_RISK_PERCENTAGE },
{ NDPI_ERROR_CODE_DETECTED, NDPI_RISK_LOW, CLIENT_LOW_RISK_PERCENTAGE },
/* Leave this as last member */
{ NDPI_MAX_RISK, NDPI_RISK_LOW, CLIENT_FAIR_RISK_PERCENTAGE }
};
+5 -1
View File
@@ -1848,7 +1848,11 @@ const char* ndpi_risk2str(ndpi_risk_enum risk) {
case NDPI_PUNYCODE_IDN:
return("IDN Domain Name");
break;
case NDPI_ERROR_CODE_DETECTED:
return("Error Code Detected");
break;
default:
snprintf(buf, sizeof(buf), "%d", (int)risk);
return(buf);
+3
View File
@@ -233,6 +233,9 @@ static int search_valid_dns(struct ndpi_detection_module_struct *ndpi_struct,
/* DNS Reply */
flow->protos.dns.reply_code = dns_header->flags & 0x0F;
if(flow->protos.dns.reply_code != 0)
ndpi_set_risk(ndpi_struct, flow, NDPI_ERROR_CODE_DETECTED);
if((dns_header->num_queries > 0) && (dns_header->num_queries <= NDPI_MAX_DNS_REQUESTS) /* Don't assume that num_queries must be zero */
&& ((((dns_header->num_answers > 0) && (dns_header->num_answers <= NDPI_MAX_DNS_REQUESTS))
|| ((dns_header->authority_rrs > 0) && (dns_header->authority_rrs <= NDPI_MAX_DNS_REQUESTS))
+3
View File
@@ -999,9 +999,12 @@ static void ndpi_check_http_tcp(struct ndpi_detection_module_struct *ndpi_struct
buf[3] = '\0';
flow->http.response_status_code = atoi(buf);
/* https://en.wikipedia.org/wiki/List_of_HTTP_status_codes */
if((flow->http.response_status_code < 100) || (flow->http.response_status_code > 509))
flow->http.response_status_code = 0; /* Out of range */
else if(flow->http.response_status_code >= 400)
ndpi_set_risk(ndpi_struct, flow, NDPI_ERROR_CODE_DETECTED);
}
ndpi_parse_packet_line_info(ndpi_struct, flow);
-11
View File
@@ -1,11 +0,0 @@
Guessed flow protos: 0
DPI Packets (UDP): 4 (1.00 pkts/flow)
Confidence DPI : 4 (flows)
DCE_RPC 16 6866 4
1 UDP 192.168.1.11:49155 -> 192.168.1.20:34964 [proto: 127/DCE_RPC][ClearText][Confidence: DPI][cat: RPC/16][6 pkts/3706 bytes -> 0 pkts/0 bytes][Goodput ratio: 93/0][0.05 sec][bytes ratio: 1.000 (Upload)][IAT c2s/s2c min/avg/max/stddev: 0/0 10/0 32/0 13/0][Pkt Len c2s/s2c min/avg/max/stddev: 174/0 618/0 995/0 338/0][PLAIN TEXT (mrpdomain)][Plen Bins: 0,0,0,0,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33,0,0,0,0,0,0,0,0,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
2 UDP 192.168.1.20:49161 -> 192.168.1.11:49155 [proto: 127/DCE_RPC][ClearText][Confidence: DPI][cat: RPC/16][6 pkts/2464 bytes -> 0 pkts/0 bytes][Goodput ratio: 90/0][0.07 sec][bytes ratio: 1.000 (Upload)][IAT c2s/s2c min/avg/max/stddev: 0/0 13/0 37/0 17/0][Pkt Len c2s/s2c min/avg/max/stddev: 174/0 411/0 846/0 308/0][Plen Bins: 0,0,0,0,33,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
3 UDP 192.168.1.11:49154 -> 192.168.1.20:49162 [proto: 127/DCE_RPC][ClearText][Confidence: DPI][cat: RPC/16][2 pkts/348 bytes -> 0 pkts/0 bytes][Goodput ratio: 76/0][< 1 sec][Plen Bins: 0,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
4 UDP 192.168.1.20:49162 -> 192.168.1.11:34964 [proto: 127/DCE_RPC][ClearText][Confidence: DPI][cat: RPC/16][2 pkts/348 bytes -> 0 pkts/0 bytes][Goodput ratio: 76/0][< 1 sec][Plen Bins: 0,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
File diff suppressed because it is too large Load Diff
+1
View File
@@ -81,6 +81,7 @@ flow_risks[39] = ProtoField.bool("ndpi.flow_risk.invalid_characters", "Invalid c
flow_risks[40] = ProtoField.bool("ndpi.flow_risk.possible_exploit", "Possible Exploit", num_bits_flow_risks, nil, bit(8), "nDPI Flow Risk: Possible exploit detected")
flow_risks[41] = ProtoField.bool("ndpi.flow_risk.cert_about_to_expire", "TLS cert about to expire", num_bits_flow_risks, nil, bit(9), "nDPI Flow Risk: TLS certificate about to expire")
flow_risks[42] = ProtoField.bool("ndpi.flow_risk.punycode_idn", "IDN Domain Name", num_bits_flow_risks, nil, bit(10), "nDPI Flow Risk: IDN Domain Name")
flow_risks[43] = ProtoField.bool("ndpi.flow_risk.error_code_detected", "Error Code Detected", num_bits_flow_risks, nil, bit(11), "nDPI Flow Risk: Error Code Detected")
-- Last one: keep in sync the bitmask when adding new risks!!
flow_risks[64] = ProtoField.new("Unused", "ndpi.flow_risk.unused", ftypes.UINT32, nil, base.HEX, bit(32) - bit(10))