• Application_BeginRequest事件过滤恶意提交


    Global.asax

     1 protected void Application_BeginRequest(object sender, EventArgs e)
     2     {
     3         //遍历Post参数,隐藏域除外 
     4         foreach (string i in this.Request.Form)
     5         {
     6             if (i == "__VIEWSTATE") continue;
     7             this.goErr(this.Request.Form[i].ToString());
     8         }
     9         //遍历Get参数。 
    10         foreach (string i in this.Request.QueryString)
    11         {
    12             this.goErr(this.Request.QueryString[i].ToString());
    13         }
    14     }
    15     private void goErr(string tm)
    16     {
    17         if (SqlFilter2(tm))
    18         {
    19             Response.Redirect("p404.html");
    20             Response.End();
    21         }
    22     }
    23     public static bool SqlFilter2(string InText)
    24     {
    25         string word = "and|exec|insert|select|delete|update|chr|mid|master|or|truncate|char|declare|join";
    26         if (InText == null)
    27             return false;
    28         foreach (string i in word.Split('|'))
    29         {
    30             if ((InText.ToLower().IndexOf(i + " ") > -1) || (InText.ToLower().IndexOf(" " + i) > -1))
    31             {
    32                 return true;
    33             }
    34         }
    35         return false;
    36     }
  • 相关阅读:
    Redis学习
    extractor
    Linux fork exec等
    Linux kill 命令
    GCC参数使用
    Shell 参数(2) --解析命令行参数工具:getopts/getopt
    Shell 参数(1)
    shell 中并发执行
    Linux 下新增用户的流程
    Linux 安全rm
  • 原文地址:https://www.cnblogs.com/LYunF/p/2665307.html
Copyright © 2020-2023  润新知