Skip to content

Commit 51d2e7e

Browse files
committed
Ensure Target Process Window Paused by Monika
1 parent f561402 commit 51d2e7e

24 files changed

Lines changed: 84 additions & 16 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

MonikaDLL/.vs/MonikaDLL/v17/.suo

5 KB
Binary file not shown.
0 Bytes
Binary file not shown.

MonikaDLL/.vs/MonikaDLL/v17/DocumentLayout.backup.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"RelativeDocumentMoniker": "InjectX64Galgame.cpp",
3737
"ToolTip": "C:\\Users\\Administrator\\DDLC-MonikaInKernel\\MonikaDLL\\InjectX64Galgame.cpp",
3838
"RelativeToolTip": "InjectX64Galgame.cpp",
39-
"ViewState": "AgIAALQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
39+
"ViewState": "AgIAAHAAAAAAAAAAAAAvwHwAAAAFAAAAAAAAAA==",
4040
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
4141
"WhenOpened": "2024-11-04T10:35:02.895Z",
4242
"EditorCaption": ""
@@ -49,7 +49,7 @@
4949
"RelativeDocumentMoniker": "ProcessGadgit.cpp",
5050
"ToolTip": "C:\\Users\\Administrator\\DDLC-MonikaInKernel\\MonikaDLL\\ProcessGadgit.cpp",
5151
"RelativeToolTip": "ProcessGadgit.cpp",
52-
"ViewState": "AgIAAAAAAAAAAAAAAAAAAB0AAAAJAAAAAAAAAA==",
52+
"ViewState": "AgIAAFEAAAAAAAAAAAAAAB0AAAAJAAAAAAAAAA==",
5353
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
5454
"WhenOpened": "2024-11-04T09:50:11.458Z"
5555
},

MonikaDLL/.vs/MonikaDLL/v17/DocumentLayout.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"RelativeDocumentMoniker": "InjectX64Galgame.cpp",
3737
"ToolTip": "C:\\Users\\Administrator\\DDLC-MonikaInKernel\\MonikaDLL\\InjectX64Galgame.cpp",
3838
"RelativeToolTip": "InjectX64Galgame.cpp",
39-
"ViewState": "AgIAAHAAAAAAAAAAAAAvwIcAAAAZAAAAAAAAAA==",
39+
"ViewState": "AgIAAHAAAAAAAAAAAAAvwHwAAAAFAAAAAAAAAA==",
4040
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
4141
"WhenOpened": "2024-11-04T10:35:02.895Z",
4242
"EditorCaption": ""
@@ -51,8 +51,7 @@
5151
"RelativeToolTip": "ProcessGadgit.cpp",
5252
"ViewState": "AgIAAFEAAAAAAAAAAAAAAB0AAAAJAAAAAAAAAA==",
5353
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
54-
"WhenOpened": "2024-11-04T09:50:11.458Z",
55-
"EditorCaption": ""
54+
"WhenOpened": "2024-11-04T09:50:11.458Z"
5655
},
5756
{
5857
"$type": "Document",

MonikaDLL/InjectX64Galgame.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ static BYTE MonikaPayload_NO_CRASH[] = {
2828
0x48, 0x83, 0xEC, 0x28, // sub rsp, 0x28 (MessageBoxA Strictly requires 32-byte aligned stack)
2929
0xE8, 0x00, 0x00, 0x00, 0x00, // call $+5 (self-relative)
3030
0x5A, // pop rdx
31-
0x48, 0x83, 0xC2, 0x3C, // add rdx, 0x3C (adjust rdx to point to "JUST Monika!")
32-
0x48, 0x31, 0xC9, // xor rcx, rcx (HWND = NULL)
31+
0x48, 0x83, 0xC2, 0x43, // add rdx, 0x43 (adjust rdx to point to "JUST Monika!")
32+
0x48, 0xB9, 0,0,0,0,0,0,0,0, // mov rcx, 0
3333
0x4C, 0x8B, 0xC2, // mov r8, rdx (R8 = address of "JUST Monika!")
3434
0x49, 0x83, 0xC0, 0x0d, // add r8, 0x0d (adjust R8 to point to "ALERT")
3535
0x4D, 0x31, 0xC9, // xor r9, r9 (uType = MB_OK)
@@ -89,6 +89,7 @@ static BYTE Gidget_Shellcode[] = {
8989
DWORD GetProcessIdByName(const char* processName);
9090
DWORD GetMainThreadId(DWORD processId);
9191
LPVOID InjectShellcode(HANDLE hProcess, UINT8 *buf, UINT64 bufsize);
92+
HWND GetTargetWindowHandleByPID(DWORD processId);
9293

9394
// Function to hijack the main thread and set its RIP to the injected MonikaPayload
9495
static UINT8 HijackMainThread(HANDLE hProcess, DWORD mainThreadId, LPVOID remotePayloadMemory)
@@ -166,6 +167,10 @@ static void GetTargetMsgBoxA_Routine(HANDLE hProcess)
166167

167168
__declspec(dllexport) UINT8 injectX64Gal(char *targetEXE)
168169
{
170+
// Update Gidget_Shellcode with function addresses
171+
*(UINT64 *)(Gidget_Shellcode + 20) = (UINT64)LoadLibraryA;
172+
*(UINT64 *)(Gidget_Shellcode + 45) = (UINT64)GetProcAddress;
173+
169174
// Get the PID of the target process
170175
DWORD processId = GetProcessIdByName(targetEXE);
171176
if (!processId)
@@ -196,8 +201,20 @@ __declspec(dllexport) UINT8 injectX64Gal(char *targetEXE)
196201
GetTargetMsgBoxA_Routine(hProcess);
197202

198203
// Update MonikaPayload with target MessageBoxA address
199-
*(UINT64 *)(MonikaPayload_NO_CRASH + 55) = *(UINT64 *)(Gidget_Shellcode + sizeof(Gidget_Shellcode) - 8);
204+
*(UINT64 *)(MonikaPayload_NO_CRASH + 62) = *(UINT64 *)(Gidget_Shellcode + sizeof(Gidget_Shellcode) - 8);
200205

206+
// Get Target Window Handle
207+
HWND targetHwnd = GetTargetWindowHandleByPID(processId);
208+
if (!targetHwnd)
209+
{
210+
printf("Failed to get target window handle\n");
211+
return -1;
212+
}
213+
printf("Target window handle: 0x%p\n", targetHwnd);
214+
215+
// Update MonikaPayload with target window handle
216+
*(UINT64 *)(MonikaPayload_NO_CRASH + 42) = (UINT64)targetHwnd;
217+
201218
// Inject MonikaPayload into the target process and get the address of the remote memory
202219
LPVOID remoteMemory = InjectShellcode(hProcess, MonikaPayload_NO_CRASH, sizeof(MonikaPayload_NO_CRASH));
203220
if (!remoteMemory)
824 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)