diff --git a/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02741.java b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02741.java new file mode 100644 index 0000000000..30885f58a3 --- /dev/null +++ b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02741.java @@ -0,0 +1,54 @@ +/** + * 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.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@WebServlet(value = "/xss-00/BenchmarkTest02741") +public class BenchmarkTest02741 extends SanitizingHttpServlet { + + private static final long serialVersionUID = 1L; + + @Override + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + response.setHeader("X-XSS-Protection", "0"); + + String param = request.getParameter("email"); + if (param == null) param = ""; + String sanitizeParam = sanitizeAttribute(param); + + String htmlResponse = ""; + htmlResponse += + "

\n" + + " " + + "
"; + htmlResponse += ""; + + response.getWriter().println(htmlResponse); + } +} diff --git a/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02741.xml b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02741.xml new file mode 100644 index 0000000000..8dae3f1b37 --- /dev/null +++ b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02741.xml @@ -0,0 +1,7 @@ + + 1.2 + xss + 02741 + false + 79 + diff --git a/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02742.java b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02742.java new file mode 100644 index 0000000000..1b0dc83561 --- /dev/null +++ b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02742.java @@ -0,0 +1,53 @@ +/** + * 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.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@WebServlet(value = "/xss-00/BenchmarkTest02742") +public class BenchmarkTest02742 extends SanitizingHttpServlet { + + private static final long serialVersionUID = 1L; + + @Override + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + response.setHeader("X-XSS-Protection", "0"); + + String param = request.getParameter("email"); + if (param == null) param = ""; + String sanitizeParam = sanitizeTag(param); + + String htmlResponse = ""; + htmlResponse += + "

\n" + + " " + + "
"; + htmlResponse += ""; + + response.getWriter().println(htmlResponse); + } +} diff --git a/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02742.xml b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02742.xml new file mode 100644 index 0000000000..7b26c50b83 --- /dev/null +++ b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02742.xml @@ -0,0 +1,7 @@ + + 1.2 + xss + 02742 + true + 79 + diff --git a/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02743.java b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02743.java new file mode 100644 index 0000000000..f3b452bf0c --- /dev/null +++ b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02743.java @@ -0,0 +1,40 @@ +package org.owasp.benchmark.testcode; + +import java.io.IOException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@WebServlet(value = "/xss-00/BenchmarkTest02743") +public class BenchmarkTest02743 extends SanitizingHttpServlet { + private static final long serialVersionUID = 1L; + + @Override + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + response.setHeader("X-XSS-Protection", "0"); + + String param = request.getParameter("email"); + if (param == null) param = ""; + Pattern p = + Pattern.compile( + "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", Pattern.CASE_INSENSITIVE); + Matcher m = p.matcher(param); + boolean b = m.find(); + String sanitizeParam = newSanitizedValue(param); + + String htmlRespone = ""; + response.getWriter().println(htmlRespone); + } +} diff --git a/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02743.xml b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02743.xml new file mode 100644 index 0000000000..ab16fdfbc7 --- /dev/null +++ b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02743.xml @@ -0,0 +1,7 @@ + + 1.2 + xss + 02743 + true + 79 + diff --git a/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02744.java b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02744.java new file mode 100644 index 0000000000..b295b2dcd8 --- /dev/null +++ b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02744.java @@ -0,0 +1,38 @@ +package org.owasp.benchmark.testcode; + +import java.io.IOException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@WebServlet(value = "/xss-00/BenchmarkTest02744") +public class BenchmarkTest02744 extends SanitizingHttpServlet { + private static final long serialVersionUID = 1L; + + @Override + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + response.setHeader("X-XSS-Protection", "0"); + String param = request.getParameter("email"); + if (param == null) param = ""; + Pattern p = + Pattern.compile( + "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", Pattern.CASE_INSENSITIVE); + Matcher m = p.matcher(param); + boolean b = m.find(); + String sanitizeParam = newSanitizedValue(param); + + String htmlRespone = "

"; + if (param != null && param.trim().length() != 0 && b) { + htmlRespone += "Our reply will be sent to your email: " + sanitizeParam; + } else { + htmlRespone += "the provided email is not correct: " + sanitizeParam; + } + htmlRespone += "

"; + response.getWriter().println(htmlRespone); + } +} diff --git a/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02744.xml b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02744.xml new file mode 100644 index 0000000000..fc113cc247 --- /dev/null +++ b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02744.xml @@ -0,0 +1,7 @@ + + 1.2 + xss + 02744 + false + 79 + diff --git a/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02745.java b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02745.java new file mode 100644 index 0000000000..23cb6aa285 --- /dev/null +++ b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02745.java @@ -0,0 +1,47 @@ +/** + * 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.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@WebServlet(value = "/xss-00/BenchmarkTest02745") +public class BenchmarkTest02745 extends SanitizingHttpServlet { + + private static final long serialVersionUID = 1L; + + @Override + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + response.setHeader("X-XSS-Protection", "0"); + + String param = request.getParameter("email"); + if (param == null) param = ""; + String sanitizeParam = sanitizeAttribute(param); + + String htmlResponse = ""; + htmlResponse += "" + sanitizeParam + ""; + htmlResponse += ""; + + response.getWriter().println(htmlResponse); + } +} diff --git a/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02745.xml b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02745.xml new file mode 100644 index 0000000000..30e6c34ad1 --- /dev/null +++ b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02745.xml @@ -0,0 +1,7 @@ + + 1.2 + xss + 02745 + true + 79 + \ No newline at end of file diff --git a/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02746.java b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02746.java new file mode 100644 index 0000000000..c271cfc6aa --- /dev/null +++ b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02746.java @@ -0,0 +1,47 @@ +/** + * 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.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@WebServlet(value = "/xss-00/BenchmarkTest02746") +public class BenchmarkTest02746 extends SanitizingHttpServlet { + + private static final long serialVersionUID = 1L; + + @Override + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + response.setHeader("X-XSS-Protection", "0"); + + String param = request.getParameter("email"); + if (param == null) param = ""; + String sanitizeParam = sanitizeTag(param); + + String htmlResponse = ""; + htmlResponse += "" + sanitizeParam + ""; + htmlResponse += ""; + + response.getWriter().println(htmlResponse); + } +} diff --git a/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02746.xml b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02746.xml new file mode 100644 index 0000000000..56daff28eb --- /dev/null +++ b/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02746.xml @@ -0,0 +1,7 @@ + + 1.2 + xss + 02746 + false + 79 + \ No newline at end of file diff --git a/src/main/java/org/owasp/benchmark/testcode/Intermediate.java b/src/main/java/org/owasp/benchmark/testcode/Intermediate.java new file mode 100644 index 0000000000..cffa7e7d5b --- /dev/null +++ b/src/main/java/org/owasp/benchmark/testcode/Intermediate.java @@ -0,0 +1,56 @@ +/** + * 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.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class Intermediate extends HttpServlet { + + @Override + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + doPost(request, response); + } + + protected String sanitizeAttribute(String parameter) { + String parameter1 = parameter; + parameter1 = parameter1.replaceAll("'", "'"); + parameter1 = parameter1.replaceAll("\"", """); + parameter1 = parameter1.replaceAll("&", "&"); + return parameter1; + } + + protected String sanitizeTag(String parameter) { + String parameter1 = parameter; + parameter1 = parameter1.replaceAll("&", "&"); + parameter1 = parameter1.replaceAll("<", "\\u003C"); + parameter1 = parameter1.replaceAll(">", "\\u003E"); + return parameter1; + } + + protected String newSanitizedValue(String parameter) { + parameter = parameter.replaceAll("&", "&"); + parameter = parameter.replaceAll("<", "<"); + parameter = parameter.replaceAll(">", ">"); + return parameter; + } +} diff --git a/src/main/java/org/owasp/benchmark/testcode/SanitizingHttpServlet.java b/src/main/java/org/owasp/benchmark/testcode/SanitizingHttpServlet.java new file mode 100644 index 0000000000..ac27352d4c --- /dev/null +++ b/src/main/java/org/owasp/benchmark/testcode/SanitizingHttpServlet.java @@ -0,0 +1,56 @@ +/** + * 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.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class SanitizingHttpServlet extends HttpServlet { + + @Override + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + doPost(request, response); + } + + protected String sanitizeAttribute(String parameter) { + String parameter1 = parameter; + parameter1 = parameter1.replaceAll("'", "'"); + parameter1 = parameter1.replaceAll("\"", """); + parameter1 = parameter1.replaceAll("&", "&"); + return parameter1; + } + + protected String sanitizeTag(String parameter) { + String parameter1 = parameter; + parameter1 = parameter1.replaceAll("&", "&"); + parameter1 = parameter1.replaceAll("<", "\\u003C"); + parameter1 = parameter1.replaceAll(">", "\\u003E"); + return parameter1; + } + + protected String newSanitizedValue(String parameter) { + parameter = parameter.replaceAll("&", "&"); + parameter = parameter.replaceAll("<", "<"); + parameter = parameter.replaceAll(">", ">"); + return parameter; + } +} diff --git a/src/main/webapp/xss-00/BenchmarkTest02741.html b/src/main/webapp/xss-00/BenchmarkTest02741.html new file mode 100644 index 0000000000..32a11425d1 --- /dev/null +++ b/src/main/webapp/xss-00/BenchmarkTest02741.html @@ -0,0 +1,39 @@ + + + + + + +BenchmarkTest02741 + + +

+
+ +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
 
+
+ +
+
+
+ +
+
+ + + diff --git a/src/main/webapp/xss-00/BenchmarkTest02742.html b/src/main/webapp/xss-00/BenchmarkTest02742.html new file mode 100644 index 0000000000..2d637db545 --- /dev/null +++ b/src/main/webapp/xss-00/BenchmarkTest02742.html @@ -0,0 +1,39 @@ + + + + + + +BenchmarkTest02742 + + +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
 
+
+ +
+
+
+ +
+
+ + + diff --git a/src/main/webapp/xss-00/BenchmarkTest02743.html b/src/main/webapp/xss-00/BenchmarkTest02743.html new file mode 100644 index 0000000000..0dcccbe0d2 --- /dev/null +++ b/src/main/webapp/xss-00/BenchmarkTest02743.html @@ -0,0 +1,66 @@ + + + + + + +BenchmarkTest02743 + + +
+
+

Feedback

+ +

+ Our Frequently Asked Questions area will help you with many of your inquiries.
If you can't find your question, return to this page and use the e-mail form below. +

+ +

+ IMPORTANT! This feedback facility is not secure. Please do not send any
account information in a message sent from here. +

+ + +
+ +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+ + + + diff --git a/src/main/webapp/xss-00/BenchmarkTest02744.html b/src/main/webapp/xss-00/BenchmarkTest02744.html new file mode 100644 index 0000000000..83f316f6ec --- /dev/null +++ b/src/main/webapp/xss-00/BenchmarkTest02744.html @@ -0,0 +1,64 @@ + + + + + + +BenchmarkTest02744 + + +
+
+

Feedback

+ +

+ Our Frequently Asked Questions area will help you with many of your inquiries.
If you can't find your question, return to this page and use the e-mail form below. +

+ +

+ IMPORTANT! This feedback facility is not secure. Please do not send any
account information in a message sent from here. +

+ + +
+ +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+ + diff --git a/src/main/webapp/xss-00/BenchmarkTest02745.html b/src/main/webapp/xss-00/BenchmarkTest02745.html new file mode 100644 index 0000000000..5c43606da0 --- /dev/null +++ b/src/main/webapp/xss-00/BenchmarkTest02745.html @@ -0,0 +1,39 @@ + + + + + + +BenchmarkTest02745 + + +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
 
+
+ +
+
+
+ +
+
+ + + diff --git a/src/main/webapp/xss-00/BenchmarkTest02746.html b/src/main/webapp/xss-00/BenchmarkTest02746.html new file mode 100644 index 0000000000..b3950791b0 --- /dev/null +++ b/src/main/webapp/xss-00/BenchmarkTest02746.html @@ -0,0 +1,39 @@ + + + + + + +BenchmarkTest02746 + + +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
 
+
+ +
+
+
+ +
+
+ + + diff --git a/src/main/webapp/xss-Index.html b/src/main/webapp/xss-Index.html index 08dd9edb48..62f1a79595 100644 --- a/src/main/webapp/xss-Index.html +++ b/src/main/webapp/xss-Index.html @@ -480,6 +480,20 @@

OWASP Benchmark XSS (Cross-Site Scripting) Test Case Index

  • BenchmarkTest02695
  • BenchmarkTest02696
  • BenchmarkTest02712
  • +
  • BenchmarkTest02741
  • + +
  • BenchmarkTest02742
  • + +
  • BenchmarkTest02743
  • + +
  • BenchmarkTest02744
  • + + +
  • BenchmarkTest02745
  • + +
  • BenchmarkTest02746
  • + +