Replaced the tabs with spaces so we do not mess up the formatting, used the expand command from linux

This commit is contained in:
nbaars
2014-09-15 16:40:51 +02:00
parent 9bb1cb8d9c
commit 3ae898784f
118 changed files with 21208 additions and 21214 deletions

View File

@ -58,125 +58,125 @@ import org.owasp.webgoat.util.WebGoatI18N;
*/
public class BypassHtmlFieldRestrictions extends SequentialLessonAdapter
{
public final static A MANDIANT_LOGO = new A().setHref("http://www.mandiant.com").addElement(new IMG("images/logos/mandiant.png").setAlt("MANDIANT").setBorder(0).setHspace(0).setVspace(0));
private final static String USERID = "userid";
public final static A MANDIANT_LOGO = new A().setHref("http://www.mandiant.com").addElement(new IMG("images/logos/mandiant.png").setAlt("MANDIANT").setBorder(0).setHspace(0).setVspace(0));
private final static String USERID = "userid";
private String userid;
private String userid;
/**
* Description of the Method
*
* @param s
* Description of the Parameter
* @return Description of the Return Value
*/
protected Element createContent(WebSession s)
{
ElementContainer ec = new ElementContainer();
try {
boolean failed = false;
/**
* Description of the Method
*
* @param s
* Description of the Parameter
* @return Description of the Return Value
*/
protected Element createContent(WebSession s)
{
ElementContainer ec = new ElementContainer();
try {
boolean failed = false;
// select element
ec.addElement(new Div().addElement(new StringElement("Select field with two possible values:")));
String[] allowedSelect = {"foo", "bar"};
ec.addElement(new org.apache.ecs.html.Select("select", allowedSelect));
// radio button element
ec.addElement(new P());
ec.addElement(new Div().addElement(new StringElement("Radio button with two possible values:")));
Input radiofoo = new Input("radio", "radio", "foo");
radiofoo.setChecked(true);
ec.addElement(radiofoo);
ec.addElement(new StringElement("foo"));
ec.addElement(new BR());
ec.addElement(new Input("radio", "radio", "bar"));
ec.addElement(new StringElement("bar"));
// checkbox
ec.addElement(new P());
ec.addElement(new Div().addElement(new StringElement("Checkbox:")));
Input checkbox = new Input("checkbox", "checkbox");
checkbox.setChecked(true);
ec.addElement(checkbox);
ec.addElement(new StringElement("checkbox"));
// create shortinput
ec.addElement(new P());
ec.addElement(new Div().addElement(new StringElement("Input field restricted to 5 characters:")));
Input shortinput = new Input(Input.TEXT, "shortinput", "12345");
shortinput.setMaxlength(5);
ec.addElement(shortinput);
// select element
ec.addElement(new Div().addElement(new StringElement("Select field with two possible values:")));
String[] allowedSelect = {"foo", "bar"};
ec.addElement(new org.apache.ecs.html.Select("select", allowedSelect));
// radio button element
ec.addElement(new P());
ec.addElement(new Div().addElement(new StringElement("Radio button with two possible values:")));
Input radiofoo = new Input("radio", "radio", "foo");
radiofoo.setChecked(true);
ec.addElement(radiofoo);
ec.addElement(new StringElement("foo"));
ec.addElement(new BR());
ec.addElement(new Input("radio", "radio", "bar"));
ec.addElement(new StringElement("bar"));
// checkbox
ec.addElement(new P());
ec.addElement(new Div().addElement(new StringElement("Checkbox:")));
Input checkbox = new Input("checkbox", "checkbox");
checkbox.setChecked(true);
ec.addElement(checkbox);
ec.addElement(new StringElement("checkbox"));
// create shortinput
ec.addElement(new P());
ec.addElement(new Div().addElement(new StringElement("Input field restricted to 5 characters:")));
Input shortinput = new Input(Input.TEXT, "shortinput", "12345");
shortinput.setMaxlength(5);
ec.addElement(shortinput);
ec.addElement(new P());
ec.addElement(new Div().addElement(new StringElement("Disabled input field:")));
String defaultdisabledinputtext = "disabled";
Input disabledinput = new Input(Input.TEXT, "disabledinput", defaultdisabledinputtext);
disabledinput.setDisabled(true);
ec.addElement(disabledinput);
ec.addElement(new BR());
// Submit Button
ec.addElement(new P());
ec.addElement(new Div().addElement(new StringElement("Submit button:")));
String submittext = "Submit";
Element b = ECSFactory.makeButton(submittext);
ec.addElement(b);
// Now check inputs that were submitted (if any)
// check select field
String submittedselect = s.getParser().getRawParameter("select");
if(submittedselect.equals("foo")) failed = true;
if(submittedselect.equals("bar")) failed = true;
// check radio buttons
String submittedradio = s.getParser().getRawParameter("radio");
if(submittedselect.equals("foo")) failed = true;
if(submittedselect.equals("bar")) failed = true;
// check checkbox (note - if the box is not checked, this will throw an exception, but that
// is okay)
if(s.getParser().getRawParameter("checkbox").equals("on")) failed = true;
// check shortinput
if(s.getParser().getRawParameter("shortinput").length() < 6) failed = true;
// check disabledinput (note - if the field was not re-enabled, this will throw an exception, but that
// is okay)
if(s.getParser().getRawParameter("disabledinput").equals(defaultdisabledinputtext)) failed = true;
// check submitbutton
if(s.getParser().getRawParameter("SUBMIT").equals(submittext)) failed = true;
// if we didn't fail, we succeeded!
if(failed != true) {
makeSuccess(s);
}
} catch(ParameterNotFoundException e) {
//s.setMessage("Error, required parameter not found");
e.printStackTrace();
}
return (ec);
}
ec.addElement(new P());
ec.addElement(new Div().addElement(new StringElement("Disabled input field:")));
String defaultdisabledinputtext = "disabled";
Input disabledinput = new Input(Input.TEXT, "disabledinput", defaultdisabledinputtext);
disabledinput.setDisabled(true);
ec.addElement(disabledinput);
ec.addElement(new BR());
// Submit Button
ec.addElement(new P());
ec.addElement(new Div().addElement(new StringElement("Submit button:")));
String submittext = "Submit";
Element b = ECSFactory.makeButton(submittext);
ec.addElement(b);
// Now check inputs that were submitted (if any)
// check select field
String submittedselect = s.getParser().getRawParameter("select");
if(submittedselect.equals("foo")) failed = true;
if(submittedselect.equals("bar")) failed = true;
// check radio buttons
String submittedradio = s.getParser().getRawParameter("radio");
if(submittedselect.equals("foo")) failed = true;
if(submittedselect.equals("bar")) failed = true;
// check checkbox (note - if the box is not checked, this will throw an exception, but that
// is okay)
if(s.getParser().getRawParameter("checkbox").equals("on")) failed = true;
// check shortinput
if(s.getParser().getRawParameter("shortinput").length() < 6) failed = true;
// check disabledinput (note - if the field was not re-enabled, this will throw an exception, but that
// is okay)
if(s.getParser().getRawParameter("disabledinput").equals(defaultdisabledinputtext)) failed = true;
// check submitbutton
if(s.getParser().getRawParameter("SUBMIT").equals(submittext)) failed = true;
// if we didn't fail, we succeeded!
if(failed != true) {
makeSuccess(s);
}
} catch(ParameterNotFoundException e) {
//s.setMessage("Error, required parameter not found");
e.printStackTrace();
}
return (ec);
}
/**
* Gets the category attribute of the object
*
* @return The category value
*/
protected Category getDefaultCategory()
{
return Category.PARAMETER_TAMPERING;
}
/**
* Gets the category attribute of the object
*
* @return The category value
*/
protected Category getDefaultCategory()
{
return Category.PARAMETER_TAMPERING;
}
/**
* Gets the credits attribute of the AbstractLesson object
@ -185,41 +185,41 @@ public class BypassHtmlFieldRestrictions extends SequentialLessonAdapter
*/
public Element getCredits()
{
return super.getCustomCredits("Created by Chuck Willis&nbsp;", MANDIANT_LOGO);
return super.getCustomCredits("Created by Chuck Willis&nbsp;", MANDIANT_LOGO);
}
/**
* Gets the hints attribute of the DatabaseFieldScreen object
*
* @return The hints value
*/
protected List<String> getHints(WebSession s)
{
List<String> hints = new ArrayList<String>();
hints.add(WebGoatI18N.get("BypassHtmlFieldRestrictionsHint1"));
hints.add(WebGoatI18N.get("BypassHtmlFieldRestrictionsHint2"));
hints.add(WebGoatI18N.get("BypassHtmlFieldRestrictionsHint3"));
/**
* Gets the hints attribute of the DatabaseFieldScreen object
*
* @return The hints value
*/
protected List<String> getHints(WebSession s)
{
List<String> hints = new ArrayList<String>();
hints.add(WebGoatI18N.get("BypassHtmlFieldRestrictionsHint1"));
hints.add(WebGoatI18N.get("BypassHtmlFieldRestrictionsHint2"));
hints.add(WebGoatI18N.get("BypassHtmlFieldRestrictionsHint3"));
return hints;
}
return hints;
}
private final static Integer DEFAULT_RANKING = new Integer(10);
private final static Integer DEFAULT_RANKING = new Integer(10);
protected Integer getDefaultRanking()
{
return DEFAULT_RANKING;
}
protected Integer getDefaultRanking()
{
return DEFAULT_RANKING;
}
/**
* Gets the title attribute of the DatabaseFieldScreen object
*
* @return The title value
*/
public String getTitle()
{
return ("Bypass HTML Field Restrictions");
}
/**
* Gets the title attribute of the DatabaseFieldScreen object
*
* @return The title value
*/
public String getTitle()
{
return ("Bypass HTML Field Restrictions");
}
/**
* Gets the instructions attribute of the SqlInjection object
@ -228,29 +228,29 @@ public class BypassHtmlFieldRestrictions extends SequentialLessonAdapter
*/
public String getInstructions(WebSession s)
{
String instructions = "The form below uses HTML form field restrictions. " +
" In order to pass this lesson, submit the form with each field containing an unallowed value. "
+ "<b>You must submit invalid values for all six fields in one form submission.</b>";
String instructions = "The form below uses HTML form field restrictions. " +
" In order to pass this lesson, submit the form with each field containing an unallowed value. "
+ "<b>You must submit invalid values for all six fields in one form submission.</b>";
return (instructions);
return (instructions);
}
/**
* Constructor for the DatabaseFieldScreen object
*
* @param s
* Description of the Parameter
*/
public void handleRequest(WebSession s)
{
try
{
super.handleRequest(s);
} catch (Exception e)
{
// System.out.println("Exception caught: " + e);
e.printStackTrace(System.out);
}
}
/**
* Constructor for the DatabaseFieldScreen object
*
* @param s
* Description of the Parameter
*/
public void handleRequest(WebSession s)
{
try
{
super.handleRequest(s);
} catch (Exception e)
{
// System.out.println("Exception caught: " + e);
e.printStackTrace(System.out);
}
}
}