jsp参数过滤防注入的解决方法
2012-05-29 00:02
337 查看
首先注入的类型分为参数数字型注入,参数字浮型注入,搜索框注入三种。
防注入的方法
1)参数过滤。
2)sql语句添加参数用占位符。
防注入的方法
1)参数过滤。
2)sql语句添加参数用占位符。
public static boolean sql_inj(String str) { String inj_str = "'|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare|;|or|-|+|,"; String inj_stra[] = split(inj_str,"|"); for (int i=0 ; i < inj_stra.length ; i++ ) { if (str.indexOf(inj_stra)>=0) { return true; } } return false; } jsp中调用该函数检查是否包函非法字符 <% if(request.getParameter("userID") != null) userID = request.getParameter("userID").trim(); if (StringUtil.sql_inj(userID) || StringUtil.sql_inj(pwd)){ %> <Script Language=javascript>alert('参数中包含非法字符!');history.back(-1);</Script>" ; <% }else{ …… }%>
相关文章推荐
- javascript通过url向jsp页面传递中文参数乱码解决方法
- Jsp中通过get方法传递参数为中文时出现乱码如何解决?
- JSP中文及传中文参数乱码解决方法小结
- JSP传递参数中文乱码问题的一种解决方法
- Flex-Jsp 中Flex和Jsp传递中文参数问题的解决方法!(Tomcat服务器)
- jsp获得get方式请求中文参数解决方法
- 在jsp之间传递中文参数出现乱码解决方法
- JSP传递中文参数乱码问题的解决方法 !
- JSP页面之间传递中文参数的解决方法
- JSP、AJax中文乱码问题解决,escape(), encodeURI(), encodeURIComponent(),js对参数连续两次调用 encodeURI(String) 方法
- jsp:forward jsp:include传中文参数乱码问题的解决方法
- 关于上个Flex-Jsp-DB例子中Flex和Jsp传递中文参数问题的解决方法!(Tomcat服务器)
- JSP、AJax中文乱码问题解决,escape(), encodeURI(), encodeURIComponent(),js对参数连续两次调用 encodeURI(String) 方法
- javascript通过url向jsp页面传递中文参数乱码解决方法
- javascript通过url向jsp页面传递中文参数乱码解决方法
- JSP页面中超链接传递中文参数出现乱码问题解决方法
- javascript通过url向jsp页面传递中文参数乱码解决方法
- jsp之间传参数接受中文有乱码问题解决方法
- 过滤 URL 参数 空值,删除 FORM GET URL 空值解决函数方法
- jsp之间传参数接受中文有乱码问题解决方法