fix vnc dissector

This commit is contained in:
Campus
2016-10-12 00:10:06 +02:00
parent bbe4717075
commit 3b95cd9a11
+27 -30
View File
@@ -1,8 +1,7 @@
/* /*
* vnc.c * vnc.c
* *
* Copyright (C) 2009-2011 by ipoque GmbH * Copyright (C) 2016 - ntop.org
* Copyright (C) 2011-15 - ntop.org
* *
* This file is part of nDPI, an open source deep packet inspection * This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH * library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -21,48 +20,46 @@
* along with nDPI. If not, see <http://www.gnu.org/licenses/>. * along with nDPI. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
#include "ndpi_protocols.h" #include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_VNC #ifdef NDPI_PROTOCOL_VNC
static void ndpi_int_vnc_add_connection(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_VNC, NDPI_PROTOCOL_UNKNOWN);
}
/*
return 0 if nothing has been detected
return 1 if it is a http packet
*/
void ndpi_search_vnc_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) void ndpi_search_vnc_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src; /* search over TCP */
// struct ndpi_id_struct *dst=ndpi_struct->dst; if(packet->tcp) {
if(flow->l4.tcp.vnc_stage == 0) {
if (flow->l4.tcp.vnc_stage == 0) { if(packet->payload_packet_len == 12 &&
if (packet->payload_packet_len == 12 (memcmp(packet->payload, "RFB 003.003", 11) == 0 && packet->payload[11] == 0x0a) ||
&& memcmp(packet->payload, "RFB 003.00", 10) == 0 && packet->payload[11] == 0x0a) { (memcmp(packet->payload, "RFB 003.007", 11) == 0 && packet->payload[11] == 0x0a) ||
NDPI_LOG(NDPI_PROTOCOL_VNC, ndpi_struct, NDPI_LOG_DEBUG, "reached vnc stage one\n"); (memcmp(packet->payload, "RFB 003.008", 11) == 0 && packet->payload[11] == 0x0a) ||
flow->l4.tcp.vnc_stage = 1 + packet->packet_direction; (memcmp(packet->payload, "RFB 004.001", 11) == 0 && packet->payload[11] == 0x0a)) {
return;
} NDPI_LOG(NDPI_PROTOCOL_VNC, ndpi_struct, NDPI_LOG_DEBUG, "reached vnc stage one\n");
} else if (flow->l4.tcp.vnc_stage == 2 - packet->packet_direction) { flow->l4.tcp.vnc_stage = 1 + packet->packet_direction;
if (packet->payload_packet_len == 12 return;
&& memcmp(packet->payload, "RFB 003.00", 10) == 0 && packet->payload[11] == 0x0a) { }
NDPI_LOG(NDPI_PROTOCOL_VNC, ndpi_struct, NDPI_LOG_DEBUG, "found vnc\n"); } else if(flow->l4.tcp.vnc_stage == 2 - packet->packet_direction) {
ndpi_int_vnc_add_connection(ndpi_struct, flow);
return; if(packet->payload_packet_len == 12 &&
(memcmp(packet->payload, "RFB 003.003", 11) == 0 && packet->payload[11] == 0x0a) ||
(memcmp(packet->payload, "RFB 003.007", 11) == 0 && packet->payload[11] == 0x0a) ||
(memcmp(packet->payload, "RFB 003.008", 11) == 0 && packet->payload[11] == 0x0a) ||
(memcmp(packet->payload, "RFB 004.001", 11) == 0 && packet->payload[11] == 0x0a)) {
NDPI_LOG(NDPI_PROTOCOL_VNC, ndpi_struct, NDPI_LOG_DEBUG, "found vnc\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_VNC, NDPI_PROTOCOL_UNKNOWN);
return;
}
} }
} }
/* exclude VNC */
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_VNC); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_VNC);
} }