Merge branch 'leonn-AJP_protocol' into dev
This commit is contained in:
@@ -179,10 +179,7 @@
|
|||||||
#define NDPI_PROTOCOL_YOUTUBE_UPLOAD 136 /* Upload files to youtube */
|
#define NDPI_PROTOCOL_YOUTUBE_UPLOAD 136 /* Upload files to youtube */
|
||||||
#define NDPI_PROTOCOL_ICQ 137
|
#define NDPI_PROTOCOL_ICQ 137
|
||||||
#define NDPI_PROTOCOL_CHECKMK 138
|
#define NDPI_PROTOCOL_CHECKMK 138
|
||||||
|
#define NDPI_PROTOCOL_AJP 139 /* Leonn Paiva <leonn.paiva@gmail.com>*/
|
||||||
/* Free to use */
|
|
||||||
#define NDPI_PROTOCOL_FREE_B 139
|
|
||||||
|
|
||||||
#define NDPI_PROTOCOL_APPLE 140
|
#define NDPI_PROTOCOL_APPLE 140
|
||||||
#define NDPI_PROTOCOL_WEBEX 141
|
#define NDPI_PROTOCOL_WEBEX 141
|
||||||
#define NDPI_PROTOCOL_WHATSAPP 142
|
#define NDPI_PROTOCOL_WHATSAPP 142
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ void ndpi_search_smpp(struct ndpi_detection_module_struct *ndpi_struct, struct n
|
|||||||
void ndpi_search_tinc(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
void ndpi_search_tinc(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||||
void ndpi_search_fix(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
void ndpi_search_fix(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||||
void ndpi_search_csgo(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
void ndpi_search_csgo(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||||
|
void ndpi_search_ajp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||||
/* --- INIT FUNCTIONS --- */
|
/* --- INIT FUNCTIONS --- */
|
||||||
void init_diameter_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
void init_diameter_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||||
void init_afp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
void init_afp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||||
@@ -354,4 +355,5 @@ void init_csgo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int
|
|||||||
void init_checkmk_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
void init_checkmk_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||||
void init_apple_push_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
void init_apple_push_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||||
void init_whatsapp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
void init_whatsapp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||||
|
void init_ajp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||||
#endif /* __NDPI_PROTOCOLS_H__ */
|
#endif /* __NDPI_PROTOCOLS_H__ */
|
||||||
|
|||||||
@@ -350,7 +350,6 @@ struct bt_announce { // 192 bytes
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NDPI_PROTOCOL_TINC
|
#ifdef NDPI_PROTOCOL_TINC
|
||||||
|
|
||||||
#define TINC_CACHE_MAX_SIZE 10
|
#define TINC_CACHE_MAX_SIZE 10
|
||||||
|
|
||||||
PACK_ON struct tinc_cache_entry {
|
PACK_ON struct tinc_cache_entry {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ libndpi_la_include_HEADERS = ../include/ndpi_api.h \
|
|||||||
libndpi_la_SOURCES = ndpi_content_match.c.inc \
|
libndpi_la_SOURCES = ndpi_content_match.c.inc \
|
||||||
ndpi_main.c \
|
ndpi_main.c \
|
||||||
protocols/afp.c \
|
protocols/afp.c \
|
||||||
|
protocols/ajp.c \
|
||||||
protocols/aimini.c \
|
protocols/aimini.c \
|
||||||
protocols/applejuice.c \
|
protocols/applejuice.c \
|
||||||
protocols/apple_push.c \
|
protocols/apple_push.c \
|
||||||
|
|||||||
+12
-9
@@ -1793,18 +1793,18 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
|
|||||||
no_master, "CSGO", NDPI_PROTOCOL_CATEGORY_GAME,
|
no_master, "CSGO", NDPI_PROTOCOL_CATEGORY_GAME,
|
||||||
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
|
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
|
||||||
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
|
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
|
||||||
|
ndpi_set_proto_defaults(ndpi_mod, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_AJP,
|
||||||
|
no_master,
|
||||||
|
no_master, "AJP", NDPI_PROTOCOL_CATEGORY_WEB,
|
||||||
|
ndpi_build_default_ports(ports_a, 8009, 0, 0, 0, 0) /* TCP */,
|
||||||
|
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
|
||||||
|
|
||||||
/* To remove */
|
/* To remove */
|
||||||
ndpi_set_proto_defaults(ndpi_mod, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_FREE_A,
|
ndpi_set_proto_defaults(ndpi_mod, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_FREE_A,
|
||||||
no_master,
|
no_master,
|
||||||
no_master, "PlaceholderA", NDPI_PROTOCOL_CATEGORY_UNSPECIFIED,
|
no_master, "PlaceholderA", NDPI_PROTOCOL_CATEGORY_UNSPECIFIED,
|
||||||
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
|
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
|
||||||
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
|
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
|
||||||
ndpi_set_proto_defaults(ndpi_mod, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_FREE_B,
|
|
||||||
no_master,
|
|
||||||
no_master, "PlaceholderB", NDPI_PROTOCOL_CATEGORY_UNSPECIFIED,
|
|
||||||
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
|
|
||||||
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
|
|
||||||
|
|
||||||
/* calling function for host and content matched protocols */
|
/* calling function for host and content matched protocols */
|
||||||
init_string_based_protocols(ndpi_mod);
|
init_string_based_protocols(ndpi_mod);
|
||||||
@@ -2955,6 +2955,9 @@ void ndpi_set_protocol_detection_bitmask2(struct ndpi_detection_module_struct *n
|
|||||||
/* LISP */
|
/* LISP */
|
||||||
init_lisp_dissector(ndpi_struct, &a, detection_bitmask);
|
init_lisp_dissector(ndpi_struct, &a, detection_bitmask);
|
||||||
|
|
||||||
|
/* AJP */
|
||||||
|
init_ajp_dissector(ndpi_struct, &a, detection_bitmask);
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
|
|
||||||
ndpi_struct->callback_buffer_size = a;
|
ndpi_struct->callback_buffer_size = a;
|
||||||
|
|||||||
@@ -0,0 +1,153 @@
|
|||||||
|
/*
|
||||||
|
* ajp.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2018 by Leonn Paiva <leonn.paiva@gmail.com>
|
||||||
|
*
|
||||||
|
* This file is part of nDPI, an open source deep packet inspection
|
||||||
|
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||||
|
*
|
||||||
|
* nDPI is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* nDPI is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ndpi_protocol_ids.h"
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_AJP
|
||||||
|
|
||||||
|
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_AJP
|
||||||
|
|
||||||
|
#include "ndpi_api.h"
|
||||||
|
|
||||||
|
enum ajp_direction {
|
||||||
|
AJP_SERVER_TO_CONTAINER = 0x1234,
|
||||||
|
AJP_CONTAINER_TO_SERVER = 0x4142
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ajp_packet_type {
|
||||||
|
AJP_UNKNOWN = 0,
|
||||||
|
|
||||||
|
/* packet types */
|
||||||
|
AJP_FORWARD_REQUEST = 2,
|
||||||
|
AJP_SEND_BODY_CHUNK = 3,
|
||||||
|
AJP_SEND_HEADERS = 4,
|
||||||
|
AJP_END_RESPONSE = 5,
|
||||||
|
AJP_GET_BODY_CHUNK = 6,
|
||||||
|
AJP_SHUTDOWN = 7,
|
||||||
|
AJP_PING = 8,
|
||||||
|
AJP_CPONG = 9,
|
||||||
|
AJP_CPING = 10,
|
||||||
|
AJP_BODY = 11
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ajp_header {
|
||||||
|
uint16_t magic;
|
||||||
|
uint16_t len;
|
||||||
|
uint8_t code;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void set_ajp_detected(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
struct ndpi_flow_struct *flow) {
|
||||||
|
|
||||||
|
if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {
|
||||||
|
ndpi_search_tcp_or_udp(ndpi_struct, flow);
|
||||||
|
|
||||||
|
/* If no custom protocol has been detected */
|
||||||
|
/* if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) */
|
||||||
|
ndpi_int_reset_protocol(flow);
|
||||||
|
ndpi_set_detected_protocol(ndpi_struct, flow, flow->guessed_host_protocol_id, NDPI_PROTOCOL_AJP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
static void ndpi_check_ajp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
struct ajp_header ajp_hdr;
|
||||||
|
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|
||||||
|
if (packet->payload_packet_len < 5 /* ajp_header size*/) {
|
||||||
|
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ajp_hdr = *((struct ajp_header *) (packet->payload));
|
||||||
|
ajp_hdr.magic = ntohs(ajp_hdr.magic);
|
||||||
|
ajp_hdr.len = ntohs(ajp_hdr.len);
|
||||||
|
|
||||||
|
if (ajp_hdr.len > 0 && ajp_hdr.magic == AJP_SERVER_TO_CONTAINER) {
|
||||||
|
if (ajp_hdr.code == AJP_FORWARD_REQUEST || ajp_hdr.code == AJP_SHUTDOWN
|
||||||
|
|| ajp_hdr.code == AJP_PING || ajp_hdr.code == AJP_CPING) {
|
||||||
|
|
||||||
|
set_ajp_detected(ndpi_struct, flow);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
NDPI_LOG_DBG(ndpi_struct, "Invalid AJP request type");
|
||||||
|
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||||
|
}
|
||||||
|
} else if (ajp_hdr.len > 0 && ajp_hdr.magic == AJP_CONTAINER_TO_SERVER) {
|
||||||
|
if (ajp_hdr.code == AJP_SEND_BODY_CHUNK || ajp_hdr.code == AJP_SEND_HEADERS
|
||||||
|
|| ajp_hdr.code == AJP_END_RESPONSE || ajp_hdr.code == AJP_GET_BODY_CHUNK
|
||||||
|
|| ajp_hdr.code == AJP_CPONG) {
|
||||||
|
|
||||||
|
set_ajp_detected(ndpi_struct, flow);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
NDPI_LOG_DBG(ndpi_struct, "Invalid AJP response type");
|
||||||
|
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
NDPI_LOG_DBG(ndpi_struct,"Invalid AJP packet\n");
|
||||||
|
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ndpi_search_ajp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|
||||||
|
// Break after 20 packets.
|
||||||
|
if(flow->packet_counter > 20) {
|
||||||
|
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_LOG_DBG(ndpi_struct, "search AJP\n");
|
||||||
|
ndpi_check_ajp(ndpi_struct, flow);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ********************************* */
|
||||||
|
|
||||||
|
|
||||||
|
void init_ajp_dissector(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||||
|
{
|
||||||
|
ndpi_set_bitmask_protocol_detection("AJP", ndpi_struct, detection_bitmask,
|
||||||
|
*id, NDPI_PROTOCOL_AJP, ndpi_search_ajp,
|
||||||
|
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
|
||||||
|
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||||
|
ADD_TO_DETECTION_BITMASK);
|
||||||
|
|
||||||
|
*id += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
Binary file not shown.
@@ -0,0 +1,10 @@
|
|||||||
|
Unknown 6 2200 2
|
||||||
|
AJP 26 4446 2
|
||||||
|
|
||||||
|
1 TCP 172.29.9.146:38856 <-> 172.29.9.147:8009 [VLAN: 7][proto: 139/AJP][7 pkts/1554 bytes <-> 6 pkts/669 bytes]
|
||||||
|
2 TCP 172.29.9.146:38856 <-> 172.29.9.147:8010 [VLAN: 7][proto: 139/AJP][7 pkts/1554 bytes <-> 6 pkts/669 bytes]
|
||||||
|
|
||||||
|
|
||||||
|
Undetected flows:
|
||||||
|
1 80 93.88.129.0:0 -> 0.7.8.0:0 [proto: 0/Unknown][4 pkts/2012 bytes -> 0 pkts/0 bytes]
|
||||||
|
2 80 142.243.129.0:0 -> 0.7.8.0:0 [proto: 0/Unknown][2 pkts/188 bytes -> 0 pkts/0 bytes]
|
||||||
Reference in New Issue
Block a user