diff options
| author | auth <[email protected]> | 2020-07-17 15:47:51 +0200 |
|---|---|---|
| committer | auth <[email protected]> | 2020-07-17 15:47:51 +0200 |
| commit | 8e5e48337a6cf7a33ecbee7cf9c594fa18bd93ae (patch) | |
| tree | a3a7293f9ee95755f2530dae0ac6ca35f03ae75f /client/src/shellcode | |
| parent | Added certificates. (diff) | |
| download | loader-8e5e48337a6cf7a33ecbee7cf9c594fa18bd93ae.tar.xz loader-8e5e48337a6cf7a33ecbee7cf9c594fa18bd93ae.zip | |
Refactoring.
Diffstat (limited to 'client/src/shellcode')
| -rw-r--r-- | client/src/shellcode/shellcode.cpp | 31 | ||||
| -rw-r--r-- | client/src/shellcode/shellcode.h | 35 |
2 files changed, 66 insertions, 0 deletions
diff --git a/client/src/shellcode/shellcode.cpp b/client/src/shellcode/shellcode.cpp new file mode 100644 index 0000000..67cbabf --- /dev/null +++ b/client/src/shellcode/shellcode.cpp @@ -0,0 +1,31 @@ +#include "../include.h" +#include "shellcode.h" + +void sc::generator::start() {} + +void sc::generator::push(const std::vector<uintptr_t>& args) { + if (!m_x64) { + for (auto it = args.rbegin(); it != args.rend(); ++it) { + m_assembler.push(*it); + } + return; + } + + // 64bit impl +} + +void sc::generator::call(const uintptr_t addr) {} + +void sc::generator::end() { + if (m_x64) { + } + + void* func; + m_runtime.add(&func, &m_code); + + const size_t size = m_code.codeSize(); + + m_buf.resize(size); + + std::memcpy(&m_buf[0], func, size); +}
\ No newline at end of file diff --git a/client/src/shellcode/shellcode.h b/client/src/shellcode/shellcode.h new file mode 100644 index 0000000..5f0e135 --- /dev/null +++ b/client/src/shellcode/shellcode.h @@ -0,0 +1,35 @@ +#pragma once + +#include <asmjit/src/asmjit/asmjit.h> + +using namespace asmjit; + +namespace sc { + +class generator { + std::vector<uint8_t> m_buf; + + CodeHolder m_code; + JitRuntime m_runtime; + x86::Assembler m_assembler; + + bool m_x64; + public: + generator(const bool x64 = false) : m_x64{x64} { + Environment env(x64 ? Environment::kArchX64 : Environment::kArchX86); + + m_code.init(env); + m_code.attach(&m_assembler); + } + + void start(); + void push(const std::vector<uintptr_t> &args); + void call(const uintptr_t addr); + void save_ret(const uintptr_t addr); + void end(); + + auto &operator()() const { return m_buf; } + auto &operator->() const { return m_assembler; } +}; + +};
\ No newline at end of file |