Kernel Injection
Inject shellcode and DLLs from kernel mode via RtlCreateUserThread, bypassing usermode hooks.
Bypasses Usermode Security
Kernel injection bypasses usermode hooks and monitoring. Use only for authorized security research.
Methods
Kernel Shellcode Injection
Ring 0Allocate RWX memory in target process, write shellcode, create thread from kernel mode.
- Resolve
RtlCreateUserThreadviaMmGetSystemRoutineAddress PsLookupProcessByProcessId()to get EPROCESSKeStackAttachProcess()to attach to targetZwAllocateVirtualMemory()to allocate RWX memoryRtlCopyMemory()to write shellcodeRtlCreateUserThread()at shellcode address- Cleanup:
ZwClose,KeUnstackDetachProcess,ObDereferenceObject
Kernel DLL Injection
Ring 0Resolve LoadLibraryW in target process via PEB walking, create thread with DLL path.
- Resolve
RtlCreateUserThreaddynamically - Get
LoadLibraryWaddress in target:- • Get PEB via
PROCESS_PEB_OFFSET[version] - • Walk
PEB→Ldr→InLoadOrderModuleListto find kernel32.dll - • Parse PE export directory to find LoadLibraryW
- • Get PEB via
- Attach to target process
- Allocate memory for wide-char DLL path
- Write DLL path via
RtlCopyMemory RtlCreateUserThread(LoadLibraryW, dll_path_addr)
Advantages over Usermode Injection
- • Bypasses usermode hooks — No ntdll.dll syscall interception
- • No CreateRemoteThread — Uses kernel-only RtlCreateUserThread
- • Direct memory access — No WriteProcessMemory API calls
- • Harder to detect — No usermode API call traces
Usage
- Ensure the kernel driver is loaded
- Right-click on a process in the Process tab
- Navigate to Miscellaneous → Kernel Injection
- Select Shellcode Injection or DLL Injection
- Browse for shellcode file (.bin) or DLL file
Implementation
| Item | Location |
|---|---|
| Rust bindings | crates/misc/src/kernel_inject.rs |
| Kernel code | kernelmode/.../DioProcessDriver.cpp |
| IOCTL (Shellcode) | 0x80C |
| IOCTL (DLL) | 0x80D |