Fixed CPHA missing protocol initialization

Improved IEC104 and IRC detection
This commit is contained in:
Luca Deri
2021-02-10 15:22:20 +01:00
parent 0de3d4c37a
commit e2f6569adb
7 changed files with 28 additions and 45 deletions
+1 -1
View File
@@ -195,7 +195,7 @@ typedef struct ndpi_flow_info {
struct ndpi_analyze_struct *iat_c_to_s, *iat_s_to_c, *iat_flow, struct ndpi_analyze_struct *iat_c_to_s, *iat_s_to_c, *iat_flow,
*pktlen_c_to_s, *pktlen_s_to_c; *pktlen_c_to_s, *pktlen_s_to_c;
char info[160]; char info[255];
char flow_extra_info[16]; char flow_extra_info[16];
char host_server_name[240]; char host_server_name[240];
char bittorent_hash[41]; char bittorent_hash[41];
+1
View File
@@ -192,6 +192,7 @@ void init_fix_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int3
void init_nintendo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_nintendo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_csgo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_csgo_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_checkmk_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_cpha_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_amazon_video_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_amazon_video_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);
+3
View File
@@ -3116,6 +3116,9 @@ void ndpi_set_protocol_detection_bitmask2(struct ndpi_detection_module_struct *n
/* check_mk */ /* check_mk */
init_checkmk_dissector(ndpi_str, &a, detection_bitmask); init_checkmk_dissector(ndpi_str, &a, detection_bitmask);
/* cpha */
init_cpha_dissector(ndpi_str, &a, detection_bitmask);
/* AIMINI */ /* AIMINI */
init_aimini_dissector(ndpi_str, &a, detection_bitmask); init_aimini_dissector(ndpi_str, &a, detection_bitmask);
+10 -2
View File
@@ -45,8 +45,16 @@ void ndpi_search_iec60870_tcp(struct ndpi_detection_module_struct *ndpi_struct,
if(len == 0) if(len == 0)
break; break;
else else {
offset += len + 2, found = 1; u_int8_t len = packet->payload[offset+1];
if((len + offset + 2) == packet->payload_packet_len) {
found = 1;
break;
}
offset += len + 2;
}
} else } else
break; break;
} }
-33
View File
@@ -373,7 +373,6 @@ void ndpi_search_irc_tcp(struct ndpi_detection_module_struct *ndpi_struct, struc
struct ndpi_id_struct *dst = flow->dst; struct ndpi_id_struct *dst = flow->dst;
int less; int less;
u_int16_t c = 0; u_int16_t c = 0;
u_int16_t c1 = 0;
u_int16_t port = 0; u_int16_t port = 0;
u_int16_t sport = 0; u_int16_t sport = 0;
u_int16_t dport = 0; u_int16_t dport = 0;
@@ -439,38 +438,6 @@ void ndpi_search_irc_tcp(struct ndpi_detection_module_struct *ndpi_struct, struc
} }
} }
#if 0
if (flow->detected_protocol_stack[0] != NDPI_PROTOCOL_IRC
&& flow->packet_counter == 2 && (packet->payload_packet_len > 400 && packet->payload_packet_len < 1381)) {
for (c1 = 50; c1 < packet->payload_packet_len - 23; c1++) {
if (packet->payload[c1] == 'i' || packet->payload[c1] == 'd') {
if ((memcmp(&packet->payload[c1], "irc.hackthissite.org0", 21)
== 0)
|| (memcmp(&packet->payload[c1], "irc.gamepad.ca1", 15) == 0)
|| (memcmp(&packet->payload[c1], "dungeon.axenet.org0", 19)
== 0)
|| (memcmp(&packet->payload[c1], "dazed.nuggethaus.net", 20)
== 0)
|| (memcmp(&packet->payload[c1], "irc.indymedia.org", 17)
== 0)
|| (memcmp(&packet->payload[c1], "irc.cccp-project.net", 20)
== 0)
|| (memcmp(&packet->payload[c1], "dirc.followell.net0", 19)
== 0)
|| (memcmp(&packet->payload[c1], "irc.discostars.de1", 18)
== 0)
|| (memcmp(&packet->payload[c1], "irc.rizon.net", 13) == 0)) {
NDPI_LOG_INFO(ndpi_struct,
"found IRC SSL: - irc.hackthissite.org0 | irc.gamepad.ca1 | dungeon.axenet.org0 "
"| dazed.nuggethaus.net | irc.indymedia.org | irc.discostars.de1 ");
ndpi_int_irc_add_connection(ndpi_struct, flow);
break;
}
}
}
}
#endif
if (flow->detected_protocol_stack[0] != NDPI_PROTOCOL_IRC && if (flow->detected_protocol_stack[0] != NDPI_PROTOCOL_IRC &&
ndpi_search_irc_ssl_detect_ninety_percent_but_very_fast(ndpi_struct, flow) != 0) { ndpi_search_irc_ssl_detect_ninety_percent_but_very_fast(ndpi_struct, flow) != 0) {
return; return;
Binary file not shown.
+4
View File
@@ -0,0 +1,4 @@
IEC60870 15 1431 2
1 TCP 10.175.211.1:2404 <-> 10.119.105.26:54768 [proto: 245/IEC60870][cat: IoT-Scada/31][7 pkts/987 bytes <-> 5 pkts/270 bytes][Goodput ratio: 61/0][2.00 sec][bytes ratio: 0.570 (Upload)][IAT c2s/s2c min/avg/max/stddev: 36/199 360/521 935/935 313/307][Pkt Len c2s/s2c min/avg/max/stddev: 60/54 141/54 306/54 90/0][Plen Bins: 51,0,0,16,0,16,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
2 TCP 10.175.211.3:2404 <-> 10.119.105.26:54769 [proto: 245/IEC60870][cat: IoT-Scada/31][2 pkts/120 bytes <-> 1 pkts/54 bytes][Goodput ratio: 5/0][0.22 sec][Plen Bins: 100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]