From 8c5cbe50e9f7a7085f1ccb3ffb0f4ba3d9b8599c Mon Sep 17 00:00:00 2001 From: Tyrolyean Date: Thu, 30 Apr 2020 22:38:33 +0200 Subject: [PATCH] Added minimum message length Signed-off-by: Tyrolyean --- README | 11 +++++++++++ include/config.h | 1 + src/attach.c | 4 ++++ src/config.c | 1 + src/main.c | 9 ++++++++- 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README b/README index 6aa5652..b4693cd 100644 --- a/README +++ b/README @@ -39,6 +39,17 @@ You can specify the following command line options: webserver! That WILL BE a security riks! +--other-base64 --only-base64 + Decides wether ONLY base64 encoded files should be removed from the + actual mail, or ALL files. + +--minfilesize -s + The minimum file size which a file has to have before beeing attached. + Thissize is before base64 decoding if nescessary. Size is in bytes, + ONLY bytes. Do NOT prefix a M or K, it will not be parsed! Defaults to + 500Kb. If 0 is specified, all files will be attached. A negative value + effectively disables us. + HOWTO We essentially are MITM sniffing your email traffic and playing proxy from your diff --git a/include/config.h b/include/config.h index 1c5ef90..a00323e 100644 --- a/include/config.h +++ b/include/config.h @@ -33,5 +33,6 @@ extern int verbose; extern char* directory; extern char* url_base; +extern long min_filesize; #endif /* CONFIG_H */ diff --git a/src/attach.c b/src/attach.c index b9ec3c4..62e0ac3 100644 --- a/src/attach.c +++ b/src/attach.c @@ -342,6 +342,10 @@ int replace_base64_files(struct email_t* mail, const char* dirname){ if(mail->file_info.name == NULL){ return 0; } + if((mail->message_length - mail->body_offset) < (unsigned long) + min_filesize ){ + return 0; + } if(mail->base64_encoded){ if(base64_decode_file(dirname, mail) < 0){ diff --git a/src/config.c b/src/config.c index fb2f8d1..8a0cd69 100644 --- a/src/config.c +++ b/src/config.c @@ -28,3 +28,4 @@ char* directory = NULL; char* url_base = NULL; +long min_filesize= 1024*512; diff --git a/src/main.c b/src/main.c index d2b7987..6f19d6e 100644 --- a/src/main.c +++ b/src/main.c @@ -36,13 +36,14 @@ int main(int argc, char* argv[]){ {"out-port", required_argument, 0, 'o'}, {"instance-id", required_argument, 0, 'n'}, {"directory", required_argument, 0, 'd'}, + {"minfilesize", required_argument, 0, 's'}, {"url", required_argument, 0, 'u'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; - c = getopt_long (argc, argv, "n:i:o:d:u:", + c = getopt_long (argc, argv, "n:i:o:d:u:s:", long_options, &option_index); /* Detect the end of the options. */ @@ -71,6 +72,9 @@ int main(int argc, char* argv[]){ case 'u': url_base = optarg; break; + case 's': + min_filesize = atol(optarg); + break; case '?': /* getopt_long already printed an error message. */ @@ -119,6 +123,9 @@ int main(int argc, char* argv[]){ printf("Only saving bas64 encoded files: %s\n", only_base64 ? "true":"false"); + + printf("Min filesize to store messages: %liB\n", + min_filesize); printf("Placing files into [%s] linked by [%s]\n", directory,