From 575d040c2443a0062bad8e6199d7ae487f574dbb Mon Sep 17 00:00:00 2001 From: "sherif.fathy" Date: Thu, 21 Dec 2006 04:39:32 +0000 Subject: [PATCH] Added XMLInjection lesson Modified DOM Injection lesson Added gratification to http splitting git-svn-id: http://webgoat.googlecode.com/svn/trunk@37 4033779f-a91e-0410-96ef-6bf7bf53c507 --- .../owasp/webgoat/lessons/DOMInjection.java | 22 -- .../owasp/webgoat/lessons/HttpSplitting.java | 30 ++- .../owasp/webgoat/lessons/XMLInjection.java | 205 ++++++++++++++++++ .../WebContent/lesson_plans/XMLInjection.html | 18 ++ 4 files changed, 248 insertions(+), 27 deletions(-) create mode 100644 webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/XMLInjection.java create mode 100644 webgoat/main/project/WebContent/lesson_plans/XMLInjection.html diff --git a/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/DOMInjection.java b/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/DOMInjection.java index ab89ef7e9..2de1c05e0 100644 --- a/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/DOMInjection.java +++ b/ webgoat/main/project/JavaSource/org/owasp/webgoat/lessons/DOMInjection.java @@ -8,32 +8,17 @@ import org.apache.ecs.Element; import org.apache.ecs.ElementContainer; import org.apache.ecs.StringElement; import org.apache.ecs.html.BR; -import org.apache.ecs.html.Form; import org.apache.ecs.html.H1; import org.apache.ecs.html.Input; import org.apache.ecs.html.TD; import org.apache.ecs.html.TR; import org.apache.ecs.html.Table; -import org.apache.ecs.html.Button; -import org.owasp.webgoat.session.ECSFactory; import org.owasp.webgoat.session.WebSession; public class DOMInjection extends LessonAdapter { private final static Integer DEFAULT_RANKING = new Integer(10); private final static String KEY = "key"; - /*public void handleRequest( WebSession s ) - { - //Setting a special action to be able to submit to redirect.jsp - Form form = new Form( "/WebGoat/lessons/AJAXSecurity/DOMInjection.jsp?" + - "Screen=" + String.valueOf(getScreenId()) + - "&menu=" + getDefaultCategory().getRanking().toString() - , Form.POST ).setName( "form" ).setEncType( "" ); - - form.addElement( createContent( s ) ); - - setContent(form); - }*/ protected Element createContent(WebSession s) { @@ -68,7 +53,6 @@ public class DOMInjection extends LessonAdapter { String lineSep = System.getProperty("line.separator"); String script = "" + lineSep; + + if (!isDone) + { + ec.addElement( new StringElement(script)); + } + ec.addElement( new BR().addElement (new H1().addElement( "Welcome to WebGoat-Miles Reward Miles Program."))); + ec.addElement( new BR()); + + Table t1 = new Table().setCellSpacing(0).setCellPadding(0).setBorder(0).setWidth("90%").setAlign("center"); + + + TR tr = new TR(); + + tr = new TR(); + + tr.addElement( new TD("Please enter your account ID:") ); + + Input input1 = new Input( Input.TEXT, ACCOUNTID, "" ); + input1.addAttribute("onkeyup", "getRewards();"); + + tr.addElement( new TD(input1)); + t1.addElement( tr ); + + ec.addElement(t1); + ec.addElement(new BR()); + ec.addElement(new BR()); + ec.addElement(new BR()); + + Div div = new Div(); + div.addAttribute("name", "rewardsDiv"); + div.addAttribute("id", "rewardsDiv"); + ec.addElement(div); + + Input b = new Input(); + b.setType( Input.SUBMIT ); + b.setValue( "Submit" ); + b.setName("SUBMIT"); + ec.addElement(b); + + if (s.getParser().getRawParameter("SUBMIT", "")!= "") + { + if(s.getParser().getRawParameter("check3", "") != "") + { + makeSuccess(s); + } + + } + + return ec; + } + + protected Element makeSuccess(WebSession s) + { + getLessonTracker( s ).setCompleted( true ); + + s.setMessage("Congratulations. You have successfully completed this lesson."); + + return ( null ); + } + + public Element getCredits() { + + return new StringElement("Created by Sherif Koussa"); + } + + protected Category getDefaultCategory() { + + return AJAX_SECURITY; + } + + protected Integer getDefaultRanking() { + + return DEFAULT_RANKING; + } + + protected List getHints() { + + List hints = new ArrayList(); + hints.add( "This page is using XMLHTTP to comunicate with the server." ); + hints.add( "Try to intercept the reply and check the reply." ); + hints.add( "Intercept the reply and try to inject some XML to add more rewards to yourself." ); + return hints; + } + + public String getTitle() { + return "XML Injection"; + } + +} diff --git a/ webgoat/main/project/WebContent/lesson_plans/XMLInjection.html b/ webgoat/main/project/WebContent/lesson_plans/XMLInjection.html new file mode 100644 index 000000000..ab272d1b7 --- /dev/null +++ b/ webgoat/main/project/WebContent/lesson_plans/XMLInjection.html @@ -0,0 +1,18 @@ +
+

Lesson Plan Title: XML Injection Attacks.

+
+ +

Concept / Topic To Teach:

+ This lesson teaches how to perform XML Injection attacks. +
+
+

+How the attacks works: +

+AJAX applications use XML to exchange information with the server. This XML can be easily intercepted and altered by a malacious attacker. + +
+

General Goal(s):

+ +The form below takes your WebGoat Rewards Mile account and returns back the kind of rewards you can afford. Your goal is to try to add more rewards to your allowed set of rewards. Your account ID is 836239. +