diff --git a/java/org/owasp/webgoat/HammerHead.java b/java/org/owasp/webgoat/HammerHead.java index 941e1dd4e..a39287b2c 100644 --- a/java/org/owasp/webgoat/HammerHead.java +++ b/java/org/owasp/webgoat/HammerHead.java @@ -134,6 +134,12 @@ public class HammerHead extends HttpServlet { return; } + if ("true".equals(request.getParameter("start"))) { + logger.warn("Redirecting to start controller"); + response.sendRedirect("start.mvc"); + return; + } + // Note: For the lesson to track the status, we need to update // the lesson tracker object // from the screen.createContent() method. The create content is @@ -176,8 +182,9 @@ public class HammerHead extends HttpServlet { clientBrowser = userAgent; } request.setAttribute("client.browser", clientBrowser); - request.getSession().setAttribute("websession", mySession); - request.getSession().setAttribute("course", mySession.getCourse()); + request.getSession().setAttribute(WebSession.SESSION, mySession); + // not sure why this is being set in the session? + request.getSession().setAttribute(WebSession.COURSE, mySession.getCourse()); String viewPage = getViewPage(mySession); logger.debug("Forwarding to view: " + viewPage); logger.debug("Screen: " + screen); @@ -199,18 +206,9 @@ public class HammerHead extends HttpServlet { } private String getViewPage(WebSession webSession) { - String page; - - // If this session has not seen the landing page yet, go there instead. - HttpSession session = webSession.getRequest().getSession(); - if (session.getAttribute(WELCOMED) == null) { - session.setAttribute(WELCOMED, "true"); - page = "/webgoat.jsp"; - } else { - //page = "/main.jsp"; - page = "/lesson_content.jsp"; - } - + // now always display the lesson content + String page = "/lesson_content.jsp"; + //page = "/main.jsp"; return page; } @@ -378,7 +376,7 @@ public class HammerHead extends HttpServlet { HttpSession hs; hs = request.getSession(true); - // System.out.println( "HH Entering Session_id: " + hs.getId() ); + logger.debug("HH Entering Session_id: " + hs.getId()); // dumpSession( hs ); // Get our session object out of the HTTP session WebSession session = null; @@ -388,7 +386,7 @@ public class HammerHead extends HttpServlet { session = (WebSession) o; } else { // Create new custom session and save it in the HTTP session - // System.out.println( "HH Creating new WebSession: " ); + logger.warn("HH Creating new WebSession"); session = new WebSession(webgoatContext, context); // Ensure splash screen shows on any restart // rlawson - removed this since we show splash screen at login now @@ -405,8 +403,8 @@ public class HammerHead extends HttpServlet { session.update(request, response, this.getServletName()); // to authenticate - // System.out.println( "HH Leaving Session_id: " + hs.getId() ); - // dumpSession( hs ); + logger.debug("HH Leaving Session_id: " + hs.getId()); + //dumpSession( hs ); return (session); } diff --git a/java/org/owasp/webgoat/controller/Start.java b/java/org/owasp/webgoat/controller/Start.java index 8b0f5843c..86789eb9f 100644 --- a/java/org/owasp/webgoat/controller/Start.java +++ b/java/org/owasp/webgoat/controller/Start.java @@ -6,7 +6,6 @@ package org.owasp.webgoat.controller; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; diff --git a/java/org/owasp/webgoat/controller/Welcome.java b/java/org/owasp/webgoat/controller/Welcome.java index 60c9db003..5d2f9e93b 100644 --- a/java/org/owasp/webgoat/controller/Welcome.java +++ b/java/org/owasp/webgoat/controller/Welcome.java @@ -7,6 +7,8 @@ package org.owasp.webgoat.controller; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -19,9 +21,10 @@ import org.springframework.web.servlet.ModelAndView; */ @Controller public class Welcome { - + + final Logger logger = LoggerFactory.getLogger(Welcome.class); private static final String WELCOMED = "welcomed"; - + @RequestMapping(value = "welcome.mvc", method = RequestMethod.GET) public ModelAndView welcome(HttpServletRequest request, @RequestParam(value = "error", required = false) String error, @@ -34,11 +37,13 @@ public class Welcome { if (session.getAttribute(WELCOMED) == null) { session.setAttribute(WELCOMED, "true"); } - //@TODO put stuff here the welcome page needs to access + + //go ahead and send them to webgoat (skip the welcome page) ModelAndView model = new ModelAndView(); - model.setViewName("welcome"); - + //model.setViewName("welcome"); + //model.setViewName("main_new"); + model.setViewName("forward:/attack?start=true"); return model; - } + } diff --git a/java/org/owasp/webgoat/lessons/HttpBasicsController.java b/java/org/owasp/webgoat/lessons/HttpBasicsController.java deleted file mode 100644 index 406bebdbd..000000000 --- a/java/org/owasp/webgoat/lessons/HttpBasicsController.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.owasp.webgoat.lessons; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.owasp.webgoat.lessons.model.HttpBasicsModel; -import org.owasp.webgoat.session.WebSession; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -/** - *
- * Handles the "HTTP Basics" lesson. Contains all - * mapping methods for that lesson as well as all helper methods - * used by those mappers. - *
- * - */ -@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 ListLesson Plan Title: Http Basics
-Concept / Topic To Teach:
- This lesson presents the basics for understanding the transfer of data between the browser and the web application.- How HTTP works: -
- All HTTP transactions follow the same general format. Each client request and server response has three parts: the request or response line, a header section, and the entity body. The client initiates a transaction as follows:General Goal(s):
- <%-- Start Instructions --%> - 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. -- 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:
-