• Stars
    star
    175
  • Rank 218,059 (Top 5 %)
  • Language
    C++
  • Created over 3 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kernel mode to user mode dll injection

windows-kernel-dll-injector

TL;DR

Windows kernel mode to user mode dll injection

Tested on Windows x64 1909

Inject a dll to target process from kernel driver

How its works

The injection process is divided into several stages:

  1. Attach current kernel thread to the virtual address space of the target process (KeStackAttachProcess)
  2. Parse kernel32.dll PE header and locate LoadLibraryW function address
    • Get current process PEB (PsGetProcessPeb)
    • Iterate over all loaded modules and find kernel32.dll
    • Parse kernel32.dll PE header in order to find the address of LoadLibraryW
  3. Allocate and copy to target process the APC callback arguments RW (ZwAllocateVirtualMemory)
  4. Allocate and copy to target process the APC callback RWX (ZwAllocateVirtualMemory)
  5. Detach from target process address space (KeUnstackDetachProcess)
  6. Find all target process threads
    • ZwQuerySystemInformation(SystemProcessInformation...)
    • Iterate over all processes and find the target process by its id
    • Return all threads id of the target process
  7. Inject APC to target process in order to execute our APC callback which loads the dll (KeInitializeApc & KeInsertQueueApc)

The whole process described above happens in the kernel driver. The only things that the kernel module needs are: target pid, dll file path.

Limitations

  • The current version supports only in x64 binaries
  • The current version doesn't release the APC callback or the APC callback arguments allocations

Usage

sc create DllInjector binPath= {driver_path} type= kernel

sc start DllInjector

DLLInjectorCom.exe {dll_path} {pid}

DONE!!!

More Repositories

1

linux-kernel-so-injector

Kernel mode to user mode so injection
C
64
star
2

windows-kernel-file-delete

Force a file delete using a windows kernel driver
C++
53
star
3

linux-kernel-debugging

How to create a setup for linux kernel debugging using buildroot
Shell
33
star
4

windows-kernel-file-protector

Protect a file from being deleted using windows kernel file system minifilter driver
C++
26
star
5

linux-kernel-development

Setup for linux kernel development (development, debugging automation and compiling)
Shell
26
star
6

windows-kernel-process-protector

Protect a process from code injection, termination and hooking
C++
25
star
7

linux-kernel-patch-guard

Minimal patch guard for linux kernel
C
22
star
8

windows-kernel-process-killer

Force kill a process using windows kernel driver
C++
20
star
9

linux-kernel-shadow-ssh

Hiding SSH public keys in SSH server using a kernel agent
C
18
star
10

linux-kernel-process-hider

Process hider for Linux systems using a kernel agent
C
17
star
11

linux-kernel-filesystem-filter

Linux kernel filesystem filter driver
C
17
star
12

linux-kernel-ata-sniffer

ATA command sniffer for Linux
C
15
star
13

linux-kernel-pci-enumerator

Enumrate all pci devices inside all pci buses
C
14
star
14

windows-kernel-development

Setup for windows kernel development (development, debugging automation and compiling)
PowerShell
11
star
15

windows-chrome-monitor

Monitor Chrome in order to know when a movie or TV show ends and turns off the computer automatically
C++
9
star
16

windows-kernel-debugging

How to create a setup for windows kernel debugging using WinDbg and VMware Workstation
8
star
17

hypervisor-transparent-hook

Transparent hooks using hypervisor and kernel agent
C++
8
star
18

find-executable-max-stack-size

Find binary maximum stack size usage
Python
6
star
19

windows-kernel-process-initialization

Debug the early stage of process initialization using kernel mode debugging
6
star
20

simple-x86-bootloader

Simple x86 legacy boot bootloader
Assembly
5
star
21

cpuid-utility

Simple exe for sending cpuid
C++
3
star
22

shifts-assigner

Assign shifts to employee pool
Python
2
star
23

book-list

All the books that I recently read
2
star
24

windows-terminal-customization

Windows Terminal Customization
PowerShell
2
star