diff --git a/build.xml b/build.xml index c81152c38..278dfbb5c 100644 --- a/build.xml +++ b/build.xml @@ -60,8 +60,8 @@ - - + + diff --git a/pom.xml b/pom.xml index 8938e3613..9238c4fef 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ WebGoat WebGoat war - 5.4-SNAPSHOT + 6.0-SNAPSHOT @@ -13,7 +13,13 @@ http://download.java.net/maven/2 - + + + + 3.0.5.RELEASE + 3.1.2.RELEASE + 2.2.2 + @@ -149,14 +155,7 @@ net.sourceforge.jtds jtds 1.2.2 - - - - javax.servlet - servlet-api - 2.3 - provided - + org.apache.tomcat tomcat-catalina @@ -164,5 +163,139 @@ provided + + + + + + javax + javaee-api + 6.0 + provided + + + + org.springframework + spring-core + ${org.springframework.version} + + + + + org.springframework + spring-webmvc + ${org.springframework.version} + jar + + + + org.springframework.security + spring-security-core + ${spring.security.version} + + + + org.springframework.security + spring-security-config + ${spring.security.version} + + + + org.springframework.security + spring-security-web + ${spring.security.version} + + + + + commons-fileupload + commons-fileupload + 1.2.2 + + + + + commons-io + commons-io + 1.3.2 + + + + + javax.servlet + jstl + 1.2 + + + + taglibs + standard + 1.1.2 + + + + log4j + log4j + 1.2.15 + + + javax.jms + jms + + + com.sun.jdmk + jmxtools + + + com.sun.jmx + jmxri + + + + + junit + junit + 4.8.1 + jar + + + org.apache.tiles + tiles-core + ${tiles.version} + jar + + + org.apache.tiles + tiles-template + ${tiles.version} + jar + + + org.apache.tiles + tiles-servlet + ${tiles.version} + jar + + + org.apache.tiles + tiles-jsp + ${tiles.version} + jar + + + org.slf4j + slf4j-api + 1.5.8 + jar + + + org.slf4j + slf4j-log4j12 + 1.5.8 + jar + + + + diff --git a/src/main/java/org/owasp/webgoat/lessons/AbstractLesson.java b/src/main/java/org/owasp/webgoat/lessons/AbstractLesson.java index 54a710146..804c1d0df 100644 --- a/src/main/java/org/owasp/webgoat/lessons/AbstractLesson.java +++ b/src/main/java/org/owasp/webgoat/lessons/AbstractLesson.java @@ -561,6 +561,20 @@ public abstract class AbstractLesson extends Screen implements ComparableReturns the default "path" portion of a lesson's URL.

+ * + *

Legacy webgoat lesson links are of the form "attack?Screen=Xmenu=Ystage=Z". + * This method returns the path portion of the url, i.e., "attack" in the string above.

+ * + *

Newer, Spring-Controller-based classes will override this method + * to return "*.do"-styled paths.

+ */ + protected String getPath() { + return "attack"; + } /** * Get the link that can be used to request this screen. @@ -571,7 +585,8 @@ public abstract class AbstractLesson extends Screen implements Comparable + * + */ +@Controller +public class HttpBasicsController extends LessonAdapter { + + protected static Logger logger = Logger.getLogger("controller"); + + // [url] path used by this lesson + private final String PAGE_PATH = "httpBasics.do"; + + // The (apache) tile used by this lesson, as specified in tiles-definitions.xml + private String TILE_NAME = "http-basics"; + + // ID attribute associated with the JSP's form. + private String FORM_NAME = "command"; + + + /** + * @see {@link org.owasp.webgoat.lessons.AbstractLesson#getPath()} + * @see {@link org.owasp.webgoat.lessons.AbstractLesson#getLink()} + */ + protected String getPath() { + return PAGE_PATH; + } + + /** + * Handles GET requests for this lesson. + * @return + */ + @RequestMapping(value = PAGE_PATH, method = RequestMethod.GET) + public ModelAndView displayPage() { + return new ModelAndView(TILE_NAME, FORM_NAME, new HttpBasicsModel()); + } + + /** + * Handles POST requests for this lesson. Takes the user's name and displays + * a reversed copy of it. + * + * @param httpBasicsModel + * @param model + * @return + */ + @RequestMapping(value = PAGE_PATH, method = RequestMethod.POST) + public ModelAndView processSubmit( + @ModelAttribute("")HttpBasicsModel httpBasicsModel, ModelMap model) { + + StringBuffer personName = new StringBuffer(httpBasicsModel.getPersonName()); + httpBasicsModel.setPersonName(personName.reverse().toString()); + + return new ModelAndView(TILE_NAME, FORM_NAME, httpBasicsModel); + } + + + public Category getCategory() + { + return Category.GENERAL; + } + + /** + * Gets the hints attribute of the HelloScreen object + * + * @return The hints value + */ + public List getHints(WebSession s) + { + List hints = new ArrayList(); + hints.add("Type in your name and press 'go'"); + hints.add("Turn on Show Parameters or other features"); + hints.add("Try to intercept the request with WebScarab"); + hints.add("Press the Show Lesson Plan button to view a lesson summary"); + hints.add("Press the Show Solution button to view a lesson solution"); + + return hints; + } + + protected String getInstructions() + { + return null; + } + + public String getTitle() + { + // TODO: GET RID OF THE "(Spring MVC)" BELOW LATER!!!!" + return "HTTP Basics (Spring MVC)"; + } +} diff --git a/src/main/java/org/owasp/webgoat/lessons/model/HttpBasicsModel.java b/src/main/java/org/owasp/webgoat/lessons/model/HttpBasicsModel.java new file mode 100644 index 000000000..c601eae00 --- /dev/null +++ b/src/main/java/org/owasp/webgoat/lessons/model/HttpBasicsModel.java @@ -0,0 +1,21 @@ +package org.owasp.webgoat.lessons.model; + +/** + * Model component for the Http Basics lesson. Using a model + * for that simple lesson is architectural overkill. We do it anyway + * for illustrative purposes - to demonstrate the pattern that we will + * use for more complex lessons. + * + */ +public class HttpBasicsModel { + + private String personName; + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } +} diff --git a/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml b/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml new file mode 100644 index 000000000..e39db6527 --- /dev/null +++ b/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/pages/layouts/genericLesson.jsp b/src/main/webapp/WEB-INF/pages/layouts/genericLesson.jsp new file mode 100644 index 000000000..2c2896489 --- /dev/null +++ b/src/main/webapp/WEB-INF/pages/layouts/genericLesson.jsp @@ -0,0 +1,70 @@ +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%> +<%@ page + language="java" + contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8" + import="org.owasp.webgoat.session.*, org.owasp.webgoat.lessons.AbstractLesson, org.owasp.webgoat.util.*" + errorPage="" + isELIgnored="false" %> + + + + + + <tiles:insertAttribute name="title-content" /> + + + + + + + + + + + + + <% + Course course = ((Course)session.getAttribute("course")); + WebSession webSession = ((WebSession)session.getAttribute("websession")); + + // pcs 8/29/2012 - HACK + // + // Legacy lessons result in a call to WebSession.update(). Among other things, that call + // sets the previous and current screens. The latter determines the title that is displayed + // in the webgoat banner. + // + // The new Spring-MVC jsps, among which is this genericLesson.jsp, are loaded via our dispatcher servlet + // and does not pass through the code path that results in that update() call. + // + // As a result, we must call update() explicitly here. If we refactor away that legacy code as part + // of webgoat 6 development, we will need to get rid of the call below. + // + webSession.update(request, response, "genericLesson"); + AbstractLesson currentLesson = webSession.getCurrentLesson(); + %> + +
+
+
<%= currentLesson.getTitle() %>
+ + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/pages/lessons/httpBasics.jsp b/src/main/webapp/WEB-INF/pages/lessons/httpBasics.jsp new file mode 100644 index 000000000..4a4284e64 --- /dev/null +++ b/src/main/webapp/WEB-INF/pages/lessons/httpBasics.jsp @@ -0,0 +1,77 @@ +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%> +<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%> +<%@ page + language="java" + contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8" + import="org.owasp.webgoat.session.*, org.owasp.webgoat.lessons.AbstractLesson" + errorPage="" + isELIgnored="false" %> + + + + +<% + Course course = ((Course)session.getAttribute("course")); + WebSession webSession = ((WebSession)session.getAttribute("websession")); +%> + + <%-- + This form posts to httpBasics.do. However, we must append the "menu" request parameter in order + for the current submenu to display properly, hence the getLink() call to build the form's + action attribute below. + --%> + +

+ Enter your name in the input field below and press "go" to submit. + The server will accept the request, reverse the input, and display it back to the user, + illustrating the basics of handling an HTTP request. +

+ +

+ The user should become familiar with the features of WebGoat by manipulating + the above buttons to view hints, show the HTTP request parameters, + the HTTP request cookies, and the Java source code. + You may also try using WebScarab for the first time. +

+ +

+ Enter your name: + + +

+
diff --git a/src/main/webapp/WEB-INF/pages/sections/footer.jsp b/src/main/webapp/WEB-INF/pages/sections/footer.jsp new file mode 100644 index 000000000..4f330d11b --- /dev/null +++ b/src/main/webapp/WEB-INF/pages/sections/footer.jsp @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/pages/sections/header.jsp b/src/main/webapp/WEB-INF/pages/sections/header.jsp new file mode 100644 index 000000000..68072d255 --- /dev/null +++ b/src/main/webapp/WEB-INF/pages/sections/header.jsp @@ -0,0 +1,2 @@ +
+
\ No newline at end of file diff --git a/src/main/webapp/WEB-INF/pages/sections/hintsParamsAndCookies.jsp b/src/main/webapp/WEB-INF/pages/sections/hintsParamsAndCookies.jsp new file mode 100644 index 000000000..aaf05658f --- /dev/null +++ b/src/main/webapp/WEB-INF/pages/sections/hintsParamsAndCookies.jsp @@ -0,0 +1,45 @@ +<%@ page + language="java" + contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8" + import="java.util.Iterator, org.owasp.webgoat.session.*, org.owasp.webgoat.lessons.AbstractLesson, org.owasp.webgoat.util.*" + errorPage="" + isELIgnored="false" %> + +<% +Course course = ((Course)session.getAttribute("course")); +WebSession webSession = ((WebSession)session.getAttribute("websession")); +AbstractLesson currentLesson = webSession.getCurrentLesson(); + +if (webSession.getHint() != null) +{ +%> +
<%= webSession.getHint() %>

+<% +} + +if (webSession.getParams() != null) +{ + Iterator i = webSession.getParams().iterator(); + while (i.hasNext()) + { + Parameter p = (Parameter) i.next(); +%> +
<%= p.getName()%> = <%= p.getValue() %>

+<% + } +} + + +if (webSession.getCookies() != null) +{ + Iterator i = webSession.getCookies().iterator(); + while (i.hasNext()) + { + Cookie c = (Cookie) i.next(); +%> +
+<% + } +} +%> \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/pages/sections/menu.jsp b/src/main/webapp/WEB-INF/pages/sections/menu.jsp new file mode 100644 index 000000000..aa192f9cb --- /dev/null +++ b/src/main/webapp/WEB-INF/pages/sections/menu.jsp @@ -0,0 +1,202 @@ +<%@ page contentType="text/html; charset=ISO-8859-1" language="java" + import="org.owasp.webgoat.session.*, org.owasp.webgoat.lessons.Category, org.owasp.webgoat.lessons.AbstractLesson, org.owasp.webgoat.util.*, java.util.*" + errorPage="" %> +<% +Course course = ((Course)session.getAttribute("course")); +WebSession webSession = ((WebSession)session.getAttribute("websession")); +AbstractLesson currentLesson = webSession.getCurrentLesson(); +%> + + +<%@page import="org.owasp.webgoat.lessons.RandomLessonAdapter"%> + + + +<% +final String menuPrefix = WebSession.MENU; +final String submenuPrefix = "submenu"; +final String mbutPrefix = "mbut"; +String printHint = ""; +String printParameters = ""; +String printCookies = ""; +String lessonComplete = ""; + +List categories = course.getCategories(); + +StringBuffer buildList = new StringBuffer(); + + Iterator iter1 = categories.iterator(); + while(iter1.hasNext()) + { + Category category = (Category)iter1.next(); + + buildList.append("'"); + buildList.append(menuPrefix); + buildList.append(category.getRanking()); + buildList.append("','"); + buildList.append(submenuPrefix); + buildList.append(category.getRanking()); + buildList.append("','"); + buildList.append(mbutPrefix); + buildList.append(category.getRanking()); + buildList.append("'"); + + if (iter1.hasNext()) + buildList.append(","); + }%> + + +
+ <% + int topCord = 140; + int zIndex = 105; + + Iterator iter2 = categories.iterator(); + while(iter2.hasNext()) + { + Category category = (Category)iter2.next(); + %> + + <% + topCord=topCord + 30; + zIndex=zIndex + 1; + } + + int topSubMenu = 72; + + Iterator iter3 = categories.iterator(); + while(iter3.hasNext()) + { + Category category = (Category)iter3.next(); + List lessons = webSession.getLessons(category); + Iterator iter4 = lessons.iterator(); + %> + <% + }%> +
+
+
+ <% if (currentLesson.getAvailableLanguages().size() != 0 ) + { + %> +
+ Choose another language:
+ <% + } else { + %> + Internationalization is not available for this lesson + <% + } + %> +
+
+ LogOut Help +
+
+ <% + if (webSession.isAuthorizedInLesson(webSession.getRole(), WebSession.SHOWHINTS)) + { + %> + + Previous Hint + + + Hints + + + Next Hint + + <%}%> + + Show Params + + + Show Cookies + + + Lesson Plans + + <% + if (webSession.isAuthorizedInLesson(webSession.getRole(), WebSession.SHOWSOURCE)) + { + %> + + Show Java + + + Show Solution + + <%}%> + +
+
+ + +
+
+ + diff --git a/src/main/webapp/WEB-INF/spring-security.xml b/src/main/webapp/WEB-INF/spring-security.xml new file mode 100644 index 000000000..a7a0082e4 --- /dev/null +++ b/src/main/webapp/WEB-INF/spring-security.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/tiles-context.xml b/src/main/webapp/WEB-INF/tiles-context.xml new file mode 100644 index 000000000..c4f1dccc7 --- /dev/null +++ b/src/main/webapp/WEB-INF/tiles-context.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + /WEB-INF/tiles-definitions.xml + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/tiles-definitions.xml b/src/main/webapp/WEB-INF/tiles-definitions.xml new file mode 100644 index 000000000..3f63bb5e7 --- /dev/null +++ b/src/main/webapp/WEB-INF/tiles-definitions.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index ea46dea27..1490812cc 100755 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -1,9 +1,9 @@ - - - + WebGoat @@ -42,6 +42,16 @@ and comments about this application should be addressed. + + + + contextConfigLocation + + /WEB-INF/mvc-dispatcher-servlet.xml, + /WEB-INF/spring-security.xml + + + + + mvc-dispatcher + org.springframework.web.servlet.DispatcherServlet + 1 + + + + mvc-dispatcher + *.do + + + + + org.springframework.web.context.ContextLoaderListener + + + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + + springSecurityFilterChain + /* + + + + + + diff --git a/src/main/webapp/images/header/header.jpg b/src/main/webapp/images/header/header.jpg index d5c71eeba..8900b1327 100644 Binary files a/src/main/webapp/images/header/header.jpg and b/src/main/webapp/images/header/header.jpg differ