Search in sources :

Example 1 with MethodMappingData

use of the.bytecode.club.bytecodeviewer.obfuscators.mapping.data.MethodMappingData in project bytecode-viewer by Konloch.

the class RenameMethods method obfuscate.

@Override
public void obfuscate() {
    int stringLength = getStringLength();
    System.out.println("Obfuscating method names...");
    for (ClassNode c : BytecodeViewer.getLoadedClasses()) {
        methodLoop: for (Object o : c.methods.toArray()) {
            MethodNode m = (MethodNode) o;
            /* As we dont want to rename native dll methods */
            if ((m.access & Opcodes.ACC_NATIVE) != 0)
                continue methodLoop;
            if (m.access != Opcodes.ACC_ABSTRACT && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PUBLIC && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PRIVATE && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PROTECTED && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PUBLIC && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PRIVATE && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PROTECTED) {
                if (!m.name.equals("main") && !m.name.equals("<init>") && !m.name.equals("<clinit>")) {
                    String newName = generateUniqueName(stringLength);
                    BytecodeViewer.refactorer.getHooks().addMethod(new MethodMappingData(c.name, new MappingData(m.name, newName), m.desc));
                /*ASMUtil_OLD.renameMethodNode(c.name, m.name, m.desc,
								null, newName, null);*/
                }
            }
        }
    }
    System.out.println("Obfuscated method names.");
}
Also used : ClassNode(org.objectweb.asm.tree.ClassNode) MethodNode(org.objectweb.asm.tree.MethodNode) MethodMappingData(the.bytecode.club.bytecodeviewer.obfuscators.mapping.data.MethodMappingData) MappingData(the.bytecode.club.bytecodeviewer.obfuscators.mapping.data.MappingData) MethodMappingData(the.bytecode.club.bytecodeviewer.obfuscators.mapping.data.MethodMappingData)

Aggregations

ClassNode (org.objectweb.asm.tree.ClassNode)1 MethodNode (org.objectweb.asm.tree.MethodNode)1 MappingData (the.bytecode.club.bytecodeviewer.obfuscators.mapping.data.MappingData)1 MethodMappingData (the.bytecode.club.bytecodeviewer.obfuscators.mapping.data.MethodMappingData)1