Added risk/score dump (ndpiReader -h)
Added ndpi_dump_risks_score() API score
This commit is contained in:
@@ -535,6 +535,9 @@ static void help(u_int long_help) {
|
||||
ndpi_set_protocol_detection_bitmask2(ndpi_info_mod, &all);
|
||||
|
||||
ndpi_dump_protocols(ndpi_info_mod);
|
||||
|
||||
printf("\n\nnDPI supported risks:\n");
|
||||
ndpi_dump_risks_score(ndpi_info_mod);
|
||||
}
|
||||
|
||||
exit(!long_help);
|
||||
|
||||
@@ -680,6 +680,13 @@ extern "C" {
|
||||
*/
|
||||
void ndpi_dump_protocols(struct ndpi_detection_module_struct *mod);
|
||||
|
||||
/**
|
||||
* Write the list of the scores and their associated risks
|
||||
*
|
||||
* @par ndpi_mod = the detection module
|
||||
*/
|
||||
void ndpi_dump_risks_score();
|
||||
|
||||
/**
|
||||
* Read a file and load the protocols
|
||||
*
|
||||
@@ -1512,6 +1519,7 @@ extern "C" {
|
||||
void ndpi_serialize_risk(ndpi_serializer *serializer, struct ndpi_flow_struct *flow);
|
||||
|
||||
const char* ndpi_risk2str(ndpi_risk_enum risk);
|
||||
const char* ndpi_severity2str(ndpi_risk_severity s);
|
||||
ndpi_risk_severity ndpi_risk2severity(ndpi_risk_enum risk);
|
||||
u_int16_t ndpi_risk2score(ndpi_risk risk);
|
||||
|
||||
|
||||
@@ -114,10 +114,12 @@ typedef enum {
|
||||
NDPI_RISK_SEVERE
|
||||
} ndpi_risk_severity;
|
||||
|
||||
#define NDPI_SCORE_RISK_LOW 10
|
||||
#define NDPI_SCORE_RISK_MEDIUM 50
|
||||
#define NDPI_SCORE_RISK_HIGH 100
|
||||
#define NDPI_SCORE_RISK_SEVERE 250
|
||||
typedef enum {
|
||||
NDPI_SCORE_RISK_LOW = 10,
|
||||
NDPI_SCORE_RISK_MEDIUM = 50,
|
||||
NDPI_SCORE_RISK_HIGH = 100,
|
||||
NDPI_SCORE_RISK_SEVERE = 250,
|
||||
} ndpi_risk_score;
|
||||
|
||||
/* NDPI_VISIT */
|
||||
typedef enum {
|
||||
|
||||
+3044
-3006
File diff suppressed because it is too large
Load Diff
+23
-1
@@ -1714,7 +1714,7 @@ const char* ndpi_risk2str(ndpi_risk_enum risk) {
|
||||
return("Possibly Malicious JA3 Fingerprint");
|
||||
|
||||
case NDPI_MALICIOUS_SHA1_CERTIFICATE:
|
||||
return("Possibly Malicious SSL Certificate SHA1 Fingerprint");
|
||||
return("Possibly Malicious SSL Cert. SHA1 Fingerprint");
|
||||
|
||||
case NDPI_DESKTOP_OR_FILE_SHARING_SESSION:
|
||||
return("Desktop/File Sharing Session");
|
||||
@@ -1781,6 +1781,28 @@ ndpi_risk_severity ndpi_risk2severity(ndpi_risk_enum risk) {
|
||||
|
||||
/* ******************************************************************** */
|
||||
|
||||
const char* ndpi_severity2str(ndpi_risk_severity s) {
|
||||
switch(s) {
|
||||
case NDPI_RISK_LOW:
|
||||
return("Low");
|
||||
break;
|
||||
|
||||
case NDPI_RISK_MEDIUM:
|
||||
return("Medium");
|
||||
break;
|
||||
|
||||
case NDPI_RISK_HIGH:
|
||||
return("High");
|
||||
break;
|
||||
|
||||
case NDPI_RISK_SEVERE:
|
||||
return("Severe");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* ******************************************************************** */
|
||||
|
||||
u_int16_t ndpi_risk2score(ndpi_risk risk) {
|
||||
u_int16_t score = 0;
|
||||
u_int32_t i;
|
||||
|
||||
+20
-4
@@ -43,6 +43,8 @@ extern int is_version_with_var_int_transport_params(uint32_t version);
|
||||
// #define DEBUG_TLS_BLOCKS 1
|
||||
// #define DEBUG_CERTIFICATE_HASH
|
||||
|
||||
// #define DEBUG_HEURISTIC
|
||||
|
||||
// #define DEBUG_JA3C 1
|
||||
|
||||
/* #define DEBUG_FINGERPRINT 1 */
|
||||
@@ -1513,6 +1515,12 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
flow->protos.tls_quic_stun.tls_quic.browser_euristics.is_chrome_tls = 1;
|
||||
else if(safari_ciphers == 12)
|
||||
flow->protos.tls_quic_stun.tls_quic.browser_euristics.is_safari_tls = 1;
|
||||
|
||||
#ifdef DEBUG_HEURISTIC
|
||||
printf("[is_chrome_tls: %u][is_safari_tls: %u]\n",
|
||||
flow->protos.tls_quic_stun.tls_quic.browser_euristics.is_chrome_tls,
|
||||
flow->protos.tls_quic_stun.tls_quic.browser_euristics.is_safari_tls);
|
||||
#endif
|
||||
} else {
|
||||
invalid_ja3 = 1;
|
||||
#ifdef DEBUG_TLS
|
||||
@@ -1725,11 +1733,12 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
}
|
||||
|
||||
for(i=0; i<tot_signature_algorithms_len; i+=2) {
|
||||
u_int16_t cipher_id = (u_int16_t)ntohs(*((u_int16_t*)&packet->payload[s_offset+i]));
|
||||
u_int16_t signature_algo = (u_int16_t)ntohs(*((u_int16_t*)&packet->payload[s_offset+i]));
|
||||
|
||||
// printf("=>> %04X\n", cipher_id);
|
||||
|
||||
switch(cipher_id) {
|
||||
#ifdef DEBUG_HEURISTIC
|
||||
printf("[TLS Signature Algorithm] 0x%04X\n", signature_algo);
|
||||
#endif
|
||||
switch(signature_algo) {
|
||||
case ECDSA_SECP521R1_SHA512:
|
||||
flow->protos.tls_quic_stun.tls_quic.browser_euristics.is_firefox_tls = 1;
|
||||
break;
|
||||
@@ -1757,6 +1766,13 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
if(chrome_signature_algorithms != 8)
|
||||
flow->protos.tls_quic_stun.tls_quic.browser_euristics.is_chrome_tls = 0;
|
||||
|
||||
#ifdef DEBUG_HEURISTIC
|
||||
printf("[is_firefox_tls: %u][is_chrome_tls: %u][is_safari_tls: %u]\n",
|
||||
flow->protos.tls_quic_stun.tls_quic.browser_euristics.is_firefox_tls,
|
||||
flow->protos.tls_quic_stun.tls_quic.browser_euristics.is_chrome_tls,
|
||||
flow->protos.tls_quic_stun.tls_quic.browser_euristics.is_safari_tls);
|
||||
#endif
|
||||
|
||||
ja3.client.signature_algorithms[i*2] = '\0';
|
||||
|
||||
#ifdef DEBUG_TLS
|
||||
|
||||
Reference in New Issue
Block a user