ptrace-inject

Crates.ioptrace-inject
lib.rsptrace-inject
version0.1.2
sourcesrc
created_at2023-04-07 02:06:07.750615
updated_at2023-04-16 23:20:30.055233
descriptionShared library injection for *nix using ptrace.
homepage
repositoryhttps://github.com/Artemis21/ptrace-inject
max_upload_size
id832693
size59,543
Artemis Vellacott (Artemis21)

documentation

https://docs.rs/ptrace-inject

README

ptrace-inject

ptrace-inject is a tool for injecting code into a running process using ptrace. It is a tool for *nix systems - for Windows, see dll-syringe. Currently, only x64 is supported, but support for other architectures is planned as soon as I can test them.

ptrace-inject is both a Rust library and a command line tool. Here's an example of using the library:

use std::{process::Command, path::PathBuf};
use ptrace_inject::{Injector, Process};

let library = PathBuf::from("path/to/library.so");

// Spawn a new process and inject the library into it.
let target = Command::new("target-process");
Injector::spawn(target)?.inject(&library)?;

// Or attach to an existing process.
let proc = Process::by_name("target-process")?.expect("to find target process");
Injector::attach(proc)?.inject(&library)?;

See the documentation for more information.

The usage of the command line tool is as follows:

Usage: ptrace-inject [OPTIONS] <--name <NAME>|--pid <PID>> <LIBRARY>

Arguments:
  <LIBRARY>  Path to the library to inject

Options:
  -v, --verbose...   More output per occurrence
  -q, --quiet...     Less output per occurrence
  -n, --name <NAME>  Name of a process to attach to
  -p, --pid <PID>    PID of a process to attach to
  -h, --help         Print help
  -V, --version      Print version

You can install it with cargo install ptrace-inject --features cli.

Commit count: 4

cargo fmt