Reformat of Java source. Added JavaStyle format definitions.
git-svn-id: http://webgoat.googlecode.com/svn/trunk/webgoat@287 4033779f-a91e-0410-96ef-6bf7bf53c507
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
|
||||
package org.owasp.webgoat.lessons;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ecs.Element;
|
||||
import org.apache.ecs.ElementContainer;
|
||||
import org.apache.ecs.HtmlColor;
|
||||
@ -18,157 +18,145 @@ import org.apache.ecs.html.Table;
|
||||
import org.owasp.webgoat.session.ECSFactory;
|
||||
import org.owasp.webgoat.session.WebSession;
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
/***************************************************************************************************
|
||||
*
|
||||
*
|
||||
* This file is part of WebGoat, an Open Web Application Security Project
|
||||
* utility. For details, please see http://www.owasp.org/
|
||||
* This file is part of WebGoat, an Open Web Application Security Project utility. For details,
|
||||
* please see http://www.owasp.org/
|
||||
*
|
||||
* Copyright (c) 2002 - 2007 Bruce Mayhew
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option) any later
|
||||
* version.
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
* Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* You should have received a copy of the GNU General Public License along with this program; if
|
||||
* not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* Getting Source ==============
|
||||
*
|
||||
* Source for this application is maintained at code.google.com, a repository
|
||||
* for free software projects.
|
||||
* Source for this application is maintained at code.google.com, a repository for free software
|
||||
* projects.
|
||||
*
|
||||
* For details, please see http://code.google.com/p/webgoat/
|
||||
*
|
||||
* @author Sherif Koussa <a href="http://www.macadamian.com">Macadamian Technologies</a>
|
||||
* @created October 28, 2006
|
||||
* @author Sherif Koussa <a href="http://www.macadamian.com">Macadamian Technologies</a>
|
||||
* @created October 28, 2006
|
||||
*/
|
||||
|
||||
public class LogSpoofing extends LessonAdapter
|
||||
{
|
||||
|
||||
private static final String USERNAME = "username";
|
||||
private static final String USERNAME = "username";
|
||||
|
||||
private static final String PASSWORD = "password";
|
||||
private static final String PASSWORD = "password";
|
||||
|
||||
private final static IMG MAC_LOGO = new IMG("images/logos/macadamian.gif").setAlt(
|
||||
"Macadamian Technologies").setBorder(0).setHspace(0).setVspace(0);
|
||||
private final static IMG MAC_LOGO = new IMG("images/logos/macadamian.gif").setAlt("Macadamian Technologies")
|
||||
.setBorder(0).setHspace(0).setVspace(0);
|
||||
|
||||
protected Element createContent(WebSession s)
|
||||
{
|
||||
|
||||
ElementContainer ec = null;
|
||||
String inputUsername = null;
|
||||
try
|
||||
protected Element createContent(WebSession s)
|
||||
{
|
||||
|
||||
Table t = new Table(0).setCellSpacing(0).setCellPadding(0)
|
||||
.setBorder(0);
|
||||
TR row1 = new TR();
|
||||
TR row2 = new TR();
|
||||
TR row3 = new TR();
|
||||
ElementContainer ec = null;
|
||||
String inputUsername = null;
|
||||
try
|
||||
{
|
||||
|
||||
row1.addElement(new TD(new StringElement("Username: ")));
|
||||
Input username = new Input(Input.TEXT, USERNAME, "");
|
||||
row1.addElement(new TD(username));
|
||||
Table t = new Table(0).setCellSpacing(0).setCellPadding(0).setBorder(0);
|
||||
TR row1 = new TR();
|
||||
TR row2 = new TR();
|
||||
TR row3 = new TR();
|
||||
|
||||
row2.addElement(new TD(new StringElement("Password: ")));
|
||||
Input password = new Input(Input.PASSWORD, PASSWORD, "");
|
||||
row2.addElement(new TD(password));
|
||||
row1.addElement(new TD(new StringElement("Username: ")));
|
||||
Input username = new Input(Input.TEXT, USERNAME, "");
|
||||
row1.addElement(new TD(username));
|
||||
|
||||
Element b = ECSFactory.makeButton("Login");
|
||||
row3.addElement(new TD(new StringElement(" ")));
|
||||
row3.addElement(new TD(b)).setAlign("right");
|
||||
row2.addElement(new TD(new StringElement("Password: ")));
|
||||
Input password = new Input(Input.PASSWORD, PASSWORD, "");
|
||||
row2.addElement(new TD(password));
|
||||
|
||||
t.addElement(row1);
|
||||
t.addElement(row2);
|
||||
t.addElement(row3);
|
||||
Element b = ECSFactory.makeButton("Login");
|
||||
row3.addElement(new TD(new StringElement(" ")));
|
||||
row3.addElement(new TD(b)).setAlign("right");
|
||||
|
||||
ec = new ElementContainer();
|
||||
ec.addElement(t);
|
||||
t.addElement(row1);
|
||||
t.addElement(row2);
|
||||
t.addElement(row3);
|
||||
|
||||
inputUsername = new String(s.getParser().getRawParameter(USERNAME,
|
||||
""));
|
||||
if (inputUsername.length() != 0)
|
||||
{
|
||||
inputUsername = URLDecoder.decode(inputUsername, "UTF-8");
|
||||
}
|
||||
ec = new ElementContainer();
|
||||
ec.addElement(t);
|
||||
|
||||
ec.addElement(new PRE(" "));
|
||||
inputUsername = new String(s.getParser().getRawParameter(USERNAME, ""));
|
||||
if (inputUsername.length() != 0)
|
||||
{
|
||||
inputUsername = URLDecoder.decode(inputUsername, "UTF-8");
|
||||
}
|
||||
|
||||
Table t2 = new Table(0).setCellSpacing(0).setCellPadding(0)
|
||||
.setBorder(0);
|
||||
TR row4 = new TR();
|
||||
row4.addElement(
|
||||
new TD(new PRE("Login failed for username: "
|
||||
+ inputUsername))).setBgColor(HtmlColor.GRAY);
|
||||
ec.addElement(new PRE(" "));
|
||||
|
||||
t2.addElement(row4);
|
||||
Table t2 = new Table(0).setCellSpacing(0).setCellPadding(0).setBorder(0);
|
||||
TR row4 = new TR();
|
||||
row4.addElement(new TD(new PRE("Login failed for username: " + inputUsername))).setBgColor(HtmlColor.GRAY);
|
||||
|
||||
ec.addElement(t2);
|
||||
t2.addElement(row4);
|
||||
|
||||
if (inputUsername.length() != 0
|
||||
&& inputUsername.toUpperCase().indexOf(
|
||||
System.getProperty("line.separator")
|
||||
+ "LOGIN SUCCEEDED FOR USERNAME:") >= 0)
|
||||
{
|
||||
makeSuccess(s);
|
||||
}
|
||||
ec.addElement(t2);
|
||||
|
||||
if (inputUsername.length() != 0
|
||||
&& inputUsername.toUpperCase().indexOf(
|
||||
System.getProperty("line.separator")
|
||||
+ "LOGIN SUCCEEDED FOR USERNAME:") >= 0)
|
||||
{
|
||||
makeSuccess(s);
|
||||
}
|
||||
} catch (UnsupportedEncodingException e)
|
||||
{
|
||||
s.setMessage("Error generating " + this.getClass().getName());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ec;
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
|
||||
private final static Integer DEFAULT_RANKING = new Integer(72);
|
||||
|
||||
protected Integer getDefaultRanking()
|
||||
{
|
||||
s.setMessage("Error generating " + this.getClass().getName());
|
||||
e.printStackTrace();
|
||||
return DEFAULT_RANKING;
|
||||
}
|
||||
return ec;
|
||||
}
|
||||
|
||||
private final static Integer DEFAULT_RANKING = new Integer(72);
|
||||
@Override
|
||||
protected List<String> getHints(WebSession s)
|
||||
{
|
||||
List<String> hints = new ArrayList<String>();
|
||||
hints.add("Try to fool the humane eye by using new lines.");
|
||||
hints.add("Use CR (%0d) and LF (%0a) for a new line.");
|
||||
hints.add("Try: Smith%0d%0aLogin Succeeded for username: admin");
|
||||
hints
|
||||
.add("Try: Smith%0d%0aLogin Succeeded for username: admin<script>alert(document.cookie)</script>");
|
||||
|
||||
return hints;
|
||||
}
|
||||
|
||||
protected Integer getDefaultRanking()
|
||||
{
|
||||
return DEFAULT_RANKING;
|
||||
}
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return "Log Spoofing";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Category getDefaultCategory()
|
||||
{
|
||||
return Category.INJECTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getHints(WebSession s)
|
||||
{
|
||||
List<String> hints = new ArrayList<String>();
|
||||
hints.add("Try to fool the humane eye by using new lines.");
|
||||
hints.add("Use CR (%0d) and LF (%0a) for a new line.");
|
||||
hints.add("Try: Smith%0d%0aLogin Succeeded for username: admin");
|
||||
hints
|
||||
.add("Try: Smith%0d%0aLogin Succeeded for username: admin<script>alert(document.cookie)</script>");
|
||||
|
||||
return hints;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return "Log Spoofing";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Category getDefaultCategory()
|
||||
{
|
||||
return Category.INJECTION;
|
||||
}
|
||||
|
||||
|
||||
public Element getCredits()
|
||||
{
|
||||
return super.getCustomCredits("Created by Sherif Koussa ", MAC_LOGO);
|
||||
}
|
||||
public Element getCredits()
|
||||
{
|
||||
return super.getCustomCredits("Created by Sherif Koussa ", MAC_LOGO);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user