summaryrefslogtreecommitdiff
path: root/injector/main.cpp
diff options
context:
space:
mode:
authorJustSomePwner <crotchyalt@gmail.com>2018-08-30 14:01:54 +0200
committerJustSomePwner <crotchyalt@gmail.com>2018-08-30 14:01:54 +0200
commit7ccb819f867493f8ec202ea3b39c94c198c64584 (patch)
tree94622e61af0ff359e3d6689cf274d74f60b2492a /injector/main.cpp
parent564d979b79e8a5aaa5014eba0ecd36c61575934f (diff)
first
Diffstat (limited to 'injector/main.cpp')
-rw-r--r--injector/main.cpp121
1 files changed, 121 insertions, 0 deletions
diff --git a/injector/main.cpp b/injector/main.cpp
new file mode 100644
index 0000000..f3d3511
--- /dev/null
+++ b/injector/main.cpp
@@ -0,0 +1,121 @@
+#include <stdio.h>
+#include "winapi.h"
+
+const wchar_t* const kernel32_str = L"KERNEL32.DLL";
+const wchar_t* const ucrtbase_str = L"ucrtbase.dll";
+const char* const loadlib_str = "LoadLibraryA";
+const char* const printf_str = "printf";
+
+const char* const printf_fmt = "print: %08x\n\0";
+const char* const fail_msg = "k32 null\n";
+const char* const pause_str = "pause";
+const char* const system_str = "system";
+
+uintptr_t printf_addr = ( uintptr_t )&printf;
+uintptr_t system_addr = 0;
+
+//i dont even
+//unfinished btw
+
+__declspec( naked ) int print_var( uint32_t var ) {
+ __asm {
+ push ebp
+ mov ebp, esp
+ sub esp, __LOCAL_SIZE
+
+ mov eax, var
+ push eax
+ push printf_fmt
+ call printf_addr
+
+ add esp, 8
+ mov esp, ebp
+ pop ebp
+
+ mov eax, 0
+ ret
+ }
+}
+
+__declspec( naked ) void print_error( const char* err ) {
+ __asm {
+ push ebp
+ mov ebp, esp
+ sub esp, __LOCAL_SIZE
+
+ mov eax, err
+ push eax
+ call printf_addr
+
+ add esp, 8
+ mov esp, ebp
+ pop ebp
+ }
+}
+
+__declspec( naked ) int main( void ) {
+ void* k32;
+ void* ucrtbase;
+ uintptr_t loadlib;
+
+ __asm {
+ push ebp
+ mov ebp, esp
+ sub esp, __LOCAL_SIZE
+
+ mov eax, ds:ucrtbase_str
+ push eax
+ call winapi::k32::get_module_handle
+ add esp, 4
+ mov ucrtbase, eax
+
+ mov eax, ds:system_str
+ push eax
+ mov ecx, ucrtbase
+ push ecx
+ call winapi::k32::get_proc_address
+ add esp, 4
+ mov system_addr, eax
+
+ mov eax, ds:kernel32_str
+ push eax
+ call winapi::k32::get_module_handle
+ add esp, 4
+ mov k32, eax
+
+ mov eax, k32
+ push eax
+ call print_var
+
+ cmp k32, 0
+ je K32_FAIL
+
+ mov eax, ds:loadlib_str
+ push eax
+ mov ecx, k32
+ push ecx
+ call winapi::k32::get_proc_address
+
+ add esp, 8
+ mov loadlib, eax
+
+ mov eax, loadlib
+ push eax
+ call print_var
+
+ jmp END
+
+ K32_FAIL:
+ mov eax, fail_msg
+ push eax
+ call printf_addr
+
+ END:
+ mov eax, pause_str
+ push eax
+ call system_addr
+ mov esp, ebp
+ pop ebp
+ ret
+ }
+} \ No newline at end of file