Added check to reduce MongoDB false positive detection
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
#include "ndpi_api.h"
|
#include "ndpi_api.h"
|
||||||
|
|
||||||
enum mongo_opcodes
|
enum mongo_opcodes
|
||||||
{
|
{
|
||||||
OP_REPLY = 1,
|
OP_REPLY = 1,
|
||||||
OP_UPDATE = 2001,
|
OP_UPDATE = 2001,
|
||||||
OP_INSERT = 2002,
|
OP_INSERT = 2002,
|
||||||
@@ -37,7 +37,7 @@ enum mongo_opcodes
|
|||||||
OP_DELETE = 2006,
|
OP_DELETE = 2006,
|
||||||
OP_KILL_CURSORS = 2007,
|
OP_KILL_CURSORS = 2007,
|
||||||
OP_MSG = 2013
|
OP_MSG = 2013
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mongo_message_header
|
struct mongo_message_header
|
||||||
{
|
{
|
||||||
@@ -75,9 +75,12 @@ static void ndpi_check_mongodb(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
|
|
||||||
memcpy(&mongodb_hdr, packet->payload, sizeof(struct mongo_message_header));
|
memcpy(&mongodb_hdr, packet->payload, sizeof(struct mongo_message_header));
|
||||||
|
|
||||||
mongodb_hdr.message_length = ntohs(mongodb_hdr.message_length);
|
/* All MongoDB numbers are in host byte order */
|
||||||
|
// mongodb_hdr.message_length = ntohl(mongodb_hdr.message_length);
|
||||||
|
|
||||||
if (mongodb_hdr.message_length < 4) {
|
if((mongodb_hdr.message_length < 4)
|
||||||
|
|| (mongodb_hdr.message_length > 1000000) /* Used to avoid false positives */
|
||||||
|
) {
|
||||||
NDPI_LOG_DBG(ndpi_struct, "Invalid MONGODB length");
|
NDPI_LOG_DBG(ndpi_struct, "Invalid MONGODB length");
|
||||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||||
return;
|
return;
|
||||||
@@ -127,8 +130,7 @@ void ndpi_search_mongodb(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
|
|
||||||
|
|
||||||
void init_mongodb_dissector(struct ndpi_detection_module_struct *ndpi_struct,
|
void init_mongodb_dissector(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask) {
|
||||||
{
|
|
||||||
ndpi_set_bitmask_protocol_detection("MongoDB", ndpi_struct, detection_bitmask,
|
ndpi_set_bitmask_protocol_detection("MongoDB", ndpi_struct, detection_bitmask,
|
||||||
*id, NDPI_PROTOCOL_MONGODB, ndpi_search_mongodb,
|
*id, NDPI_PROTOCOL_MONGODB, ndpi_search_mongodb,
|
||||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
|
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
|
||||||
|
|||||||
Reference in New Issue
Block a user