Skip to content

Commit 103c560

Browse files
committed
Merge branch 'devel1'
2 parents f459224 + 97770f3 commit 103c560

File tree

6 files changed

+22
-14
lines changed

6 files changed

+22
-14
lines changed

loader_v2/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.asm
2+
*.obj
3+
*.lnk

loader_v2/peb_lookup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ inline DWORD calc_checksum(CHAR_TYPE* curr_name, bool case_sensitive)
4141
}
4242
return ~crc;
4343
}
44+
4445
inline LPVOID get_module_by_checksum(DWORD checksum)
4546
{
4647
PEB *peb;

loader_v2/peloader.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,17 @@ bool load_imports(t_mini_iat iat, IMAGE_DATA_DIRECTORY importsDirectory, BYTE* i
9292
while (thunk->u1.AddressOfData != NULL)
9393
{
9494
FIELD_PTR functionAddress = NULL;
95+
LPCSTR functionName = NULL;
9596
if (IMAGE_SNAP_BY_ORDINAL(thunk->u1.Ordinal)) {
96-
LPCSTR functionOrdinal = (LPCSTR)IMAGE_ORDINAL(thunk->u1.Ordinal);
97-
functionAddress = (FIELD_PTR)iat._GetProcAddress(library, functionOrdinal);
97+
functionName = (LPCSTR)IMAGE_ORDINAL(thunk->u1.Ordinal);
9898
}
9999
else {
100-
PIMAGE_IMPORT_BY_NAME functionName = (PIMAGE_IMPORT_BY_NAME)((FIELD_PTR)image + thunk->u1.AddressOfData);
101-
functionAddress = (FIELD_PTR)iat._GetProcAddress(library, functionName->Name);
100+
PIMAGE_IMPORT_BY_NAME functionByName = (PIMAGE_IMPORT_BY_NAME)((FIELD_PTR)image + thunk->u1.AddressOfData);
101+
functionName = functionByName->Name;
102102
}
103+
if (!functionName) return false;
104+
105+
functionAddress = (FIELD_PTR)iat._GetProcAddress(library, functionName);
103106
if (!functionAddress) return false;
104107

105108
thunk->u1.Function = functionAddress;
@@ -120,7 +123,8 @@ bool run_tls_callbacks(IMAGE_DATA_DIRECTORY& tlsDir, BYTE* image)
120123
FIELD_PTR callback_va = *callbacks_ptr;
121124
if (!callback_va) break;
122125

123-
void(NTAPI * callback_func)(PVOID DllHandle, DWORD dwReason, PVOID) = (void(NTAPI*)(PVOID, DWORD, PVOID)) callback_va;
126+
void(NTAPI * callback_func)(PVOID DllHandle, DWORD dwReason, PVOID)
127+
= (void(NTAPI*)(PVOID, DWORD, PVOID)) callback_va;
124128
callback_func(image, DLL_PROCESS_ATTACH, NULL);
125129

126130
callbacks_ptr++;

pe2shc/main.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "peconv.h"
55
#include "resource.h"
66

7-
#define VERSION "1.0"
7+
#define VERSION "1.1"
88

99
bool overwrite_hdr(BYTE *my_exe, size_t exe_size, DWORD raw, bool is64b)
1010
{
@@ -17,23 +17,23 @@ bool overwrite_hdr(BYTE *my_exe, size_t exe_size, DWORD raw, bool is64b)
1717
"\x45" //inc ebp
1818
"\x52" //push edx
1919
"\xE8\x00\x00\x00\x00" //call <next_line>
20-
"\x5B" // pop ebx
21-
"\x48\x83\xEB\x09" // sub ebx,9
22-
"\x53" // push ebx (Image Base)
23-
"\x48\x81\xC3" // add ebx,
20+
"\x58" // pop eax
21+
"\x83\xE8\x09" // sub eax,9
22+
"\x50" // push eax (Image Base)
23+
"\x05" // add eax,
2424
"\x59\x04\x00\x00" // value
25-
"\xFF\xD3" // call ebx
25+
"\xFF\xD0" // call ebx
2626
"\xc3"; // ret
2727

2828
BYTE redir_code64[] = "\x4D\x5A" //pop r10
2929
"\x45\x52" //push r10
3030
"\xE8\x00\x00\x00\x00" //call <next_line>
3131
"\x59" // pop rcx
3232
"\x48\x83\xE9\x09" // sub rcx,9 (rcx -> Image Base)
33-
"\x48\x8B\xD9" // mov rbx,rcx
34-
"\x48\x81\xC3" // add ebx,
33+
"\x48\x8B\xC1" // mov rax,rcx
34+
"\x48\x05" // add eax,
3535
"\x59\x04\x00\x00" // value
36-
"\xFF\xD3" // call ebx
36+
"\xFF\xD0" // call eax
3737
"\xc3"; // ret
3838

3939
redir_code = redir_code32;

pe2shc/stub2/stub32.bin

96 Bytes
Binary file not shown.

pe2shc/stub2/stub64.bin

272 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)