- Статус
- Оффлайн
- Регистрация
- 24 Ноя 2024
- Сообщения
- 671
- Реакции
- 11
вот щас у меня такой пример обфусцированного класса (моего же обфускатора):
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
чо можно добавить? идеи в комменты кидайте, попробуйте деобфнуть
				
			
			
				Java:
			
		
		
		import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.IntInsnNode;
import org.objectweb.asm.tree.JumpInsnNode;
import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.LdcInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
public class JarObfuscator {
   private static final Random random = new Random();
   private static final String[] chineseChars = new String[]{"一", "丁", "丂", "七", "丄", "丅", "丆", "万", "丈", "三", "上", "下", "丌", "不", "与", "丏", "丐", "丑", "丒", "专", "且", "丕", "世", "丗", "丘", "丙", "业", "丛", "东", "丝"};
   public static void main(String[] args) throws IOException {
      if (args.length != 2) {
         System.out.println(IIlIIlll(new String("七丂丅丆万丈三上下丌不与丏丐丑丒专且丕世丗丘丙业丛东丝").intern()));
         return;
      }
      String inputJarPath = args[0];
      String outputJarPath = args[1];
      lllIlIIl(inputJarPath, outputJarPath);
   }
   public static void lllIlIIl(String inputJarPath, String outputJarPath) throws IOException {
      java.io.File inputJarFile = new java.io.File(inputJarPath);
      java.io.File outputJarFile = new java.io.File(outputJarPath);
      if (!inputJarFile.exists()) {
         System.out.println(IIlIIlll(new String("七丂丅丆万丈三上不与丏丐丑丒专且丕世丗丘丙业丛东丝丝").intern()) + inputJarPath);
         return;
      }
      JarFile jarFile = new JarFile(inputJarFile);
      try {
         JarOutputStream jarOutputStream = new JarOutputStream(new java.io.FileOutputStream(outputJarFile));
         try {
            jarFile.stream().forEach((jarEntry) -> {
               try {
                  jarOutputStream.putNextEntry(new JarEntry(jarEntry.getName()));
                  if (jarEntry.isDirectory()) {
                     return;
                  }
                  if (jarEntry.getName().endsWith(IIlIIlll(new String("七七丂丂丁").intern()))) {
                     ClassReader classReader = new ClassReader(jarFile.getInputStream(jarEntry));
                     ClassNode classNode = new ClassNode();
                     classReader.accept(classNode, 0);
                     lIIlIIlI(classNode);
                     ClassWriter classWriter = new ClassWriter(3);
                     classNode.accept(classWriter);
                     byte[] modifiedBytecode = classWriter.toByteArray();
                     jarOutputStream.write(modifiedBytecode);
                  } else {
                     InputStream inputStream = jarFile.getInputStream(jarEntry);
                     byte[] buffer = inputStream.readAllBytes();
                     jarOutputStream.write(buffer);
                     inputStream.close();
                  }
                  jarOutputStream.closeEntry();
               } catch (IOException var11) {
                  var11.printStackTrace();
               }
            });
         } catch (Throwable var13) {
            try {
               jarOutputStream.close();
            } catch (Throwable var12) {
               var13.addSuppressed(var12);
            }
            throw var13;
         }
         jarOutputStream.close();
      } catch (Throwable var14) {
         try {
            jarFile.close();
         } catch (Throwable var10) {
            var14.addSuppressed(var10);
         }
         throw var14;
      }
      jarFile.close();
      System.out.println(IIlIIlll(new String("丆万丈三上不与丏丐丑丒专且丕世丗丘丙业丛东丝丝丝丝丝").intern()) + outputJarPath);
   }
   private static void lIIlIIlI(ClassNode classNode) {
      HashMap methodRenameMap = new HashMap();
      IllIIlIl(classNode);
      Iterator var2 = classNode.methods.iterator();
      while(var2.hasNext()) {
         MethodNode methodNode = (MethodNode)var2.next();
         if (!methodNode.name.equals(IIlIIlll(new String("与丗").intern())) && !methodNode.name.equals(IIlIIlll(new String("与丐丙丝").intern())) && !methodNode.name.equals(IIlIIlll(new String("与上丅丐").intern())) && !methodNode.name.equals(IIlIIlll(new String("丅专专专").intern())) && !methodNode.name.equals(IIlIIlll(new String("丅七丝七丅").intern()))) {
            lIllIIII(methodNode, methodRenameMap);
         }
         lIlIIlll(methodNode);
         IllIlIll(methodNode);
         lIIIIlll(methodNode);
         lIIlIlll(methodNode);
      }
      lIIlIlIl(classNode, methodRenameMap);
   }
   private static void lIllIIII(MethodNode methodNode, Map renameMap) {
      String originalName = methodNode.name;
      String obfuscatedName = IllIIIIl();
      methodNode.name = obfuscatedName;
      renameMap.put(originalName, obfuscatedName);
   }
   private static String IllIIIIl() {
      StringBuilder sb = new StringBuilder();
      int length = random.nextInt(50) + 2;
      for(int i = 0; i < length; ++i) {
         sb.append(random.nextBoolean() ? 'l' : 'I');
      }
      return sb.toString();
   }
   private static void lIIlIlIl(ClassNode classNode, Map renameMap) {
      Iterator var2 = classNode.methods.iterator();
      while(var2.hasNext()) {
         MethodNode methodNode = (MethodNode)var2.next();
         Iterator var4 = methodNode.instructions.iterator();
         while(var4.hasNext()) {
            AbstractInsnNode insn = (AbstractInsnNode)var4.next();
            if (insn instanceof MethodInsnNode) {
               MethodInsnNode methodInsn = (MethodInsnNode)insn;
               if (renameMap.containsKey(methodInsn.name) && methodInsn.owner.equals(classNode.name)) {
                  methodInsn.name = (String)renameMap.get(methodInsn.name);
               }
            }
         }
      }
   }
   private static void IllIIlIl(ClassNode classNode) {
      MethodNode deadMethod = new MethodNode(2, IIlIIlll(new String("上丅丐丙丝丁").intern()) + random.nextInt(1000), IIlIIlll(new String("专专丝").intern()), (String)null, (String[])null);
      deadMethod.instructions.add((AbstractInsnNode)(new FieldInsnNode(178, IIlIIlll(new String("丈上丝专丈专").intern()), IIlIIlll(new String("与丝丅").intern()), IIlIIlll(new String("丁专丈与丝丕丁丅丝丝").intern()))));
      deadMethod.instructions.add((AbstractInsnNode)(new LdcInsnNode(IIlIIlll(new String("丅丝丅丅丁丕丐丙丝").intern()))));
      deadMethod.instructions.add((AbstractInsnNode)(new MethodInsnNode(182, IIlIIlll(new String("丁专丈与丝丕丁丅丝丝").intern()), IIlIIlll(new String("丙丝丁丅丝丝").intern()), IIlIIlll(new String("专丁专丈与丝丕丁丅丝丝丅丙丝").intern()), false)));
      deadMethod.instructions.add((AbstractInsnNode)(new InsnNode(177)));
      classNode.methods.add(deadMethod);
      Iterator var1 = classNode.methods.iterator();
      while(var1.hasNext()) {
         MethodNode method = (MethodNode)var1.next();
         InsnList instructions = method.instructions;
         if (instructions.size() > 0) {
            LabelNode startLabel = new LabelNode();
            instructions.insert(instructions.getFirst(), startLabel);
            instructions.insert(startLabel, new JumpInsnNode(167, startLabel));
            instructions.remove(startLabel.getNext());
         }
      }
   }
   private static void lIlIIlll(MethodNode methodNode) {
      InsnList instructions = methodNode.instructions;
      if (instructions.size() > 0) {
         for(int i = 0; i < instructions.size(); i += 2) {
            AbstractInsnNode insn = instructions.get(i);
            if (insn.getOpcode() != 159 && insn.getOpcode() != 132) {
               LabelNode label = new LabelNode();
               instructions.insertBefore(insn, label);
               instructions.insertBefore(insn, new InsnNode(0));
               instructions.insertBefore(insn, new JumpInsnNode(154, label));
               instructions.insertBefore(insn, new InsnNode(4));
            }
         }
      }
   }
   private static void IllIlIll(MethodNode methodNode) {
      List stringLiterals = new ArrayList();
      Iterator var2 = methodNode.instructions.iterator();
      while(var2.hasNext()) {
         AbstractInsnNode insn = (AbstractInsnNode)var2.next();
         if (insn instanceof LdcInsnNode && ((LdcInsnNode)insn).cst instanceof String) {
            stringLiterals.add((LdcInsnNode)insn);
         }
      }
      Iterator var6 = stringLiterals.iterator();
      while(var6.hasNext()) {
         LdcInsnNode stringLiteral = (LdcInsnNode)var6.next();
         String originalString = (String)stringLiteral.cst;
         String encryptedString = IIllllIl(originalString);
         String decryptMethodName = IllIIIIl();
         String decryptMethodDesc = IIlIIlll(new String("丁专丈与丝丕丁丅丝丝丅丙丝专丁专丈与丝").intern());
         if (!IllIlIlI(methodNode.classNode, decryptMethodName, decryptMethodDesc)) {
            lIllIllI(methodNode.classNode, decryptMethodName, decryptMethodDesc);
         }
         methodNode.instructions.insertBefore(stringLiteral, new LdcInsnNode(encryptedString));
         methodNode.instructions.set(stringLiteral, new MethodInsnNode(184, methodNode.classNode.name, decryptMethodName, decryptMethodDesc, false));
      }
   }
   private static String IIllllIl(String original) {
      StringBuilder sb = new StringBuilder();
      char[] var2 = original.toCharArray();
      int var3 = var2.length;
      for(int var4 = 0; var4 < var3; ++var4) {
         char c = var2[var4];
         sb.append(chineseChars[c % chineseChars.length]);
      }
      return sb.toString();
   }
   private static void lIllIllI(ClassNode classNode, String methodName, String methodDesc) {
      MethodNode decryptMethod = new MethodNode(10, methodName, methodDesc, (String)null, (String[])null);
      decryptMethod.visitCode();
      decryptMethod.visitTypeInsn(187, IIlIIlll(new String("丈丝丕专丅丝丙").intern()));
      decryptMethod.visitInsn(89);
      decryptMethod.visitMethodInsn(183, IIlIIlll(new String("丈丝丕专丅丝丙").intern()), IIlIIlll(new String("丅专专专").intern()), IIlIIlll(new String("专专丝专专丝").intern()), false);
      decryptMethod.visitVarInsn(58, 1);
      decryptMethod.visitVarInsn(25, 0);
      decryptMethod.visitMethodInsn(182, IIlIIlll(new String("丈丝丕专丅丝丙").intern()), IIlIIlll(new String("丙丅丅七丁专丈丕丝丝").intern()), IIlIIlll(new String("专专丁专专絲丝").intern()), false);
      decryptMethod.visitVarInsn(58, 2);
      decryptMethod.visitVarInsn(25, 2);
      decryptMethod.visitInsn(190);
      decryptMethod.visitVarInsn(54, 3);
      decryptMethod.visitInsn(3);
      decryptMethod.visitVarInsn(54, 4);
      Label labelStartLoop = new Label();
      decryptMethod.visitLabel(labelStartLoop);
      decryptMethod.visitVarInsn(21, 4);
      decryptMethod.visitVarInsn(21, 3);
      Label labelEndLoop = new Label();
      decryptMethod.visitJumpInsn(162, labelEndLoop);
      decryptMethod.visitVarInsn(25, 2);
      decryptMethod.visitVarInsn(21, 4);
      decryptMethod.visitInsn(50);
      decryptMethod.visitVarInsn(58, 5);
      decryptMethod.visitVarInsn(25, 1);
      decryptMethod.visitVarInsn(25, 5);
      decryptMethod.visitMethodInsn(182, IIlIIlll(new String("丈丝丕专丅丝丙").intern()), IIlIIlll(new String("与丙丙丝丝丁").intern()), IIlIIlll(new String("丁专专丝丁丈丝丕专丅丝丙絲丝").intern()), false);
      decryptMethod.visitInsn(87);
      decryptMethod.visitIincInsn(4, 1);
      decryptMethod.visitJumpInsn(167, labelStartLoop);
      decryptMethod.visitLabel(labelEndLoop);
      decryptMethod.visitVarInsn(25, 1);
      decryptMethod.visitMethodInsn(182, IIlIIlll(new String("丈丝丕专丅丝丙").intern()), IIlIIlll(new String("丅丝丝丁丙丝丝").intern()), IIlIIlll(new String("专专丝专专丝").intern()), false);
      decryptMethod.visitInsn(176);
      decryptMethod.visitMaxs(3, 6);
      decryptMethod.visitEnd();
      classNode.methods.add(decryptMethod);
   }
   private static boolean IllIlIlI(ClassNode classNode, String methodName, String methodDesc) {
      Iterator var3 = classNode.methods.iterator();
      MethodNode method;
      do {
         if (!var3.hasNext()) {
            return false;
         }
         method = (MethodNode)var3.next();
      } while(!method.name.equals(methodName) || !method.desc.equals(methodDesc));
      return true;
   }
   private static void lIIIIlll(MethodNode methodNode) {
      List numberLiterals = new ArrayList();
      Iterator var2 = methodNode.instructions.iterator();
      while(var2.hasNext()) {
         AbstractInsnNode insn = (AbstractInsnNode)var2.next();
         if (insn instanceof LdcInsnNode && ((LdcInsnNode)insn).cst instanceof Integer) {
            numberLiterals.add((LdcInsnNode)insn);
         }
      }
      Iterator var6 = numberLiterals.iterator();
      while(var6.hasNext()) {
         LdcInsnNode numberLiteral = (LdcInsnNode)var6.next();
         int originalNumber = (Integer)numberLiteral.cst;
         String obfuscatedNumber = lIlllIII(originalNumber);
         methodNode.instructions.insertBefore(numberLiteral, new LdcInsnNode(obfuscatedNumber));
         methodNode.instructions.remove(numberLiteral);
      }
   }
   private static String lIlllIII(int number) {
      return IIlIIlll(new String("专").intern()) + number + IllIIIIl();
   }
   private static void lIIlIlll(MethodNode methodNode) {
      if (methodNode.instructions.size() > 2) {
         InsnList nestedLoops = new InsnList();
         LabelNode startLoop1 = new LabelNode();
         LabelNode endLoop1 = new LabelNode();
         LabelNode startLoop2 = new LabelNode();
         LabelNode endLoop2 = new LabelNode();
         LabelNode startLoop3 = new LabelNode();
         LabelNode endLoop3 = new LabelNode();
         nestedLoops.add((AbstractInsnNode)(new InsnNode(3)));
         nestedLoops.add((AbstractInsnNode)(new VarInsnNode(54, 10)));
         nestedLoops.add(startLoop1);
         nestedLoops.add((AbstractInsnNode)(new VarInsnNode(21, 10)));
         pushInt(nestedLoops, 5);
         nestedLoops.add((AbstractInsnNode)(new JumpInsnNode(162, endLoop1)));
         nestedLoops.add((AbstractInsnNode)(new InsnNode(3)));
         nestedLoops.add((AbstractInsnNode)(new VarInsnNode(54, 11)));
         nestedLoops.add(startLoop2);
         nestedLoops.add((AbstractInsnNode)(new VarInsnNode(21, 11)));
         pushInt(nestedLoops, 100);
         nestedLoops.add((AbstractInsnNode)(new JumpInsnNode(162, endLoop2)));
         nestedLoops.add((AbstractInsnNode)(new InsnNode(3)));
         nestedLoops.add((AbstractInsnNode)(new VarInsnNode(54, 12)));
         nestedLoops.add(startLoop3);
         nestedLoops.add((AbstractInsnNode)(new VarInsnNode(21, 12)));
         pushInt(nestedLoops, 100);
         nestedLoops.add((AbstractInsnNode)(new JumpInsnNode(162, endLoop3)));
         nestedLoops.add((AbstractInsnNode)(new InsnNode(0)));
         nestedLoops.add((AbstractInsnNode)(new IincInsnNode(12, 1)));
         nestedLoops.add((AbstractInsnNode)(new JumpInsnNode(167, startLoop3)));
         nestedLoops.add(endLoop3);
         nestedLoops.add((AbstractInsnNode)(new IincInsnNode(11, 1)));
         nestedLoops.add((AbstractInsnNode)(new JumpInsnNode(167, startLoop2)));
         nestedLoops.add(endLoop2);
         nestedLoops.add((AbstractInsnNode)(new IincInsnNode(10, 1)));
         nestedLoops.add((AbstractInsnNode)(new JumpInsnNode(167, startLoop1)));
         nestedLoops.add(endLoop1);
         methodNode.instructions.insertBefore(methodNode.instructions.getFirst(), nestedLoops);
      }
   }
   private static void pushInt(InsnList list, int value) {
      if (value >= -1 && value <= 5) {
         list.add((AbstractInsnNode)(new InsnNode(3 + value)));
      } else if (value >= -128 && value <= 127) {
         list.add((AbstractInsnNode)(new IntInsnNode(16, value)));
      } else if (value >= -32768 && value <= 32767) {
         list.add((AbstractInsnNode)(new IntInsnNode(17, value)));
      } else {
         list.add((AbstractInsnNode)(new LdcInsnNode(value)));
      }
   }
   private static String IIlIIlll(String str) {
      StringBuilder sb = new StringBuilder();
      char[] var2 = str.toCharArray();
      int var3 = var2.length;
      for(int var4 = 0; var4 < var3; ++var4) {
         char c = var2[var4];
         sb.append(c);
      }
      return sb.toString();
   }
}чо можно добавить? идеи в комменты кидайте, попробуйте деобфнуть
 
				 
	 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		