From 964d4c06eb6c46354a3437fe7ba97763374b0a70 Mon Sep 17 00:00:00 2001 From: Florian Bach Date: Wed, 5 Jan 2022 21:40:13 +0100 Subject: [PATCH] Try to reduce AV false-positives --- .gitignore | 3 ++- calibre-plugin/keyextract/Makefile | 2 +- calibre-plugin/keyextract/main.c | 11 +++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 2efa203..25125fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /calibre-plugin/*.zip /calibre-plugin/keyextract/*.exe -/calibre-plugin/module_id.txt \ No newline at end of file +/calibre-plugin/module_id.txt +/calibre-plugin/__pycache__ diff --git a/calibre-plugin/keyextract/Makefile b/calibre-plugin/keyextract/Makefile index f25d6b8..2e2b5b7 100644 --- a/calibre-plugin/keyextract/Makefile +++ b/calibre-plugin/keyextract/Makefile @@ -5,7 +5,7 @@ clean: rm decrypt_win32.exe decrypt_win64.exe 2>/dev/null || /bin/true decrypt_win32.exe: main.c Makefile - i686-w64-mingw32-gcc main.c -Os -o decrypt_win32.exe -lcrypt32 + i686-w64-mingw32-gcc main.c -O2 -o decrypt_win32.exe -lcrypt32 i686-w64-mingw32-strip decrypt_win32.exe decrypt_win64.exe: main.c Makefile diff --git a/calibre-plugin/keyextract/main.c b/calibre-plugin/keyextract/main.c index bbe5767..7870114 100644 --- a/calibre-plugin/keyextract/main.c +++ b/calibre-plugin/keyextract/main.c @@ -19,7 +19,7 @@ int char2int(char input) { if (input >= 'a' && input <= 'f') return input - 'a' + 10; - printf("PROGOUTPUT:-3"); + fputs("PROGOUTPUT:-3", stdout); exit(-3); } @@ -119,7 +119,7 @@ int main() { char * entropy_hex = getenv(var_entropy); if (data_hex == NULL || entropy_hex == NULL) { - printf("PROGOUTPUT:-1"); + fputs("PROGOUTPUT:-1", stdout); exit(-1); } @@ -127,7 +127,7 @@ int main() { char * entropy_bytes = malloc((strlen(entropy_hex) / 2)); if (data_bytes == NULL || entropy_bytes == NULL) { - printf("PROGOUTPUT:-2"); + fputs("PROGOUTPUT:-2", stdout); exit(-2); } @@ -153,6 +153,7 @@ input_data.cbData = strlen(data_hex)/2; entropy_data.pbData = entropy_bytes; entropy_data.cbData = strlen(entropy_hex)/2; + int ret = CryptUnprotectData( &input_data, NULL, @@ -162,13 +163,15 @@ int ret = CryptUnprotectData( 0, &output_data); + + if (ret) { if (output_data.cbData != 16) { printf("PROGOUTPUT:-5:%d", output_data.cbData); exit(-5); } // Success! Return decrypted data - printf("PROGOUTPUT:0:"); + fputs("PROGOUTPUT:0:", stdout); for (int i = 0; i < 16; i++) { printf("%02x", output_data.pbData[i]); }