-
-
Save CalfCrusher/4235e864b88c6e275c6ae82eddb80009 to your computer and use it in GitHub Desktop.
Simple ASPX application (vulnerable to OS command injections)
This file contains hidden or 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
<%@ Page Language="C#" Debug="true" Trace="false" %> | |
<%@ Import Namespace="System.Diagnostics" %> | |
<%@ Import Namespace="System.IO" %> | |
<script Language="c#" runat="server"> | |
void Page_Load(object sender, EventArgs e){ | |
} | |
string ExcuteCmd(string arg){ | |
ProcessStartInfo psi = new ProcessStartInfo(); | |
psi.FileName = "cmd.exe"; | |
psi.Arguments = "/c ping -n 2 " + arg; | |
psi.RedirectStandardOutput = true; | |
psi.UseShellExecute = false; | |
Process p = Process.Start(psi); | |
StreamReader stmrdr = p.StandardOutput; | |
string s = stmrdr.ReadToEnd(); | |
stmrdr.Close(); | |
return s; | |
} | |
void cmdExe_Click(object sender, System.EventArgs e){ | |
Response.Write(Server.HtmlEncode(ExcuteCmd(addr.Text))); | |
} | |
</script> | |
<HTML> | |
<HEAD> | |
<title>ASP.NET Ping Application</title> | |
</HEAD> | |
<body> | |
<form id="cmd" method="post" runat="server"> | |
<asp:Label id="lblText" runat="server">Command:</asp:Label> | |
<asp:TextBox id="addr" runat="server" Width="250px"> | |
</asp:TextBox> | |
<asp:Button id="testing" runat="server" Text="excute" OnClick="cmdExe_Click"> | |
</asp:Button> | |
</form> | |
</body> | |
</HTML> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment