-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated to V4.5, improved handle hijacking routines, better start/sto…
…p download functionality, added FakeVEH shellcode execution method, fixed symbol issue and handle hijacking crash (hopefully)
- Loading branch information
Showing
65 changed files
with
4,984 additions
and
2,173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,76 @@ | ||
#include "pch.h" | ||
|
||
#include "Eject.h" | ||
#include "Start Routine.h" | ||
|
||
bool EjectDll(HANDLE hTargetProc, HINSTANCE hModule) | ||
bool EjectDll(HANDLE hTargetProc, HINSTANCE hModule, bool WOW64) | ||
{ | ||
LOG(" EjectDll called\n"); | ||
LOG(" PID = %08X\n", GetProcessId(hTargetProc)); | ||
LOG(" hModule = %p\n", hModule); | ||
LOG(3, "EjectDll called\n"); | ||
LOG(4, "PID = %08X\n", GetProcessId(hTargetProc)); | ||
LOG(4, "hModule = %p\n", hModule); | ||
|
||
HANDLE hThread = nullptr; | ||
auto ntRet = NATIVE::NtCreateThreadEx(&hThread, THREAD_ALL_ACCESS, nullptr, hTargetProc, NATIVE::LdrUnloadDll, ReCa<void *>(hModule), NULL, 0, 0, 0, nullptr); | ||
if (FAILED(ntRet)) | ||
{ | ||
LOG(" NtCreateThreadEx failed: %08X\n", ntRet); | ||
ERROR_DATA eject_data; | ||
DWORD remote_ret = 0; | ||
DWORD ret = 0; | ||
|
||
return false; | ||
#ifdef _WIN64 | ||
if (WOW64) | ||
{ | ||
ret = StartRoutine_WOW64(hTargetProc, WOW64::LdrUnloadDll_WOW64, MDWD(hModule), LAUNCH_METHOD::LM_NtCreateThreadEx, NULL, remote_ret, INJ_EJECT_TIMEOUT, eject_data); | ||
} | ||
|
||
if (WaitForSingleObject(hThread, 500) != WAIT_OBJECT_0) | ||
else | ||
{ | ||
LOG(" Ejection thread timed out\n"); | ||
ret = StartRoutine(hTargetProc, ReCa<f_Routine>(NATIVE::LdrUnloadDll), hModule, LAUNCH_METHOD::LM_NtCreateThreadEx, NULL, remote_ret, INJ_EJECT_TIMEOUT, eject_data); | ||
} | ||
#else | ||
UNREFERENCED_PARAMETER(WOW64); | ||
|
||
TerminateThread(hThread, 0); | ||
CloseHandle(hThread); | ||
ret = StartRoutine(hTargetProc, ReCa<f_Routine>(NATIVE::LdrUnloadDll), hModule, LAUNCH_METHOD::LM_NtCreateThreadEx, NULL, remote_ret, INJ_EJECT_TIMEOUT, eject_data); | ||
#endif | ||
|
||
if (ret != SR_ERR_SUCCESS) | ||
{ | ||
LOG(3, "Failed to eject dll:\n"); | ||
LOG(4, "ret = %08X\n", ret); | ||
LOG(4, "advanced = %08X\n", eject_data.AdvErrorCode); | ||
|
||
return false; | ||
} | ||
|
||
if (!GetExitCodeThread(hThread, ReCa<DWORD *>(&ntRet))) | ||
else if (NT_FAIL(remote_ret)) | ||
{ | ||
LOG(" GetExitCodeThread failed: %08X\n", GetLastError()); | ||
|
||
CloseHandle(hThread); | ||
LOG(3, "Failed to eject dll:\n"); | ||
LOG(4, "remote_ret = %08X:\n", remote_ret); | ||
|
||
return false; | ||
} | ||
|
||
CloseHandle(hThread); | ||
LOG(3, "Dll ejected successfully\n"); | ||
|
||
if (NT_FAIL(ntRet)) | ||
{ | ||
LOG(" LdrUnloadDll failed: %08X\n", ntRet); | ||
return true; | ||
} | ||
|
||
return false; | ||
bool EjectHijackLibrary(HANDLE hTargetProc, HINSTANCE hInjectionModuleEx, bool Interrupt) | ||
{ | ||
LOG(2, "Ejecting hijack library\n"); | ||
|
||
if (!Interrupt) | ||
{ | ||
return EjectDll(hTargetProc, hInjectionModuleEx); | ||
} | ||
|
||
LOG(" Dll ejected successfully\n"); | ||
ERROR_DATA interrupt_data; | ||
DWORD remote_ret = 0; | ||
DWORD ret = 0; | ||
f_Routine pInterruptDownloadEx = ReCa<f_Routine>(ReCa<UINT_PTR>(InterruptDownloadEx) - ReCa<UINT_PTR>(g_hInjMod) + ReCa<UINT_PTR>(hInjectionModuleEx)); | ||
|
||
return true; | ||
ret = StartRoutine(hTargetProc, pInterruptDownloadEx, nullptr, LAUNCH_METHOD::LM_NtCreateThreadEx, NULL, remote_ret, INJ_EJECT_TIMEOUT, interrupt_data); | ||
|
||
if (ret != SR_ERR_SUCCESS) | ||
{ | ||
LOG(2, "Failed to interrupt hijack library:\n"); | ||
LOG(3, "ret = %08X\n", ret); | ||
LOG(3, "advanced = %08X\n", interrupt_data.AdvErrorCode); | ||
} //try to eject even if interrupt failed | ||
|
||
return EjectDll(hTargetProc, hInjectionModuleEx); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.