-
Notifications
You must be signed in to change notification settings - Fork 9
/
test.cpp
34 lines (27 loc) · 959 Bytes
/
test.cpp
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
#include <Windows.h>
#include "obfuscated_jump_generator.h"
int test_fn(int a, void* obfu_printf) {
((int(__cdecl*)(const char*, ...))obfu_printf)("Obfuscated printf: %i\n", a);
return a + 1;
}
int main()
{
std::random_device rd;
std::mt19937 mt(rd());
int tot = 0;
auto buf = (uint8_t*)VirtualAlloc(nullptr, 0x1000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
// generate obfuscated call to test_fn
auto generator = shellcode_jmp_generator(&mt);
auto fn = (int(__cdecl*)(int, void*))(buf + tot);
tot += generator.write_to_buf(buf + tot, (uint32_t)test_fn);
// generate obfuscated call to printf
generator = shellcode_jmp_generator(&mt);
auto obfu_printf = (void*)(buf + tot);
tot += generator.write_to_buf(buf + tot, (uint32_t)printf);
// call test_fn and obfuscated printf a bunch of times
for (int i = 0; i < 10000; i++) {
fn(i, obfu_printf);
}
std::getchar();
return 0;
}