zoukankan      html  css  js  c++  java
  • java防止sql注入

    public final static String filterSQLInjection(String s) {
        if (s == null || "".equals(s)) {
            return "";
        }
        try {
            s = s.trim().replaceAll("</?[s,S][c,C][r,R][i,I][p,P][t,T]>?", "");//script
            s = s.trim().replaceAll("[a,A][l,L][e,E][r,R][t,T]\(", "").replace(""", "");// alert
            s = s.trim().replace("\.swf", "").replaceAll("\.htc", "");
            s = s.trim().replace("\.php\b", "").replaceAll("\.asp\b", "");
            s = s.trim().replace("document\.", "").replaceAll("[e,E][v,V][a,A][l,L]\(", "");
            s = s.trim().replaceAll("'", "").replaceAll(">", "");
            s = s.trim().replaceAll("<", "").replaceAll("=", "");
            s = s.trim().replaceAll(" [o,O][r,R]", "");
            s = s.trim().replaceAll("etc/", "").replaceAll("cat ", "");
            s = s.trim().replaceAll("/passwd ", "");
            s = s.trim().replaceAll("sleep\(", "").replaceAll("limit ", "").replaceAll("LIMIT ", "");
            s = s.trim().replaceAll("[d,D][e,E][l,L][e,E][t,T][e,E] ", "");// delete
            s = s.trim().replaceAll("[s,S][e,E][l,L][e,E][c,C][t,T] ", "");// select;
            s = s.trim().replaceAll("[u,U][p,P][d,D][a,A][t,T][e,E] ", "");// update
            s = s.trim().replaceAll("[d,D][e,E][l,L][a,A][y,Y] ", "").replaceAll("waitfor ", "");
            s = s.trim().replaceAll("print\(", "").replaceAll("md5\(", "");
            s = s.trim().replaceAll("cookie\(", "").replaceAll("send\(", "");
            s = s.trim().replaceAll("response\.", "").replaceAll("write\(", "")
                    .replaceAll("&", "");
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
        return s;
    }
  • 相关阅读:
    iptables 常用命令解析
    iptables 常用处理动作
    centos7 中iptables、firewalld 和 netfilter 的关系
    iptables 的几个状态
    centos7 中没有service iptables save指令来保存防火墙规则
    iptables 数据走向流程
    数据库PDO简介
    php连接mySql,加密函数
    php数组,常量,遍历等
    php的会话控制
  • 原文地址:https://www.cnblogs.com/lr393993507/p/5542791.html
Copyright © 2011-2022 走看看