Theodosius  v3.0
Jit linker, mapper, obfuscator, and mutator
Public Member Functions | List of all members
theo::theo_t Class Reference

the main class which encapsulates a symbol table, decomp, and recomp objects. This class is a bridge that connects all three: decomp, obf, recomp. More...

#include <theo.hpp>

Public Member Functions

 theo_t (std::vector< std::uint8_t > &lib, lnk_fns_t lnkr_fns, const std::string &&entry_sym)
 explicit constructor for theo class. More...
 
std::optional< std::uint32_t > decompose ()
 decomposes the lib file and return the number of symbols that are used. More...
 
std::uintptr_t compose ()
 compose the decomposed module. This will run obfuscation passes, the map and resolve symbols to each other. More...
 
std::uintptr_t resolve (const std::string &&sym)
 given the name of a symbol, it returns the address of where its mapped. More...
 

Detailed Description

the main class which encapsulates a symbol table, decomp, and recomp objects. This class is a bridge that connects all three: decomp, obf, recomp.

You will create an object of this type when using theo.

Constructor & Destructor Documentation

◆ theo_t()

theo::theo_t::theo_t ( std::vector< std::uint8_t > &  lib,
lnk_fns_t  lnkr_fns,
const std::string &&  entry_sym 
)
explicit

explicit constructor for theo class.

Parameters
liba vector of bytes consisting of a lib
lnkr_fns
entry_symthe name of the function which will be used as the entry point
37  : m_dcmp(lib, &m_sym_tbl),
38  m_recmp(&m_dcmp, {}, {}, {}),
39  m_entry_sym(entry_sym) {
40  m_recmp.allocator(std::get<0>(lnkr_fns));
41  m_recmp.copier(std::get<1>(lnkr_fns));
42  m_recmp.resolver(std::get<2>(lnkr_fns));
43 }
void allocator(allocator_t alloc)
setter for the allocater lambda function.
Definition: recomp.cpp:163
void resolver(resolver_t resolve)
setter for the resolve lambda function.
Definition: recomp.cpp:171
void copier(copier_t copy)
setter for the copier lambda function.
Definition: recomp.cpp:167

Member Function Documentation

◆ compose()

std::uintptr_t theo::theo_t::compose ( )

compose the decomposed module. This will run obfuscation passes, the map and resolve symbols to each other.

Returns
returns the address of the entry point symbol
56  {
57  // run obfuscation engine on all symbols...
58  //
59  auto engine = obf::engine_t::get();
60  m_sym_tbl.for_each([&](decomp::symbol_t& sym) { engine->run(&sym); });
61 
62  m_recmp.allocate();
63  m_recmp.resolve();
64  m_recmp.copy_syms();
65  return m_recmp.resolve(m_entry_sym.data());
66 }
static engine_t * get()
get the singleton object of this class.
Definition: engine.cpp:34
void copy_syms()
when called, this function copies symbols into allocations.
Definition: recomp.cpp:155
void resolve()
when called, this function resolves all relocations in every symbol.
Definition: recomp.cpp:92
void allocate()
when called, this function allocates space for every symbol.
Definition: recomp.cpp:40
void for_each(std::function< void(decomp::symbol_t &sym)> fn)
this function is a wrapper function that allows you to get at each entry in the symbol table by refer...
Definition: symbol_table.cpp:49

◆ decompose()

std::optional< std::uint32_t > theo::theo_t::decompose ( )

decomposes the lib file and return the number of symbols that are used.

Returns
optional amount of symbols that are used. no value if decomposition fails.
45  {
46  auto res = m_dcmp.decompose(m_entry_sym);
47  if (!res.has_value()) {
48  spdlog::error("failed to decompose...\n");
49  return {};
50  }
51 
52  spdlog::info("decompose successful... {} symbols", res.value()->size());
53  return res.value()->size();
54 }
std::optional< recomp::symbol_table_t * > decompose(std::string &entry_sym)
decomposes (extracts) the symbols used. this function determines all used symbols given the entry poi...
Definition: decomp.cpp:37

◆ resolve()

std::uintptr_t theo::theo_t::resolve ( const std::string &&  sym)

given the name of a symbol, it returns the address of where its mapped.

Parameters
symthe name of the symbol
Returns
the address of the symbol
68  {
69  auto val = m_sym_tbl.sym_from_hash(decomp::symbol_t::hash(sym));
70  if (!val.has_value())
71  return {};
72 
73  return val.value()->allocated_at();
74 }
std::size_t hash()
gets the hash of the symbol name.
Definition: symbol.cpp:88
std::optional< decomp::symbol_t * > sym_from_hash(std::size_t hash)
returns an optional pointer to a symbol from the symbol table given the symbols hash (hash of its nam...
Definition: symbol_table.cpp:54

The documentation for this class was generated from the following files: