/**
* 验证有无敏感字符
* @author heshuang
* @date 20191224
*/
public boolean checkParams(String param) {
String reg = "(?:')|(?:--)|(/\\*(?:.|[\\n\\r])*?\\*/)|"
+ "(\\b(select|update|and|or|delete|insert|trancate|char|into|substr|ascii|declare|exec|count|master|into|drop|execute)\\b)";
Pattern sqlPattern = Pattern.compile(reg, Pattern.CASE_INSENSITIVE);
//String cFlag = "Y";
if (sqlPattern.matcher(param).find()) {
//cFlag = "N";
return false;
}
return true;
}
过滤敏感字符
SQL注入防护检查
最新推荐文章于 2021-10-05 11:02:51 发布
本文介绍了一个用于检测SQL注入攻击的方法,通过正则表达式匹配潜在的恶意字符串,确保应用程序的安全。该方法能够识别并阻止常见的SQL关键字和特殊字符,防止非法操作。
247

被折叠的 条评论
为什么被折叠?



