hook/pro: Add net-crypt module, monitor network packet decryption failure

This commit is contained in:
icex2
2021-01-17 01:58:24 +01:00
parent 07146a7672
commit 8747fce0ca
2 changed files with 41 additions and 0 deletions
+1
View File
@@ -8,6 +8,7 @@ add_resources(DOG_KEY ${SRC} prihook.hasp.key)
set(SOURCE_FILES
${SRC}/main.c
${SRC}/net-crypt.c
${SRC}/options.c
${SRC}/usb-updates.c)
+40
View File
@@ -0,0 +1,40 @@
#define LOG_MODULE "prinet-net-crypt"
#include "capnhook/hook/lib.h"
#include "util/log.h"
typedef int (*crypto_box_open_easy_t)(
unsigned char* m,
const unsigned char* c,
unsigned long long clen,
unsigned long long unkn_len,
const unsigned char* n,
const unsigned char* pk,
const unsigned char* sk);
static crypto_box_open_easy_t prihook_net_crypt_real_crypto_box_open_easy;
int crypto_box_open_easy(
unsigned char* m,
const unsigned char* c,
unsigned long long clen,
unsigned long long unkn_len,
const unsigned char* n,
const unsigned char* pk,
const unsigned char* sk)
{
if (!prihook_net_crypt_real_crypto_box_open_easy) {
prihook_net_crypt_real_crypto_box_open_easy =
(crypto_box_open_easy_t) cnh_lib_get_func_addr("crypto_box_open_easy");
}
int res = prihook_net_crypt_real_crypto_box_open_easy(
m, c, clen, unkn_len, n, pk, sk);
if (res != 0) {
log_error("Decrypting message (len %d) failed: %d", clen, res);
}
return res;
}