Coder Social home page Coder Social logo

windows-kernel-dll-injector's Introduction

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!!!

windows-kernel-dll-injector's People

Contributors

rhydon1337 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.