Skip to main content

Python DLL injector for Windows.

Project description

PyDll-Injector

Python DLL injector for Windows. Supports various injection methods.

Features

PyDll-Injector comes with the following features:

  • DLL Injection on app start: Injects DLL(s) into a process when it starts;
  • Env variables support: Enables you to pass environmental variables to the injected DLL;
  • Multiple injection methods: Supports various injection methods;
  • Check if process is running: Checks if a process is running after injection;
  • Graceful process termination: Allows you to terminate the spawned process;
  • Ready to use CLI: Comes with a command line interface for easy usage.

Injection methods

The following injection methods are supported:

  • standard: Classic CreateRemoteThread + LoadLibraryA;
  • apc: QueueUserAPC + LoadLibraryA. Target thread must enter an alertable state;
  • nt: NtCreateThreadEx + LoadLibraryA (stealthier than CreateRemoteThread);
  • hook: SetWindowsHookExA(WH_CBT) injection. DLL must export HookProc.

Usage

You can use PyDll-Injector via the command line interface or as a library in your Python code.

CLI

Install the package on your system:

pip install pydll-injector ".[cli]"

You can now use PyDll-Injector from the command line like this:

pydll-injector --executable-file "A:\Path\To\App.exe" --dll-list "B:\Path\To\Your.dll"

For the list of all available CLI options, run:

pydll-injector --help

This injector also allows you to pass configuration via a toml file. Here is a sample configuration file:

[launcher]
executable_file = "A:\\Path\\To\\App.exe"
cmd_line_args = "-arg1 -arg2"
dll_list = [
    "B:\\Path\\To\\Your.dll",
]
injection_method = "nt"

[environment]
vars = ["FOO=bar", "BAZ=qux"]
use_system_env = true
environment_append = false

Library

First, install the package. For example, using uv:

uv add pydll-injector

You can now import the library and use it in your Python code:

from pydll_injector.process import spawn_process, is_process_running
from pydll_injector.models import Launcher, Environment

def main() -> None:
    launcher = Launcher(
        executable_file= r"A:\Path\To\App.exe",
        cmd_line_args="",
        dll_list=[r"B:\\Path\\To\\Your.dll"],
        injection_method='apc',
    )
    env = Environment(
        vars=["FOO=bar"],
        use_system_env=True,
        environment_append=False
    )

    ctx = spawn_process(launcher, env)
    while is_process_running(ctx):
        pass

    print("Process has exited.")

if __name__ == "__main__":
    main()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydll_injector-0.1.0.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydll_injector-0.1.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file pydll_injector-0.1.0.tar.gz.

File metadata

  • Download URL: pydll_injector-0.1.0.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.20

File hashes

Hashes for pydll_injector-0.1.0.tar.gz
Algorithm Hash digest
SHA256 29b58d115e9b46217ddbd89139c3079abae0f095e3606fba05be7b50186a0cc3
MD5 20e12269da0222d9266224b06a646312
BLAKE2b-256 7978384a41c0114560047cd7dea2d6737f0b7b28df8c8e4a2bf748f6544dbb83

See more details on using hashes here.

File details

Details for the file pydll_injector-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pydll_injector-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69c520671aa3fa80af369a39487b2a4dd36fb0eac5f76c9917bdeed5fcc830aa
MD5 117b62fb86d52fda7ad4493993b874bd
BLAKE2b-256 8714cf6499b0fbc7463af858e162acb47e9dc75b7ac04c1e5b302910fa7b7553

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page