Fixed false positives with NATS
This commit is contained in:
@@ -28,13 +28,12 @@ static const char* commands[] =
|
|||||||
"INFO {",
|
"INFO {",
|
||||||
"CONNECT {",
|
"CONNECT {",
|
||||||
"PUB ",
|
"PUB ",
|
||||||
"SUB",
|
"SUB ",
|
||||||
"UNSUB ",
|
"UNSUB ",
|
||||||
"MSG ",
|
"MSG ",
|
||||||
"PING",
|
"PING",
|
||||||
"PONG",
|
"PONG",
|
||||||
"+OK",
|
|
||||||
"-ERR",
|
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -49,19 +48,14 @@ void ndpi_search_nats_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i=0; commands[i] != NULL; i++) {
|
for(i=0; commands[i] != NULL; i++) {
|
||||||
char *match = ndpi_strnstr((const char *)packet->payload,
|
int len = ndpi_min(strlen(commands[i]), packet->payload_packet_len);
|
||||||
commands[i],
|
int rc = strncmp((const char *)packet->payload, commands[i], len);
|
||||||
ndpi_min(strlen(commands[i]), packet->payload_packet_len));
|
|
||||||
|
if(rc != 0) continue;
|
||||||
|
|
||||||
if(!match) continue;
|
if(ndpi_strnstr((const char *)packet->payload,
|
||||||
|
"\r\n",
|
||||||
/* These commands are used by POP3 too. To avoid false positives, look for the other ones */
|
packet->payload_packet_len) != NULL) {
|
||||||
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");
|
NDPI_LOG_INFO(ndpi_struct, "found NATS\n");
|
||||||
|
|
||||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_NATS, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
|
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_NATS, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
|
||||||
|
|||||||
Reference in New Issue
Block a user