有时我们在管理服务器时为了安全起见会禁用windows scripting host,这样能防止某些不法用户利用wsh生成一个webshell,对服务器造成很大的安全隐患。但如果我们又想禁用wsh,又想使用自己的webshell用于服务器的管理怎么办呢?这里介绍了一种实现asp中运行cmd并显示结果的组件编程。希望对大家能有所帮助。
|||t;text/css>
<!--
.singleborder {
border: 1px solid;
background-color: #000000;
font-family: arial, helvetica, sans-serif;
color: #ffffff;
}
.noborder {
border: 1px none;
background-color: #000000;
font-family: arial, helvetica, sans-serif;
color: #ffffff;
}
body{background-color: #000000;scrollbar-face-color: #333333; font-size: 12px; scrollbar-highlight-color: #000000; scrollbar-shadow-color: #000000; scrollbar-3dlight-color: #000000; scrollbar-arrow-color: #000000; scrollbar-track-color: #000000; scrollbar-darkshadow-color: #000000
font-family: fixedsys; font-size: 9pt}
-->
</style>
<form action= method=post>
<input name=cmd class=singleborder value=<%=request.form(cmd)%> size=102>
<input type=submit class=singleborder value=execute>
</form>
<%
if request.form(cmd)<> then
set testme=server.createobject(aspcmd.cmdshell)
%>
<div class=noborder><%=request.form(cmd)%></div><br>
<textarea cols=120 rows=30 class=noborder>
<%=testme.exec1(request.form(cmd))%></textarea>
<% set testme=nothing
end if
%>
以下是运行ipconfig /all的结果:
windows 2000 ip configuration
host name . . . . . . . . . . . . : ibm-wrk-02
primary dns suffix . . . . . . . :
node type . . . . . . . . . . . . : broadcast
ip routing enabled. . . . . . . . : no
wins proxy enabled. . . . . . . . : no
ethernet adapter 本地连接:
connection-specific dns suffix . :
description . . . . . . . . . . . : intel(r) pro/100 vm network connection
physical address. . . . . . . . . : 00-08-02-bd-d7-eb
dhcp enabled. . . . . . . . . . . : no
ip address. . . . . . . . . . . . : 192.168.0.4
subnet mask . . . . . . . . . . . : 255.255.255.0
default gateway . . . . . . . . . : 192.168.0.1
dns servers . . . . . . . . . . . : 202.106.196.115