Improved detection as non DGA for hostnames belnging to a CDN (#2068)
This commit is contained in:
+13
-11
@@ -9803,10 +9803,9 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
u_int i, j, max_tmp_len = sizeof(tmp)-1;
|
u_int i, j, max_tmp_len = sizeof(tmp)-1;
|
||||||
|
|
||||||
len = ndpi_snprintf(tmp, max_tmp_len, "%s", name);
|
len = ndpi_snprintf(tmp, max_tmp_len, "%s", name);
|
||||||
|
|
||||||
if(len < 0) {
|
if(len < 0) {
|
||||||
|
NDPI_LOG_DBG2(ndpi_str, "[DGA] too short");
|
||||||
NDPI_LOG_DBG2(ndpi_str, "[DGA] too short");
|
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
} else
|
} else
|
||||||
tmp[(u_int)len < max_tmp_len ? (u_int)len : max_tmp_len] = '\0';
|
tmp[(u_int)len < max_tmp_len ? (u_int)len : max_tmp_len] = '\0';
|
||||||
@@ -9913,7 +9912,7 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
u_int max_num_consecutive_digits_first_word = 0, num_word = 0;
|
u_int max_num_consecutive_digits_first_word = 0, num_word = 0;
|
||||||
|
|
||||||
for(word = strtok_r(tmp, ".", &tok_tmp); ; word = strtok_r(NULL, ".", &tok_tmp)) {
|
for(word = strtok_r(tmp, ".", &tok_tmp); ; word = strtok_r(NULL, ".", &tok_tmp)) {
|
||||||
u_int num_consecutive_digits = 0;
|
u_int num_consecutive_digits = 0, word_len;
|
||||||
|
|
||||||
if(!word) break; else num_word++;
|
if(!word) break; else num_word++;
|
||||||
|
|
||||||
@@ -9922,7 +9921,10 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
if(num_words > 2)
|
if(num_words > 2)
|
||||||
break; /* Stop after the 2nd word of the domain name */
|
break; /* Stop after the 2nd word of the domain name */
|
||||||
|
|
||||||
if(strlen(word) < 5) continue;
|
if((word_len = strlen(word)) < 5) continue;
|
||||||
|
|
||||||
|
if((word_len < 10) && (ndpi_ends_with(ndpi_str, word, "cdn") /* Content Delivery Network ? */))
|
||||||
|
continue; /* Ignore names (not too long) that end with cdn [ ssl.p.jwpcdn.com or www.awxcdn.com ] */
|
||||||
|
|
||||||
NDPI_LOG_DBG2(ndpi_str, "[DGA] word(%s) [%s][len: %u]\n", word, name, (unsigned int)strlen(word));
|
NDPI_LOG_DBG2(ndpi_str, "[DGA] word(%s) [%s][len: %u]\n", word, name, (unsigned int)strlen(word));
|
||||||
|
|
||||||
@@ -10007,11 +10009,11 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
max_num_consecutive_digits_first_word = num_consecutive_digits;
|
max_num_consecutive_digits_first_word = num_consecutive_digits;
|
||||||
} /* for */
|
} /* for */
|
||||||
|
|
||||||
NDPI_LOG_DBG2(ndpi_str, "[DGA] max_num_consecutive_digits_first_word=%u\n", max_num_consecutive_digits_first_word);
|
NDPI_LOG_DBG2(ndpi_str, "[DGA] max_num_consecutive_digits_first_word=%u\n", max_num_consecutive_digits_first_word);
|
||||||
|
|
||||||
NDPI_LOG_DBG2(ndpi_str, "[DGA] [%s][num_found: %u][num_impossible: %u][num_digits: %u][num_bigram_checks: %u][num_vowels: %u/%u][num_trigram_vowels: %u][num_trigram_found: %u/%u][vowels: %u][rc: %u]\n",
|
NDPI_LOG_DBG2(ndpi_str, "[DGA] [%s][num_found: %u][num_impossible: %u][num_digits: %u][num_bigram_checks: %u][num_vowels: %u/%u][num_trigram_vowels: %u][num_trigram_found: %u/%u][vowels: %u][rc: %u]\n",
|
||||||
name, num_found, num_impossible, num_digits, num_bigram_checks, num_vowels, len, num_trigram_vowels,
|
name, num_found, num_impossible, num_digits, num_bigram_checks, num_vowels, len, num_trigram_vowels,
|
||||||
num_trigram_checked, num_trigram_found, num_vowels, rc);
|
num_trigram_checked, num_trigram_found, num_vowels, rc);
|
||||||
|
|
||||||
if((len > 16) && (num_dots < 3) && ((num_vowels*4) < (len-num_dots))) {
|
if((len > 16) && (num_dots < 3) && ((num_vowels*4) < (len-num_dots))) {
|
||||||
if((num_trigram_checked > 2) && (num_trigram_vowels >= (num_trigram_found-1)))
|
if((num_trigram_checked > 2) && (num_trigram_vowels >= (num_trigram_found-1)))
|
||||||
@@ -10043,8 +10045,8 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
rc = 0;
|
rc = 0;
|
||||||
|
|
||||||
if(rc)
|
if(rc)
|
||||||
NDPI_LOG_DBG2(ndpi_str, "[DGA] %s [num_found: %u][num_impossible: %u]\n",
|
NDPI_LOG_DBG2(ndpi_str, "[DGA] %s [num_found: %u][num_impossible: %u]\n",
|
||||||
name, num_found, num_impossible);
|
name, num_found, num_impossible);
|
||||||
}
|
}
|
||||||
|
|
||||||
NDPI_LOG_DBG2(ndpi_str, "[DGA] Result: %u\n", rc);
|
NDPI_LOG_DBG2(ndpi_str, "[DGA] Result: %u\n", rc);
|
||||||
|
|||||||
Reference in New Issue
Block a user