简体   繁体   English

无法反编译JAR文件

[英]Cannot decompile a JAR file

I found a really strange JAR file. 我发现了一个非常奇怪的JAR文件。 It contains two classes. 它包含两个类。 I tried every single decompiler I know, even IntelliJ's Fernflower. 我尝试了我认识的每个反编译器,甚至是IntelliJ的Fernflower。 All of them gave me this result: Screenshot of IntelliJ's decompiler When I try to view the bytecode of the class, I can see some weird stuff aswell: Screenshot of ASM Bytecode Viewer in IntelliJ It says that the class is "synthetic". 所有这些都给了我这个结果: IntelliJ反编译器的屏幕快照当我尝试查看该类的字节码时,我也可以看到一些奇怪的东西: IntelliJ中的ASM Bytecode Viewer的屏幕快照它说该类是“合成的”。 I looked up what it means in google and I really have no idea how such a class can be considered synthetic. 我查了一下Google的含义,但我真的不知道如何将此类视为合成类。 Any ideas how this is made and how it's possible to replicate such a thing? 有什么想法如何做到的以及如何复制这种东西吗?

In the most cases you are not allowed to decompile software. 在大多数情况下,不允许您反编译软件。 In this case I'm pretty sure you are not allowed, because the class name was obfuscated . 在这种情况下,我可以肯定您是不允许的,因为类名被混淆了 But the strange @thingys are properly some type of Lombok or custom Annotation from a libary 但是奇怪的@thingys正确地是某种类型的Lombok或来自库的自定义Annotation

Edit: It is a Annotation of minecraftforge. 编辑:这是minecraftforge的Annotation Here is some information on it: https://mcforge.readthedocs.io/en/latest/gettingstarted/structuring/#what-is-mod 这是有关此的一些信息: https : //mcforge.readthedocs.io/zh/latest/gettingstarted/structuring/#what-is-mod

Please do not decompile sourcecode you dont own! 请不要反编译您不拥有的源代码!

The synthetic flag is used to mark classes/fields/methods/... that have been generated by the compiler and did therefore not exist in source code. 合成标志用于标记由编译器生成的类/字段/方法/ ...,因此在源代码中不存在。 (see JVM-spec 4.1-B ) (请参阅JVM-spec 4.1-B

Since you've added the java-bytecode-asm i guess you want to know how to achieve this using the objectweb asm library. 既然您已经添加了java-bytecode-asm我想您想知道如何使用objectweb asm库来实现这一点。 It is done by setting the ACC_SYNTETHIC flag for the class. 通过为该类设置ACC_SYNTETHIC标志来完成。

Here is a class visitor that does it for the class and all fields and methods: 这是为类以及所有字段和方法执行此操作的类访问者:

public class MakeSyntheticVisitor extends ClassVisitor {
    public MakeSyntheticVisitor(int api, ClassVisitor classVisitor) {
        super(api, classVisitor);
    }

    @Override
    public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
        super.visit(version, access | Opcodes.ACC_SYNTHETIC, name, signature, superName, interfaces);
    }

    @Override
    public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) {
        return super.visitField(access | Opcodes.ACC_SYNTHETIC, name, descriptor, signature, value);
    }

    @Override
    public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
        return super.visitMethod(access | Opcodes.ACC_SYNTHETIC, name, descriptor, signature, exceptions);
    }
}

Let's use our visitor to transform a class: 让我们用访问者来转换一个类:

public static void main() throws Exception {
    InputStream in = new FileInputStream(new File("in/Test.class"));

    ClassReader cr = new ClassReader(in);
    ClassWriter cw = new ClassWriter(0);

    cr.accept(new MakeSyntheticVisitor(Opcodes.ASM7, cw), 0);

    FileOutputStream out = new FileOutputStream(new File("obfuscated/Test.class"));
    out.write(cw.toByteArray());
    out.close();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM