mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-22 07:00:43 +08:00
feat: support bytecode shrink
1. remove source file symbol (#46) 2. remove debug info when enable shrink (#29)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.reajason.javaweb;
|
||||
|
||||
import net.bytebuddy.jar.asm.ClassReader;
|
||||
import net.bytebuddy.jar.asm.ClassVisitor;
|
||||
import net.bytebuddy.jar.asm.ClassWriter;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
* @since 2025/2/25
|
||||
*/
|
||||
public class ClassBytesShrink {
|
||||
|
||||
public static byte[] shrink(byte[] bytes, boolean full) {
|
||||
ClassReader cr = new ClassReader(bytes);
|
||||
ClassWriter cw = new ClassWriter(0);
|
||||
ClassVisitor cv = new ClassVisitor(Opcodes.ASM9, cw) {
|
||||
@Override
|
||||
public void visitSource(String source, String debug) {
|
||||
|
||||
}
|
||||
};
|
||||
cr.accept(cv, full ? ClassReader.SKIP_DEBUG : 0);
|
||||
return cw.toByteArray();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user