You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.4 KiB
47 lines
1.4 KiB
4 years ago
|
#pragma once
|
||
|
#include "utils.hpp"
|
||
|
#include "linker/linker.hpp"
|
||
4 years ago
|
#include "obfuscation/obfuscation.hpp"
|
||
4 years ago
|
|
||
|
#include <Zycore/Zycore.h>
|
||
|
#include <Zydis/Decoder.h>
|
||
|
#include <Zydis/Formatter.h>
|
||
|
|
||
|
#include <winternl.h>
|
||
|
#include <type_traits>
|
||
|
#include <dbghelp.h>
|
||
4 years ago
|
#include <mutex>
|
||
4 years ago
|
#include <string>
|
||
|
|
||
4 years ago
|
#pragma comment(lib, "Dbghelp.lib")
|
||
4 years ago
|
namespace theo
|
||
4 years ago
|
{
|
||
4 years ago
|
using malloc_t = std::function<decltype(malloc)>;
|
||
|
using memcpy_t = std::function<decltype(memcpy)>;
|
||
4 years ago
|
using kmemset_t = std::function<decltype(memset)>;
|
||
4 years ago
|
using resolve_symbol_t = std::function<std::uintptr_t(const char*)>;
|
||
4 years ago
|
|
||
|
using image_entry_t = std::uintptr_t;
|
||
4 years ago
|
using mapper_routines_t = std::tuple<malloc_t, memcpy_t, resolve_symbol_t>;
|
||
4 years ago
|
|
||
4 years ago
|
class hmm_ctx
|
||
4 years ago
|
{
|
||
|
public:
|
||
4 years ago
|
explicit hmm_ctx(const mapper_routines_t& routines);
|
||
4 years ago
|
auto map_objs(std::vector<lnk::obj_buffer_t>& objs) -> image_entry_t;
|
||
|
|
||
4 years ago
|
malloc_t kalloc;
|
||
|
memcpy_t kmemcpy;
|
||
4 years ago
|
resolve_symbol_t resolve_symbol;
|
||
4 years ago
|
private:
|
||
4 years ago
|
bool map_symbols(std::vector<lnk::obj_buffer_t>& objs);
|
||
|
bool map_obfuscated_symbols(std::vector<lnk::obj_buffer_t>& objs);
|
||
|
|
||
|
bool resolve_relocs(std::vector<lnk::obj_buffer_t>& objs);
|
||
|
bool alloc_obfuscated_symbol_space(std::vector<lnk::obj_buffer_t>& objs);
|
||
|
bool alloc_symbol_space(std::vector<lnk::obj_buffer_t>& objs);
|
||
4 years ago
|
|
||
4 years ago
|
std::map<std::string, std::uintptr_t> mapped_symbols;
|
||
4 years ago
|
std::map<std::uintptr_t, std::shared_ptr<obfuscation::obfuscate>> obfuscated_gadgets;
|
||
4 years ago
|
};
|
||
|
}
|