MCPcopy Create free account
hub / github.com/d35ha/CallObfuscator / load_syms

Method load_syms

src/shellcode.cpp:467–505  ·  view source on GitHub ↗

Load the obfuscated symbols at runtime.

Source from the content-addressed store, hash-verified

465
466// Load the obfuscated symbols at runtime.
467VOID shellcode::load_syms(HANDLE pe_base, DWORD sh_funs_rva, DWORD syms_rva)
468{
469 // Calculate the pointers.
470 PDWORD sh_funs = (PDWORD)((PBYTE)pe_base + sh_funs_rva);
471 p_obfuscated_sym syms = (p_obfuscated_sym)((PBYTE)pe_base + syms_rva);
472
473 // Resolving the needed functions.
474 auto fun_load_dll = sh_resolve(pe_base, sh_funs, load_dll);
475 auto fun_get_symbol_ptr = sh_resolve(pe_base, sh_funs, get_symbol_ptr);
476 auto fun_load_halt = sh_resolve(pe_base, sh_funs, exit);
477
478 // Looping on the entries.
479 while (syms->dll_name)
480 {
481 // Calculate the pointers.
482 p_obfuscated_sym p_sym = syms++;
483 PCHAR c_dll_name = (PCHAR)pe_base + p_sym->dll_name;
484 PVOID* p_thunk = (PVOID*)((PBYTE)pe_base + p_sym->sym_thnk);
485
486 // Get the loaded dll handle.
487 HANDLE dll_handle = fun_load_dll(pe_base, sh_funs, c_dll_name);
488 if (!dll_handle)
489 {
490 // The dll is not loaded.
491 return fun_load_halt();
492 };
493
494 // Get the symbol address.
495 PVOID sym_ptr = fun_get_symbol_ptr(pe_base, sh_funs, dll_handle, p_sym->sym_info, p_sym->by_name);
496 if (!dll_handle)
497 {
498 // The symbol is not found.
499 return fun_load_halt();
500 };
501
502 // Replace the symbol thunk.
503 *p_thunk = sym_ptr;
504 };
505};
506
507// Used to flag the end of the functions.
508VOID shellcode::funs_end() {};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected