Skip to content

Commit 6f0a8dc

Browse files
LeonardoE95copybara-github
authored andcommitted
Copybara import of the project:
-- ce33b31 by LeonardoE95 <[email protected]>: Add JSP payload for Reflective RCE -- 4b6b849 by LeonardoE95 <[email protected]>: Fix: Add newline COPYBARA_INTEGRATE_REVIEW=#127 from mindedsecurity:master 4b6b849 PiperOrigin-RevId: 705246572 Change-Id: I1661382d3a82855365bc8d253598dd2757a078e0
1 parent 2bc8a20 commit 6f0a8dc

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

plugin/src/main/resources/com/google/tsunami/plugin/payload/payload_definitions.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,12 @@ payloads:
9292
validation_regex: (?s).*TSUNAMI_PAYLOAD_START$TSUNAMI_PAYLOAD_TOKEN_RANDOMTSUNAMI_PAYLOAD_END.*
9393
vulnerabilityType:
9494
- REFLECTIVE_RCE
95+
- name: jsp_print
96+
interpretation_environment: JSP
97+
execution_environment: EXEC_INTERPRETATION_ENVIRONMENT
98+
uses_callback_server: false
99+
payload_string: <% out.print(String.format("%s%s%s","TSUNAMI_PAYLOAD_START", "$TSUNAMI_PAYLOAD_TOKEN_RANDOM", "TSUNAMI_PAYLOAD_END")); %>
100+
validation_type: VALIDATION_REGEX
101+
validation_regex: (?s).*TSUNAMI_PAYLOAD_START$TSUNAMI_PAYLOAD_TOKEN_RANDOMTSUNAMI_PAYLOAD_END.*
102+
vulnerability_type:
103+
- REFLECTIVE_RCE

plugin/src/test/java/com/google/tsunami/plugin/payload/PayloadGeneratorWithoutCallbackServerTest.java

+37
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ public void nextBytes(byte[] bytes) {
7979
.setExecutionEnvironment(
8080
PayloadGeneratorConfig.ExecutionEnvironment.EXEC_INTERPRETATION_ENVIRONMENT)
8181
.build();
82+
private static final PayloadGeneratorConfig JSP_REFLECTIVE_RCE_CONFIG =
83+
PayloadGeneratorConfig.newBuilder()
84+
.setVulnerabilityType(PayloadGeneratorConfig.VulnerabilityType.REFLECTIVE_RCE)
85+
.setInterpretationEnvironment(PayloadGeneratorConfig.InterpretationEnvironment.JSP)
86+
.setExecutionEnvironment(
87+
PayloadGeneratorConfig.ExecutionEnvironment.EXEC_INTERPRETATION_ENVIRONMENT)
88+
.build();
8289
private static final PayloadGeneratorConfig WINDOWS_REFLECTIVE_RCE_CONFIG =
8390
PayloadGeneratorConfig.newBuilder()
8491
.setVulnerabilityType(PayloadGeneratorConfig.VulnerabilityType.REFLECTIVE_RCE)
@@ -250,6 +257,36 @@ public void checkIfExecuted_withJavaConfiguration_andIncorrectInput_returnsFalse
250257
ByteString.copyFromUtf8("TSUNAMI_PAYLOAD_START ffffffffffffffff TSUNAMI_PAYLOAD_END")));
251258
}
252259

260+
@Test
261+
public void getPayload_withJspConfiguration_returnsPrintfPayload() {
262+
Payload payload = payloadGenerator.generate(JSP_REFLECTIVE_RCE_CONFIG);
263+
264+
assertThat(payload.getPayload())
265+
.isEqualTo(
266+
"<% out.print(String.format(\"%s%s%s\",\"TSUNAMI_PAYLOAD_START\", \"ffffffffffffffff\","
267+
+ " \"TSUNAMI_PAYLOAD_END\")); %>");
268+
assertFalse(payload.getPayloadAttributes().getUsesCallbackServer());
269+
}
270+
271+
@Test
272+
public void checkIfExecuted_withJspConfiguration_andCorrectInput_returnsTrue() {
273+
Payload payload = payloadGenerator.generate(JSP_REFLECTIVE_RCE_CONFIG);
274+
275+
assertTrue(
276+
payload.checkIfExecuted(
277+
ByteString.copyFromUtf8(
278+
"RANDOMOUTPUTTSUNAMI_PAYLOAD_STARTffffffffffffffffTSUNAMI_PAYLOAD_END")));
279+
}
280+
281+
@Test
282+
public void checkIfExecuted_withJspConfiguration_andIncorrectInput_returnsFalse() {
283+
Payload payload = payloadGenerator.generate(JSP_REFLECTIVE_RCE_CONFIG);
284+
285+
assertFalse(
286+
payload.checkIfExecuted(
287+
ByteString.copyFromUtf8("TSUNAMI_PAYLOAD_START ffffffffffffffff TSUNAMI_PAYLOAD_END")));
288+
}
289+
253290
@Test
254291
public void getPayload_withSsrfConfiguration_returnsGooglePayload() {
255292
Payload payload = payloadGenerator.generate(ANY_SSRF_CONFIG);

proto/payload_generator.proto

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ message PayloadGeneratorConfig {
6262
LINUX_ROOT_CRONTAB = 5;
6363
// Payload is interpreted wihin a Windows shell environment
6464
WINDOWS_SHELL = 6;
65+
// Payload is interpreted within a JSP shell environment
66+
JSP = 7;
6567
}
6668

6769
// The actual runtime environment when the payload is run e.g. while a

0 commit comments

Comments
 (0)