diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/MvcConfiguration.java b/webgoat-container/src/main/java/org/owasp/webgoat/MvcConfiguration.java index fd2bf0333..e26aa0b5e 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/MvcConfiguration.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/MvcConfiguration.java @@ -58,6 +58,8 @@ import java.io.File; */ @Configuration public class MvcConfiguration extends WebMvcConfigurerAdapter { + + private static final String UTF8 = "UTF-8"; @Autowired @Qualifier("pluginTargetDirectory") @@ -80,6 +82,7 @@ public class MvcConfiguration extends WebMvcConfigurerAdapter { resolver.setSuffix(".html"); resolver.setOrder(1); resolver.setCacheable(false); + resolver.setCharacterEncoding(UTF8); resolver.setApplicationContext(applicationContext); return resolver; } @@ -89,6 +92,7 @@ public class MvcConfiguration extends WebMvcConfigurerAdapter { LessonTemplateResolver resolver = new LessonTemplateResolver(pluginTargetDirectory, resourceLoader); resolver.setOrder(2); resolver.setCacheable(false); + resolver.setCharacterEncoding(UTF8); return resolver; } @@ -97,6 +101,7 @@ public class MvcConfiguration extends WebMvcConfigurerAdapter { AsciiDoctorTemplateResolver resolver = new AsciiDoctorTemplateResolver(language); resolver.setCacheable(false); resolver.setOrder(3); + resolver.setCharacterEncoding(UTF8); return resolver; } diff --git a/webgoat-container/src/main/resources/static/css/main.css b/webgoat-container/src/main/resources/static/css/main.css index 59f674616..27a4e6d83 100644 --- a/webgoat-container/src/main/resources/static/css/main.css +++ b/webgoat-container/src/main/resources/static/css/main.css @@ -1001,9 +1001,15 @@ cookie-container { margin: 3px; } +@keyframes blink { + 50% { border-color: white; } +} + .cur-page { - border-bottom: 2px solid #000; + animation: blink 1.5s 2 forwards; + border: 3px solid blue; color:#aaa; + background-color: lightsalmon; } span.show-next-page, span.show-prev-page { diff --git a/webgoat-lessons/chrome-dev-tools/src/main/java/org/owasp/webgoat/plugin/NetworkDummy.java b/webgoat-lessons/chrome-dev-tools/src/main/java/org/owasp/webgoat/plugin/NetworkDummy.java index 9a462f77a..e5efd285d 100644 --- a/webgoat-lessons/chrome-dev-tools/src/main/java/org/owasp/webgoat/plugin/NetworkDummy.java +++ b/webgoat-lessons/chrome-dev-tools/src/main/java/org/owasp/webgoat/plugin/NetworkDummy.java @@ -3,6 +3,7 @@ package org.owasp.webgoat.plugin; import org.owasp.webgoat.assignments.AssignmentEndpoint; import org.owasp.webgoat.assignments.AssignmentPath; import org.owasp.webgoat.assignments.AttackResult; +import org.owasp.webgoat.session.UserSessionData; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -21,7 +22,16 @@ public class NetworkDummy extends AssignmentEndpoint { @RequestMapping(method = RequestMethod.POST) public @ResponseBody - AttackResult completed(@RequestParam String networkNum) throws IOException { - return trackProgress(failed().feedback("network.request").build()); + AttackResult completed(@RequestParam String successMessage) throws IOException { + + UserSessionData userSessionData = getUserSessionData(); + String answer = (String) userSessionData.getValue("randValue"); + + if (successMessage!=null && successMessage.equals(answer)) { + return trackProgress(success().feedback("xss-dom-message-success").build()); + } else { + return trackProgress(failed().feedback("xss-dom-message-failure").build()); + } + } } \ No newline at end of file diff --git a/webgoat-lessons/chrome-dev-tools/src/main/java/org/owasp/webgoat/plugin/NetworkLesson.java b/webgoat-lessons/chrome-dev-tools/src/main/java/org/owasp/webgoat/plugin/NetworkLesson.java index 41071eaff..1969e53e9 100644 --- a/webgoat-lessons/chrome-dev-tools/src/main/java/org/owasp/webgoat/plugin/NetworkLesson.java +++ b/webgoat-lessons/chrome-dev-tools/src/main/java/org/owasp/webgoat/plugin/NetworkLesson.java @@ -4,6 +4,7 @@ import org.owasp.webgoat.assignments.AssignmentEndpoint; import org.owasp.webgoat.assignments.AssignmentHints; import org.owasp.webgoat.assignments.AssignmentPath; import org.owasp.webgoat.assignments.AttackResult; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -21,7 +22,7 @@ import java.io.IOException; @AssignmentHints({"networkHint1", "networkHint2"}) public class NetworkLesson extends AssignmentEndpoint { - @RequestMapping(method = RequestMethod.POST) + @RequestMapping(method = RequestMethod.POST, params= {"network_num","number"}) public @ResponseBody AttackResult completed(@RequestParam String network_num, @RequestParam String number) throws IOException { @@ -31,4 +32,11 @@ public class NetworkLesson extends AssignmentEndpoint { return trackProgress(failed().feedback("network.failed").build()); } } + + @RequestMapping(method = RequestMethod.POST, params="networkNum") + public + @ResponseBody + ResponseEntity ok(@RequestParam String networkNum) throws IOException { + return ResponseEntity.ok().build(); + } } diff --git a/webgoat-lessons/chrome-dev-tools/src/main/resources/html/ChromeDevTools.html b/webgoat-lessons/chrome-dev-tools/src/main/resources/html/ChromeDevTools.html index d8d576bb6..807cc5a4b 100644 --- a/webgoat-lessons/chrome-dev-tools/src/main/resources/html/ChromeDevTools.html +++ b/webgoat-lessons/chrome-dev-tools/src/main/resources/html/ChromeDevTools.html @@ -2,25 +2,29 @@ +
+
+
+
@@ -30,17 +34,19 @@
+
+
@@ -78,7 +78,7 @@
diff --git a/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson6aTest.java b/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson6aTest.java index 71d85443c..dc65e7eb3 100644 --- a/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson6aTest.java +++ b/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson6aTest.java @@ -30,7 +30,7 @@ public class SqlInjectionLesson6aTest extends LessonTest { @Test public void wrongSolution() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjection/attack6a") + mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjectionAdvanced/attack6a") .param("userid_6a", "John")) .andExpect(status().isOk()) @@ -39,7 +39,7 @@ public class SqlInjectionLesson6aTest extends LessonTest { @Test public void wrongNumberOfColumns() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjection/attack6a") + mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjectionAdvanced/attack6a") .param("userid_6a", "Smith' union select userid,user_name, password,cookie from user_system_data --")) .andExpect(status().isOk()) @@ -49,7 +49,7 @@ public class SqlInjectionLesson6aTest extends LessonTest { @Test public void wrongDataTypeOfColumns() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjection/attack6a") + mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjectionAdvanced/attack6a") .param("userid_6a", "Smith' union select 1,password, 1,'2','3', '4',1 from user_system_data --")) .andExpect(status().isOk()) @@ -59,16 +59,16 @@ public class SqlInjectionLesson6aTest extends LessonTest { @Test public void correctSolution() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjection/attack6a") + mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjectionAdvanced/attack6a") .param("userid_6a", "Smith'; SELECT * from user_system_data; --")) .andExpect(status().isOk()) - .andExpect(jsonPath("$.lessonCompleted", is(false))) + .andExpect(jsonPath("$.lessonCompleted", is(true))) .andExpect(jsonPath("$.feedback", containsString("passW0rD"))); } @Test public void noResultsReturned() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjection/attack6a") + mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjectionAdvanced/attack6a") .param("userid_6a", "Smith' and 1 = 2 --")) .andExpect(status().isOk()) @@ -78,10 +78,11 @@ public class SqlInjectionLesson6aTest extends LessonTest { @Test public void noUnionUsed() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjection/attack6a") + mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjectionAdvanced/attack6a") .param("userid_6a", "S'; Select * from user_system_data; --")) .andExpect(status().isOk()) + .andExpect(jsonPath("$.lessonCompleted", is(true))) .andExpect(jsonPath("$.feedback", containsString("UNION"))); } } \ No newline at end of file diff --git a/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson6bTest.java b/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson6bTest.java index 7341a6d3a..cfb8aebfe 100644 --- a/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson6bTest.java +++ b/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/introduction/SqlInjectionLesson6bTest.java @@ -29,7 +29,7 @@ public class SqlInjectionLesson6bTest extends LessonTest { @Test public void submitCorrectPassword() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjection/attack6b") + mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjectionAdvanced/attack6b") .param("userid_6b", "passW0rD")) .andExpect(status().isOk()).andExpect(jsonPath("$.lessonCompleted", is(true))); @@ -37,7 +37,7 @@ public class SqlInjectionLesson6bTest extends LessonTest { @Test public void submitWrongPassword() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjection/attack6b") + mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjectionAdvanced/attack6b") .param("userid_6b", "John")) .andExpect(status().isOk()).andExpect(jsonPath("$.lessonCompleted", is(false))); diff --git a/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/mitigation/SqlInjectionLesson12aTest.java b/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/mitigation/SqlInjectionLesson12aTest.java index cee8e8c13..974d48b7f 100644 --- a/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/mitigation/SqlInjectionLesson12aTest.java +++ b/webgoat-lessons/sql-injection/src/test/java/org/owasp/webgoat/plugin/mitigation/SqlInjectionLesson12aTest.java @@ -38,7 +38,7 @@ public class SqlInjectionLesson12aTest extends LessonTest { @Test public void knownAccountShouldDisplayData() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjection/servers") + mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjectionMitigations/servers") .param("column", "id")) .andExpect(status().isOk()); @@ -46,7 +46,7 @@ public class SqlInjectionLesson12aTest extends LessonTest { @Test public void addressCorrectShouldOrderByHostname() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjection/servers") + mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjectionMitigations/servers") .param("column", "CASE WHEN (SELECT ip FROM servers WHERE hostname='webgoat-prd') LIKE '104.%' THEN hostname ELSE id END")) .andExpect(status().isOk()).andExpect(jsonPath("$[0].hostname", is("webgoat-acc"))); @@ -54,17 +54,17 @@ public class SqlInjectionLesson12aTest extends LessonTest { @Test public void addressCorrectShouldOrderByHostnameUsingSubstr() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjection/servers") + mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjectionMitigations/servers") .param("column", "case when (select ip from servers where hostname='webgoat-prd' and substr(ip,1,1) = '1') IS NOT NULL then hostname else id end")) .andExpect(status().isOk()).andExpect(jsonPath("$[0].hostname", is("webgoat-acc"))); - mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjection/servers") + mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjectionMitigations/servers") .param("column", "case when (select ip from servers where hostname='webgoat-prd' and substr(ip,2,1) = '0') IS NOT NULL then hostname else id end")) .andExpect(status().isOk()).andExpect(jsonPath("$[0].hostname", is("webgoat-acc"))); - mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjection/servers") + mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjectionMitigations/servers") .param("column", "case when (select ip from servers where hostname='webgoat-prd' and substr(ip,3,1) = '4') IS NOT NULL then hostname else id end")) .andExpect(status().isOk()).andExpect(jsonPath("$[0].hostname", is("webgoat-acc"))); @@ -72,7 +72,7 @@ public class SqlInjectionLesson12aTest extends LessonTest { @Test public void addressIncorrectShouldOrderByIdUsingSubstr() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjection/servers") + mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjectionMitigations/servers") .param("column", "case when (select ip from servers where hostname='webgoat-prd' and substr(ip,1,1) = '9') IS NOT NULL then hostname else id end")) .andExpect(status().isOk()).andExpect(jsonPath("$[0].hostname", is("webgoat-dev"))); @@ -80,7 +80,7 @@ public class SqlInjectionLesson12aTest extends LessonTest { @Test public void trueShouldSortByHostname() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjection/servers") + mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjectionMitigations/servers") .param("column", "(case when (true) then hostname else id end)")) .andExpect(status().isOk()) @@ -89,7 +89,7 @@ public class SqlInjectionLesson12aTest extends LessonTest { @Test public void falseShouldSortById() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjection/servers") + mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjectionMitigations/servers") .param("column", "(case when (true) then hostname else id end)")) .andExpect(status().isOk()) @@ -98,7 +98,7 @@ public class SqlInjectionLesson12aTest extends LessonTest { @Test public void addressIncorrectShouldOrderByHostname() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjection/servers") + mockMvc.perform(MockMvcRequestBuilders.get("/SqlInjectionMitigations/servers") .param("column", "CASE WHEN (SELECT ip FROM servers WHERE hostname='webgoat-prd') LIKE '192.%' THEN hostname ELSE id END")) .andExpect(status().isOk()).andExpect(jsonPath("$[0].hostname", is("webgoat-dev"))); @@ -106,7 +106,7 @@ public class SqlInjectionLesson12aTest extends LessonTest { @Test public void postingCorrectAnswerShouldPassTheLesson() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjection/attack12a") + mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjectionMitigations/attack12a") .param("ip", "104.130.219.202")) .andExpect(status().isOk()).andExpect(jsonPath("$.lessonCompleted", is(true))); @@ -114,7 +114,7 @@ public class SqlInjectionLesson12aTest extends LessonTest { @Test public void postingWrongAnswerShouldNotPassTheLesson() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjection/attack12a") + mockMvc.perform(MockMvcRequestBuilders.post("/SqlInjectionMitigations/attack12a") .param("ip", "192.168.219.202")) .andExpect(status().isOk()).andExpect(jsonPath("$.lessonCompleted", is(false)));