Individual skill

exploiting-macos-dyld-hijacking-and-process-injection

Exploiting macOS dynamic-linker and process-injection primitives during authorized engagements - DYLD_INSERT_LIBRARIES injection, @rpath/missing-dylib hijacking with re-export proxy libraries, dyld interposing and fishhook symbol rebinding, Objective-C method swizzling, and Mach task-port thread hijacking (task_for_pid) including arm64e PAC handling - using otool, codesign, install_name_tool, gcc/clang, and lldb, with EndpointSecurity detection notes.

internal/tools/skills/data/macos-security/exploiting-macos-dyld-hijacking-and-process-injection/SKILL.md

Read pinned source

Source commit d42f381ad34843e71a42658e5c57290c713e85af

What was checked

Matches the observed repository HEAD
Yes
Scanner rules are current
Yes
Repository scan complete
No
Skill scan complete
No
Observed behavior
Network or broad shell
Last checked
Nov 9, 2026

These are observations at the recorded commit, not a guarantee of safety. Review the source before running it.

Install this skill

Choose an agent in your Stack or copy a command below. Commands fetch the pinned commit and copy only this skill directory. Existing destinations are refused. Copying a command does not install anything.

An install command is unavailable: current rules, complete repository and skill scans, an eligible behavior level and a permitted license are required.

Repository context

Repository stars (not skill ratings)
1,315
Repository last updated
Nov 8, 2026
License
Apache-2.0

Observed agent integration: No specific integration evidence. Standard SKILL.md installation does not imply verified compatibility.

Files and excerpt

File metadata and permitted, redacted excerpts come from the recorded scan. Source links are pinned to that commit.

Browse files
Read excerpt

# Exploiting macOS Dyld Hijacking & Process Injection

## When to Use
- You want to **run code inside another process** on macOS to steal secrets (passwords, messages), inherit its TCC/entitlements, or hook its functions.
- A target binary loads libraries via **`@rpath`/`DYLD_INSERT_LIBRARIES`** without library validation, or you hold a **task port** (`task_for_pid`) for a `get-task-allow` process.
- You need to choose between **load-time injection** (dyld) and **runtime injection** (thread hijack / fishhook) based on the target's protections.

## Critical: Techniques Most Often Missed
- **`DYLD_INSERT_LIBRARIES`** — the simplest primitive; a dylib `__attribute__((constructor))` runs before `main`. Blocked on hardened/platform binaries, so check restrictions first.
  ```bash
  # gcc -dynamiclib -o inject.dylib inject.c   (constructor runs execv("/bin/bash",0) etc.)
  DYLD_INSERT_LIBRARIES=inject.dylib ./target
  ```
  - How to CONFIRM: `sudo log stream --style syslog --predicate 'eventMessage CONTAINS[c] "[+] dylib"'` shows your constructor logging when loaded.