SQLSERVER扩展存储过程XP_CMDSHELL的简单应用
来源:互联网 发布:日k线叠加周k线源码 编辑:程序博客网 时间:2024/04/27 22:27
XP_CMDSHELL存储过程是执行本机的CMD命令,要求系统登陆有SA权限,也就是说如果获得SQLSERVER的SA命令,那就可以在目标机为所欲为了,知名软件“流光”使用的应该也是这个存储过程来实现在目标机上的操作。
下面是我写的一个简单的应用页面(ASP),代码如下。
CMD.ASP
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>SQLSERVER_XP_CMDSHELL实例_魔术师·刘</title>
<style type="text/css">
<!--
body{
font-size:13px;
line-height:20px;
width:760;
SCROLLBAR-FACE-COLOR: #2896e1;
SCROLLBAR-SHADOW-COLOR: #6cb4d8;
SCROLLBAR-ARROW-COLOR: #f0f0f0;
SCROLLBAR-DARKSHADOW-COLOR: #2896e1;
SCROLLBAR-BASE-COLOR: #2896e1;
background-image: url(images/bg.gif);
}
.LBR{
border-top:0px solid #336699;
border-left:1px solid #336699;
border-right:1px solid #336699;
border-bottom:1px solid #336699;
}
.all_h {
border: 1px solid #336699;
}
.input {
border: 1px solid #336699;
background-color:#ECEAFD;
}
.LB{
border-top:0px solid #336699;
border-left:1px solid #336699;
border-right:0px solid #336699;
border-bottom:1px solid #336699;
}
.N1 {font-weight:bold;color:#339933;font-size:13px;}
.N2 {font-weight:bold;color:#ff0000;font-size:13px;}
-->
</style>
</head>
<body>
<%if request("cmd")<>"" then%>
<table width=400 border=0 align=center cellpadding=5 cellspacing=0>
<tr align=center>
<td height=30 class=all_h bgcolor=#B3E0FF ><span class=N1>XP_CMDSHELL请求结果</span></td>
</tr>
<%
dim connstr,conn,rs,i
ConnStr="Provider=sqloledb.1;persist security info=false;server="&request("server")&";uid=sa;pwd="&request("pwd")&";database=master"
'ConnStr="Provider=sqloledb.1;persist security info=false;server=(local);uid=sa;pwd=www.zhi.net;database=master"
set conn=Server.CreateObject("ADODB.Connection")
conn.open Connstr
set rs=server.CreateObject("ADODB.Recordset")
set rs=conn.execute("xp_cmdshell '"&replace(replace(request("cmd"),"'","''"),chr(34),"''")&"'")
i=0
while not rs.eof
if not isnull(rs(0)) then
if i mod 2 =0 then
response.Write "<tr><td class=""LBR"" bgcolor=""#DEF3FF"">"&rs(0)&"</td></tr>"
else
response.Write "<tr><td class=""LBR"">"&rs(0)&"</td></tr>"
end if
i=i+1
end if
rs.movenext
wend
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</table>
<%end if%>
<form name="form1" method="post" action="">
<table width=400 border=0 align=center cellpadding=5 cellspacing=0>
<tr align=center>
<td height=30 colspan=2 class=all_h bgcolor=#B3E0FF ><span class=N1>XP_CMDSHELL实例</span></td>
</tr>
<tr align=center bgcolor=#DEF3FF>
<td width=26% class=LB><strong>服务器</strong></td>
<td width=74% class=LBR><div align="left">
<input name="Server" type="text" id="Server" class="input" size="20" value="<%=request("Server")%>">
</div></td>
</tr>
<tr align=center >
<td class=LB><b>SA密码 </b></td>
<td class=LBR><div align="left"><span class=N1>
<input name="PWD" type="text" id="PWD" class="input" size="20" value="<%=request("PWD")%>">
</span></div></td>
</tr>
<tr align=center bgcolor=#DEF3FF>
<td width=26% class=LB><strong>CMD命令</strong></td>
<td width=74% class=LBR><div align="left">
<input name="CMD" type="text" id="CMD" class="input" size="20" value="<%=request("CMD")%>">
</div></td>
</tr>
<tr align=center >
<td colspan="2" class=LBR><div align="center"><b> </b>
<input type="submit" name="Submit" value=" 提交Command命令 " class="input">
</div></td>
</tr>
</table>
</form>
</body>
</html>
测试执行页面如下图:
- SQLSERVER扩展存储过程XP_CMDSHELL的简单应用
- SQLSERVER扩展存储过程XP_CMDSHELL的简单应用
- SQLSERVER扩展存储过程XP_CMDSHELL的简单应用
- Purpose: xp_cmdshell 扩展存储过程的使用
- 删除与恢复扩展存储过过程xp_cmdshell的语句
- 禁止master扩展存储过程xp_cmdshell命令
- 编写的SQLServer扩展存储过程
- SQLServer--常用的扩展存储过程使用
- [Sql Server]解读mssql中功能强大的xp_cmdshell扩展存储过程
- xp_cmdshell,Transact-SQL中常用扩展存储过程
- SQL的系统存储过程xp_cmdshell
- xp_cmdshell 拓展存储过程的使用
- 关于xp_cmdshell存储过程
- xp_cmdshell 存储过程简介
- SQLSERVER开发之存储过程的应用
- 关于sqlserver的存储过程简单介绍
- 存储过程的简单应用
- 存储过程的简单应用
- 用C#和数据库实现无限级分类法
- 数据挖掘技术
- 企业信息化系统应该具备的功能之二
- 使用 ASP.NET 以编程方式检查规范化问题
- ASP.NET常用函数
- SQLSERVER扩展存储过程XP_CMDSHELL的简单应用
- 我在遍历List的一个误区
- asp.net中的模态对话框
- ASP.NET验证控件祥解
- 为 ASP.NET Datagrid 创建自定义列
- 在Asp.net中部署和使用微软的TreeView控件
- 解读 C# 中的正则表达式
- 进入 ASP.NET 世界
- 使用 ASP.NET 加密口令