zoukankan      html  css  js  c++  java
  • 防SQL注入攻击

    尽可能全的过滤SQL敏感的语句,
    先把数据库里面注入的代码替换掉,
    再在Global文件里里加入
    protected void Application_BeginRequest(Object sender, EventArgs e)
    {
    //SQL防注入
    string Sql_1 = "exec|insert+|select+|delete+|update+|count|chr|mid|master+|truncate|char|declare|drop+|drop+table|creat+|creat+table";
    string Sql_2 = "exec+|insert|insert+|delete+|update+|count(|count+|chr+|+mid(|+mid+|+master+|truncate+|char+|+char(|declare+|drop+|creat+|drop+table|creat+table";
    string[] sql_c = Sql_1.Split('|');
    string[] sql_c1 = Sql_2.Split('|');

    if (Request.QueryString != null)
    {
    foreach (string sl in sql_c)
    {
    if (Request.QueryString.ToString().ToLower().IndexOf(sl.Trim()) >= 0)
    {
    Response.Write("警告!你的IP已经被记录!不要使用敏感字符!");//
    Response.Write(sl);
    Response.Write(Request.QueryString.ToString());
    Response.End();
    break;
    }
    }
    }

    if (Request.Form.Count > 0)
    {
    string s1 = Request.ServerVariables["SERVER_NAME"].Trim();//服务器名称
    if (Request.ServerVariables["HTTP_REFERER"] != null)
    {
    string s2 = Request.ServerVariables["HTTP_REFERER"].Trim();//http接收的名称
    string s3 = "";
    if (s1.Length > (s2.Length - 7))
    {
    s3 = s2.Substring(7);
    }
    else
    {
    s3 = s2.Substring(7, s1.Length);
    }
    if (s3 != s1)
    {
    Response.Write("警告!你的IP已经被记录!不要使用敏感字符!");//
    Response.End();
    }
    }
    }
    }

  • 相关阅读:
    vsftpd的详细配置讲解
    ActiveMQ安装与配置
    Apache安装完之后再安装其他模块
    搭建 LAMP apache2.4 + php5.5 + mysql5.5/6 配置文件没有作用的问题
    LAMP apache2.4 + php5.5 + mysql5.5/6
    进制之间的转换
    Mac 常用属性
    关于颜色值透明度的设置
    关于TextView 的属性
    Android 关于软键盘
  • 原文地址:https://www.cnblogs.com/zhangq723/p/2228426.html
Copyright © 2011-2022 走看看