Pinjectra Process Injection Library

repository·master·Indexed 21 days ago

https://github.com/safebreach-labs/pinjectra

A C/C++ library for implementing modular process injection techniques on Windows 10 64-bit. It features a compositional architecture for mixing injection primitives and includes the 'Stack Bomber' technique to bypass Control Flow Guard (CFG) and Code Integrity Guard (CIG).

Tokens
682
Snippets
2
Records
2
Agent score
24%

What's inside Pinjectra

  1. Overview of Pinjectra process injection library

    master

    Pinjectra is a C/C++ library designed to implement various process injection techniques, specifically optimized for Windows 10 64-bit. The library uses a "mix and match" architectural style, allowing developers to compose different injection primitives into a single execution flow.

    Key features include:

    • Modular composition of injection primitives.
    • Implementation of the "Stack Bomber" technique, which works on Windows 10 64-bit even when Control Flow Guard (CFG) and Code Integrity Guard (CIG) are enabled.
    • Designed for research and testing of process injection capabilities.
    // CreateRemoteThread Demo + DLL Load (i.e., LoadLibraryA as Entry Point)
    executor = new CodeViaCreateRemoteThread(
        new OpenProcess_VirtualAllocEx_WriteProcessMemory(
            (void *)"MsgBoxOnProcessAttach.dll",
            25,
            PROCESS_VM_WRITE | PROCESS_CREATE_THREAD | PROCESS_VM_OPERATION,
            MEM_COMMIT | MEM_RESERVE,
            PAGE_READWRITE),
        LoadLibraryA
    );
    
    executor->inject(pid, tid);
  2. How to compose injection techniques in Pinjectra

    master

    Pinjectra uses a compositional pattern where you instantiate an executor by passing it a combination of primitives.

    In the provided example, CodeViaCreateRemoteThread acts as the high-level executor. It takes a primitive object (e.g., OpenProcess_VirtualAllocEx_WriteProcessMemory) which handles the memory allocation and writing, and an entry point function (e.g., LoadLibraryA). Once composed, you trigger the injection by calling the .inject(pid, tid) method on the executor instance.

    // Example of composing an executor with primitives
    executor = new CodeViaCreateRemoteThread(
        new OpenProcess_VirtualAllocEx_WriteProcessMemory(
            (void *)"MsgBoxOnProcessAttach.dll",
            25,
            PROCESS_VM_WRITE | PROCESS_CREATE_THREAD | PROCESS_VM_OPERATION,
            MEM_COMMIT | MEM_RESERVE,
            PAGE_READWRITE),
        LoadLibraryA
    );
    
    executor->inject(pid, tid);