Vulnerable components only work in a Docker container
This commit is contained in:
parent
bdbf66c8e1
commit
323daae578
@ -2,13 +2,12 @@ package org.owasp.webgoat;
|
|||||||
|
|
||||||
import io.restassured.RestAssured;
|
import io.restassured.RestAssured;
|
||||||
import io.restassured.http.ContentType;
|
import io.restassured.http.ContentType;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import org.hamcrest.CoreMatchers;
|
import org.hamcrest.CoreMatchers;
|
||||||
import org.hamcrest.MatcherAssert;
|
import org.hamcrest.MatcherAssert;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
public class GeneralLessonIntegrationTest extends IntegrationTest {
|
public class GeneralLessonIntegrationTest extends IntegrationTest {
|
||||||
|
|
||||||
@ -38,12 +37,19 @@ public class GeneralLessonIntegrationTest extends IntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void httpProxies() {
|
public void httpProxies() {
|
||||||
startLesson("HttpProxies");
|
startLesson("HttpProxies");
|
||||||
MatcherAssert.assertThat(RestAssured.given()
|
MatcherAssert.assertThat(
|
||||||
.when().relaxedHTTPSValidation().cookie("JSESSIONID", getWebGoatCookie()).header("x-request-intercepted", "true")
|
RestAssured.given()
|
||||||
|
.when()
|
||||||
|
.relaxedHTTPSValidation()
|
||||||
|
.cookie("JSESSIONID", getWebGoatCookie())
|
||||||
|
.header("x-request-intercepted", "true")
|
||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
.get(url("HttpProxies/intercept-request?changeMe=Requests are tampered easily"))
|
.get(url("HttpProxies/intercept-request?changeMe=Requests are tampered easily"))
|
||||||
.then()
|
.then()
|
||||||
.statusCode(200).extract().path("lessonCompleted"), CoreMatchers.is(true));
|
.statusCode(200)
|
||||||
|
.extract()
|
||||||
|
.path("lessonCompleted"),
|
||||||
|
CoreMatchers.is(true));
|
||||||
|
|
||||||
checkResults("/HttpProxies/");
|
checkResults("/HttpProxies/");
|
||||||
}
|
}
|
||||||
@ -53,28 +59,37 @@ public class GeneralLessonIntegrationTest extends IntegrationTest {
|
|||||||
startLesson("CIA");
|
startLesson("CIA");
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.clear();
|
params.clear();
|
||||||
params.put("question_0_solution", "Solution 3: By stealing a database where names and emails are stored and uploading it to a website.");
|
params.put(
|
||||||
params.put("question_1_solution", "Solution 1: By changing the names and emails of one or more users stored in a database.");
|
"question_0_solution",
|
||||||
params.put("question_2_solution", "Solution 4: By launching a denial of service attack on the servers.");
|
"Solution 3: By stealing a database where names and emails are stored and uploading it to a website.");
|
||||||
params.put("question_3_solution", "Solution 2: The systems security is compromised even if only one goal is harmed.");
|
params.put(
|
||||||
|
"question_1_solution",
|
||||||
|
"Solution 1: By changing the names and emails of one or more users stored in a database.");
|
||||||
|
params.put(
|
||||||
|
"question_2_solution",
|
||||||
|
"Solution 4: By launching a denial of service attack on the servers.");
|
||||||
|
params.put(
|
||||||
|
"question_3_solution",
|
||||||
|
"Solution 2: The systems security is compromised even if only one goal is harmed.");
|
||||||
checkAssignment(url("/WebGoat/cia/quiz"), params, true);
|
checkAssignment(url("/WebGoat/cia/quiz"), params, true);
|
||||||
checkResults("/cia/");
|
checkResults("/cia/");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void vulnerableComponents() {
|
public void vulnerableComponents() {
|
||||||
String solution = "<contact class='dynamic-proxy'>\n" +
|
if (StringUtils.hasText(System.getProperty("running.in.docker"))) {
|
||||||
"<interface>org.owasp.webgoat.lessons.vulnerablecomponents.Contact</interface>\n" +
|
String solution =
|
||||||
" <handler class='java.beans.EventHandler'>\n" +
|
"<contact class='dynamic-proxy'>\n"
|
||||||
" <target class='java.lang.ProcessBuilder'>\n" +
|
+ "<interface>org.owasp.webgoat.lessons.vulnerablecomponents.Contact</interface>\n"
|
||||||
" <command>\n" +
|
+ " <handler class='java.beans.EventHandler'>\n"
|
||||||
" <string>calc.exe</string>\n" +
|
+ " <target class='java.lang.ProcessBuilder'>\n"
|
||||||
" </command>\n" +
|
+ " <command>\n"
|
||||||
" </target>\n" +
|
+ " <string>calc.exe</string>\n"
|
||||||
" <action>start</action>\n" +
|
+ " </command>\n"
|
||||||
" </handler>\n" +
|
+ " </target>\n"
|
||||||
"</contact>";
|
+ " <action>start</action>\n"
|
||||||
|
+ " </handler>\n"
|
||||||
|
+ "</contact>";
|
||||||
startLesson("VulnerableComponents");
|
startLesson("VulnerableComponents");
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.clear();
|
params.clear();
|
||||||
@ -82,6 +97,7 @@ public class GeneralLessonIntegrationTest extends IntegrationTest {
|
|||||||
checkAssignment(url("/WebGoat/VulnerableComponents/attack1"), params, true);
|
checkAssignment(url("/WebGoat/VulnerableComponents/attack1"), params, true);
|
||||||
checkResults("/VulnerableComponents/");
|
checkResults("/VulnerableComponents/");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void insecureLogin() {
|
public void insecureLogin() {
|
||||||
@ -114,10 +130,20 @@ public class GeneralLessonIntegrationTest extends IntegrationTest {
|
|||||||
checkResults("/auth-bypass/");
|
checkResults("/auth-bypass/");
|
||||||
|
|
||||||
startLesson("HttpProxies");
|
startLesson("HttpProxies");
|
||||||
MatcherAssert.assertThat(RestAssured.given().when().relaxedHTTPSValidation().cookie("JSESSIONID", getWebGoatCookie()).header("x-request-intercepted", "true")
|
MatcherAssert.assertThat(
|
||||||
|
RestAssured.given()
|
||||||
|
.when()
|
||||||
|
.relaxedHTTPSValidation()
|
||||||
|
.cookie("JSESSIONID", getWebGoatCookie())
|
||||||
|
.header("x-request-intercepted", "true")
|
||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
.get(url("/WebGoat/HttpProxies/intercept-request?changeMe=Requests are tampered easily")).then()
|
.get(
|
||||||
.statusCode(200).extract().path("lessonCompleted"), CoreMatchers.is(true));
|
url("/WebGoat/HttpProxies/intercept-request?changeMe=Requests are tampered easily"))
|
||||||
|
.then()
|
||||||
|
.statusCode(200)
|
||||||
|
.extract()
|
||||||
|
.path("lessonCompleted"),
|
||||||
|
CoreMatchers.is(true));
|
||||||
checkResults("/HttpProxies/");
|
checkResults("/HttpProxies/");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +167,8 @@ public class GeneralLessonIntegrationTest extends IntegrationTest {
|
|||||||
.post(url("/WebGoat/CrossSiteScripting/phone-home-xss"))
|
.post(url("/WebGoat/CrossSiteScripting/phone-home-xss"))
|
||||||
.then()
|
.then()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
.extract().path("output");
|
.extract()
|
||||||
|
.path("output");
|
||||||
String secretNumber = result.substring("phoneHome Response is ".length());
|
String secretNumber = result.substring("phoneHome Response is ".length());
|
||||||
|
|
||||||
params.clear();
|
params.clear();
|
||||||
@ -168,7 +195,6 @@ public class GeneralLessonIntegrationTest extends IntegrationTest {
|
|||||||
params.put("userId", "12309746");
|
params.put("userId", "12309746");
|
||||||
checkAssignment(url("/auth-bypass/verify-account"), params, true);
|
checkAssignment(url("/auth-bypass/verify-account"), params, true);
|
||||||
checkResults("/auth-bypass/");
|
checkResults("/auth-bypass/");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -180,7 +206,5 @@ public class GeneralLessonIntegrationTest extends IntegrationTest {
|
|||||||
params.put("param2", "Main");
|
params.put("param2", "Main");
|
||||||
checkAssignment(url("/lesson-template/sample-attack"), params, true);
|
checkAssignment(url("/lesson-template/sample-attack"), params, true);
|
||||||
checkResults("/lesson-template/");
|
checkResults("/lesson-template/");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user