]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
smtp: add 'body-md5' mime option
authorEric Leblond <eric@regit.org>
Tue, 5 May 2015 13:00:58 +0000 (15:00 +0200)
committerEric Leblond <eric@regit.org>
Fri, 2 Oct 2015 20:57:58 +0000 (22:57 +0200)
This option will allow the user to select weither or not he wants
to journalize the md5 of the mail body.

src/app-layer-smtp.c
src/util-decode-mime.c
src/util-decode-mime.h

index ed034d4ed683a55b0243ce050eecb1a76bc7369d..139533468f9c1393ad4e600a4011f3251773c70f 100644 (file)
@@ -220,7 +220,7 @@ SCEnumCharMap smtp_reply_map[ ] = {
 };
 
 /* Create SMTP config structure */
-SMTPConfig smtp_config = { 0, { 0, 0, 0, 0 }, 0, 0, 0};
+SMTPConfig smtp_config = { 0, { 0, 0, 0, 0, 0 }, 0, 0, 0};
 
 static SMTPString *SMTPStringAlloc(void);
 
@@ -266,6 +266,11 @@ static void SMTPConfigure(void) {
         if (ret) {
             smtp_config.mime_config.extract_urls = val;
         }
+
+        ret = ConfGetChildValueBool(config, "body-md5", &val);
+        if (ret) {
+            smtp_config.mime_config.body_md5 = val;
+        }
     }
 
     /* Pass mime config data to MimeDec API */
index 3b33c548de36c008f96f6360ed1073e2efcb4bb6..312a9af493ae1a2c0ac43ceaf9e40f5a6aff6d70 100644 (file)
@@ -79,7 +79,7 @@
 #define MAX_IP6_CHARS  39
 
 /* Globally hold configuration data */
-static MimeDecConfig mime_dec_config = { 1, 1, 1, MAX_HEADER_VALUE };
+static MimeDecConfig mime_dec_config = { 1, 1, 1, 0, MAX_HEADER_VALUE };
 
 #ifdef DEBUG
 /* Mime Parser String translation */
@@ -2182,7 +2182,7 @@ static int ProcessMimeBody(const uint8_t *buf, uint32_t len,
     uint32_t tlen;
 
 #ifdef HAVE_NSS
-    if (state->body_begin == 1 && (state->md5_ctx == NULL)) {
+    if (MimeDecGetConfig()->body_md5 && state->body_begin == 1 && (state->md5_ctx == NULL)) {
         state->md5_ctx = HASH_Create(HASH_AlgMD5);
         if (state->md5_ctx != NULL) {
             HASH_Begin(state->md5_ctx);
index 69f328e3c693e88a035bb5695644975a8fdb76d0..020a1f16657bb28abf14d6c74ea7f98e813da10b 100644 (file)
@@ -97,6 +97,7 @@ typedef struct MimeDecConfig {
     int decode_base64;  /**< Decode base64 bodies */
     int decode_quoted_printable;  /**< Decode quoted-printable bodies */
     int extract_urls;  /**< Extract and store URLs in data structure */
+    int body_md5;  /**< Compute md5 sum of body */
     uint32_t header_value_depth;  /**< Depth of which to store header values
                                        (Default is 2000) */
 } MimeDecConfig;