* FTP needs to get updated as well as it has similiar STARTTLS semantics -> follow-up Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
@@ -48,14 +48,15 @@
|
||||
|
||||
/* #define SMTP_DEBUG 1 */
|
||||
|
||||
extern int processTLSBlock(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow);
|
||||
|
||||
static void ndpi_int_mail_smtp_add_connection(struct ndpi_detection_module_struct
|
||||
*ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
#ifdef SMTP_DEBUG
|
||||
printf("**** %s()\n", __FUNCTION__);
|
||||
#endif
|
||||
|
||||
flow->guessed_protocol_id = NDPI_PROTOCOL_MAIL_SMTP; /* Avoid SMTPS to be used s sub-protocol */
|
||||
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow,
|
||||
NDPI_PROTOCOL_MAIL_SMTP, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
|
||||
}
|
||||
@@ -299,8 +300,8 @@ void ndpi_search_mail_smtp_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
}
|
||||
}
|
||||
|
||||
if(packet->line[a].len >= 8) {
|
||||
if((packet->line[a].ptr[0] == 'S' || packet->line[a].ptr[0] == 's')
|
||||
if(packet->line[a].len >= 8) {
|
||||
if((packet->line[a].ptr[0] == 'S' || packet->line[a].ptr[0] == 's')
|
||||
&& (packet->line[a].ptr[1] == 'T' || packet->line[a].ptr[1] == 't')
|
||||
&& (packet->line[a].ptr[2] == 'A' || packet->line[a].ptr[2] == 'a')
|
||||
&& (packet->line[a].ptr[3] == 'R' || packet->line[a].ptr[3] == 'r')
|
||||
@@ -310,9 +311,9 @@ void ndpi_search_mail_smtp_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
&& (packet->line[a].ptr[7] == 'S' || packet->line[a].ptr[7] == 's')) {
|
||||
flow->l4.tcp.smtp_command_bitmask |= SMTP_BIT_STARTTLS;
|
||||
flow->l4.tcp.ftp_imap_pop_smtp.auth_tls = 1;
|
||||
flow->l4.tcp.ftp_imap_pop_smtp.auth_done = 1;
|
||||
}
|
||||
}
|
||||
flow->l4.tcp.ftp_imap_pop_smtp.auth_done = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(packet->line[a].len >= 4) {
|
||||
if((packet->line[a].ptr[0] == 'D' || packet->line[a].ptr[0] == 'd')
|
||||
@@ -381,12 +382,38 @@ void ndpi_search_mail_smtp_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
/* **************************************** */
|
||||
|
||||
int ndpi_extra_search_mail_smtp_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow) {
|
||||
int rc;
|
||||
struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct * const packet = &ndpi_struct->packet;
|
||||
int rc = 0;
|
||||
|
||||
ndpi_search_mail_smtp_tcp(ndpi_struct, flow);
|
||||
if (flow->l4.tcp.smtp_command_bitmask & SMTP_BIT_STARTTLS &&
|
||||
packet->payload_packet_len > 5)
|
||||
{
|
||||
uint8_t const * const block = &packet->payload[5];
|
||||
uint8_t const * const p = &packet->payload[0];
|
||||
uint16_t const block_len = packet->payload_packet_len - 5;
|
||||
uint16_t const l = packet->payload_packet_len;
|
||||
|
||||
rc = (flow->l4.tcp.ftp_imap_pop_smtp.password[0] == '\0') ? 1 : 0;
|
||||
packet->payload = block;
|
||||
packet->payload_packet_len = block_len;
|
||||
|
||||
if (processTLSBlock(ndpi_struct, flow) != 0) {
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
packet->payload = p;
|
||||
packet->payload_packet_len = l;
|
||||
|
||||
/* STARTTLS may be followed by a 220 - Service ready */
|
||||
if (rc == 0 && memcmp(packet->payload, "220", 3) != 0)
|
||||
{
|
||||
flow->l4.tcp.ftp_imap_pop_smtp.auth_done = 1;
|
||||
}
|
||||
} else {
|
||||
ndpi_search_mail_smtp_tcp(ndpi_struct, flow);
|
||||
rc = (flow->l4.tcp.ftp_imap_pop_smtp.password[0] == '\0') ? 1 : 0;
|
||||
}
|
||||
|
||||
#ifdef SMTP_DEBUG
|
||||
printf("**** %s() [rc: %d]\n", __FUNCTION__, rc);
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "ndpi_encryption.h"
|
||||
|
||||
extern char *strptime(const char *s, const char *format, struct tm *tm);
|
||||
extern int processTLSBlock(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow);
|
||||
extern int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow, uint32_t quic_version);
|
||||
extern int http_process_user_agent(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
@@ -839,8 +841,8 @@ int processCertificate(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
|
||||
/* **************************************** */
|
||||
|
||||
static int processTLSBlock(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow) {
|
||||
int processTLSBlock(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow) {
|
||||
struct ndpi_packet_struct *packet = &ndpi_struct->packet;
|
||||
int ret;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user