IMAP, POP3, SMTP: improve dissection (#1368)

Avoid NATS false positives
This commit is contained in:
Ivan Nardi
2021-11-11 11:55:56 +01:00
committed by GitHub
parent 9abf528c8e
commit 0f168d9150
14 changed files with 158 additions and 50 deletions
+6 -1
View File
@@ -51,10 +51,15 @@ void ndpi_search_nats_tcp(struct ndpi_detection_module_struct *ndpi_struct,
for(i=0; commands[i] != NULL; i++) {
char *match = ndpi_strnstr((const char *)packet->payload,
commands[i],
packet->payload_packet_len);
ndpi_min(strlen(commands[i]), packet->payload_packet_len));
if(!match) continue;
/* These commands are used by POP3 too. To avoid false positives, look for the other ones */
if((strcmp(commands[i], "+OK") == 0) || (strcmp(commands[i], "-ERR") == 0)) {
return;
}
if(ndpi_strnstr((const char *)match, "\r\n",
packet->payload_packet_len - ((size_t)match - (size_t)packet->payload)) != NULL) {
NDPI_LOG_INFO(ndpi_struct, "found NATS\n");