forked from WebGoat/WebGoat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
444 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>missing-function-ac</artifactId> | ||
<packaging>jar</packaging> | ||
<parent> | ||
<groupId>org.owasp.webgoat.lesson</groupId> | ||
<artifactId>webgoat-lessons-parent</artifactId> | ||
<version>8.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
</project> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+8 KB
webgoat-lessons/missing-function-ac/src/main/java/org/owasp/webgoat/.DS_Store
Binary file not shown.
61 changes: 61 additions & 0 deletions
61
...t-lessons/missing-function-ac/src/main/java/org/owasp/webgoat/plugin/HiddenMenuItems.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.owasp.webgoat.plugin; | ||
|
||
import com.google.common.collect.Lists; | ||
import org.owasp.webgoat.assignments.AssignmentEndpoint; | ||
import org.owasp.webgoat.assignments.AssignmentHints; | ||
import org.owasp.webgoat.assignments.AssignmentPath; | ||
import org.owasp.webgoat.assignments.AttackResult; | ||
import org.owasp.webgoat.session.UserSessionData; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Created by jason on 1/5/17. | ||
*/ | ||
|
||
@AssignmentPath("/access-control/hidden-menu") | ||
@AssignmentHints({"access-control.hidden-menus.hint1","access-control.hidden-menus.hint2","access-control.hidden-menus.hint3"}) | ||
public class HiddenMenuItems extends AssignmentEndpoint { | ||
//UserSessionData is bound to session and can be used to persist data across multiple assignments | ||
@Autowired | ||
UserSessionData userSessionData; | ||
|
||
|
||
@PostMapping(produces = {"application/json"}) | ||
public @ResponseBody | ||
AttackResult completed(String hiddenMenu1, String hiddenMenu2, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { | ||
|
||
//overly simple example for success. See other existing lesssons for ways to detect 'success' or 'failure' | ||
if (hiddenMenu1.equals("List Users") && hiddenMenu2.equals("Add User")) { | ||
return trackProgress(success() | ||
.output("") | ||
.feedback("access-control.hidden-menus.success") | ||
.build()); | ||
} | ||
|
||
if (hiddenMenu1.equals("Add User") && hiddenMenu2.equals("List Users")) { | ||
return trackProgress(success() | ||
.output("") | ||
.feedback("access-control.hidden-menus.close") | ||
.build()); | ||
} | ||
|
||
return trackProgress(failed() | ||
.feedback("access-control.hidden-menus.failure") | ||
.output("") | ||
.build()); | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
...essons/missing-function-ac/src/main/java/org/owasp/webgoat/plugin/MissingACListUsers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.owasp.webgoat.plugin; | ||
|
||
import org.owasp.webgoat.assignments.AssignmentEndpoint; | ||
import org.owasp.webgoat.assignments.AssignmentHints; | ||
import org.owasp.webgoat.assignments.AssignmentPath; | ||
import org.owasp.webgoat.assignments.AttackResult; | ||
import org.owasp.webgoat.session.UserSessionData; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
import java.util.HashMap; | ||
|
||
/** | ||
* Created by jason on 1/5/17. | ||
*/ | ||
|
||
@AssignmentPath("/access-control/list-users") | ||
@AssignmentHints({"access-control.hidden-menus.hint1","access-control.hidden-menus.hint2","access-control.hidden-menus.hint3"}) | ||
public class MissingACListUsers extends AssignmentEndpoint { | ||
//UserSessionData is bound to session and can be used to persist data across multiple assignments | ||
@Autowired | ||
UserSessionData userSessionData; | ||
|
||
@PostMapping(produces = {"application/json"}) | ||
public @ResponseBody | ||
AttackResult completed(String hiddenMenu1, String hiddenMenu2, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { | ||
|
||
//overly simple example for success. See other existing lesssons for ways to detect 'success' or 'failure' | ||
if (hiddenMenu1.equals("List Users") && hiddenMenu2.equals("Add User")) { | ||
return trackProgress(success() | ||
.output("") | ||
.feedback("access-control.hidden-menus.success") | ||
.build()); | ||
} | ||
|
||
if (hiddenMenu1.equals("Add User") && hiddenMenu2.equals("List Users")) { | ||
return trackProgress(success() | ||
.output("") | ||
.feedback("access-control.hidden-menus.close") | ||
.build()); | ||
} | ||
|
||
return trackProgress(failed() | ||
.feedback("access-control.hidden-menus.failure") | ||
.output("") | ||
.build()); | ||
} | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
...lessons/missing-function-ac/src/main/java/org/owasp/webgoat/plugin/MissingFunctionAC.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.owasp.webgoat.plugin; | ||
|
||
import com.beust.jcommander.internal.Lists; | ||
import org.owasp.webgoat.lessons.Category; | ||
import org.owasp.webgoat.lessons.NewLesson; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* ************************************************************************************************ | ||
* This file is part of WebGoat, an Open Web Application Security Project utility. For details, | ||
* please see http://www.owasp.org/ | ||
* <p> | ||
* Copyright (c) 2002 - 20014 Bruce Mayhew | ||
* <p> | ||
* 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. | ||
* <p> | ||
* 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. | ||
* <p> | ||
* 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. | ||
* <p> | ||
* Getting Source ============== | ||
* <p> | ||
* Source for this application is maintained at https://github.com/WebGoat/WebGoat, a repository for free software | ||
* projects. | ||
* <p> | ||
* | ||
*/ | ||
public class MissingFunctionAC extends NewLesson { | ||
|
||
@Override | ||
public Category getDefaultCategory() { | ||
return Category.ACCESS_CONTROL; | ||
} | ||
|
||
@Override | ||
public List<String> getHints() { | ||
return Lists.newArrayList(); | ||
} | ||
|
||
@Override | ||
public Integer getDefaultRanking() { | ||
return 40; | ||
} | ||
|
||
@Override | ||
public String getTitle() { | ||
return "missing-function-access-control.title"; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return "MissingFunctionAC"; | ||
} | ||
|
||
} |
113 changes: 113 additions & 0 deletions
113
webgoat-lessons/missing-function-ac/src/main/java/org/owasp/webgoat/plugin/Users.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package org.owasp.webgoat.plugin; | ||
|
||
import com.sun.org.apache.xpath.internal.axes.HasPositionalPredChecker; | ||
import org.owasp.webgoat.assignments.Endpoint; | ||
import org.owasp.webgoat.session.DatabaseUtilities; | ||
import org.owasp.webgoat.session.UserSessionData; | ||
import org.owasp.webgoat.session.WebSession; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import java.sql.*; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static javax.swing.UIManager.getString; | ||
|
||
public class Users extends Endpoint{ | ||
|
||
@Autowired | ||
private WebSession webSession; | ||
|
||
@Autowired | ||
UserSessionData userSessionData; | ||
|
||
@RequestMapping(produces = {"application/json"}, method = RequestMethod.GET) | ||
@ResponseBody | ||
protected HashMap<Integer, HashMap> getUsers (HttpServletRequest req) { | ||
|
||
try { | ||
Connection connection = DatabaseUtilities.getConnection(getWebSession()); | ||
String query = "SELECT * FROM user_data"; | ||
|
||
try { | ||
Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, | ||
ResultSet.CONCUR_READ_ONLY); | ||
ResultSet results = statement.executeQuery(query); | ||
HashMap<Integer,HashMap> allUsersMap = new HashMap(); | ||
|
||
if ((results != null) && (results.first() == true)) { | ||
ResultSetMetaData resultsMetaData = results.getMetaData(); | ||
StringBuffer output = new StringBuffer(); | ||
|
||
while (results.next()) { | ||
int id = results.getInt(0); | ||
HashMap<String,String> userMap = new HashMap<>(); | ||
userMap.put("first", results.getString(1)); | ||
userMap.put("last", results.getString(2)); | ||
userMap.put("cc", results.getString(3)); | ||
userMap.put("ccType", results.getString(4)); | ||
userMap.put("cookie", results.getString(5)); | ||
userMap.put("loginCOunt",Integer.toString(results.getInt(6))); | ||
allUsersMap.put(id,userMap); | ||
} | ||
userSessionData.setValue("allUsers",allUsersMap); | ||
return allUsersMap; | ||
|
||
} | ||
} catch (SQLException sqle) { | ||
sqle.printStackTrace(); | ||
HashMap<String,String> errMap = new HashMap() {{ | ||
put("err",sqle.getErrorCode() + "::" + sqle.getMessage()); | ||
}}; | ||
|
||
return new HashMap<Integer,HashMap>() {{ | ||
put(0,errMap); | ||
}}; | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
HashMap<String,String> errMap = new HashMap() {{ | ||
put("err",e.getMessage() + "::" + e.getCause()); | ||
}}; | ||
e.printStackTrace(); | ||
return new HashMap<Integer,HashMap>() {{ | ||
put(0,errMap); | ||
}}; | ||
|
||
|
||
} finally { | ||
try { | ||
if (connection != null) { | ||
connection.close(); | ||
} | ||
} catch (SQLException sqle) { | ||
sqle.printStackTrace(); | ||
} | ||
} | ||
|
||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
HashMap<String,String> errMap = new HashMap() {{ | ||
put("err",e.getMessage() + "::" + e.getCause()); | ||
}}; | ||
e.printStackTrace(); | ||
return new HashMap<Integer,HashMap>() {{ | ||
put(0,errMap); | ||
}}; | ||
|
||
} | ||
return null; | ||
} | ||
|
||
protected WebSession getWebSession() { | ||
return webSession; | ||
} | ||
|
||
@Override | ||
public String getPath() { | ||
return "/access-control/list-users"; | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.