diff --git a/OWASP DATASET/BenchmarkTest00001.java b/OWASP DATASET/BenchmarkTest00001.java new file mode 100644 index 0000000000000000000000000000000000000000..34c82096ba8bc1b35e854522226ae1b18dff3ae4 --- /dev/null +++ b/OWASP DATASET/BenchmarkTest00001.java @@ -0,0 +1,105 @@ +/** + * OWASP Benchmark v1.2 + * + *
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For + * details, please see https://owasp.org/www-project-benchmark/. + * + *
The OWASP Benchmark 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, version 2. + * + *
The OWASP Benchmark 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. + * + * @author Dave Wichers + * @created 2015 + */ +package org.owasp.benchmark.testcode; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@WebServlet(value = "/pathtraver-00/BenchmarkTest00001") +public class BenchmarkTest00001 extends HttpServlet { + + private static final long serialVersionUID = 1L; + + @Override + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + javax.servlet.http.Cookie userCookie = + new javax.servlet.http.Cookie("BenchmarkTest00001", "FileName"); + userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes + userCookie.setSecure(true); + userCookie.setPath(request.getRequestURI()); + userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); + response.addCookie(userCookie); + javax.servlet.RequestDispatcher rd = + request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00001.html"); + rd.include(request, response); + } + + @Override + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // some code + response.setContentType("text/html;charset=UTF-8"); + + javax.servlet.http.Cookie[] theCookies = request.getCookies(); + + String param = "noCookieValueSupplied"; + if (theCookies != null) { + for (javax.servlet.http.Cookie theCookie : theCookies) { + if (theCookie.getName().equals("BenchmarkTest00001")) { + param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); + break; + } + } + } + + String fileName = null; + java.io.FileInputStream fis = null; + + try { + fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + param; + fis = new java.io.FileInputStream(new java.io.File(fileName)); + byte[] b = new byte[1000]; + int size = fis.read(b); + response.getWriter() + .println( + "The beginning of file: '" + + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName) + + "' is:\n\n" + + org.owasp + .esapi + .ESAPI + .encoder() + .encodeForHTML(new String(b, 0, size))); + } catch (Exception e) { + System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'"); + response.getWriter() + .println( + "Problem getting FileInputStream: " + + org.owasp + .esapi + .ESAPI + .encoder() + .encodeForHTML(e.getMessage())); + } finally { + if (fis != null) { + try { + fis.close(); + fis = null; + } catch (Exception e) { + // we tried... + } + } + } + } +} diff --git a/OWASP DATASET/BenchmarkTest00002.java b/OWASP DATASET/BenchmarkTest00002.java new file mode 100644 index 0000000000000000000000000000000000000000..b31b6a33439aa4039fdd195a033f7f849eb26ea4 --- /dev/null +++ b/OWASP DATASET/BenchmarkTest00002.java @@ -0,0 +1,92 @@ +/** + * OWASP Benchmark v1.2 + * + *
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For + * details, please see https://owasp.org/www-project-benchmark/. + * + *
The OWASP Benchmark 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, version 2. + * + *
The OWASP Benchmark 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. + * + * @author Dave Wichers + * @created 2015 + */ +package org.owasp.benchmark.testcode; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@WebServlet(value = "/pathtraver-00/BenchmarkTest00002") +public class BenchmarkTest00002 extends HttpServlet { + + private static final long serialVersionUID = 1L; + + @Override + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + javax.servlet.http.Cookie userCookie = + new javax.servlet.http.Cookie("BenchmarkTest00002", "FileName"); + userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes + userCookie.setSecure(true); + userCookie.setPath(request.getRequestURI()); + userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); + response.addCookie(userCookie); + javax.servlet.RequestDispatcher rd = + request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00002.html"); + rd.include(request, response); + } + + @Override + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // some code + response.setContentType("text/html;charset=UTF-8"); + + javax.servlet.http.Cookie[] theCookies = request.getCookies(); + + String param = "noCookieValueSupplied"; + if (theCookies != null) { + for (javax.servlet.http.Cookie theCookie : theCookies) { + if (theCookie.getName().equals("BenchmarkTest00002")) { + param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); + break; + } + } + } + + String fileName = null; + java.io.FileOutputStream fos = null; + + try { + fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + param; + + fos = new java.io.FileOutputStream(fileName, false); + response.getWriter() + .println( + "Now ready to write to file: " + + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)); + + } catch (Exception e) { + System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'"); + // System.out.println("File exception caught and swallowed: " + e.getMessage()); + } finally { + if (fos != null) { + try { + fos.close(); + fos = null; + } catch (Exception e) { + // we tried... + } + } + } + } +} diff --git a/OWASP DATASET/BenchmarkTest00003.java b/OWASP DATASET/BenchmarkTest00003.java new file mode 100644 index 0000000000000000000000000000000000000000..501535c874b67daac6e9d139c8518dbcb02cef12 --- /dev/null +++ b/OWASP DATASET/BenchmarkTest00003.java @@ -0,0 +1,119 @@ +/** + * OWASP Benchmark v1.2 + * + *
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For + * details, please see https://owasp.org/www-project-benchmark/. + * + *
The OWASP Benchmark 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, version 2. + * + *
The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/hash-00/BenchmarkTest00003")
+public class BenchmarkTest00003 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00003", "someSecret");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/hash-00/BenchmarkTest00003.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00003")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ try {
+ java.util.Properties benchmarkprops = new java.util.Properties();
+ benchmarkprops.load(
+ this.getClass().getClassLoader().getResourceAsStream("benchmark.properties"));
+ String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512");
+ java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm);
+ byte[] input = {(byte) '?'};
+ Object inputParam = param;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ md.update(input);
+
+ byte[] result = md.digest();
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "hash_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' hashed and stored
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing hash - TestCase");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println(
+ "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00004.java b/OWASP DATASET/BenchmarkTest00004.java
new file mode 100644
index 0000000000000000000000000000000000000000..beaa3b25c742434e54f55a41927c1b713a32d32d
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00004.java
@@ -0,0 +1,75 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For + * details, please see https://owasp.org/www-project-benchmark/. + * + *
The OWASP Benchmark 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, version 2. + * + *
The OWASP Benchmark 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. + * + * @author Dave Wichers + * @created 2015 + */ +package org.owasp.benchmark.testcode; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@WebServlet(value = "/trustbound-00/BenchmarkTest00004") +public class BenchmarkTest00004 extends HttpServlet { + + private static final long serialVersionUID = 1L; + + @Override + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + javax.servlet.http.Cookie userCookie = + new javax.servlet.http.Cookie("BenchmarkTest00004", "color"); + userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes + userCookie.setSecure(true); + userCookie.setPath(request.getRequestURI()); + userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost()); + response.addCookie(userCookie); + javax.servlet.RequestDispatcher rd = + request.getRequestDispatcher("/trustbound-00/BenchmarkTest00004.html"); + rd.include(request, response); + } + + @Override + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // some code + response.setContentType("text/html;charset=UTF-8"); + + javax.servlet.http.Cookie[] theCookies = request.getCookies(); + + String param = "noCookieValueSupplied"; + if (theCookies != null) { + for (javax.servlet.http.Cookie theCookie : theCookies) { + if (theCookie.getName().equals("BenchmarkTest00004")) { + param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8"); + break; + } + } + } + + // javax.servlet.http.HttpSession.setAttribute(java.lang.String^,java.lang.Object) + request.getSession().setAttribute(param, "10340"); + + response.getWriter() + .println( + "Item: '" + + org.owasp.benchmark.helpers.Utils.encodeForHTML(param) + + "' with value: '10340' saved in session."); + } +} diff --git a/OWASP DATASET/BenchmarkTest00005.java b/OWASP DATASET/BenchmarkTest00005.java new file mode 100644 index 0000000000000000000000000000000000000000..64ea4187ef3155544bbafed5ff2b2c500a20e8f2 --- /dev/null +++ b/OWASP DATASET/BenchmarkTest00005.java @@ -0,0 +1,122 @@ +/** + * OWASP Benchmark v1.2 + * + *
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For + * details, please see https://owasp.org/www-project-benchmark/. + * + *
The OWASP Benchmark 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, version 2. + * + *
The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00005")
+public class BenchmarkTest00005 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00005") != null) {
+ param = request.getHeader("BenchmarkTest00005");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+ // 8-byte initialization vector
+ // byte[] iv = {
+ // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
+ // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033
+ // };
+ java.security.SecureRandom random = new java.security.SecureRandom();
+ byte[] iv = random.generateSeed(8); // DES requires 8 byte keys
+
+ try {
+ javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding");
+
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey();
+ java.security.spec.AlgorithmParameterSpec paramSpec =
+ new javax.crypto.spec.IvParameterSpec(iv);
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = param;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException
+ | java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00006.java b/OWASP DATASET/BenchmarkTest00006.java
new file mode 100644
index 0000000000000000000000000000000000000000..2359c9ba862113eb91cf1186df6cf38c778e4187
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00006.java
@@ -0,0 +1,77 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For + * details, please see https://owasp.org/www-project-benchmark/. + * + *
The OWASP Benchmark 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, version 2. + * + *
The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00006")
+public class BenchmarkTest00006 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00006") != null) {
+ param = request.getHeader("BenchmarkTest00006");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00007")
+public class BenchmarkTest00007 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00007") != null) {
+ param = request.getHeader("BenchmarkTest00007");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String cmd =
+ org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString(
+ this.getClass().getClassLoader());
+ String[] args = {cmd};
+ String[] argsEnv = {param};
+
+ Runtime r = Runtime.getRuntime();
+
+ try {
+ Process p = r.exec(args, argsEnv);
+ org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response);
+ } catch (IOException e) {
+ System.out.println("Problem executing cmdi - TestCase");
+ response.getWriter()
+ .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage()));
+ return;
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00008.java b/OWASP DATASET/BenchmarkTest00008.java
new file mode 100644
index 0000000000000000000000000000000000000000..3d2710eec4492292c190f7e8021c30a10496d344
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00008.java
@@ -0,0 +1,68 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00008")
+public class BenchmarkTest00008 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00008") != null) {
+ param = request.getHeader("BenchmarkTest00008");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String sql = "{call " + param + "}";
+
+ try {
+ java.sql.Connection connection =
+ org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection();
+ java.sql.CallableStatement statement = connection.prepareCall(sql);
+ java.sql.ResultSet rs = statement.executeQuery();
+ org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response);
+
+ } catch (java.sql.SQLException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ return;
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00009.java b/OWASP DATASET/BenchmarkTest00009.java
new file mode 100644
index 0000000000000000000000000000000000000000..abe18a4e5721040eec4af6da80b9426b38bab1c0
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00009.java
@@ -0,0 +1,124 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/hash-00/BenchmarkTest00009")
+public class BenchmarkTest00009 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00010")
+public class BenchmarkTest00010 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00011")
+public class BenchmarkTest00011 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/ldapi-00/BenchmarkTest00012")
+public class BenchmarkTest00012 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00013")
+public class BenchmarkTest00013 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00014")
+public class BenchmarkTest00014 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00015")
+public class BenchmarkTest00015 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/securecookie-00/BenchmarkTest00016")
+public class BenchmarkTest00016 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00017")
+public class BenchmarkTest00017 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00018")
+public class BenchmarkTest00018 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00019")
+public class BenchmarkTest00019 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ java.io.InputStream param = request.getInputStream();
+
+ try {
+ java.util.Properties benchmarkprops = new java.util.Properties();
+ benchmarkprops.load(
+ this.getClass().getClassLoader().getResourceAsStream("benchmark.properties"));
+ String algorithm = benchmarkprops.getProperty("cryptoAlg1", "DESede/ECB/PKCS5Padding");
+ javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm);
+
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey();
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = param;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00020")
+public class BenchmarkTest00020 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = request.getParameter("BenchmarkTest00020");
+ if (param == null) param = "";
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+ // 8-byte initialization vector
+ // byte[] iv = {
+ // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
+ // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033
+ // };
+ java.security.SecureRandom random = new java.security.SecureRandom();
+ byte[] iv = random.generateSeed(8); // DES requires 8 byte keys
+
+ try {
+ javax.crypto.Cipher c =
+ javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE");
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey();
+ java.security.spec.AlgorithmParameterSpec paramSpec =
+ new javax.crypto.spec.IvParameterSpec(iv);
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = param;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/ldapi-00/BenchmarkTest00021")
+public class BenchmarkTest00021 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = request.getParameter("BenchmarkTest00021");
+ if (param == null) param = "";
+
+ org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager();
+ try {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.naming.directory.DirContext ctx = ads.getDirContext();
+ String base = "ou=users,ou=system";
+ javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls();
+ sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE);
+ String filter = "(&(objectclass=person))(|(uid=" + param + ")(street={0}))";
+ Object[] filters = new Object[] {"The streetz 4 Ms bar"};
+ // System.out.println("Filter " + filter);
+ boolean found = false;
+ javax.naming.NamingEnumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/hash-00/BenchmarkTest00022")
+public class BenchmarkTest00022 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = request.getParameter("BenchmarkTest00022");
+ if (param == null) param = "";
+
+ try {
+ java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256");
+ byte[] input = {(byte) '?'};
+ Object inputParam = param;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ md.update(input);
+
+ byte[] result = md.digest();
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "hash_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' hashed and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00023")
+public class BenchmarkTest00023 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = request.getParameter("BenchmarkTest00023");
+ if (param == null) param = "";
+
+ float rand = new java.util.Random().nextFloat();
+ String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front.
+
+ String user = "Floyd";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00024")
+public class BenchmarkTest00024 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = request.getParameter("BenchmarkTest00024");
+ if (param == null) param = "";
+
+ String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + param + "'";
+
+ try {
+ java.sql.Connection connection =
+ org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection();
+ java.sql.PreparedStatement statement =
+ connection.prepareStatement(
+ sql,
+ java.sql.ResultSet.TYPE_FORWARD_ONLY,
+ java.sql.ResultSet.CONCUR_READ_ONLY,
+ java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT);
+ statement.setString(1, "foo");
+ statement.execute();
+ org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response);
+ } catch (java.sql.SQLException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ return;
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00025.java b/OWASP DATASET/BenchmarkTest00025.java
new file mode 100644
index 0000000000000000000000000000000000000000..051a1c7ba6fabd10c3158513afb2fb6135faa790
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00025.java
@@ -0,0 +1,66 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00025")
+public class BenchmarkTest00025 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = request.getParameter("BenchmarkTest00025");
+ if (param == null) param = "";
+
+ String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + param + "'";
+ try {
+ // Long results =
+ // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForLong(sql);
+ Long results =
+ org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject(
+ sql, Long.class);
+ response.getWriter().println("Your results are: " + String.valueOf(results));
+ } catch (org.springframework.dao.EmptyResultDataAccessException e) {
+ response.getWriter()
+ .println(
+ "No results returned for query: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql));
+ } catch (org.springframework.dao.DataAccessException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00026.java b/OWASP DATASET/BenchmarkTest00026.java
new file mode 100644
index 0000000000000000000000000000000000000000..dcdda026919e9b7c4ff656c1f22ac4e78264feb4
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00026.java
@@ -0,0 +1,76 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00026")
+public class BenchmarkTest00026 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = request.getParameter("BenchmarkTest00026");
+ if (param == null) param = "";
+
+ String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + param + "'";
+ try {
+ org.springframework.jdbc.support.rowset.SqlRowSet results =
+ org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForRowSet(sql);
+ response.getWriter().println("Your results are: ");
+
+ // System.out.println("Your results are");
+ while (results.next()) {
+ response.getWriter()
+ .println(
+ org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(results.getString("USERNAME"))
+ + " ");
+ // System.out.println(results.getString("USERNAME"));
+ }
+ } catch (org.springframework.dao.EmptyResultDataAccessException e) {
+ response.getWriter()
+ .println(
+ "No results returned for query: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql));
+ } catch (org.springframework.dao.DataAccessException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00027.java b/OWASP DATASET/BenchmarkTest00027.java
new file mode 100644
index 0000000000000000000000000000000000000000..27344a048a99114f397b0fd2f3840540d4590ec2
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00027.java
@@ -0,0 +1,61 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00027")
+public class BenchmarkTest00027 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = request.getParameter("BenchmarkTest00027");
+ if (param == null) param = "";
+
+ String sql = "INSERT INTO users (username, password) VALUES ('foo','" + param + "')";
+
+ try {
+ java.sql.Statement statement =
+ org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement();
+ int count = statement.executeUpdate(sql);
+ org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response);
+ } catch (java.sql.SQLException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ return;
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00028.java b/OWASP DATASET/BenchmarkTest00028.java
new file mode 100644
index 0000000000000000000000000000000000000000..265945d77ed0de865d42b2502b731fde9a1f2a09
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00028.java
@@ -0,0 +1,77 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00028")
+public class BenchmarkTest00028 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ java.util.Map This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/hash-00/BenchmarkTest00029")
+public class BenchmarkTest00029 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ java.util.Map This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00030")
+public class BenchmarkTest00030 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ java.util.Map This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/trustbound-00/BenchmarkTest00031")
+public class BenchmarkTest00031 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ java.util.Map This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00032")
+public class BenchmarkTest00032 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ java.util.Map This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00033")
+public class BenchmarkTest00033 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ java.util.Map This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00034")
+public class BenchmarkTest00034 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ java.util.Map This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00035")
+public class BenchmarkTest00035 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ boolean flag = true;
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00036")
+public class BenchmarkTest00036 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ boolean flag = true;
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00037")
+public class BenchmarkTest00037 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ boolean flag = true;
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00038")
+public class BenchmarkTest00038 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ boolean flag = true;
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00039")
+public class BenchmarkTest00039 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ boolean flag = true;
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00040")
+public class BenchmarkTest00040 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ org.owasp.benchmark.helpers.SeparateClassRequest scr =
+ new org.owasp.benchmark.helpers.SeparateClassRequest(request);
+ String param = scr.getTheParameter("BenchmarkTest00040");
+ if (param == null) param = "";
+
+ java.io.File fileTarget = new java.io.File(param);
+ response.getWriter()
+ .println(
+ "Access to file: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(fileTarget.toString())
+ + "' created.");
+ if (fileTarget.exists()) {
+ response.getWriter().println(" And file already exists.");
+ } else {
+ response.getWriter().println(" But file doesn't exist yet.");
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00041.java b/OWASP DATASET/BenchmarkTest00041.java
new file mode 100644
index 0000000000000000000000000000000000000000..98e58d1dce35f599b8edc0a3717986808431a324
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00041.java
@@ -0,0 +1,56 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00041")
+public class BenchmarkTest00041 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ org.owasp.benchmark.helpers.SeparateClassRequest scr =
+ new org.owasp.benchmark.helpers.SeparateClassRequest(request);
+ String param = scr.getTheParameter("BenchmarkTest00041");
+ if (param == null) param = "";
+
+ response.setHeader("X-XSS-Protection", "0");
+ int length = 1;
+ if (param != null) {
+ length = param.length();
+ response.getWriter().write(param, 0, length);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00042.java b/OWASP DATASET/BenchmarkTest00042.java
new file mode 100644
index 0000000000000000000000000000000000000000..dfa3e8ff397f92d068c48b5718a2f7292f28e603
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00042.java
@@ -0,0 +1,103 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00042")
+public class BenchmarkTest00042 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ org.owasp.benchmark.helpers.SeparateClassRequest scr =
+ new org.owasp.benchmark.helpers.SeparateClassRequest(request);
+ String param = scr.getTheParameter("BenchmarkTest00042");
+ if (param == null) param = "";
+
+ try {
+ int r = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt();
+ String rememberMeKey = Integer.toString(r);
+
+ String user = "SafeIngrid";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue()
+ .equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00043")
+public class BenchmarkTest00043 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ org.owasp.benchmark.helpers.SeparateClassRequest scr =
+ new org.owasp.benchmark.helpers.SeparateClassRequest(request);
+ String param = scr.getTheParameter("BenchmarkTest00043");
+ if (param == null) param = "";
+
+ String sql = "INSERT INTO users (username, password) VALUES ('foo','" + param + "')";
+
+ try {
+ java.sql.Statement statement =
+ org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement();
+ int count = statement.executeUpdate(sql, new int[] {1, 2});
+ org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response);
+ } catch (java.sql.SQLException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ return;
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00044.java b/OWASP DATASET/BenchmarkTest00044.java
new file mode 100644
index 0000000000000000000000000000000000000000..58d299d61993e228b8626c872e40d7fdb84df3b5
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00044.java
@@ -0,0 +1,98 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/ldapi-00/BenchmarkTest00044")
+public class BenchmarkTest00044 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String[] values = request.getParameterValues("BenchmarkTest00044");
+ String param;
+ if (values != null && values.length > 0) param = values[0];
+ else param = "";
+
+ org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager();
+ try {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.naming.directory.DirContext ctx = ads.getDirContext();
+ String base = "ou=users,ou=system";
+ javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls();
+ sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE);
+ String filter = "(&(objectclass=person)(uid=" + param + "))";
+ // System.out.println("Filter " + filter);
+ boolean found = false;
+ javax.naming.NamingEnumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00045")
+public class BenchmarkTest00045 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String[] values = request.getParameterValues("BenchmarkTest00045");
+ String param;
+ if (values != null && values.length > 0) param = values[0];
+ else param = "";
+
+ String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + param;
+
+ try (
+ // Create the file first so the test won't throw an exception if it doesn't exist.
+ // Note: Don't actually do this because this method signature could cause a tool to find
+ // THIS file constructor
+ // as a vuln, rather than the File signature we are trying to actually test.
+ // If necessary, just run the benchmark twice. The 1st run should create all the necessary
+ // files.
+ // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR +
+ // param).createNewFile();
+
+ java.io.FileOutputStream fos =
+ new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) {
+ response.getWriter()
+ .println(
+ "Now ready to write to file: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName));
+
+ } catch (Exception e) {
+ System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'");
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00046.java b/OWASP DATASET/BenchmarkTest00046.java
new file mode 100644
index 0000000000000000000000000000000000000000..4956e4a9b52f7daff93c098dbfde0d419efe9dfc
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00046.java
@@ -0,0 +1,98 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/hash-00/BenchmarkTest00046")
+public class BenchmarkTest00046 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String[] values = request.getParameterValues("BenchmarkTest00046");
+ String param;
+ if (values != null && values.length > 0) param = values[0];
+ else param = "";
+
+ try {
+ java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
+ byte[] input = {(byte) '?'};
+ Object inputParam = param;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ md.update(input);
+
+ byte[] result = md.digest();
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "hash_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' hashed and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00047")
+public class BenchmarkTest00047 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String queryString = request.getQueryString();
+ String paramval = "BenchmarkTest00047" + "=";
+ int paramLoc = -1;
+ if (queryString != null) paramLoc = queryString.indexOf(paramval);
+ if (paramLoc == -1) {
+ response.getWriter()
+ .println(
+ "getQueryString() couldn't find expected parameter '"
+ + "BenchmarkTest00047"
+ + "' in query string.");
+ return;
+ }
+
+ String param =
+ queryString.substring(
+ paramLoc
+ + paramval
+ .length()); // 1st assume "BenchmarkTest00047" param is last
+ // parameter in query string.
+ // And then check to see if its in the middle of the query string and if so, trim off what
+ // comes after.
+ int ampersandLoc = queryString.indexOf("&", paramLoc);
+ if (ampersandLoc != -1) {
+ param = queryString.substring(paramLoc + paramval.length(), ampersandLoc);
+ }
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ response.setHeader("X-XSS-Protection", "0");
+ Object[] obj = {"a", "b"};
+ response.getWriter().format(param, obj);
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00048.java b/OWASP DATASET/BenchmarkTest00048.java
new file mode 100644
index 0000000000000000000000000000000000000000..b528f008ecd1696ef8f2ac78dc159760b883e09e
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00048.java
@@ -0,0 +1,74 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00048")
+public class BenchmarkTest00048 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String queryString = request.getQueryString();
+ String paramval = "BenchmarkTest00048" + "=";
+ int paramLoc = -1;
+ if (queryString != null) paramLoc = queryString.indexOf(paramval);
+ if (paramLoc == -1) {
+ response.getWriter()
+ .println(
+ "getQueryString() couldn't find expected parameter '"
+ + "BenchmarkTest00048"
+ + "' in query string.");
+ return;
+ }
+
+ String param =
+ queryString.substring(
+ paramLoc
+ + paramval
+ .length()); // 1st assume "BenchmarkTest00048" param is last
+ // parameter in query string.
+ // And then check to see if its in the middle of the query string and if so, trim off what
+ // comes after.
+ int ampersandLoc = queryString.indexOf("&", paramLoc);
+ if (ampersandLoc != -1) {
+ param = queryString.substring(paramLoc + paramval.length(), ampersandLoc);
+ }
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ response.setHeader("X-XSS-Protection", "0");
+ response.getWriter().print(param.toCharArray());
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00049.java b/OWASP DATASET/BenchmarkTest00049.java
new file mode 100644
index 0000000000000000000000000000000000000000..c3b0e43c70f41948dc6a3e7de63a0298cd713c27
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00049.java
@@ -0,0 +1,74 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00049")
+public class BenchmarkTest00049 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ String queryString = request.getQueryString();
+ String paramval = "BenchmarkTest00049" + "=";
+ int paramLoc = -1;
+ if (queryString != null) paramLoc = queryString.indexOf(paramval);
+ if (paramLoc == -1) {
+ response.getWriter()
+ .println(
+ "getQueryString() couldn't find expected parameter '"
+ + "BenchmarkTest00049"
+ + "' in query string.");
+ return;
+ }
+
+ String param =
+ queryString.substring(
+ paramLoc
+ + paramval
+ .length()); // 1st assume "BenchmarkTest00049" param is last
+ // parameter in query string.
+ // And then check to see if its in the middle of the query string and if so, trim off what
+ // comes after.
+ int ampersandLoc = queryString.indexOf("&", paramLoc);
+ if (ampersandLoc != -1) {
+ param = queryString.substring(paramLoc + paramval.length(), ampersandLoc);
+ }
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ response.setHeader("X-XSS-Protection", "0");
+ response.getWriter().write("Parameter value: " + param);
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00050.java b/OWASP DATASET/BenchmarkTest00050.java
new file mode 100644
index 0000000000000000000000000000000000000000..2f74b7bb3415842f2fd03a365c4c99a2556a8284
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00050.java
@@ -0,0 +1,152 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00050")
+public class BenchmarkTest00050 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ org.owasp.benchmark.helpers.SeparateClassRequest scr =
+ new org.owasp.benchmark.helpers.SeparateClassRequest(request);
+ String param = scr.getTheValue("BenchmarkTest00050");
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+ // 8-byte initialization vector
+ // byte[] iv = {
+ // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
+ // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033
+ // };
+ java.security.SecureRandom random = new java.security.SecureRandom();
+ byte[] iv = random.generateSeed(8); // DES requires 8 byte keys
+
+ try {
+ javax.crypto.Cipher c =
+ javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE");
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey();
+ java.security.spec.AlgorithmParameterSpec paramSpec =
+ new javax.crypto.spec.IvParameterSpec(iv);
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = param;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00051")
+public class BenchmarkTest00051 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ org.owasp.benchmark.helpers.SeparateClassRequest scr =
+ new org.owasp.benchmark.helpers.SeparateClassRequest(request);
+ String param = scr.getTheValue("BenchmarkTest00051");
+
+ String a1 = "";
+ String a2 = "";
+ String osName = System.getProperty("os.name");
+ if (osName.indexOf("Windows") != -1) {
+ a1 = "cmd.exe";
+ a2 = "/c";
+ } else {
+ a1 = "sh";
+ a2 = "-c";
+ }
+ String[] args = {a1, a2, "echo " + param};
+
+ ProcessBuilder pb = new ProcessBuilder(args);
+
+ try {
+ Process p = pb.start();
+ org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response);
+ } catch (IOException e) {
+ System.out.println(
+ "Problem executing cmdi - java.lang.ProcessBuilder(java.lang.String[]) Test Case");
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00052.java b/OWASP DATASET/BenchmarkTest00052.java
new file mode 100644
index 0000000000000000000000000000000000000000..caa0f146155e5ae5e6fa1a55a90716beda4d9e94
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00052.java
@@ -0,0 +1,68 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Dave Wichers
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00052")
+public class BenchmarkTest00052 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ // some code
+ response.setContentType("text/html;charset=UTF-8");
+
+ org.owasp.benchmark.helpers.SeparateClassRequest scr =
+ new org.owasp.benchmark.helpers.SeparateClassRequest(request);
+ String param = scr.getTheValue("BenchmarkTest00052");
+
+ String sql = "{call " + param + "}";
+
+ try {
+ java.sql.Connection connection =
+ org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection();
+ java.sql.CallableStatement statement =
+ connection.prepareCall(
+ sql,
+ java.sql.ResultSet.TYPE_FORWARD_ONLY,
+ java.sql.ResultSet.CONCUR_READ_ONLY,
+ java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT);
+ java.sql.ResultSet rs = statement.executeQuery();
+ org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response);
+ } catch (java.sql.SQLException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ return;
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00053.java b/OWASP DATASET/BenchmarkTest00053.java
new file mode 100644
index 0000000000000000000000000000000000000000..d2b0b30ed13a49f645ef11cfc9b79d7a3bcc97e4
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00053.java
@@ -0,0 +1,172 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00053")
+public class BenchmarkTest00053 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00053", "someSecret");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/crypto-00/BenchmarkTest00053.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00053")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple ? condition that assigns constant to bar on true condition
+ int num = 106;
+
+ bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param;
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+ // 8-byte initialization vector
+ // byte[] iv = {
+ // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
+ // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033
+ // };
+ java.security.SecureRandom random = new java.security.SecureRandom();
+ byte[] iv = random.generateSeed(8); // DES requires 8 byte keys
+
+ try {
+ javax.crypto.Cipher c =
+ javax.crypto.Cipher.getInstance(
+ "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE"));
+
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey();
+ java.security.spec.AlgorithmParameterSpec paramSpec =
+ new javax.crypto.spec.IvParameterSpec(iv);
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00054")
+public class BenchmarkTest00054 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00054", "someSecret");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/crypto-00/BenchmarkTest00054.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00054")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = param;
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+ // AES/GCM example from:
+ // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/
+ // 16-byte initialization vector
+ // byte[] iv = {
+ // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
+ // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3,
+ // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9,
+ // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033
+ // };
+ java.security.SecureRandom random = new java.security.SecureRandom();
+ byte[] iv = random.generateSeed(16);
+
+ try {
+ javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING");
+
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey();
+ javax.crypto.spec.GCMParameterSpec paramSpec =
+ new javax.crypto.spec.GCMParameterSpec(16 * 8, iv);
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00055")
+public class BenchmarkTest00055 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00055", "someSecret");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/crypto-00/BenchmarkTest00055.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00055")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = param;
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+ // 8-byte initialization vector
+ // byte[] iv = {
+ // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
+ // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033
+ // };
+ java.security.SecureRandom random = new java.security.SecureRandom();
+ byte[] iv = random.generateSeed(8); // DES requires 8 byte keys
+
+ try {
+ javax.crypto.Cipher c =
+ javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE");
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey();
+ java.security.spec.AlgorithmParameterSpec paramSpec =
+ new javax.crypto.spec.IvParameterSpec(iv);
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00056")
+public class BenchmarkTest00056 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00056", "someSecret");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/crypto-00/BenchmarkTest00056.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00056")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "alsosafe";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00057")
+public class BenchmarkTest00057 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00057", "someSecret");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/crypto-00/BenchmarkTest00057.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00057")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple if statement that assigns param to bar on true condition
+ int num = 196;
+ if ((500 / 42) + num > 200) bar = param;
+ else bar = "This should never happen";
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+ // 8-byte initialization vector
+ // byte[] iv = {
+ // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
+ // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033
+ // };
+ java.security.SecureRandom random = new java.security.SecureRandom();
+ byte[] iv = random.generateSeed(8); // DES requires 8 byte keys
+
+ try {
+ javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding");
+
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey();
+ java.security.spec.AlgorithmParameterSpec paramSpec =
+ new javax.crypto.spec.IvParameterSpec(iv);
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00058")
+public class BenchmarkTest00058 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00058", "someSecret");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/crypto-00/BenchmarkTest00058.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00058")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = param;
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+
+ try {
+ javax.crypto.Cipher c =
+ javax.crypto.Cipher.getInstance(
+ "AES/CCM/NoPadding", java.security.Security.getProvider("BC"));
+
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey();
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00059")
+public class BenchmarkTest00059 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00059", "someSecret");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/crypto-00/BenchmarkTest00059.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00059")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ StringBuilder sbxyz22532 = new StringBuilder(param);
+ String bar = sbxyz22532.append("_SafeStuff").toString();
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+ // 8-byte initialization vector
+ // byte[] iv = {
+ // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
+ // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033
+ // };
+ // java.security.SecureRandom random = new java.security.SecureRandom();
+ // byte[] iv = random.generateSeed(16);
+
+ try {
+ java.util.Properties benchmarkprops = new java.util.Properties();
+ benchmarkprops.load(
+ this.getClass().getClassLoader().getResourceAsStream("benchmark.properties"));
+ String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding");
+ javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm);
+
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey();
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00060")
+public class BenchmarkTest00060 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00060", "FileName");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00060.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00060")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "";
+ if (param != null) {
+ bar =
+ new String(
+ org.apache.commons.codec.binary.Base64.decodeBase64(
+ org.apache.commons.codec.binary.Base64.encodeBase64(
+ param.getBytes())));
+ }
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR), bar);
+ response.getWriter()
+ .println(
+ "Access to file: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(fileTarget.toString())
+ + "' created.");
+ if (fileTarget.exists()) {
+ response.getWriter().println(" And file already exists.");
+ } else {
+ response.getWriter().println(" But file doesn't exist yet.");
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00061.java b/OWASP DATASET/BenchmarkTest00061.java
new file mode 100644
index 0000000000000000000000000000000000000000..e0d2e0036902f16a24ed8b68ace8aeca63a25fc2
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00061.java
@@ -0,0 +1,90 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00061")
+public class BenchmarkTest00061 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00061", "FileName");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00061.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00061")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "";
+ if (param != null) {
+ bar =
+ new String(
+ org.apache.commons.codec.binary.Base64.decodeBase64(
+ org.apache.commons.codec.binary.Base64.encodeBase64(
+ param.getBytes())));
+ }
+
+ java.io.File fileTarget = new java.io.File(bar, "/Test.txt");
+ response.getWriter()
+ .println(
+ "Access to file: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(fileTarget.toString())
+ + "' created.");
+ if (fileTarget.exists()) {
+ response.getWriter().println(" And file already exists.");
+ } else {
+ response.getWriter().println(" But file doesn't exist yet.");
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00062.java b/OWASP DATASET/BenchmarkTest00062.java
new file mode 100644
index 0000000000000000000000000000000000000000..44f0ea70b7727b314804f7765b44dddeddad5632
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00062.java
@@ -0,0 +1,111 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00062")
+public class BenchmarkTest00062 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00062", "FileName");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00062.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00062")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00063")
+public class BenchmarkTest00063 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00063", "FileName");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00063.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00063")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple ? condition that assigns constant to bar on true condition
+ int num = 106;
+
+ bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param;
+
+ String fileName = null;
+ java.io.FileInputStream fis = null;
+
+ try {
+ fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar;
+ fis = new java.io.FileInputStream(new java.io.File(fileName));
+ byte[] b = new byte[1000];
+ int size = fis.read(b);
+ response.getWriter()
+ .println(
+ "The beginning of file: '"
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)
+ + "' is:\n\n"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(b, 0, size)));
+ } catch (Exception e) {
+ System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'");
+ response.getWriter()
+ .println(
+ "Problem getting FileInputStream: "
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(e.getMessage()));
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ fis = null;
+ } catch (Exception e) {
+ // we tried...
+ }
+ }
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00064.java b/OWASP DATASET/BenchmarkTest00064.java
new file mode 100644
index 0000000000000000000000000000000000000000..79a829e3b4d877a7b17d5dc58b2873f4f352a0ef
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00064.java
@@ -0,0 +1,98 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00064")
+public class BenchmarkTest00064 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00064", "FileName");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00064.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00064")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple ? condition that assigns constant to bar on true condition
+ int num = 106;
+
+ bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param;
+
+ String fileName = null;
+ java.io.FileOutputStream fos = null;
+
+ try {
+ fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar;
+
+ fos = new java.io.FileOutputStream(fileName);
+ response.getWriter()
+ .println(
+ "Now ready to write to file: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName));
+
+ } catch (Exception e) {
+ System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'");
+ // System.out.println("File exception caught and swallowed: " + e.getMessage());
+ } finally {
+ if (fos != null) {
+ try {
+ fos.close();
+ fos = null;
+ } catch (Exception e) {
+ // we tried...
+ }
+ }
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00065.java b/OWASP DATASET/BenchmarkTest00065.java
new file mode 100644
index 0000000000000000000000000000000000000000..483faac90e3d5986f71782ed8941132f556da1e2
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00065.java
@@ -0,0 +1,111 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00065")
+public class BenchmarkTest00065 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00065", "FileName");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/pathtraver-00/BenchmarkTest00065.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00065")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "";
+ if (param != null) {
+ bar =
+ new String(
+ org.apache.commons.codec.binary.Base64.decodeBase64(
+ org.apache.commons.codec.binary.Base64.encodeBase64(
+ param.getBytes())));
+ }
+
+ String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar;
+ java.io.InputStream is = null;
+
+ try {
+ java.nio.file.Path path = java.nio.file.Paths.get(fileName);
+ is = java.nio.file.Files.newInputStream(path, java.nio.file.StandardOpenOption.READ);
+ byte[] b = new byte[1000];
+ int size = is.read(b);
+ response.getWriter()
+ .println(
+ "The beginning of file: '"
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)
+ + "' is:\n\n");
+ response.getWriter()
+ .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size)));
+ is.close();
+ } catch (Exception e) {
+ System.out.println("Couldn't open InputStream on file: '" + fileName + "'");
+ response.getWriter()
+ .println(
+ "Problem getting InputStream: "
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(e.getMessage()));
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ is = null;
+ } catch (Exception e) {
+ // we tried...
+ }
+ }
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00066.java b/OWASP DATASET/BenchmarkTest00066.java
new file mode 100644
index 0000000000000000000000000000000000000000..81f632e6467ec6db014c11a64ae928acf49250fb
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00066.java
@@ -0,0 +1,121 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00066")
+public class BenchmarkTest00066 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00066", "anything");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/weakrand-00/BenchmarkTest00066.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00066")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple if statement that assigns constant to bar on true condition
+ int num = 86;
+ if ((7 * 42) - num > 200) bar = "This_should_always_happen";
+ else bar = param;
+
+ double value = java.lang.Math.random();
+ String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front.
+
+ String user = "Doug";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00067")
+public class BenchmarkTest00067 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00067", "anything");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/weakrand-00/BenchmarkTest00067.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00067")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ // Chain a bunch of propagators in sequence
+ String a71153 = param; // assign
+ StringBuilder b71153 = new StringBuilder(a71153); // stick in stringbuilder
+ b71153.append(" SafeStuff"); // append some safe content
+ b71153.replace(
+ b71153.length() - "Chars".length(),
+ b71153.length(),
+ "Chars"); // replace some of the end content
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00068")
+public class BenchmarkTest00068 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00068", "anything");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/weakrand-00/BenchmarkTest00068.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00068")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple ? condition that assigns constant to bar on true condition
+ int num = 106;
+
+ bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param;
+
+ double value = java.lang.Math.random();
+ String rememberMeKey = Double.toString(value).substring(2); // Trim off the 0. at the front.
+
+ String user = "Doug";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/hash-00/BenchmarkTest00069")
+public class BenchmarkTest00069 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00069", "someSecret");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/hash-00/BenchmarkTest00069.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00069")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple ? condition that assigns constant to bar on true condition
+ int num = 106;
+
+ bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param;
+
+ java.security.Provider[] provider = java.security.Security.getProviders();
+ java.security.MessageDigest md;
+
+ try {
+ if (provider.length > 1) {
+
+ md = java.security.MessageDigest.getInstance("sha-384", provider[0]);
+ } else {
+ md = java.security.MessageDigest.getInstance("sha-384", "SUN");
+ }
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ md.update(input);
+
+ byte[] result = md.digest();
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "hash_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' hashed and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/hash-00/BenchmarkTest00070")
+public class BenchmarkTest00070 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00070", "someSecret");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/hash-00/BenchmarkTest00070.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00070")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple ? condition that assigns param to bar on false condition
+ int num = 106;
+
+ bar = (7 * 42) - num > 200 ? "This should never happen" : param;
+
+ try {
+ java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN");
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ md.update(input);
+
+ byte[] result = md.digest();
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "hash_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' hashed and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/hash-00/BenchmarkTest00071")
+public class BenchmarkTest00071 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00071", "someSecret");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/hash-00/BenchmarkTest00071.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00071")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple if statement that assigns param to bar on true condition
+ int num = 196;
+ if ((500 / 42) + num > 200) bar = param;
+ else bar = "This should never happen";
+
+ try {
+ java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA1", "SUN");
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ md.update(input);
+
+ byte[] result = md.digest();
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "hash_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' hashed and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/hash-00/BenchmarkTest00072")
+public class BenchmarkTest00072 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00072", "someSecret");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/hash-00/BenchmarkTest00072.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00072")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ org.owasp.benchmark.helpers.ThingInterface thing =
+ org.owasp.benchmark.helpers.ThingFactory.createThing();
+ String bar = thing.doSomething(param);
+
+ try {
+ java.security.MessageDigest md =
+ java.security.MessageDigest.getInstance("SHA-512", "SUN");
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ md.update(input);
+
+ byte[] result = md.digest();
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "hash_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' hashed and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/hash-00/BenchmarkTest00073")
+public class BenchmarkTest00073 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00073", "someSecret");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/hash-00/BenchmarkTest00073.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00073")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+ String guess = "ABC";
+ char switchTarget = guess.charAt(1); // condition 'B', which is safe
+
+ // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D'
+ switch (switchTarget) {
+ case 'A':
+ bar = param;
+ break;
+ case 'B':
+ bar = "bob";
+ break;
+ case 'C':
+ case 'D':
+ bar = param;
+ break;
+ default:
+ bar = "bob's your uncle";
+ break;
+ }
+
+ try {
+ java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ md.update(input);
+
+ byte[] result = md.digest();
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "hash_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' hashed and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/hash-00/BenchmarkTest00074")
+public class BenchmarkTest00074 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00074", "someSecret");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/hash-00/BenchmarkTest00074.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00074")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/hash-00/BenchmarkTest00075")
+public class BenchmarkTest00075 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00075", "someSecret");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/hash-00/BenchmarkTest00075.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00075")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple ? condition that assigns param to bar on false condition
+ int num = 106;
+
+ bar = (7 * 42) - num > 200 ? "This should never happen" : param;
+
+ try {
+ java.util.Properties benchmarkprops = new java.util.Properties();
+ benchmarkprops.load(
+ this.getClass().getClassLoader().getResourceAsStream("benchmark.properties"));
+ String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5");
+ java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm);
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ md.update(input);
+
+ byte[] result = md.digest();
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "hash_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' hashed and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/hash-00/BenchmarkTest00076")
+public class BenchmarkTest00076 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00076", "someSecret");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/hash-00/BenchmarkTest00076.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00076")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+ String guess = "ABC";
+ char switchTarget = guess.charAt(2);
+
+ // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D'
+ switch (switchTarget) {
+ case 'A':
+ bar = param;
+ break;
+ case 'B':
+ bar = "bobs_your_uncle";
+ break;
+ case 'C':
+ case 'D':
+ bar = param;
+ break;
+ default:
+ bar = "bobs_your_uncle";
+ break;
+ }
+
+ try {
+ java.util.Properties benchmarkprops = new java.util.Properties();
+ benchmarkprops.load(
+ this.getClass().getClassLoader().getResourceAsStream("benchmark.properties"));
+ String algorithm = benchmarkprops.getProperty("hashAlg2", "SHA5");
+ java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm);
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ md.update(input);
+
+ byte[] result = md.digest();
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "hash_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' hashed and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00077")
+public class BenchmarkTest00077 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00077", "ECHOOO");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/cmdi-00/BenchmarkTest00077.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00077")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+ String guess = "ABC";
+ char switchTarget = guess.charAt(2);
+
+ // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D'
+ switch (switchTarget) {
+ case 'A':
+ bar = param;
+ break;
+ case 'B':
+ bar = "bobs_your_uncle";
+ break;
+ case 'C':
+ case 'D':
+ bar = param;
+ break;
+ default:
+ bar = "bobs_your_uncle";
+ break;
+ }
+
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00078")
+public class BenchmarkTest00078 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00078", "whatever");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/weakrand-00/BenchmarkTest00078.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00078")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "";
+ if (param != null) {
+ bar =
+ new String(
+ org.apache.commons.codec.binary.Base64.decodeBase64(
+ org.apache.commons.codec.binary.Base64.encodeBase64(
+ param.getBytes())));
+ }
+
+ float rand = new java.util.Random().nextFloat();
+ String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front.
+
+ String user = "Floyd";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00079")
+public class BenchmarkTest00079 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00079", "whatever");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/weakrand-00/BenchmarkTest00079.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00079")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00080")
+public class BenchmarkTest00080 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00080", "whatever");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/weakrand-00/BenchmarkTest00080.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00080")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param);
+
+ float rand = new java.util.Random().nextFloat();
+ String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front.
+
+ String user = "Floyd";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00081")
+public class BenchmarkTest00081 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00081", "whatever");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/weakrand-00/BenchmarkTest00081.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00081")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param);
+
+ double stuff = new java.util.Random().nextGaussian();
+ String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front.
+
+ String user = "Gayle";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00082")
+public class BenchmarkTest00082 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00082", "whatever");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/weakrand-00/BenchmarkTest00082.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00082")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ StringBuilder sbxyz58640 = new StringBuilder(param);
+ String bar = sbxyz58640.append("_SafeStuff").toString();
+
+ int randNumber = new java.util.Random().nextInt(99);
+ String rememberMeKey = Integer.toString(randNumber);
+
+ String user = "Inga";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00083")
+public class BenchmarkTest00083 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00083", "whatever");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/weakrand-00/BenchmarkTest00083.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00083")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple if statement that assigns param to bar on true condition
+ int num = 196;
+ if ((500 / 42) + num > 200) bar = param;
+ else bar = "This should never happen";
+
+ int randNumber = new java.util.Random().nextInt(99);
+ String rememberMeKey = Integer.toString(randNumber);
+
+ String user = "Inga";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00084")
+public class BenchmarkTest00084 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00084", "whatever");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/weakrand-00/BenchmarkTest00084.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00084")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ org.owasp.benchmark.helpers.ThingInterface thing =
+ org.owasp.benchmark.helpers.ThingFactory.createThing();
+ String bar = thing.doSomething(param);
+
+ int r = new java.util.Random().nextInt();
+ String rememberMeKey = Integer.toString(r);
+
+ String user = "Ingrid";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00085")
+public class BenchmarkTest00085 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00085", "whatever");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/weakrand-00/BenchmarkTest00085.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00085")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00086")
+public class BenchmarkTest00086 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00086", "whatever");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/weakrand-00/BenchmarkTest00086.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00086")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple if statement that assigns constant to bar on true condition
+ int num = 86;
+ if ((7 * 42) - num > 200) bar = "This_should_always_happen";
+ else bar = param;
+
+ long l = new java.util.Random().nextLong();
+ String rememberMeKey = Long.toString(l);
+
+ String user = "Logan";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/securecookie-00/BenchmarkTest00087")
+public class BenchmarkTest00087 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00087", "whatever");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/securecookie-00/BenchmarkTest00087.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00087")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "";
+ if (param != null) {
+ bar =
+ new String(
+ org.apache.commons.codec.binary.Base64.decodeBase64(
+ org.apache.commons.codec.binary.Base64.encodeBase64(
+ param.getBytes())));
+ }
+
+ byte[] input = new byte[1000];
+ String str = "?";
+ Object inputParam = param;
+ if (inputParam instanceof String) str = ((String) inputParam);
+ if (inputParam instanceof java.io.InputStream) {
+ int i = ((java.io.InputStream) inputParam).read(input);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ str = new String(input, 0, i);
+ }
+ if ("".equals(str)) str = "No cookie value supplied";
+ javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str);
+
+ cookie.setSecure(false);
+ cookie.setHttpOnly(true);
+ cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ response.addCookie(cookie);
+
+ response.getWriter()
+ .println(
+ "Created cookie: 'SomeCookie': with value: '"
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str)
+ + "' and secure flag set to: false");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00088.java b/OWASP DATASET/BenchmarkTest00088.java
new file mode 100644
index 0000000000000000000000000000000000000000..4da339103388e400f33b02278a42aaba19331438
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00088.java
@@ -0,0 +1,96 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/securecookie-00/BenchmarkTest00088")
+public class BenchmarkTest00088 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00088", "whatever");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/securecookie-00/BenchmarkTest00088.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00088")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param);
+
+ byte[] input = new byte[1000];
+ String str = "?";
+ Object inputParam = param;
+ if (inputParam instanceof String) str = ((String) inputParam);
+ if (inputParam instanceof java.io.InputStream) {
+ int i = ((java.io.InputStream) inputParam).read(input);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ str = new String(input, 0, i);
+ }
+ if ("".equals(str)) str = "No cookie value supplied";
+ javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str);
+
+ cookie.setSecure(true);
+ cookie.setHttpOnly(true);
+ cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ response.addCookie(cookie);
+
+ response.getWriter()
+ .println(
+ "Created cookie: 'SomeCookie': with value: '"
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str)
+ + "' and secure flag set to: true");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00089.java b/OWASP DATASET/BenchmarkTest00089.java
new file mode 100644
index 0000000000000000000000000000000000000000..ff09d01f11e40222da0e54f4503d1f828406bd8c
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00089.java
@@ -0,0 +1,101 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/securecookie-00/BenchmarkTest00089")
+public class BenchmarkTest00089 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00089", "whatever");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/securecookie-00/BenchmarkTest00089.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00089")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple ? condition that assigns param to bar on false condition
+ int num = 106;
+
+ bar = (7 * 42) - num > 200 ? "This should never happen" : param;
+
+ byte[] input = new byte[1000];
+ String str = "?";
+ Object inputParam = param;
+ if (inputParam instanceof String) str = ((String) inputParam);
+ if (inputParam instanceof java.io.InputStream) {
+ int i = ((java.io.InputStream) inputParam).read(input);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ str = new String(input, 0, i);
+ }
+ if ("".equals(str)) str = "No cookie value supplied";
+ javax.servlet.http.Cookie cookie = new javax.servlet.http.Cookie("SomeCookie", str);
+
+ cookie.setSecure(true);
+ cookie.setHttpOnly(true);
+ cookie.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ response.addCookie(cookie);
+
+ response.getWriter()
+ .println(
+ "Created cookie: 'SomeCookie': with value: '"
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(str)
+ + "' and secure flag set to: true");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00090.java b/OWASP DATASET/BenchmarkTest00090.java
new file mode 100644
index 0000000000000000000000000000000000000000..6f045cb9f0c939eaff680f52f58f1c07d734bf27
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00090.java
@@ -0,0 +1,90 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00090")
+public class BenchmarkTest00090 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00090", "ls");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/cmdi-00/BenchmarkTest00090.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00090")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple if statement that assigns constant to bar on true condition
+ int num = 86;
+ if ((7 * 42) - num > 200) bar = "This_should_always_happen";
+ else bar = param;
+
+ String cmd = "";
+ String osName = System.getProperty("os.name");
+ if (osName.indexOf("Windows") != -1) {
+ cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo");
+ }
+
+ Runtime r = Runtime.getRuntime();
+
+ try {
+ Process p = r.exec(cmd + bar);
+ org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response);
+ } catch (IOException e) {
+ System.out.println("Problem executing cmdi - TestCase");
+ response.getWriter()
+ .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage()));
+ return;
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00091.java b/OWASP DATASET/BenchmarkTest00091.java
new file mode 100644
index 0000000000000000000000000000000000000000..4a983d3ca684def58aa8f7e6c4731b81d36b805b
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00091.java
@@ -0,0 +1,85 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00091")
+public class BenchmarkTest00091 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00091", "FOO%3Decho+Injection");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/cmdi-00/BenchmarkTest00091.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00091")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = param;
+
+ String cmd =
+ org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString(
+ this.getClass().getClassLoader());
+ String[] args = {cmd};
+ String[] argsEnv = {bar};
+
+ Runtime r = Runtime.getRuntime();
+
+ try {
+ Process p = r.exec(args, argsEnv);
+ org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response);
+ } catch (IOException e) {
+ System.out.println("Problem executing cmdi - TestCase");
+ response.getWriter()
+ .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage()));
+ return;
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00092.java b/OWASP DATASET/BenchmarkTest00092.java
new file mode 100644
index 0000000000000000000000000000000000000000..9421950e4329beb281ffa87fdb6f340d5abc2f6e
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00092.java
@@ -0,0 +1,104 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00092")
+public class BenchmarkTest00092 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00092", "FOO%3Decho+Injection");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/cmdi-00/BenchmarkTest00092.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00092")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+ String guess = "ABC";
+ char switchTarget = guess.charAt(2);
+
+ // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D'
+ switch (switchTarget) {
+ case 'A':
+ bar = param;
+ break;
+ case 'B':
+ bar = "bobs_your_uncle";
+ break;
+ case 'C':
+ case 'D':
+ bar = param;
+ break;
+ default:
+ bar = "bobs_your_uncle";
+ break;
+ }
+
+ String cmd =
+ org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString(
+ this.getClass().getClassLoader());
+ String[] args = {cmd};
+ String[] argsEnv = {bar};
+
+ Runtime r = Runtime.getRuntime();
+
+ try {
+ Process p = r.exec(args, argsEnv);
+ org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response);
+ } catch (IOException e) {
+ System.out.println("Problem executing cmdi - TestCase");
+ response.getWriter()
+ .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage()));
+ return;
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00093.java b/OWASP DATASET/BenchmarkTest00093.java
new file mode 100644
index 0000000000000000000000000000000000000000..56372b8c82c29db48b1c24b1744d57c12e5ae18d
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00093.java
@@ -0,0 +1,96 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00093")
+public class BenchmarkTest00093 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00093", "ls");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/cmdi-00/BenchmarkTest00093.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00093")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "alsosafe";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00094")
+public class BenchmarkTest00094 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00094", "whatever");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/weakrand-00/BenchmarkTest00094.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00094")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00095")
+public class BenchmarkTest00095 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00095", "whatever");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/weakrand-00/BenchmarkTest00095.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00095")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00096")
+public class BenchmarkTest00096 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00096", "whatever");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/weakrand-00/BenchmarkTest00096.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00096")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple ? condition that assigns param to bar on false condition
+ int num = 106;
+
+ bar = (7 * 42) - num > 200 ? "This should never happen" : param;
+
+ try {
+ int randNumber = java.security.SecureRandom.getInstance("SHA1PRNG").nextInt(99);
+ String rememberMeKey = Integer.toString(randNumber);
+
+ String user = "SafeInga";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue()
+ .equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/trustbound-00/BenchmarkTest00097")
+public class BenchmarkTest00097 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00097", "color");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/trustbound-00/BenchmarkTest00097.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00097")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple ? condition that assigns constant to bar on true condition
+ int num = 106;
+
+ bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param;
+
+ // javax.servlet.http.HttpSession.putValue(java.lang.String^,java.lang.Object)
+ request.getSession().putValue(bar, "10340");
+
+ response.getWriter()
+ .println(
+ "Item: '"
+ + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar)
+ + "' with value: 10340 saved in session.");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00098.java b/OWASP DATASET/BenchmarkTest00098.java
new file mode 100644
index 0000000000000000000000000000000000000000..daeadc40ef3df37c103a60cff02b8db8ea78a89f
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00098.java
@@ -0,0 +1,76 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/trustbound-00/BenchmarkTest00098")
+public class BenchmarkTest00098 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00098", "my_user_id");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/trustbound-00/BenchmarkTest00098.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00098")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param);
+
+ // javax.servlet.http.HttpSession.putValue(java.lang.String,java.lang.Object^)
+ request.getSession().putValue("userid", bar);
+
+ response.getWriter()
+ .println(
+ "Item: 'userid' with value: '"
+ + org.owasp.benchmark.helpers.Utils.encodeForHTML(bar)
+ + "' saved in session.");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00099.java b/OWASP DATASET/BenchmarkTest00099.java
new file mode 100644
index 0000000000000000000000000000000000000000..bc8c41f1403f63976a0d68d05c69decd252bceaf
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00099.java
@@ -0,0 +1,86 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/trustbound-00/BenchmarkTest00099")
+public class BenchmarkTest00099 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00099", "my_userid");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/trustbound-00/BenchmarkTest00099.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00099")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "alsosafe";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00100")
+public class BenchmarkTest00100 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00100", "bar");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/sqli-00/BenchmarkTest00100.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00100")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00101")
+public class BenchmarkTest00101 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00101", "bar");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/sqli-00/BenchmarkTest00101.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00101")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00102")
+public class BenchmarkTest00102 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00102", "bar");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/sqli-00/BenchmarkTest00102.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00102")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ org.owasp.benchmark.helpers.ThingInterface thing =
+ org.owasp.benchmark.helpers.ThingFactory.createThing();
+ String bar = thing.doSomething(param);
+
+ String sql =
+ "SELECT TOP 1 userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
+ try {
+ java.util.Map This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00103")
+public class BenchmarkTest00103 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00103", "bar");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/sqli-00/BenchmarkTest00103.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00103")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple ? condition that assigns param to bar on false condition
+ int num = 106;
+
+ bar = (7 * 42) - num > 200 ? "This should never happen" : param;
+
+ String sql =
+ "SELECT TOP 1 USERNAME from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
+ try {
+ Object results =
+ org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject(
+ sql, new Object[] {}, String.class);
+ response.getWriter().println("Your results are: ");
+
+ // System.out.println("Your results are");
+ response.getWriter()
+ .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(results.toString()));
+ // System.out.println(results.toString());
+ } catch (org.springframework.dao.EmptyResultDataAccessException e) {
+ response.getWriter()
+ .println(
+ "No results returned for query: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql));
+ } catch (org.springframework.dao.DataAccessException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00104.java b/OWASP DATASET/BenchmarkTest00104.java
new file mode 100644
index 0000000000000000000000000000000000000000..2794ec8e110f0ed92c90a181e9c10d36fbd3117c
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00104.java
@@ -0,0 +1,88 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00104")
+public class BenchmarkTest00104 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00104", "bar");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/sqli-00/BenchmarkTest00104.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00104")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple if statement that assigns constant to bar on true condition
+ int num = 86;
+ if ((7 * 42) - num > 200) bar = "This_should_always_happen";
+ else bar = param;
+
+ try {
+ String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
+
+ org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql);
+ response.getWriter()
+ .println(
+ "No results can be displayed for query: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)
+ + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00105")
+public class BenchmarkTest00105 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00105", "bar");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/sqli-00/BenchmarkTest00105.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00105")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple ? condition that assigns constant to bar on true condition
+ int num = 106;
+
+ bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param;
+
+ String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
+
+ try {
+ java.sql.Statement statement =
+ org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement();
+ statement.addBatch(sql);
+ int[] counts = statement.executeBatch();
+ org.owasp.benchmark.helpers.DatabaseHelper.printResults(sql, counts, response);
+ } catch (java.sql.SQLException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ return;
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00106.java b/OWASP DATASET/BenchmarkTest00106.java
new file mode 100644
index 0000000000000000000000000000000000000000..e844eb8d45662d9925c2b4fdd8ebfc41cff8a131
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00106.java
@@ -0,0 +1,91 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00106")
+public class BenchmarkTest00106 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00106", "bar");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/sqli-00/BenchmarkTest00106.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00106")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00107")
+public class BenchmarkTest00107 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00107", "bar");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/sqli-00/BenchmarkTest00107.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00107")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ // Chain a bunch of propagators in sequence
+ String a18521 = param; // assign
+ StringBuilder b18521 = new StringBuilder(a18521); // stick in stringbuilder
+ b18521.append(" SafeStuff"); // append some safe content
+ b18521.replace(
+ b18521.length() - "Chars".length(),
+ b18521.length(),
+ "Chars"); // replace some of the end content
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00108")
+public class BenchmarkTest00108 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00108", "bar");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/sqli-00/BenchmarkTest00108.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00108")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+ String guess = "ABC";
+ char switchTarget = guess.charAt(2);
+
+ // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D'
+ switch (switchTarget) {
+ case 'A':
+ bar = param;
+ break;
+ case 'B':
+ bar = "bobs_your_uncle";
+ break;
+ case 'C':
+ case 'D':
+ bar = param;
+ break;
+ default:
+ bar = "bobs_your_uncle";
+ break;
+ }
+
+ String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
+
+ try {
+ java.sql.Statement statement =
+ org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement();
+ statement.execute(sql, new int[] {1, 2});
+ org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response);
+ } catch (java.sql.SQLException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ return;
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00109.java b/OWASP DATASET/BenchmarkTest00109.java
new file mode 100644
index 0000000000000000000000000000000000000000..2816bc4edc4c20d2ae806ce4cb1a35282d4bf8bd
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00109.java
@@ -0,0 +1,88 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00109")
+public class BenchmarkTest00109 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00109", "bar");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/sqli-00/BenchmarkTest00109.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00109")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "";
+ if (param != null) {
+ bar =
+ new String(
+ org.apache.commons.codec.binary.Base64.decodeBase64(
+ org.apache.commons.codec.binary.Base64.encodeBase64(
+ param.getBytes())));
+ }
+
+ String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
+
+ try {
+ java.sql.Statement statement =
+ org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement();
+ statement.execute(sql, new String[] {"username", "password"});
+ org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response);
+ } catch (java.sql.SQLException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ return;
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00110.java b/OWASP DATASET/BenchmarkTest00110.java
new file mode 100644
index 0000000000000000000000000000000000000000..3bb8262098e91b97e4081b89e2da777feaa3c1e1
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00110.java
@@ -0,0 +1,102 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00110")
+public class BenchmarkTest00110 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00110", "bar");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/sqli-00/BenchmarkTest00110.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00110")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ // Chain a bunch of propagators in sequence
+ String a69840 = param; // assign
+ StringBuilder b69840 = new StringBuilder(a69840); // stick in stringbuilder
+ b69840.append(" SafeStuff"); // append some safe content
+ b69840.replace(
+ b69840.length() - "Chars".length(),
+ b69840.length(),
+ "Chars"); // replace some of the end content
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00111")
+public class BenchmarkTest00111 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00111", "bar");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/sqli-00/BenchmarkTest00111.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00111")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00112")
+public class BenchmarkTest00112 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00112", "bar");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/sqli-00/BenchmarkTest00112.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00112")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ org.owasp.benchmark.helpers.ThingInterface thing =
+ org.owasp.benchmark.helpers.ThingFactory.createThing();
+ String bar = thing.doSomething(param);
+
+ String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')";
+
+ try {
+ java.sql.Statement statement =
+ org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement();
+ int count = statement.executeUpdate(sql);
+ org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response);
+ } catch (java.sql.SQLException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ return;
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00113.java b/OWASP DATASET/BenchmarkTest00113.java
new file mode 100644
index 0000000000000000000000000000000000000000..fb9bc79c7cf94b7abdd0e90914efc139d921bcb4
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00113.java
@@ -0,0 +1,87 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00113")
+public class BenchmarkTest00113 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00113", "bar");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/sqli-00/BenchmarkTest00113.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00113")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00114")
+public class BenchmarkTest00114 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00114", "bar");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/sqli-00/BenchmarkTest00114.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00114")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple if statement that assigns constant to bar on true condition
+ int num = 86;
+ if ((7 * 42) - num > 200) bar = "This_should_always_happen";
+ else bar = param;
+
+ String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')";
+
+ try {
+ java.sql.Statement statement =
+ org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement();
+ int count = statement.executeUpdate(sql, new int[] {1, 2});
+ org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response);
+ } catch (java.sql.SQLException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ return;
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00115.java b/OWASP DATASET/BenchmarkTest00115.java
new file mode 100644
index 0000000000000000000000000000000000000000..677548bb40a0ff883bc5c8406ec9683f2f394876
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00115.java
@@ -0,0 +1,86 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00115")
+public class BenchmarkTest00115 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00115", "bar");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/sqli-00/BenchmarkTest00115.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00115")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xpathi-00/BenchmarkTest00116")
+public class BenchmarkTest00116 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00116", "2222");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/xpathi-00/BenchmarkTest00116.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00116")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xpathi-00/BenchmarkTest00117")
+public class BenchmarkTest00117 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00117", "2222");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/xpathi-00/BenchmarkTest00117.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00117")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple if statement that assigns constant to bar on true condition
+ int num = 86;
+ if ((7 * 42) - num > 200) bar = "This_should_always_happen";
+ else bar = param;
+
+ try {
+ java.io.FileInputStream file =
+ new java.io.FileInputStream(
+ org.owasp.benchmark.helpers.Utils.getFileFromClasspath(
+ "employees.xml", this.getClass().getClassLoader()));
+ javax.xml.parsers.DocumentBuilderFactory builderFactory =
+ javax.xml.parsers.DocumentBuilderFactory.newInstance();
+ // Prevent XXE
+ builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+ javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder();
+ org.w3c.dom.Document xmlDocument = builder.parse(file);
+ javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance();
+ javax.xml.xpath.XPath xp = xpf.newXPath();
+
+ String expression = "/Employees/Employee[@emplid='" + bar + "']";
+ org.w3c.dom.NodeList nodeList =
+ (org.w3c.dom.NodeList)
+ xp.compile(expression)
+ .evaluate(xmlDocument, javax.xml.xpath.XPathConstants.NODESET);
+
+ response.getWriter().println("Your query results are: This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xpathi-00/BenchmarkTest00118")
+public class BenchmarkTest00118 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ javax.servlet.http.Cookie userCookie =
+ new javax.servlet.http.Cookie("BenchmarkTest00118", "2222");
+ userCookie.setMaxAge(60 * 3); // Store cookie for 3 minutes
+ userCookie.setSecure(true);
+ userCookie.setPath(request.getRequestURI());
+ userCookie.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ response.addCookie(userCookie);
+ javax.servlet.RequestDispatcher rd =
+ request.getRequestDispatcher("/xpathi-00/BenchmarkTest00118.html");
+ rd.include(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ javax.servlet.http.Cookie[] theCookies = request.getCookies();
+
+ String param = "noCookieValueSupplied";
+ if (theCookies != null) {
+ for (javax.servlet.http.Cookie theCookie : theCookies) {
+ if (theCookie.getName().equals("BenchmarkTest00118")) {
+ param = java.net.URLDecoder.decode(theCookie.getValue(), "UTF-8");
+ break;
+ }
+ }
+ }
+
+ String bar;
+
+ // Simple if statement that assigns constant to bar on true condition
+ int num = 86;
+ if ((7 * 42) - num > 200) bar = "This_should_always_happen";
+ else bar = param;
+
+ try {
+ java.io.FileInputStream file =
+ new java.io.FileInputStream(
+ org.owasp.benchmark.helpers.Utils.getFileFromClasspath(
+ "employees.xml", this.getClass().getClassLoader()));
+ javax.xml.parsers.DocumentBuilderFactory builderFactory =
+ javax.xml.parsers.DocumentBuilderFactory.newInstance();
+ // Prevent XXE
+ builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+ javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder();
+ org.w3c.dom.Document xmlDocument = builder.parse(file);
+ javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance();
+ javax.xml.xpath.XPath xp = xpf.newXPath();
+
+ String expression = "/Employees/Employee[@emplid='" + bar + "']";
+ String result = xp.evaluate(expression, xmlDocument);
+
+ response.getWriter().println("Your query results are: " + result + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00119")
+public class BenchmarkTest00119 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00119") != null) {
+ param = request.getHeader("BenchmarkTest00119");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ // Chain a bunch of propagators in sequence
+ String a8142 = param; // assign
+ StringBuilder b8142 = new StringBuilder(a8142); // stick in stringbuilder
+ b8142.append(" SafeStuff"); // append some safe content
+ b8142.replace(
+ b8142.length() - "Chars".length(),
+ b8142.length(),
+ "Chars"); // replace some of the end content
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00120")
+public class BenchmarkTest00120 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00120") != null) {
+ param = request.getHeader("BenchmarkTest00120");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = param;
+ if (param != null && param.length() > 1) {
+ StringBuilder sbxyz43804 = new StringBuilder(param);
+ bar = sbxyz43804.replace(param.length() - "Z".length(), param.length(), "Z").toString();
+ }
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+ // 8-byte initialization vector
+ // byte[] iv = {
+ // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
+ // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033
+ // };
+ java.security.SecureRandom random = new java.security.SecureRandom();
+ byte[] iv = random.generateSeed(8); // DES requires 8 byte keys
+
+ try {
+ javax.crypto.Cipher c =
+ javax.crypto.Cipher.getInstance(
+ "DES/CBC/PKCS5PADDING", java.security.Security.getProvider("SunJCE"));
+
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey();
+ java.security.spec.AlgorithmParameterSpec paramSpec =
+ new javax.crypto.spec.IvParameterSpec(iv);
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00121")
+public class BenchmarkTest00121 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00121") != null) {
+ param = request.getHeader("BenchmarkTest00121");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00122")
+public class BenchmarkTest00122 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00122") != null) {
+ param = request.getHeader("BenchmarkTest00122");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = param;
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+ // AES/GCM example from:
+ // https://javainterviewpoint.com/java-aes-256-gcm-encryption-and-decryption/
+ // 16-byte initialization vector
+ // byte[] iv = {
+ // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
+ // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3,
+ // (byte)0xF3, (byte)0x3C, (byte)0x23, (byte)0xB9,
+ // (byte)0x9E, (byte)0xC5, (byte)0x77, (byte)0x0B033
+ // };
+ java.security.SecureRandom random = new java.security.SecureRandom();
+ byte[] iv = random.generateSeed(16);
+
+ try {
+ javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("AES/GCM/NOPADDING");
+
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey();
+ javax.crypto.spec.GCMParameterSpec paramSpec =
+ new javax.crypto.spec.GCMParameterSpec(16 * 8, iv);
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00123")
+public class BenchmarkTest00123 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00123") != null) {
+ param = request.getHeader("BenchmarkTest00123");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = org.owasp.esapi.ESAPI.encoder().encodeForHTML(param);
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+ // 8-byte initialization vector
+ // byte[] iv = {
+ // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
+ // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033
+ // };
+ java.security.SecureRandom random = new java.security.SecureRandom();
+ byte[] iv = random.generateSeed(8); // DES requires 8 byte keys
+
+ try {
+ javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding");
+
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey();
+ java.security.spec.AlgorithmParameterSpec paramSpec =
+ new javax.crypto.spec.IvParameterSpec(iv);
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00124")
+public class BenchmarkTest00124 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00124") != null) {
+ param = request.getHeader("BenchmarkTest00124");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple ? condition that assigns constant to bar on true condition
+ int num = 106;
+
+ bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param;
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+ // 8-byte initialization vector
+ // byte[] iv = {
+ // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
+ // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033
+ // };
+ java.security.SecureRandom random = new java.security.SecureRandom();
+ byte[] iv = random.generateSeed(8); // DES requires 8 byte keys
+
+ try {
+ javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding");
+
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey();
+ java.security.spec.AlgorithmParameterSpec paramSpec =
+ new javax.crypto.spec.IvParameterSpec(iv);
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00125")
+public class BenchmarkTest00125 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00125") != null) {
+ param = request.getHeader("BenchmarkTest00125");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param);
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+ // 8-byte initialization vector
+ // byte[] iv = {
+ // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
+ // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033
+ // };
+ java.security.SecureRandom random = new java.security.SecureRandom();
+ byte[] iv = random.generateSeed(8); // DES requires 8 byte keys
+
+ try {
+ javax.crypto.Cipher c = javax.crypto.Cipher.getInstance("DES/CBC/PKCS5Padding");
+
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("DES").generateKey();
+ java.security.spec.AlgorithmParameterSpec paramSpec =
+ new javax.crypto.spec.IvParameterSpec(iv);
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key, paramSpec);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00126")
+public class BenchmarkTest00126 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00126") != null) {
+ param = request.getHeader("BenchmarkTest00126");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "alsosafe";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00127")
+public class BenchmarkTest00127 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00127") != null) {
+ param = request.getHeader("BenchmarkTest00127");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "alsosafe";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00128")
+public class BenchmarkTest00128 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00128") != null) {
+ param = request.getHeader("BenchmarkTest00128");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple if statement that assigns constant to bar on true condition
+ int num = 86;
+ if ((7 * 42) - num > 200) bar = "This_should_always_happen";
+ else bar = param;
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+ // 8-byte initialization vector
+ // byte[] iv = {
+ // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
+ // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033
+ // };
+ // java.security.SecureRandom random = new java.security.SecureRandom();
+ // byte[] iv = random.generateSeed(16);
+
+ try {
+ java.util.Properties benchmarkprops = new java.util.Properties();
+ benchmarkprops.load(
+ this.getClass().getClassLoader().getResourceAsStream("benchmark.properties"));
+ String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding");
+ javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm);
+
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey();
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00129")
+public class BenchmarkTest00129 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00129") != null) {
+ param = request.getHeader("BenchmarkTest00129");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param);
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+ // 8-byte initialization vector
+ // byte[] iv = {
+ // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
+ // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033
+ // };
+ // java.security.SecureRandom random = new java.security.SecureRandom();
+ // byte[] iv = random.generateSeed(16);
+
+ try {
+ java.util.Properties benchmarkprops = new java.util.Properties();
+ benchmarkprops.load(
+ this.getClass().getClassLoader().getResourceAsStream("benchmark.properties"));
+ String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding");
+ javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm);
+
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey();
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00130")
+public class BenchmarkTest00130 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00130") != null) {
+ param = request.getHeader("BenchmarkTest00130");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+ String guess = "ABC";
+ char switchTarget = guess.charAt(1); // condition 'B', which is safe
+
+ // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D'
+ switch (switchTarget) {
+ case 'A':
+ bar = param;
+ break;
+ case 'B':
+ bar = "bob";
+ break;
+ case 'C':
+ case 'D':
+ bar = param;
+ break;
+ default:
+ bar = "bob's your uncle";
+ break;
+ }
+
+ // Code based on example from:
+ // http://examples.javacodegeeks.com/core-java/crypto/encrypt-decrypt-file-stream-with-des/
+ // 8-byte initialization vector
+ // byte[] iv = {
+ // (byte)0xB2, (byte)0x12, (byte)0xD5, (byte)0xB2,
+ // (byte)0x44, (byte)0x21, (byte)0xC3, (byte)0xC3033
+ // };
+ // java.security.SecureRandom random = new java.security.SecureRandom();
+ // byte[] iv = random.generateSeed(16);
+
+ try {
+ java.util.Properties benchmarkprops = new java.util.Properties();
+ benchmarkprops.load(
+ this.getClass().getClassLoader().getResourceAsStream("benchmark.properties"));
+ String algorithm = benchmarkprops.getProperty("cryptoAlg2", "AES/ECB/PKCS5Padding");
+ javax.crypto.Cipher c = javax.crypto.Cipher.getInstance(algorithm);
+
+ // Prepare the cipher to encrypt
+ javax.crypto.SecretKey key = javax.crypto.KeyGenerator.getInstance("AES").generateKey();
+ c.init(javax.crypto.Cipher.ENCRYPT_MODE, key);
+
+ // encrypt and store the results
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ byte[] result = c.doFinal(input);
+
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "secret_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' encrypted and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00131")
+public class BenchmarkTest00131 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00131") != null) {
+ param = request.getHeader("BenchmarkTest00131");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+ String guess = "ABC";
+ char switchTarget = guess.charAt(1); // condition 'B', which is safe
+
+ // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D'
+ switch (switchTarget) {
+ case 'A':
+ bar = param;
+ break;
+ case 'B':
+ bar = "bob";
+ break;
+ case 'C':
+ case 'D':
+ bar = param;
+ break;
+ default:
+ bar = "bob's your uncle";
+ break;
+ }
+
+ java.io.File fileTarget = new java.io.File(bar);
+ response.getWriter()
+ .println(
+ "Access to file: '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(fileTarget.toString())
+ + "' created.");
+ if (fileTarget.exists()) {
+ response.getWriter().println(" And file already exists.");
+ } else {
+ response.getWriter().println(" But file doesn't exist yet.");
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00132.java b/OWASP DATASET/BenchmarkTest00132.java
new file mode 100644
index 0000000000000000000000000000000000000000..1137f02bcfede421f4ef02ef9acda277426674ed
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00132.java
@@ -0,0 +1,111 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00132")
+public class BenchmarkTest00132 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00132") != null) {
+ param = request.getHeader("BenchmarkTest00132");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+ String guess = "ABC";
+ char switchTarget = guess.charAt(1); // condition 'B', which is safe
+
+ // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D'
+ switch (switchTarget) {
+ case 'A':
+ bar = param;
+ break;
+ case 'B':
+ bar = "bob";
+ break;
+ case 'C':
+ case 'D':
+ bar = param;
+ break;
+ default:
+ bar = "bob's your uncle";
+ break;
+ }
+
+ String fileName = null;
+ java.io.FileInputStream fis = null;
+
+ try {
+ fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar;
+ fis = new java.io.FileInputStream(new java.io.File(fileName));
+ byte[] b = new byte[1000];
+ int size = fis.read(b);
+ response.getWriter()
+ .println(
+ "The beginning of file: '"
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)
+ + "' is:\n\n"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(b, 0, size)));
+ } catch (Exception e) {
+ System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'");
+ response.getWriter()
+ .println(
+ "Problem getting FileInputStream: "
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(e.getMessage()));
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ fis = null;
+ } catch (Exception e) {
+ // we tried...
+ }
+ }
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00133.java b/OWASP DATASET/BenchmarkTest00133.java
new file mode 100644
index 0000000000000000000000000000000000000000..4a280986b6cb384a1158c1ea83d8dffaf0f42aeb
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00133.java
@@ -0,0 +1,87 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00133")
+public class BenchmarkTest00133 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00133") != null) {
+ param = request.getHeader("BenchmarkTest00133");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple ? condition that assigns param to bar on false condition
+ int num = 106;
+
+ bar = (7 * 42) - num > 200 ? "This should never happen" : param;
+
+ String fileName = null;
+ java.io.FileInputStream fis = null;
+
+ try {
+ fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar;
+ fis = new java.io.FileInputStream(fileName);
+ byte[] b = new byte[1000];
+ int size = fis.read(b);
+ response.getWriter()
+ .println(
+ "The beginning of file: '"
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName)
+ + "' is:\n\n");
+ response.getWriter()
+ .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(new String(b, 0, size)));
+ } catch (Exception e) {
+ System.out.println("Couldn't open FileInputStream on file: '" + fileName + "'");
+ // System.out.println("File exception caught and swallowed: " + e.getMessage());
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ fis = null;
+ } catch (Exception e) {
+ // we tried...
+ }
+ }
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00134.java b/OWASP DATASET/BenchmarkTest00134.java
new file mode 100644
index 0000000000000000000000000000000000000000..f6ef36539ebb05fcaa0fa2ee39d32b2776322a1c
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00134.java
@@ -0,0 +1,85 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00134")
+public class BenchmarkTest00134 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00134") != null) {
+ param = request.getHeader("BenchmarkTest00134");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "alsosafe";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00135")
+public class BenchmarkTest00135 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00135") != null) {
+ param = request.getHeader("BenchmarkTest00135");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+ String guess = "ABC";
+ char switchTarget = guess.charAt(1); // condition 'B', which is safe
+
+ // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D'
+ switch (switchTarget) {
+ case 'A':
+ bar = param;
+ break;
+ case 'B':
+ bar = "bob";
+ break;
+ case 'C':
+ case 'D':
+ bar = param;
+ break;
+ default:
+ bar = "bob's your uncle";
+ break;
+ }
+
+ String fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar;
+
+ try (
+ // Create the file first so the test won't throw an exception if it doesn't exist.
+ // Note: Don't actually do this because this method signature could cause a tool to find
+ // THIS file constructor
+ // as a vuln, rather than the File signature we are trying to actually test.
+ // If necessary, just run the benchmark twice. The 1st run should create all the necessary
+ // files.
+ // new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar).createNewFile();
+
+ java.io.FileOutputStream fos =
+ new java.io.FileOutputStream(new java.io.FileInputStream(fileName).getFD()); ) {
+ response.getWriter()
+ .println(
+ "Now ready to write to file: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName));
+
+ } catch (Exception e) {
+ System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'");
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00136.java b/OWASP DATASET/BenchmarkTest00136.java
new file mode 100644
index 0000000000000000000000000000000000000000..7c0dccfd42479b789a1d8292404479600fa389d6
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00136.java
@@ -0,0 +1,98 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00136")
+public class BenchmarkTest00136 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00136") != null) {
+ param = request.getHeader("BenchmarkTest00136");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+ String guess = "ABC";
+ char switchTarget = guess.charAt(1); // condition 'B', which is safe
+
+ // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D'
+ switch (switchTarget) {
+ case 'A':
+ bar = param;
+ break;
+ case 'B':
+ bar = "bob";
+ break;
+ case 'C':
+ case 'D':
+ bar = param;
+ break;
+ default:
+ bar = "bob's your uncle";
+ break;
+ }
+
+ String fileName = null;
+ java.io.FileOutputStream fos = null;
+
+ try {
+ fileName = org.owasp.benchmark.helpers.Utils.TESTFILES_DIR + bar;
+
+ fos = new java.io.FileOutputStream(fileName, false);
+ response.getWriter()
+ .println(
+ "Now ready to write to file: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(fileName));
+
+ } catch (Exception e) {
+ System.out.println("Couldn't open FileOutputStream on file: '" + fileName + "'");
+ // System.out.println("File exception caught and swallowed: " + e.getMessage());
+ } finally {
+ if (fos != null) {
+ try {
+ fos.close();
+ fos = null;
+ } catch (Exception e) {
+ // we tried...
+ }
+ }
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00137.java b/OWASP DATASET/BenchmarkTest00137.java
new file mode 100644
index 0000000000000000000000000000000000000000..b9e3febf72501d9a9af867b50c53673f0f843d17
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00137.java
@@ -0,0 +1,96 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/pathtraver-00/BenchmarkTest00137")
+public class BenchmarkTest00137 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00137") != null) {
+ param = request.getHeader("BenchmarkTest00137");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/ldapi-00/BenchmarkTest00138")
+public class BenchmarkTest00138 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00138") != null) {
+ param = request.getHeader("BenchmarkTest00138");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple ? condition that assigns constant to bar on true condition
+ int num = 106;
+
+ bar = (7 * 18) + num > 200 ? "This_should_always_happen" : param;
+
+ org.owasp.benchmark.helpers.LDAPManager ads = new org.owasp.benchmark.helpers.LDAPManager();
+ try {
+ response.setContentType("text/html;charset=UTF-8");
+ String base = "ou=users,ou=system";
+ javax.naming.directory.SearchControls sc = new javax.naming.directory.SearchControls();
+ sc.setSearchScope(javax.naming.directory.SearchControls.SUBTREE_SCOPE);
+ String filter = "(&(objectclass=person))(|(uid=" + bar + ")(street={0}))";
+ Object[] filters = new Object[] {"The streetz 4 Ms bar"};
+
+ javax.naming.directory.DirContext ctx = ads.getDirContext();
+ javax.naming.directory.InitialDirContext idc =
+ (javax.naming.directory.InitialDirContext) ctx;
+ boolean found = false;
+ javax.naming.NamingEnumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/ldapi-00/BenchmarkTest00139")
+public class BenchmarkTest00139 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00139") != null) {
+ param = request.getHeader("BenchmarkTest00139");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ // Chain a bunch of propagators in sequence
+ String a48394 = param; // assign
+ StringBuilder b48394 = new StringBuilder(a48394); // stick in stringbuilder
+ b48394.append(" SafeStuff"); // append some safe content
+ b48394.replace(
+ b48394.length() - "Chars".length(),
+ b48394.length(),
+ "Chars"); // replace some of the end content
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00140")
+public class BenchmarkTest00140 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00140") != null) {
+ param = request.getHeader("BenchmarkTest00140");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/hash-00/BenchmarkTest00141")
+public class BenchmarkTest00141 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00141") != null) {
+ param = request.getHeader("BenchmarkTest00141");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple ? condition that assigns param to bar on false condition
+ int num = 106;
+
+ bar = (7 * 42) - num > 200 ? "This should never happen" : param;
+
+ java.security.Provider[] provider = java.security.Security.getProviders();
+ java.security.MessageDigest md;
+
+ try {
+ if (provider.length > 1) {
+
+ md = java.security.MessageDigest.getInstance("SHA1", provider[0]);
+ } else {
+ md = java.security.MessageDigest.getInstance("SHA1", "SUN");
+ }
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ md.update(input);
+
+ byte[] result = md.digest();
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "hash_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' hashed and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/hash-00/BenchmarkTest00142")
+public class BenchmarkTest00142 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00142") != null) {
+ param = request.getHeader("BenchmarkTest00142");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple if statement that assigns constant to bar on true condition
+ int num = 86;
+ if ((7 * 42) - num > 200) bar = "This_should_always_happen";
+ else bar = param;
+
+ try {
+ java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256");
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ md.update(input);
+
+ byte[] result = md.digest();
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "hash_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' hashed and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/hash-00/BenchmarkTest00143")
+public class BenchmarkTest00143 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00143") != null) {
+ param = request.getHeader("BenchmarkTest00143");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+ String guess = "ABC";
+ char switchTarget = guess.charAt(2);
+
+ // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D'
+ switch (switchTarget) {
+ case 'A':
+ bar = param;
+ break;
+ case 'B':
+ bar = "bobs_your_uncle";
+ break;
+ case 'C':
+ case 'D':
+ bar = param;
+ break;
+ default:
+ bar = "bobs_your_uncle";
+ break;
+ }
+
+ try {
+ java.util.Properties benchmarkprops = new java.util.Properties();
+ benchmarkprops.load(
+ this.getClass().getClassLoader().getResourceAsStream("benchmark.properties"));
+ String algorithm = benchmarkprops.getProperty("hashAlg1", "SHA512");
+ java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm);
+ byte[] input = {(byte) '?'};
+ Object inputParam = bar;
+ if (inputParam instanceof String) input = ((String) inputParam).getBytes();
+ if (inputParam instanceof java.io.InputStream) {
+ byte[] strInput = new byte[1000];
+ int i = ((java.io.InputStream) inputParam).read(strInput);
+ if (i == -1) {
+ response.getWriter()
+ .println(
+ "This input source requires a POST, not a GET. Incompatible UI for the InputStream source.");
+ return;
+ }
+ input = java.util.Arrays.copyOf(strInput, i);
+ }
+ md.update(input);
+
+ byte[] result = md.digest();
+ java.io.File fileTarget =
+ new java.io.File(
+ new java.io.File(org.owasp.benchmark.helpers.Utils.TESTFILES_DIR),
+ "passwordFile.txt");
+ java.io.FileWriter fw =
+ new java.io.FileWriter(fileTarget, true); // the true will append the new data
+ fw.write(
+ "hash_value="
+ + org.owasp.esapi.ESAPI.encoder().encodeForBase64(result, true)
+ + "\n");
+ fw.close();
+ response.getWriter()
+ .println(
+ "Sensitive value '"
+ + org.owasp
+ .esapi
+ .ESAPI
+ .encoder()
+ .encodeForHTML(new String(input))
+ + "' hashed and stored This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00144")
+public class BenchmarkTest00144 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("Referer") != null) {
+ param = request.getHeader("Referer");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00145")
+public class BenchmarkTest00145 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("Referer") != null) {
+ param = request.getHeader("Referer");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00146")
+public class BenchmarkTest00146 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("Referer") != null) {
+ param = request.getHeader("Referer");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = param;
+ if (param != null && param.length() > 1) {
+ StringBuilder sbxyz67327 = new StringBuilder(param);
+ bar = sbxyz67327.replace(param.length() - "Z".length(), param.length(), "Z").toString();
+ }
+
+ response.setHeader("X-XSS-Protection", "0");
+ Object[] obj = {"a", "b"};
+ response.getWriter().format(java.util.Locale.US, bar, obj);
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00147.java b/OWASP DATASET/BenchmarkTest00147.java
new file mode 100644
index 0000000000000000000000000000000000000000..f714badb2c2fb86f93c7b36e7bc04d4c3c5d5893
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00147.java
@@ -0,0 +1,67 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00147")
+public class BenchmarkTest00147 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("Referer") != null) {
+ param = request.getHeader("Referer");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "alsosafe";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00148")
+public class BenchmarkTest00148 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("Referer") != null) {
+ param = request.getHeader("Referer");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple if statement that assigns param to bar on true condition
+ int num = 196;
+ if ((500 / 42) + num > 200) bar = param;
+ else bar = "This should never happen";
+
+ response.setHeader("X-XSS-Protection", "0");
+ Object[] obj = {"a", bar};
+ response.getWriter().format("Formatted like: %1$s and %2$s.", obj);
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00149.java b/OWASP DATASET/BenchmarkTest00149.java
new file mode 100644
index 0000000000000000000000000000000000000000..329650dc1dfc45e2ee42739f7d43ddf3a5d79e4c
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00149.java
@@ -0,0 +1,58 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00149")
+public class BenchmarkTest00149 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("Referer") != null) {
+ param = request.getHeader("Referer");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ StringBuilder sbxyz19132 = new StringBuilder(param);
+ String bar = sbxyz19132.append("_SafeStuff").toString();
+
+ response.setHeader("X-XSS-Protection", "0");
+ Object[] obj = {"a", bar};
+ response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj);
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00150.java b/OWASP DATASET/BenchmarkTest00150.java
new file mode 100644
index 0000000000000000000000000000000000000000..39baf141418fc51551b17a14bb08a8728edd53f9
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00150.java
@@ -0,0 +1,62 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00150")
+public class BenchmarkTest00150 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("Referer") != null) {
+ param = request.getHeader("Referer");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple if statement that assigns param to bar on true condition
+ int num = 196;
+ if ((500 / 42) + num > 200) bar = param;
+ else bar = "This should never happen";
+
+ response.setHeader("X-XSS-Protection", "0");
+ Object[] obj = {"a", bar};
+ response.getWriter().printf(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj);
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00151.java b/OWASP DATASET/BenchmarkTest00151.java
new file mode 100644
index 0000000000000000000000000000000000000000..e530e70eb59522d473953f23d4fe7b23ca2b7e6f
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00151.java
@@ -0,0 +1,67 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00151")
+public class BenchmarkTest00151 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("Referer") != null) {
+ param = request.getHeader("Referer");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "alsosafe";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00152")
+public class BenchmarkTest00152 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("Referer") != null) {
+ param = request.getHeader("Referer");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+ String guess = "ABC";
+ char switchTarget = guess.charAt(2);
+
+ // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D'
+ switch (switchTarget) {
+ case 'A':
+ bar = param;
+ break;
+ case 'B':
+ bar = "bobs_your_uncle";
+ break;
+ case 'C':
+ case 'D':
+ bar = param;
+ break;
+ default:
+ bar = "bobs_your_uncle";
+ break;
+ }
+
+ response.setHeader("X-XSS-Protection", "0");
+ response.getWriter().println(bar.toCharArray());
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00153.java b/OWASP DATASET/BenchmarkTest00153.java
new file mode 100644
index 0000000000000000000000000000000000000000..84410887a0f7be1d463c8bb78c1cda7a3d6c2930
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00153.java
@@ -0,0 +1,61 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00153")
+public class BenchmarkTest00153 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("Referer") != null) {
+ param = request.getHeader("Referer");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00154")
+public class BenchmarkTest00154 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("Referer") != null) {
+ param = request.getHeader("Referer");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+ String guess = "ABC";
+ char switchTarget = guess.charAt(2);
+
+ // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D'
+ switch (switchTarget) {
+ case 'A':
+ bar = param;
+ break;
+ case 'B':
+ bar = "bobs_your_uncle";
+ break;
+ case 'C':
+ case 'D':
+ bar = param;
+ break;
+ default:
+ bar = "bobs_your_uncle";
+ break;
+ }
+
+ response.setHeader("X-XSS-Protection", "0");
+ response.getWriter().println(bar);
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00155.java b/OWASP DATASET/BenchmarkTest00155.java
new file mode 100644
index 0000000000000000000000000000000000000000..f709a012d57ec649370bf001e9ff8888c6488d60
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00155.java
@@ -0,0 +1,58 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00155")
+public class BenchmarkTest00155 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("Referer") != null) {
+ param = request.getHeader("Referer");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ org.owasp.benchmark.helpers.ThingInterface thing =
+ org.owasp.benchmark.helpers.ThingFactory.createThing();
+ String bar = thing.doSomething(param);
+
+ response.setHeader("X-XSS-Protection", "0");
+ response.getWriter().println(bar);
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00156.java b/OWASP DATASET/BenchmarkTest00156.java
new file mode 100644
index 0000000000000000000000000000000000000000..d6b2b741fc1899cdef8912c3fc3d652326738b51
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00156.java
@@ -0,0 +1,66 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00156")
+public class BenchmarkTest00156 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("Referer") != null) {
+ param = request.getHeader("Referer");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xss-00/BenchmarkTest00157")
+public class BenchmarkTest00157 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("Referer") != null) {
+ param = request.getHeader("Referer");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple ? condition that assigns param to bar on false condition
+ int num = 106;
+
+ bar = (7 * 42) - num > 200 ? "This should never happen" : param;
+
+ response.setHeader("X-XSS-Protection", "0");
+ response.getWriter().write(bar);
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00158.java b/OWASP DATASET/BenchmarkTest00158.java
new file mode 100644
index 0000000000000000000000000000000000000000..bf3f04011f29f27cf058da76240a08861a508bcb
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00158.java
@@ -0,0 +1,81 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00158")
+public class BenchmarkTest00158 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00158") != null) {
+ param = request.getHeader("BenchmarkTest00158");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple if statement that assigns constant to bar on true condition
+ int num = 86;
+ if ((7 * 42) - num > 200) bar = "This_should_always_happen";
+ else bar = param;
+
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00159")
+public class BenchmarkTest00159 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00159") != null) {
+ param = request.getHeader("BenchmarkTest00159");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ org.owasp.benchmark.helpers.ThingInterface thing =
+ org.owasp.benchmark.helpers.ThingFactory.createThing();
+ String bar = thing.doSomething(param);
+
+ String a1 = "";
+ String a2 = "";
+ String osName = System.getProperty("os.name");
+ if (osName.indexOf("Windows") != -1) {
+ a1 = "cmd.exe";
+ a2 = "/c";
+ } else {
+ a1 = "sh";
+ a2 = "-c";
+ }
+ String[] args = {a1, a2, "echo " + bar};
+
+ ProcessBuilder pb = new ProcessBuilder(args);
+
+ try {
+ Process p = pb.start();
+ org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response);
+ } catch (IOException e) {
+ System.out.println(
+ "Problem executing cmdi - java.lang.ProcessBuilder(java.lang.String[]) Test Case");
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00160.java b/OWASP DATASET/BenchmarkTest00160.java
new file mode 100644
index 0000000000000000000000000000000000000000..0d667252d6cf0234f0c520e4fb4b70a1c8f72dad
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00160.java
@@ -0,0 +1,110 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00160")
+public class BenchmarkTest00160 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00160") != null) {
+ param = request.getHeader("BenchmarkTest00160");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "";
+ if (param != null) {
+ bar =
+ new String(
+ org.apache.commons.codec.binary.Base64.decodeBase64(
+ org.apache.commons.codec.binary.Base64.encodeBase64(
+ param.getBytes())));
+ }
+
+ byte[] bytes = new byte[10];
+ new java.util.Random().nextBytes(bytes);
+ String rememberMeKey = org.owasp.esapi.ESAPI.encoder().encodeForBase64(bytes, true);
+
+ String user = "Byron";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00161")
+public class BenchmarkTest00161 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00161") != null) {
+ param = request.getHeader("BenchmarkTest00161");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00162")
+public class BenchmarkTest00162 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00162") != null) {
+ param = request.getHeader("BenchmarkTest00162");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param);
+
+ double stuff = new java.util.Random().nextGaussian();
+ String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front.
+
+ String user = "Gayle";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00163")
+public class BenchmarkTest00163 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00163") != null) {
+ param = request.getHeader("BenchmarkTest00163");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ StringBuilder sbxyz89305 = new StringBuilder(param);
+ String bar = sbxyz89305.append("_SafeStuff").toString();
+
+ double stuff = new java.util.Random().nextGaussian();
+ String rememberMeKey = Double.toString(stuff).substring(2); // Trim off the 0. at the front.
+
+ String user = "Gayle";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00164")
+public class BenchmarkTest00164 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00164") != null) {
+ param = request.getHeader("BenchmarkTest00164");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple if statement that assigns constant to bar on true condition
+ int num = 86;
+ if ((7 * 42) - num > 200) bar = "This_should_always_happen";
+ else bar = param;
+
+ int r = new java.util.Random().nextInt();
+ String rememberMeKey = Integer.toString(r);
+
+ String user = "Ingrid";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00165")
+public class BenchmarkTest00165 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00165") != null) {
+ param = request.getHeader("BenchmarkTest00165");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = param;
+ if (param != null && param.length() > 1) {
+ bar = param.substring(0, param.length() - 1);
+ }
+
+ int r = new java.util.Random().nextInt();
+ String rememberMeKey = Integer.toString(r);
+
+ String user = "Ingrid";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00166")
+public class BenchmarkTest00166 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00166") != null) {
+ param = request.getHeader("BenchmarkTest00166");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = param;
+
+ long l = new java.util.Random().nextLong();
+ String rememberMeKey = Long.toString(l);
+
+ String user = "Logan";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00167")
+public class BenchmarkTest00167 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00167") != null) {
+ param = request.getHeader("BenchmarkTest00167");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "";
+ if (param != null) {
+ bar =
+ new String(
+ org.apache.commons.codec.binary.Base64.decodeBase64(
+ org.apache.commons.codec.binary.Base64.encodeBase64(
+ param.getBytes())));
+ }
+
+ long l = new java.util.Random().nextLong();
+ String rememberMeKey = Long.toString(l);
+
+ String user = "Logan";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00168")
+public class BenchmarkTest00168 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00168") != null) {
+ param = request.getHeader("BenchmarkTest00168");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple ? condition that assigns param to bar on false condition
+ int num = 106;
+
+ bar = (7 * 42) - num > 200 ? "This should never happen" : param;
+
+ long l = new java.util.Random().nextLong();
+ String rememberMeKey = Long.toString(l);
+
+ String user = "Logan";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/securecookie-00/BenchmarkTest00169")
+public class BenchmarkTest00169 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00169") != null) {
+ param = request.getHeader("BenchmarkTest00169");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "alsosafe";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/securecookie-00/BenchmarkTest00170")
+public class BenchmarkTest00170 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00170") != null) {
+ param = request.getHeader("BenchmarkTest00170");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ // Chain a bunch of propagators in sequence
+ String a9823 = param; // assign
+ StringBuilder b9823 = new StringBuilder(a9823); // stick in stringbuilder
+ b9823.append(" SafeStuff"); // append some safe content
+ b9823.replace(
+ b9823.length() - "Chars".length(),
+ b9823.length(),
+ "Chars"); // replace some of the end content
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00171")
+public class BenchmarkTest00171 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00171") != null) {
+ param = request.getHeader("BenchmarkTest00171");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00172")
+public class BenchmarkTest00172 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00172") != null) {
+ param = request.getHeader("BenchmarkTest00172");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00173")
+public class BenchmarkTest00173 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00173") != null) {
+ param = request.getHeader("BenchmarkTest00173");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00174")
+public class BenchmarkTest00174 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00174") != null) {
+ param = request.getHeader("BenchmarkTest00174");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ org.owasp.benchmark.helpers.ThingInterface thing =
+ org.owasp.benchmark.helpers.ThingFactory.createThing();
+ String bar = thing.doSomething(param);
+
+ String cmd =
+ org.owasp.benchmark.helpers.Utils.getInsecureOSCommandString(
+ this.getClass().getClassLoader());
+
+ String[] argsEnv = {bar};
+ Runtime r = Runtime.getRuntime();
+
+ try {
+ Process p = r.exec(cmd, argsEnv);
+ org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response);
+ } catch (IOException e) {
+ System.out.println("Problem executing cmdi - TestCase");
+ response.getWriter()
+ .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage()));
+ return;
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00175.java b/OWASP DATASET/BenchmarkTest00175.java
new file mode 100644
index 0000000000000000000000000000000000000000..5bcda084605db96e0118e81e6144a6b55d85c43a
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00175.java
@@ -0,0 +1,76 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00175")
+public class BenchmarkTest00175 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00175") != null) {
+ param = request.getHeader("BenchmarkTest00175");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00176")
+public class BenchmarkTest00176 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00176") != null) {
+ param = request.getHeader("BenchmarkTest00176");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = param;
+
+ String cmd = "";
+ String osName = System.getProperty("os.name");
+ if (osName.indexOf("Windows") != -1) {
+ cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo");
+ }
+
+ String[] argsEnv = {"Foo=bar"};
+ Runtime r = Runtime.getRuntime();
+
+ try {
+ Process p =
+ r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir")));
+ org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response);
+ } catch (IOException e) {
+ System.out.println("Problem executing cmdi - TestCase");
+ response.getWriter()
+ .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage()));
+ return;
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00177.java b/OWASP DATASET/BenchmarkTest00177.java
new file mode 100644
index 0000000000000000000000000000000000000000..f5b663ce6faeeac8eed45895c0b572dbe60d3c19
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00177.java
@@ -0,0 +1,78 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/cmdi-00/BenchmarkTest00177")
+public class BenchmarkTest00177 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00177") != null) {
+ param = request.getHeader("BenchmarkTest00177");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple if statement that assigns constant to bar on true condition
+ int num = 86;
+ if ((7 * 42) - num > 200) bar = "This_should_always_happen";
+ else bar = param;
+
+ String cmd = "";
+ String osName = System.getProperty("os.name");
+ if (osName.indexOf("Windows") != -1) {
+ cmd = org.owasp.benchmark.helpers.Utils.getOSCommandString("echo");
+ }
+
+ String[] argsEnv = {"Foo=bar"};
+ Runtime r = Runtime.getRuntime();
+
+ try {
+ Process p =
+ r.exec(cmd + bar, argsEnv, new java.io.File(System.getProperty("user.dir")));
+ org.owasp.benchmark.helpers.Utils.printOSCommandResults(p, response);
+ } catch (IOException e) {
+ System.out.println("Problem executing cmdi - TestCase");
+ response.getWriter()
+ .println(org.owasp.esapi.ESAPI.encoder().encodeForHTML(e.getMessage()));
+ return;
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00178.java b/OWASP DATASET/BenchmarkTest00178.java
new file mode 100644
index 0000000000000000000000000000000000000000..1463e976c3abc89ff2e1b8b831a6aa2de79b5daa
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00178.java
@@ -0,0 +1,119 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00178")
+public class BenchmarkTest00178 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00178") != null) {
+ param = request.getHeader("BenchmarkTest00178");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param);
+
+ try {
+ java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG");
+
+ // Get 40 random bytes
+ byte[] randomBytes = new byte[40];
+ getNextNumber(numGen, randomBytes);
+
+ String rememberMeKey =
+ org.owasp.esapi.ESAPI.encoder().encodeForBase64(randomBytes, true);
+
+ String user = "SafeBystander";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue()
+ .equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00179")
+public class BenchmarkTest00179 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00179") != null) {
+ param = request.getHeader("BenchmarkTest00179");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = org.apache.commons.lang.StringEscapeUtils.escapeHtml(param);
+
+ try {
+ double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble();
+
+ String rememberMeKey =
+ Double.toString(rand).substring(2); // Trim off the 0. at the front.
+
+ String user = "SafeDonna";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue()
+ .equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00180")
+public class BenchmarkTest00180 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00180") != null) {
+ param = request.getHeader("BenchmarkTest00180");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple if statement that assigns param to bar on true condition
+ int num = 196;
+ if ((500 / 42) + num > 200) bar = param;
+ else bar = "This should never happen";
+
+ try {
+ java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG");
+ double rand = getNextNumber(numGen);
+
+ String rememberMeKey =
+ Double.toString(rand).substring(2); // Trim off the 0. at the front.
+
+ String user = "SafeDonatella";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue()
+ .equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00181")
+public class BenchmarkTest00181 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00181") != null) {
+ param = request.getHeader("BenchmarkTest00181");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = org.springframework.web.util.HtmlUtils.htmlEscape(param);
+
+ try {
+ double rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextDouble();
+
+ String rememberMeKey =
+ Double.toString(rand).substring(2); // Trim off the 0. at the front.
+
+ String user = "SafeDonna";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue()
+ .equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00182")
+public class BenchmarkTest00182 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00182") != null) {
+ param = request.getHeader("BenchmarkTest00182");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ // Chain a bunch of propagators in sequence
+ String a48649 = param; // assign
+ StringBuilder b48649 = new StringBuilder(a48649); // stick in stringbuilder
+ b48649.append(" SafeStuff"); // append some safe content
+ b48649.replace(
+ b48649.length() - "Chars".length(),
+ b48649.length(),
+ "Chars"); // replace some of the end content
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00183")
+public class BenchmarkTest00183 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00183") != null) {
+ param = request.getHeader("BenchmarkTest00183");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+ String guess = "ABC";
+ char switchTarget = guess.charAt(1); // condition 'B', which is safe
+
+ // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D'
+ switch (switchTarget) {
+ case 'A':
+ bar = param;
+ break;
+ case 'B':
+ bar = "bob";
+ break;
+ case 'C':
+ case 'D':
+ bar = param;
+ break;
+ default:
+ bar = "bob's your uncle";
+ break;
+ }
+
+ try {
+ double stuff = java.security.SecureRandom.getInstance("SHA1PRNG").nextGaussian();
+ String rememberMeKey =
+ Double.toString(stuff).substring(2); // Trim off the 0. at the front.
+
+ String user = "SafeGayle";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue()
+ .equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00184")
+public class BenchmarkTest00184 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00184") != null) {
+ param = request.getHeader("BenchmarkTest00184");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00185")
+public class BenchmarkTest00185 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00185") != null) {
+ param = request.getHeader("BenchmarkTest00185");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "safe!";
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00186")
+public class BenchmarkTest00186 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00186") != null) {
+ param = request.getHeader("BenchmarkTest00186");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ // Chain a bunch of propagators in sequence
+ String a18509 = param; // assign
+ StringBuilder b18509 = new StringBuilder(a18509); // stick in stringbuilder
+ b18509.append(" SafeStuff"); // append some safe content
+ b18509.replace(
+ b18509.length() - "Chars".length(),
+ b18509.length(),
+ "Chars"); // replace some of the end content
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00187")
+public class BenchmarkTest00187 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00187") != null) {
+ param = request.getHeader("BenchmarkTest00187");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/weakrand-00/BenchmarkTest00188")
+public class BenchmarkTest00188 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00188") != null) {
+ param = request.getHeader("BenchmarkTest00188");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple if statement that assigns param to bar on true condition
+ int num = 196;
+ if ((500 / 42) + num > 200) bar = param;
+ else bar = "This should never happen";
+
+ try {
+ long l = java.security.SecureRandom.getInstance("SHA1PRNG").nextLong();
+ String rememberMeKey = Long.toString(l);
+
+ String user = "SafeLogan";
+ String fullClassName = this.getClass().getName();
+ String testCaseNumber =
+ fullClassName.substring(
+ fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
+ user += testCaseNumber;
+
+ String cookieName = "rememberMe" + testCaseNumber;
+
+ boolean foundUser = false;
+ javax.servlet.http.Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; !foundUser && i < cookies.length; i++) {
+ javax.servlet.http.Cookie cookie = cookies[i];
+ if (cookieName.equals(cookie.getName())) {
+ if (cookie.getValue()
+ .equals(request.getSession().getAttribute(cookieName))) {
+ foundUser = true;
+ }
+ }
+ }
+ }
+
+ if (foundUser) {
+ response.getWriter().println("Welcome back: " + user + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/trustbound-00/BenchmarkTest00189")
+public class BenchmarkTest00189 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00189") != null) {
+ param = request.getHeader("BenchmarkTest00189");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ // Chain a bunch of propagators in sequence
+ String a14330 = param; // assign
+ StringBuilder b14330 = new StringBuilder(a14330); // stick in stringbuilder
+ b14330.append(" SafeStuff"); // append some safe content
+ b14330.replace(
+ b14330.length() - "Chars".length(),
+ b14330.length(),
+ "Chars"); // replace some of the end content
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00190")
+public class BenchmarkTest00190 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00190") != null) {
+ param = request.getHeader("BenchmarkTest00190");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "alsosafe";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00191")
+public class BenchmarkTest00191 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00191") != null) {
+ param = request.getHeader("BenchmarkTest00191");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+ String guess = "ABC";
+ char switchTarget = guess.charAt(1); // condition 'B', which is safe
+
+ // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D'
+ switch (switchTarget) {
+ case 'A':
+ bar = param;
+ break;
+ case 'B':
+ bar = "bob";
+ break;
+ case 'C':
+ case 'D':
+ bar = param;
+ break;
+ default:
+ bar = "bob's your uncle";
+ break;
+ }
+
+ String sql = "{call " + bar + "}";
+
+ try {
+ java.sql.Connection connection =
+ org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection();
+ java.sql.CallableStatement statement =
+ connection.prepareCall(
+ sql,
+ java.sql.ResultSet.TYPE_FORWARD_ONLY,
+ java.sql.ResultSet.CONCUR_READ_ONLY);
+ java.sql.ResultSet rs = statement.executeQuery();
+ org.owasp.benchmark.helpers.DatabaseHelper.printResults(rs, sql, response);
+ } catch (java.sql.SQLException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ return;
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00192.java b/OWASP DATASET/BenchmarkTest00192.java
new file mode 100644
index 0000000000000000000000000000000000000000..605094f65b00d31a85e81e976c96648d7c7d62b0
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00192.java
@@ -0,0 +1,88 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00192")
+public class BenchmarkTest00192 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00192") != null) {
+ param = request.getHeader("BenchmarkTest00192");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+ String guess = "ABC";
+ char switchTarget = guess.charAt(2);
+
+ // Simple case statement that assigns param to bar on conditions 'A', 'C', or 'D'
+ switch (switchTarget) {
+ case 'A':
+ bar = param;
+ break;
+ case 'B':
+ bar = "bobs_your_uncle";
+ break;
+ case 'C':
+ case 'D':
+ bar = param;
+ break;
+ default:
+ bar = "bobs_your_uncle";
+ break;
+ }
+
+ String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'";
+
+ try {
+ java.sql.Connection connection =
+ org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection();
+ java.sql.PreparedStatement statement = connection.prepareStatement(sql);
+ statement.setString(1, "foo");
+ statement.execute();
+ org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response);
+ } catch (java.sql.SQLException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ return;
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00193.java b/OWASP DATASET/BenchmarkTest00193.java
new file mode 100644
index 0000000000000000000000000000000000000000..f8930ef5168af19f0fc75b7fd6ae10e74f411f0c
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00193.java
@@ -0,0 +1,75 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00193")
+public class BenchmarkTest00193 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00193") != null) {
+ param = request.getHeader("BenchmarkTest00193");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple if statement that assigns param to bar on true condition
+ int num = 196;
+ if ((500 / 42) + num > 200) bar = param;
+ else bar = "This should never happen";
+
+ String sql = "SELECT * from USERS where USERNAME=? and PASSWORD='" + bar + "'";
+
+ try {
+ java.sql.Connection connection =
+ org.owasp.benchmark.helpers.DatabaseHelper.getSqlConnection();
+ java.sql.PreparedStatement statement =
+ connection.prepareStatement(sql, new String[] {"Column1", "Column2"});
+ statement.setString(1, "foo");
+ statement.execute();
+ org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, response);
+ } catch (java.sql.SQLException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ return;
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00194.java b/OWASP DATASET/BenchmarkTest00194.java
new file mode 100644
index 0000000000000000000000000000000000000000..a80f08636b7b5d5a9344bcfdb15c082b23f9503b
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00194.java
@@ -0,0 +1,78 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00194")
+public class BenchmarkTest00194 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00194") != null) {
+ param = request.getHeader("BenchmarkTest00194");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "";
+ if (param != null) {
+ bar =
+ new String(
+ org.apache.commons.codec.binary.Base64.decodeBase64(
+ org.apache.commons.codec.binary.Base64.encodeBase64(
+ param.getBytes())));
+ }
+
+ try {
+ String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
+
+ org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.batchUpdate(sql);
+ response.getWriter()
+ .println(
+ "No results can be displayed for query: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)
+ + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00195")
+public class BenchmarkTest00195 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00195") != null) {
+ param = request.getHeader("BenchmarkTest00195");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple ? condition that assigns param to bar on false condition
+ int num = 106;
+
+ bar = (7 * 42) - num > 200 ? "This should never happen" : param;
+
+ try {
+ String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
+
+ org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql);
+ response.getWriter()
+ .println(
+ "No results can be displayed for query: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)
+ + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00196")
+public class BenchmarkTest00196 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00196") != null) {
+ param = request.getHeader("BenchmarkTest00196");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple if statement that assigns param to bar on true condition
+ int num = 196;
+ if ((500 / 42) + num > 200) bar = param;
+ else bar = "This should never happen";
+
+ try {
+ String sql = "SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
+
+ org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.execute(sql);
+ response.getWriter()
+ .println(
+ "No results can be displayed for query: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql)
+ + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00197")
+public class BenchmarkTest00197 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00197") != null) {
+ param = request.getHeader("BenchmarkTest00197");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "alsosafe";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00198")
+public class BenchmarkTest00198 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00198") != null) {
+ param = request.getHeader("BenchmarkTest00198");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ org.owasp.benchmark.helpers.ThingInterface thing =
+ org.owasp.benchmark.helpers.ThingFactory.createThing();
+ String bar = thing.doSomething(param);
+
+ String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
+ try {
+ // int results =
+ // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForInt(sql);
+ Integer results =
+ org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject(
+ sql, Integer.class);
+ response.getWriter().println("Your results are: " + results);
+ // System.out.println("Your results are: " + results);
+ } catch (org.springframework.dao.EmptyResultDataAccessException e) {
+ response.getWriter()
+ .println(
+ "No results returned for query: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql));
+ } catch (org.springframework.dao.DataAccessException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00199.java b/OWASP DATASET/BenchmarkTest00199.java
new file mode 100644
index 0000000000000000000000000000000000000000..b0239488b143dab0c883575cf35b19e0c4dd95fa
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00199.java
@@ -0,0 +1,78 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00199")
+public class BenchmarkTest00199 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00199") != null) {
+ param = request.getHeader("BenchmarkTest00199");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple if statement that assigns param to bar on true condition
+ int num = 196;
+ if ((500 / 42) + num > 200) bar = param;
+ else bar = "This should never happen";
+
+ String sql = "SELECT userid from USERS where USERNAME='foo' and PASSWORD='" + bar + "'";
+ try {
+ // int results =
+ // org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForInt(sql);
+ Integer results =
+ org.owasp.benchmark.helpers.DatabaseHelper.JDBCtemplate.queryForObject(
+ sql, Integer.class);
+ response.getWriter().println("Your results are: " + results);
+ // System.out.println("Your results are: " + results);
+ } catch (org.springframework.dao.EmptyResultDataAccessException e) {
+ response.getWriter()
+ .println(
+ "No results returned for query: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql));
+ } catch (org.springframework.dao.DataAccessException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00200.java b/OWASP DATASET/BenchmarkTest00200.java
new file mode 100644
index 0000000000000000000000000000000000000000..168078f440b6b5b2fa281b5c3b9f61a2b8473c33
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00200.java
@@ -0,0 +1,79 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00200")
+public class BenchmarkTest00200 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00200") != null) {
+ param = request.getHeader("BenchmarkTest00200");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "alsosafe";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00201")
+public class BenchmarkTest00201 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00201") != null) {
+ param = request.getHeader("BenchmarkTest00201");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ // Chain a bunch of propagators in sequence
+ String a60073 = param; // assign
+ StringBuilder b60073 = new StringBuilder(a60073); // stick in stringbuilder
+ b60073.append(" SafeStuff"); // append some safe content
+ b60073.replace(
+ b60073.length() - "Chars".length(),
+ b60073.length(),
+ "Chars"); // replace some of the end content
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00202")
+public class BenchmarkTest00202 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00202") != null) {
+ param = request.getHeader("BenchmarkTest00202");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ // Chain a bunch of propagators in sequence
+ String a15497 = param; // assign
+ StringBuilder b15497 = new StringBuilder(a15497); // stick in stringbuilder
+ b15497.append(" SafeStuff"); // append some safe content
+ b15497.replace(
+ b15497.length() - "Chars".length(),
+ b15497.length(),
+ "Chars"); // replace some of the end content
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00203")
+public class BenchmarkTest00203 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00203") != null) {
+ param = request.getHeader("BenchmarkTest00203");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar;
+
+ // Simple ? condition that assigns param to bar on false condition
+ int num = 106;
+
+ bar = (7 * 42) - num > 200 ? "This should never happen" : param;
+
+ String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')";
+
+ try {
+ java.sql.Statement statement =
+ org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement();
+ int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"});
+ org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response);
+ } catch (java.sql.SQLException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ return;
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00204.java b/OWASP DATASET/BenchmarkTest00204.java
new file mode 100644
index 0000000000000000000000000000000000000000..0c57cef4ad0332b5c7e0a1c1510e4e73d6c1b237
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00204.java
@@ -0,0 +1,69 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00204")
+public class BenchmarkTest00204 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00204") != null) {
+ param = request.getHeader("BenchmarkTest00204");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ org.owasp.benchmark.helpers.ThingInterface thing =
+ org.owasp.benchmark.helpers.ThingFactory.createThing();
+ String bar = thing.doSomething(param);
+
+ String sql = "INSERT INTO users (username, password) VALUES ('foo','" + bar + "')";
+
+ try {
+ java.sql.Statement statement =
+ org.owasp.benchmark.helpers.DatabaseHelper.getSqlStatement();
+ int count = statement.executeUpdate(sql, new String[] {"USERNAME", "PASSWORD"});
+ org.owasp.benchmark.helpers.DatabaseHelper.outputUpdateComplete(sql, response);
+ } catch (java.sql.SQLException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ return;
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00205.java b/OWASP DATASET/BenchmarkTest00205.java
new file mode 100644
index 0000000000000000000000000000000000000000..354f00c30497b2b0df38fd8f7f016e072372e05d
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00205.java
@@ -0,0 +1,77 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ * This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00205")
+public class BenchmarkTest00205 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00205") != null) {
+ param = request.getHeader("BenchmarkTest00205");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "alsosafe";
+ if (param != null) {
+ java.util.List This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/sqli-00/BenchmarkTest00206")
+public class BenchmarkTest00206 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00206") != null) {
+ param = request.getHeader("BenchmarkTest00206");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ // Chain a bunch of propagators in sequence
+ String a13396 = param; // assign
+ StringBuilder b13396 = new StringBuilder(a13396); // stick in stringbuilder
+ b13396.append(" SafeStuff"); // append some safe content
+ b13396.replace(
+ b13396.length() - "Chars".length(),
+ b13396.length(),
+ "Chars"); // replace some of the end content
+ java.util.HashMap This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/xpathi-00/BenchmarkTest00207")
+public class BenchmarkTest00207 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ if (request.getHeader("BenchmarkTest00207") != null) {
+ param = request.getHeader("BenchmarkTest00207");
+ }
+
+ // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
+ param = java.net.URLDecoder.decode(param, "UTF-8");
+
+ String bar = "";
+ if (param != null) {
+ bar =
+ new String(
+ org.apache.commons.codec.binary.Base64.decodeBase64(
+ org.apache.commons.codec.binary.Base64.encodeBase64(
+ param.getBytes())));
+ }
+
+ try {
+ java.io.FileInputStream file =
+ new java.io.FileInputStream(
+ org.owasp.benchmark.helpers.Utils.getFileFromClasspath(
+ "employees.xml", this.getClass().getClassLoader()));
+ javax.xml.parsers.DocumentBuilderFactory builderFactory =
+ javax.xml.parsers.DocumentBuilderFactory.newInstance();
+ // Prevent XXE
+ builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+ javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder();
+ org.w3c.dom.Document xmlDocument = builder.parse(file);
+ javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance();
+ javax.xml.xpath.XPath xp = xpf.newXPath();
+
+ String expression = "/Employees/Employee[@emplid='" + bar + "']";
+ String result = xp.evaluate(expression, xmlDocument);
+
+ response.getWriter().println("Your query results are: " + result + " This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00208")
+public class BenchmarkTest00208 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00209")
+public class BenchmarkTest00209 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00210")
+public class BenchmarkTest00210 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00211")
+public class BenchmarkTest00211 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00212")
+public class BenchmarkTest00212 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00213")
+public class BenchmarkTest00213 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. For
+ * details, please see https://owasp.org/www-project-benchmark/.
+ *
+ * The OWASP Benchmark 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, version 2.
+ *
+ * The OWASP Benchmark 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.
+ *
+ * @author Nick Sanidas
+ * @created 2015
+ */
+package org.owasp.benchmark.testcode;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(value = "/crypto-00/BenchmarkTest00214")
+public class BenchmarkTest00214 extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+
+ String param = "";
+ java.util.Enumeration
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println(
+ "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)");
+ throw new ServletException(e);
+ } catch (java.security.NoSuchProviderException e) {
+ System.out.println(
+ "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println(
+ "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00010.java b/OWASP DATASET/BenchmarkTest00010.java
new file mode 100644
index 0000000000000000000000000000000000000000..2a083966ec9bb4f97e61b6fd4957df646f7d6bd9
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00010.java
@@ -0,0 +1,116 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase");
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00011.java b/OWASP DATASET/BenchmarkTest00011.java
new file mode 100644
index 0000000000000000000000000000000000000000..cfda6fb0fa0f96d9e5586709122f15abfe0f8f94
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00011.java
@@ -0,0 +1,70 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
"
+ + "Record found with name "
+ + attr.get()
+ + "
"
+ + "Address: "
+ + attr2.get()
+ + "
");
+ // System.out.println("record found " + attr.get());
+ found = true;
+ }
+ }
+ if (!found) {
+ response.getWriter()
+ .println(
+ "LDAP query results: nothing found for query: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter));
+ }
+ } catch (javax.naming.NamingException e) {
+ throw new ServletException(e);
+ } finally {
+ try {
+ ads.closeDirContext();
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00013.java b/OWASP DATASET/BenchmarkTest00013.java
new file mode 100644
index 0000000000000000000000000000000000000000..0073b0e90d2f0871cbef7b879b6fe24089f725b1
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00013.java
@@ -0,0 +1,58 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00020.java b/OWASP DATASET/BenchmarkTest00020.java
new file mode 100644
index 0000000000000000000000000000000000000000..33266ef3e6a21f85fba7b57fa2ed2cce87b7a3bb
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00020.java
@@ -0,0 +1,151 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.NoSuchProviderException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.NoSuchPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.IllegalBlockSizeException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.BadPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println(
+ "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00021.java b/OWASP DATASET/BenchmarkTest00021.java
new file mode 100644
index 0000000000000000000000000000000000000000..0b469a363f74833345e5db3aa1fb0f910b9fe871
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00021.java
@@ -0,0 +1,97 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
"
+ + "Record found with name "
+ + attr.get()
+ + "
"
+ + "Address: "
+ + attr2.get()
+ + "
");
+ // System.out.println("record found " + attr.get());
+ found = true;
+ }
+ }
+ if (!found) {
+ response.getWriter()
+ .println(
+ "LDAP query results: nothing found for query: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter));
+ }
+ } catch (javax.naming.NamingException e) {
+ throw new ServletException(e);
+ } finally {
+ try {
+ ads.closeDirContext();
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00022.java b/OWASP DATASET/BenchmarkTest00022.java
new file mode 100644
index 0000000000000000000000000000000000000000..b9c8ae630e9bac8b664a2dd84ab1b0118ec38181
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00022.java
@@ -0,0 +1,96 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing hash - TestCase");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println(
+ "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00023.java b/OWASP DATASET/BenchmarkTest00023.java
new file mode 100644
index 0000000000000000000000000000000000000000..a26bb3eb4418ac3669e12e205ec9945b6d1ba021
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00023.java
@@ -0,0 +1,96 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00024.java b/OWASP DATASET/BenchmarkTest00024.java
new file mode 100644
index 0000000000000000000000000000000000000000..a43678bea54ad1fb2417c4b088d17615f203b72f
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00024.java
@@ -0,0 +1,68 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing hash - TestCase");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println(
+ "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00030.java b/OWASP DATASET/BenchmarkTest00030.java
new file mode 100644
index 0000000000000000000000000000000000000000..5077e0d9d7118f3bd354ed558a4fba2fbf1a6b0c
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00030.java
@@ -0,0 +1,55 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
"
+ + " because the Spring execute method doesn't return results.");
+
+ } catch (org.springframework.dao.DataAccessException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00033.java b/OWASP DATASET/BenchmarkTest00033.java
new file mode 100644
index 0000000000000000000000000000000000000000..bcfa5d1d4f3d8c82733adca517a520ce76207154
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00033.java
@@ -0,0 +1,80 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00036.java b/OWASP DATASET/BenchmarkTest00036.java
new file mode 100644
index 0000000000000000000000000000000000000000..2b6c4576230b373fb0d184d949412f856dafd5aa
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00036.java
@@ -0,0 +1,68 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
");
+ }
+ } catch (org.springframework.dao.EmptyResultDataAccessException e) {
+ response.getWriter()
+ .println(
+ "No results returned for query: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql));
+ } catch (org.springframework.dao.DataAccessException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00039.java b/OWASP DATASET/BenchmarkTest00039.java
new file mode 100644
index 0000000000000000000000000000000000000000..d4fce4685bd9cc44981befeaa0473c0fd4dc513f
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00039.java
@@ -0,0 +1,83 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing SecureRandom.nextInt() - TestCase");
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00043.java b/OWASP DATASET/BenchmarkTest00043.java
new file mode 100644
index 0000000000000000000000000000000000000000..e20d25a567a6a3ccdfd83999ce932e0c20b75dbe
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00043.java
@@ -0,0 +1,63 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
"
+ + "Record found with name "
+ + attr.get()
+ + "
"
+ + "Address: "
+ + attr2.get()
+ + "
");
+ // System.out.println("record found " + attr.get());
+ found = true;
+ }
+ }
+ if (!found) {
+ response.getWriter()
+ .println(
+ "LDAP query results: nothing found for query: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter));
+ }
+ } catch (javax.naming.NamingException e) {
+ throw new ServletException(e);
+ } finally {
+ try {
+ ads.closeDirContext();
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00045.java b/OWASP DATASET/BenchmarkTest00045.java
new file mode 100644
index 0000000000000000000000000000000000000000..f425d61a1e38d6eafdac907103cf5bd8b89d940e
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00045.java
@@ -0,0 +1,72 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing hash - TestCase");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println(
+ "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00047.java b/OWASP DATASET/BenchmarkTest00047.java
new file mode 100644
index 0000000000000000000000000000000000000000..59f12dc1788df96210819a3eb0b20ba3ee39e473
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00047.java
@@ -0,0 +1,75 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.NoSuchProviderException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.NoSuchPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.IllegalBlockSizeException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.BadPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println(
+ "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00051.java b/OWASP DATASET/BenchmarkTest00051.java
new file mode 100644
index 0000000000000000000000000000000000000000..b9ec7bb47c45ef4fc84b2e7bdd5e29eabae6ac69
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00051.java
@@ -0,0 +1,71 @@
+/**
+ * OWASP Benchmark v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.NoSuchPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.IllegalBlockSizeException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.BadPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println(
+ "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00054.java b/OWASP DATASET/BenchmarkTest00054.java
new file mode 100644
index 0000000000000000000000000000000000000000..f7686414626be33f222cd1965aa7074bf61bc13b
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00054.java
@@ -0,0 +1,168 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.NoSuchPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.IllegalBlockSizeException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.BadPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00055.java b/OWASP DATASET/BenchmarkTest00055.java
new file mode 100644
index 0000000000000000000000000000000000000000..23bd9f8d49c8216cee021ea44bd3fcec0d18a5c1
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00055.java
@@ -0,0 +1,171 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.NoSuchProviderException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.NoSuchPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.IllegalBlockSizeException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.BadPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println(
+ "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00056.java b/OWASP DATASET/BenchmarkTest00056.java
new file mode 100644
index 0000000000000000000000000000000000000000..29390d61909e51b1759fdbc6e67bcee02440f67d
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00056.java
@@ -0,0 +1,181 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.NoSuchProviderException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.NoSuchPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.IllegalBlockSizeException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.BadPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println(
+ "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00057.java b/OWASP DATASET/BenchmarkTest00057.java
new file mode 100644
index 0000000000000000000000000000000000000000..4ef862d5aea7e09b735da54ec7c99b611b201263
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00057.java
@@ -0,0 +1,142 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException
+ | java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00058.java b/OWASP DATASET/BenchmarkTest00058.java
new file mode 100644
index 0000000000000000000000000000000000000000..7d03df2bafb543c77a0b738f522f8c036514bd3b
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00058.java
@@ -0,0 +1,129 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00059.java b/OWASP DATASET/BenchmarkTest00059.java
new file mode 100644
index 0000000000000000000000000000000000000000..2a138ea63b14d662f8ae0d8b3bca0d548c80e710
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00059.java
@@ -0,0 +1,139 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00060.java b/OWASP DATASET/BenchmarkTest00060.java
new file mode 100644
index 0000000000000000000000000000000000000000..a64f933d3e74a454dbaad3cfabc389bcfa0aee25
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00060.java
@@ -0,0 +1,92 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00067.java b/OWASP DATASET/BenchmarkTest00067.java
new file mode 100644
index 0000000000000000000000000000000000000000..625cb93271629698cad0963f5bbcf513775be5c9
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00067.java
@@ -0,0 +1,137 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00068.java b/OWASP DATASET/BenchmarkTest00068.java
new file mode 100644
index 0000000000000000000000000000000000000000..a767d4fed3ed52376f115f8f46666d6685de1ae2
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00068.java
@@ -0,0 +1,121 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00069.java b/OWASP DATASET/BenchmarkTest00069.java
new file mode 100644
index 0000000000000000000000000000000000000000..508d372969bc7c2886a63e4dfe343ee6d9f292a4
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00069.java
@@ -0,0 +1,134 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println(
+ "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)");
+ throw new ServletException(e);
+ } catch (java.security.NoSuchProviderException e) {
+ System.out.println(
+ "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println(
+ "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00070.java b/OWASP DATASET/BenchmarkTest00070.java
new file mode 100644
index 0000000000000000000000000000000000000000..594071e2b8ee97034f17f444fdf6c4d1f8f8da90
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00070.java
@@ -0,0 +1,126 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println(
+ "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)");
+ throw new ServletException(e);
+ } catch (java.security.NoSuchProviderException e) {
+ System.out.println(
+ "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println(
+ "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00071.java b/OWASP DATASET/BenchmarkTest00071.java
new file mode 100644
index 0000000000000000000000000000000000000000..a2400b31c9f01d6a93f2694596f78b5145255bcb
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00071.java
@@ -0,0 +1,126 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println(
+ "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)");
+ throw new ServletException(e);
+ } catch (java.security.NoSuchProviderException e) {
+ System.out.println(
+ "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println(
+ "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00072.java b/OWASP DATASET/BenchmarkTest00072.java
new file mode 100644
index 0000000000000000000000000000000000000000..afa3284c5724b21f852d8e1852e4c98b237938eb
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00072.java
@@ -0,0 +1,124 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println(
+ "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)");
+ throw new ServletException(e);
+ } catch (java.security.NoSuchProviderException e) {
+ System.out.println(
+ "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println(
+ "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00073.java b/OWASP DATASET/BenchmarkTest00073.java
new file mode 100644
index 0000000000000000000000000000000000000000..6aa740440aa0c47984fe3a82efb5ee5d912814c1
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00073.java
@@ -0,0 +1,135 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing hash - TestCase");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println(
+ "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00074.java b/OWASP DATASET/BenchmarkTest00074.java
new file mode 100644
index 0000000000000000000000000000000000000000..b1cc4ddfc2bb4aa03c56a8526113afa0cebaef40
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00074.java
@@ -0,0 +1,125 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing hash - TestCase");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println(
+ "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00075.java b/OWASP DATASET/BenchmarkTest00075.java
new file mode 100644
index 0000000000000000000000000000000000000000..5722b0bc4c1c5fb4e21e1e647b0299823029d327
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00075.java
@@ -0,0 +1,125 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing hash - TestCase");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println(
+ "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00076.java b/OWASP DATASET/BenchmarkTest00076.java
new file mode 100644
index 0000000000000000000000000000000000000000..3b38ebb83c80abcb4c441c92e151e4179a1bf9e4
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00076.java
@@ -0,0 +1,139 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing hash - TestCase");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println(
+ "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00077.java b/OWASP DATASET/BenchmarkTest00077.java
new file mode 100644
index 0000000000000000000000000000000000000000..d929ba69349ccda063630b5fac03ea3143b9fe97
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00077.java
@@ -0,0 +1,109 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00079.java b/OWASP DATASET/BenchmarkTest00079.java
new file mode 100644
index 0000000000000000000000000000000000000000..0cc7c196d807ae7f1d699c7c410e1b9223cf9937
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00079.java
@@ -0,0 +1,121 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00080.java b/OWASP DATASET/BenchmarkTest00080.java
new file mode 100644
index 0000000000000000000000000000000000000000..b39fc2434f8515ba5cd98336b6683bcf7b6be2cf
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00080.java
@@ -0,0 +1,116 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00081.java b/OWASP DATASET/BenchmarkTest00081.java
new file mode 100644
index 0000000000000000000000000000000000000000..a0b486ee756b7a5dcfafa8b9630f33e6e35b11bd
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00081.java
@@ -0,0 +1,116 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter()
+ .println("Weak Randomness Test java.util.Random.nextGaussian() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00082.java b/OWASP DATASET/BenchmarkTest00082.java
new file mode 100644
index 0000000000000000000000000000000000000000..c0de01c39c2186f69a8bb8919d2afa9845df2943
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00082.java
@@ -0,0 +1,116 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00083.java b/OWASP DATASET/BenchmarkTest00083.java
new file mode 100644
index 0000000000000000000000000000000000000000..6f509bf5deedf3fc8af646d0a4de945591964ecc
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00083.java
@@ -0,0 +1,120 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter().println("Weak Randomness Test java.util.Random.nextInt(int) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00084.java b/OWASP DATASET/BenchmarkTest00084.java
new file mode 100644
index 0000000000000000000000000000000000000000..03c3eb0cb3e15083776cd54cf287cdda6ddb389e
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00084.java
@@ -0,0 +1,117 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00085.java b/OWASP DATASET/BenchmarkTest00085.java
new file mode 100644
index 0000000000000000000000000000000000000000..3cd977db9ea79ebc8e87b7dfb1a31c2c5147698d
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00085.java
@@ -0,0 +1,121 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00086.java b/OWASP DATASET/BenchmarkTest00086.java
new file mode 100644
index 0000000000000000000000000000000000000000..cd31ec9742351aacdb7b4101415abf2481f2f7da
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00086.java
@@ -0,0 +1,121 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00087.java b/OWASP DATASET/BenchmarkTest00087.java
new file mode 100644
index 0000000000000000000000000000000000000000..460086f96cb7a49e669f0be55c7dbac94ffdccd2
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00087.java
@@ -0,0 +1,103 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing SecureRandom.nextDouble() - TestCase");
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00095.java b/OWASP DATASET/BenchmarkTest00095.java
new file mode 100644
index 0000000000000000000000000000000000000000..d817be4a47601ab42c9dbbd91024b71b0da210dc
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00095.java
@@ -0,0 +1,127 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase");
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00096.java b/OWASP DATASET/BenchmarkTest00096.java
new file mode 100644
index 0000000000000000000000000000000000000000..53537aea13157035ce1c0cd6813b04f6949bb448
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00096.java
@@ -0,0 +1,126 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase");
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00097.java b/OWASP DATASET/BenchmarkTest00097.java
new file mode 100644
index 0000000000000000000000000000000000000000..10fe45f85c739e9305381210932414a704f179fa
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00097.java
@@ -0,0 +1,81 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
"
+ + " because the Spring batchUpdate method doesn't return results.");
+ } catch (org.springframework.dao.DataAccessException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00105.java b/OWASP DATASET/BenchmarkTest00105.java
new file mode 100644
index 0000000000000000000000000000000000000000..6d5d0f5b5f6bf5b17d986bdbba9ef04dfe31fad6
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00105.java
@@ -0,0 +1,87 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i);
+ response.getWriter().println(value.getTextContent() + "
");
+ }
+ } catch (javax.xml.xpath.XPathExpressionException
+ | javax.xml.parsers.ParserConfigurationException
+ | org.xml.sax.SAXException e) {
+ response.getWriter()
+ .println(
+ "Error parsing XPath input: '"
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar)
+ + "'");
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00117.java b/OWASP DATASET/BenchmarkTest00117.java
new file mode 100644
index 0000000000000000000000000000000000000000..9829ccc8a143bc7aeae963d225db10ff42b3db9b
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00117.java
@@ -0,0 +1,109 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ org.w3c.dom.Element value = (org.w3c.dom.Element) nodeList.item(i);
+ response.getWriter().println(value.getTextContent() + "
");
+ }
+ } catch (javax.xml.xpath.XPathExpressionException
+ | javax.xml.parsers.ParserConfigurationException
+ | org.xml.sax.SAXException e) {
+ response.getWriter()
+ .println(
+ "Error parsing XPath input: '"
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar)
+ + "'");
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00118.java b/OWASP DATASET/BenchmarkTest00118.java
new file mode 100644
index 0000000000000000000000000000000000000000..c768c2a1c85d86647503995eedb376e6a22840a1
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00118.java
@@ -0,0 +1,102 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (javax.xml.xpath.XPathExpressionException
+ | javax.xml.parsers.ParserConfigurationException
+ | org.xml.sax.SAXException e) {
+ response.getWriter()
+ .println(
+ "Error parsing XPath input: '"
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar)
+ + "'");
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00119.java b/OWASP DATASET/BenchmarkTest00119.java
new file mode 100644
index 0000000000000000000000000000000000000000..ad33562eebfc7712b1c2d68ed198ff4f4d527850
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00119.java
@@ -0,0 +1,173 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.NoSuchPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.IllegalBlockSizeException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.BadPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println(
+ "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00120.java b/OWASP DATASET/BenchmarkTest00120.java
new file mode 100644
index 0000000000000000000000000000000000000000..893bb42d2a5ee93364d44bacfc66d930d6457c7c
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00120.java
@@ -0,0 +1,157 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.NoSuchPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.IllegalBlockSizeException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.BadPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println(
+ "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00121.java b/OWASP DATASET/BenchmarkTest00121.java
new file mode 100644
index 0000000000000000000000000000000000000000..eeac03e8a92046642844eabe5ebc1461d09fd158
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00121.java
@@ -0,0 +1,164 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.NoSuchPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.IllegalBlockSizeException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.BadPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00122.java b/OWASP DATASET/BenchmarkTest00122.java
new file mode 100644
index 0000000000000000000000000000000000000000..9dc618f3d6bf6050d9f2b91d0bf109a9adc0c8a3
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00122.java
@@ -0,0 +1,154 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.NoSuchPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.IllegalBlockSizeException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.BadPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Crypto Test javax.crypto.Cipher.getInstance(java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00123.java b/OWASP DATASET/BenchmarkTest00123.java
new file mode 100644
index 0000000000000000000000000000000000000000..2869e95dd7c4f48807062794c3c30c61a2d0219e
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00123.java
@@ -0,0 +1,123 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException
+ | java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00124.java b/OWASP DATASET/BenchmarkTest00124.java
new file mode 100644
index 0000000000000000000000000000000000000000..d896eccdba374491e157a20b4b64baa625f2aa58
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00124.java
@@ -0,0 +1,128 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException
+ | java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00125.java b/OWASP DATASET/BenchmarkTest00125.java
new file mode 100644
index 0000000000000000000000000000000000000000..f7e36690aeee8d18b41ae79a0daace5d0582f3c7
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00125.java
@@ -0,0 +1,123 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException
+ | java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00126.java b/OWASP DATASET/BenchmarkTest00126.java
new file mode 100644
index 0000000000000000000000000000000000000000..90b106024c4aa30b70844c2039b0b3258d7d8dd6
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00126.java
@@ -0,0 +1,125 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00127.java b/OWASP DATASET/BenchmarkTest00127.java
new file mode 100644
index 0000000000000000000000000000000000000000..5192eaf3f00e463ad3ac7f1f8a463c3e0baca757
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00127.java
@@ -0,0 +1,134 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00128.java b/OWASP DATASET/BenchmarkTest00128.java
new file mode 100644
index 0000000000000000000000000000000000000000..0a8d0a3a0cc58f23fc5f6fd9a24cacb6c72767b6
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00128.java
@@ -0,0 +1,129 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00129.java b/OWASP DATASET/BenchmarkTest00129.java
new file mode 100644
index 0000000000000000000000000000000000000000..f3d4766958bdd757c8b1ad7d5c76d09bfc815244
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00129.java
@@ -0,0 +1,124 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00130.java b/OWASP DATASET/BenchmarkTest00130.java
new file mode 100644
index 0000000000000000000000000000000000000000..d9013fb9bd096933dc77807dab99f8fec4480fd8
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00130.java
@@ -0,0 +1,143 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00131.java b/OWASP DATASET/BenchmarkTest00131.java
new file mode 100644
index 0000000000000000000000000000000000000000..1ff9951b9dad1eb812472107985a5494770029bb
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00131.java
@@ -0,0 +1,88 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
"
+ + "Record found with name "
+ + attr.get()
+ + "
"
+ + "Address: "
+ + attr2.get()
+ + "
");
+ // System.out.println("record found " + attr.get());
+ found = true;
+ }
+ }
+ if (!found) {
+ response.getWriter()
+ .println(
+ "LDAP query results: nothing found for query: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter));
+ }
+ } catch (javax.naming.NamingException e) {
+ throw new ServletException(e);
+ } finally {
+ try {
+ ads.closeDirContext();
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00139.java b/OWASP DATASET/BenchmarkTest00139.java
new file mode 100644
index 0000000000000000000000000000000000000000..06f78927f91122ad79b205bb68e55c54de7149ba
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00139.java
@@ -0,0 +1,126 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
"
+ + "Record found with name "
+ + attr.get()
+ + "
"
+ + "Address: "
+ + attr2.get()
+ + "
");
+ // System.out.println("record found " + attr.get());
+ found = true;
+ }
+ }
+ if (!found) {
+ response.getWriter()
+ .println(
+ "LDAP query results: nothing found for query: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(filter));
+ }
+ } catch (javax.naming.NamingException e) {
+ throw new ServletException(e);
+ } finally {
+ try {
+ ads.closeDirContext();
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00140.java b/OWASP DATASET/BenchmarkTest00140.java
new file mode 100644
index 0000000000000000000000000000000000000000..31b9bdc4c7decdc8f2cc7ec27c74eac1ab7e7607
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00140.java
@@ -0,0 +1,112 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ response.getWriter().println("Weak Randomness Test java.lang.Math.random() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00141.java b/OWASP DATASET/BenchmarkTest00141.java
new file mode 100644
index 0000000000000000000000000000000000000000..b6bb3d4d83117561d86d9bbef1d9c78b4bc22b26
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00141.java
@@ -0,0 +1,120 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println(
+ "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)");
+ throw new ServletException(e);
+ } catch (java.security.NoSuchProviderException e) {
+ System.out.println(
+ "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider)");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println(
+ "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.security.Provider) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00142.java b/OWASP DATASET/BenchmarkTest00142.java
new file mode 100644
index 0000000000000000000000000000000000000000..61e88c935dbcab096a5bc46ae25ac25207ec4e9c
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00142.java
@@ -0,0 +1,107 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing hash - TestCase");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println(
+ "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00143.java b/OWASP DATASET/BenchmarkTest00143.java
new file mode 100644
index 0000000000000000000000000000000000000000..d20c36d262e339729e8c59d0b9a056db0c230fee
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00143.java
@@ -0,0 +1,125 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing hash - TestCase");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println(
+ "Hash Test java.security.MessageDigest.getInstance(java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00144.java b/OWASP DATASET/BenchmarkTest00144.java
new file mode 100644
index 0000000000000000000000000000000000000000..4638da678c6203b6b86c39ce35a1e12c651fc4aa
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00144.java
@@ -0,0 +1,67 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter().println("Weak Randomness Test java.util.Random.nextBytes() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00161.java b/OWASP DATASET/BenchmarkTest00161.java
new file mode 100644
index 0000000000000000000000000000000000000000..eb6b25098cb4309a851114ff7d367b87f5600ba7
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00161.java
@@ -0,0 +1,108 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setDomain(new java.net.URL(request.getRequestURL().toString()).getHost());
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter().println("Weak Randomness Test java.util.Random.nextDouble() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00162.java b/OWASP DATASET/BenchmarkTest00162.java
new file mode 100644
index 0000000000000000000000000000000000000000..8ee8b4d1b528385067839447510b624d336f0c8b
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00162.java
@@ -0,0 +1,102 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter()
+ .println("Weak Randomness Test java.util.Random.nextGaussian() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00163.java b/OWASP DATASET/BenchmarkTest00163.java
new file mode 100644
index 0000000000000000000000000000000000000000..8df34551ec23cc864b45016ee89b1578ecfac5e3
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00163.java
@@ -0,0 +1,103 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter()
+ .println("Weak Randomness Test java.util.Random.nextGaussian() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00164.java b/OWASP DATASET/BenchmarkTest00164.java
new file mode 100644
index 0000000000000000000000000000000000000000..79ff234e0c7a94d08c1f604acf12181386d9d760
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00164.java
@@ -0,0 +1,106 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00165.java b/OWASP DATASET/BenchmarkTest00165.java
new file mode 100644
index 0000000000000000000000000000000000000000..94a570566c4359b2af703ffad6930e8915557661
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00165.java
@@ -0,0 +1,104 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter().println("Weak Randomness Test java.util.Random.nextInt() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00166.java b/OWASP DATASET/BenchmarkTest00166.java
new file mode 100644
index 0000000000000000000000000000000000000000..45bc5f4e384a7637cb229fb64128c24760735060
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00166.java
@@ -0,0 +1,102 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00167.java b/OWASP DATASET/BenchmarkTest00167.java
new file mode 100644
index 0000000000000000000000000000000000000000..a9428f90a3b3a35c277d51b17b7369da6f2d25e6
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00167.java
@@ -0,0 +1,109 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00168.java b/OWASP DATASET/BenchmarkTest00168.java
new file mode 100644
index 0000000000000000000000000000000000000000..82d00266d6a09f701799d5d6893b01a2addc6d7e
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00168.java
@@ -0,0 +1,107 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+
+ response.getWriter().println("Weak Randomness Test java.util.Random.nextLong() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00169.java b/OWASP DATASET/BenchmarkTest00169.java
new file mode 100644
index 0000000000000000000000000000000000000000..4a05d35b12ba11572342b99b06fb84bd84ed524a
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00169.java
@@ -0,0 +1,92 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing SecureRandom.nextBytes() - TestCase");
+ throw new ServletException(e);
+ } finally {
+ response.getWriter()
+ .println(
+ "Randomness Test java.security.SecureRandom.nextBytes(byte[]) executed");
+ }
+ }
+
+ void getNextNumber(java.util.Random generator, byte[] barray) {
+ generator.nextBytes(barray);
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00179.java b/OWASP DATASET/BenchmarkTest00179.java
new file mode 100644
index 0000000000000000000000000000000000000000..32bfc396d695f8fd12320e97d0d6da93012a3db5
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00179.java
@@ -0,0 +1,110 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing SecureRandom.nextDouble() - TestCase");
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00180.java b/OWASP DATASET/BenchmarkTest00180.java
new file mode 100644
index 0000000000000000000000000000000000000000..5766f679d1687b572a47cc2e5fd89433caab4091
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00180.java
@@ -0,0 +1,120 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing SecureRandom.nextDouble() - TestCase");
+ throw new ServletException(e);
+ }
+
+ response.getWriter()
+ .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed");
+ }
+
+ double getNextNumber(java.util.Random generator) {
+ return generator.nextDouble();
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00181.java b/OWASP DATASET/BenchmarkTest00181.java
new file mode 100644
index 0000000000000000000000000000000000000000..1e8ab75c4bcc6067df5745ef658a86d741f6e1fe
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00181.java
@@ -0,0 +1,110 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing SecureRandom.nextDouble() - TestCase");
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00182.java b/OWASP DATASET/BenchmarkTest00182.java
new file mode 100644
index 0000000000000000000000000000000000000000..4106cc18b0d63f42c1ba30032630910c45ad83c7
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00182.java
@@ -0,0 +1,129 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase");
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00183.java b/OWASP DATASET/BenchmarkTest00183.java
new file mode 100644
index 0000000000000000000000000000000000000000..03ea2fa671240845982beeb2e80c5c166503a5ea
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00183.java
@@ -0,0 +1,127 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing SecureRandom.nextGaussian() - TestCase");
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Weak Randomness Test java.security.SecureRandom.nextGaussian() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00184.java b/OWASP DATASET/BenchmarkTest00184.java
new file mode 100644
index 0000000000000000000000000000000000000000..b4a000b8c6a000d78cf2f936b9959266336a40b5
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00184.java
@@ -0,0 +1,112 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase");
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00185.java b/OWASP DATASET/BenchmarkTest00185.java
new file mode 100644
index 0000000000000000000000000000000000000000..5857f480c1f8d30bdf7dda6464f85a50576f645b
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00185.java
@@ -0,0 +1,113 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase");
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00186.java b/OWASP DATASET/BenchmarkTest00186.java
new file mode 100644
index 0000000000000000000000000000000000000000..fd833585dc0badf35070972a13f91a99e54232c4
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00186.java
@@ -0,0 +1,128 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing SecureRandom.nextInt(int) - TestCase");
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Weak Randomness Test java.security.SecureRandom.nextInt(int) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00187.java b/OWASP DATASET/BenchmarkTest00187.java
new file mode 100644
index 0000000000000000000000000000000000000000..84603b9b741b37869b4b95ae0f4f727349fd69c7
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00187.java
@@ -0,0 +1,117 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing SecureRandom.nextInt() - TestCase");
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Weak Randomness Test java.security.SecureRandom.nextInt() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00188.java b/OWASP DATASET/BenchmarkTest00188.java
new file mode 100644
index 0000000000000000000000000000000000000000..022c204b3441c02a128bc546decb84c358b2cb9e
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00188.java
@@ -0,0 +1,112 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ } else {
+ javax.servlet.http.Cookie rememberMe =
+ new javax.servlet.http.Cookie(cookieName, rememberMeKey);
+ rememberMe.setSecure(true);
+ rememberMe.setHttpOnly(true);
+ rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet
+ // e.g., /benchmark/sql-01/BenchmarkTest01001
+ request.getSession().setAttribute(cookieName, rememberMeKey);
+ response.addCookie(rememberMe);
+ response.getWriter()
+ .println(
+ user
+ + " has been remembered with cookie: "
+ + rememberMe.getName()
+ + " whose value is: "
+ + rememberMe.getValue()
+ + "
");
+ }
+ } catch (java.security.NoSuchAlgorithmException e) {
+ System.out.println("Problem executing SecureRandom.nextLong() - TestCase");
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println("Weak Randomness Test java.security.SecureRandom.nextLong() executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00189.java b/OWASP DATASET/BenchmarkTest00189.java
new file mode 100644
index 0000000000000000000000000000000000000000..74f43ee145fa9da28cbfae5bcbdca102eb71b510
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00189.java
@@ -0,0 +1,83 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
"
+ + " because the Spring batchUpdate method doesn't return results.");
+ // System.out.println("no results for query: " + sql + " because the Spring batchUpdate
+ // method doesn't return results.");
+ } catch (org.springframework.dao.DataAccessException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00195.java b/OWASP DATASET/BenchmarkTest00195.java
new file mode 100644
index 0000000000000000000000000000000000000000..c986f56838d643050ff56df81e4e123673b314e4
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00195.java
@@ -0,0 +1,75 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
"
+ + " because the Spring execute method doesn't return results.");
+
+ } catch (org.springframework.dao.DataAccessException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00196.java b/OWASP DATASET/BenchmarkTest00196.java
new file mode 100644
index 0000000000000000000000000000000000000000..77a8276aedfb6624c4c2790bfe2816e7e058cff2
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00196.java
@@ -0,0 +1,75 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
"
+ + " because the Spring execute method doesn't return results.");
+
+ } catch (org.springframework.dao.DataAccessException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00197.java b/OWASP DATASET/BenchmarkTest00197.java
new file mode 100644
index 0000000000000000000000000000000000000000..f4275e752a30f6bb9ac0902a9103cfc3651a9afb
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00197.java
@@ -0,0 +1,99 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+ }
+ } catch (org.springframework.dao.EmptyResultDataAccessException e) {
+ response.getWriter()
+ .println(
+ "No results returned for query: "
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(sql));
+ } catch (org.springframework.dao.DataAccessException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00198.java b/OWASP DATASET/BenchmarkTest00198.java
new file mode 100644
index 0000000000000000000000000000000000000000..52d3c7cd3679ffbdc8d0bf623d09b688cbbe9d83
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00198.java
@@ -0,0 +1,75 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
"
+ + " because the Spring batchUpdate method doesn't return results.");
+ } catch (org.springframework.dao.DataAccessException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00201.java b/OWASP DATASET/BenchmarkTest00201.java
new file mode 100644
index 0000000000000000000000000000000000000000..b07ee826e9389db421c2b09583fd1f76cc663124
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00201.java
@@ -0,0 +1,90 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
"
+ + " because the Spring batchUpdate method doesn't return results.");
+ } catch (org.springframework.dao.DataAccessException e) {
+ if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
+ response.getWriter().println("Error processing request.");
+ } else throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00202.java b/OWASP DATASET/BenchmarkTest00202.java
new file mode 100644
index 0000000000000000000000000000000000000000..c0f68de0fe14b64f78441afae676bef2d8698312
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00202.java
@@ -0,0 +1,88 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (javax.xml.xpath.XPathExpressionException
+ | javax.xml.parsers.ParserConfigurationException
+ | org.xml.sax.SAXException e) {
+ response.getWriter()
+ .println(
+ "Error parsing XPath input: '"
+ + org.owasp.esapi.ESAPI.encoder().encodeForHTML(bar)
+ + "'");
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00208.java b/OWASP DATASET/BenchmarkTest00208.java
new file mode 100644
index 0000000000000000000000000000000000000000..e2a7460927aabe0c3d01736777a74f0d0bce9f73
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00208.java
@@ -0,0 +1,172 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.NoSuchProviderException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.NoSuchPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.IllegalBlockSizeException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.BadPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println(
+ "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00209.java b/OWASP DATASET/BenchmarkTest00209.java
new file mode 100644
index 0000000000000000000000000000000000000000..f0f5508c7f4a7fac99e8e2eb7dd94c31eab4cd91
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00209.java
@@ -0,0 +1,124 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (javax.crypto.IllegalBlockSizeException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ } catch (javax.crypto.BadPaddingException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ response.getWriter()
+ .println(
+ "Crypto Test javax.crypto.Cipher.getInstance(java.lang.String,java.lang.String) executed");
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00210.java b/OWASP DATASET/BenchmarkTest00210.java
new file mode 100644
index 0000000000000000000000000000000000000000..27939e7269f1683ee9e474802c426cea6a189234
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00210.java
@@ -0,0 +1,136 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException
+ | java.security.InvalidAlgorithmParameterException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00211.java b/OWASP DATASET/BenchmarkTest00211.java
new file mode 100644
index 0000000000000000000000000000000000000000..054a9c07ef26bdf23e51e528d09fbd2b2143738f
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00211.java
@@ -0,0 +1,135 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00212.java b/OWASP DATASET/BenchmarkTest00212.java
new file mode 100644
index 0000000000000000000000000000000000000000..2a84fac295517f5e5e83f38b6e6c2fdb0a673523
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00212.java
@@ -0,0 +1,130 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String,java.security.Provider) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00213.java b/OWASP DATASET/BenchmarkTest00213.java
new file mode 100644
index 0000000000000000000000000000000000000000..ffe3c9f91cdb9a29b5aea1b92a2f5e8f25bf8dab
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00213.java
@@ -0,0 +1,144 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *
");
+
+ } catch (java.security.NoSuchAlgorithmException
+ | javax.crypto.NoSuchPaddingException
+ | javax.crypto.IllegalBlockSizeException
+ | javax.crypto.BadPaddingException
+ | java.security.InvalidKeyException e) {
+ response.getWriter()
+ .println(
+ "Problem executing crypto - javax.crypto.Cipher.getInstance(java.lang.String) Test Case");
+ e.printStackTrace(response.getWriter());
+ throw new ServletException(e);
+ }
+ }
+}
diff --git a/OWASP DATASET/BenchmarkTest00214.java b/OWASP DATASET/BenchmarkTest00214.java
new file mode 100644
index 0000000000000000000000000000000000000000..9cd8e1aeef25d6b9d3a55665f0f72fa4bc8c94b4
--- /dev/null
+++ b/OWASP DATASET/BenchmarkTest00214.java
@@ -0,0 +1,134 @@
+/**
+ * OWASP Benchmark Project v1.2
+ *
+ *