1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
| class StringObfuscator {
private:
static constexpr uint8_t AES_KEY[16] = {
0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
};
static void aes_decrypt(const uint8_t* encrypted, uint8_t* decrypted, size_t len) {
AES_KEY aes_key;
AES_set_decrypt_key(AES_KEY, 128, &aes_key);
for (size_t i = 0; i < len; i += 16) {
AES_decrypt(encrypted + i, decrypted + i, &aes_key);
}
}
public:
static std::string decrypt_string(const uint8_t* encrypted_data, size_t len) {
std::vector<uint8_t> decrypted(len);
aes_decrypt(encrypted_data, decrypted.data(), len);
// 移除 padding
size_t actual_len = len;
while (actual_len > 0 && decrypted[actual_len - 1] == 0) {
actual_len--;
}
return std::string(reinterpret_cast<char*>(decrypted.data()), actual_len);
}
};
// 使用加密字符串
void advanced_anti_debug() {
// 加密的 "/proc/self/status" 字符串
const uint8_t encrypted_proc_status[] = {
0x8a, 0x2d, 0x5e, 0x1f, 0x9b, 0x7c, 0x85, 0xa3,
0x4e, 0x92, 0x67, 0xc1, 0x55, 0x98, 0x33, 0x2a
};
std::string proc_status = StringObfuscator::decrypt_string(
encrypted_proc_status, sizeof(encrypted_proc_status)
);
check_debugger_via_status(proc_status.c_str());
}
|