如何反编译混淆的java程序,避免类/包名冲突

编程入门 行业动态 更新时间:2024-10-16 16:52:52
本文介绍了如何反编译混淆的java程序,避免类/包名冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想反编译一个java程序并重新编译派生(混淆)的源代码。我解压缩.jar存档并获得了类似的目录结构:

I want to decompile a java program and recompile the derived (obfuscated) source. I unpacked the .jar archive and got a directory structure like that:

com/ com/foo/A/ com/foo/A/A.class com/foo/A/B.Class com/foo/B/A.class ... com/foo/A.class com/foo/B.class org/foo/Bar.class ...

问题是包和类之间存在名称冲突,这使得无法重新编译反编译的类文件。 反编译类看起来像这样:

The problem is that there are name collisions between packages and classes, which makes it impossible to recompile the decompiled class files. A decompiled class will look like this:

package org.foo; import com.foo.A; // <-- name collision error class Bar { ... }

有没有办法解决这些命名问题,而无需重命名类文件?

Is there any way to resolve those naming issues, without renaming the class files?

编辑:这是不是一个反编译器问题,而是如何使用违反命名约定的类来生成.jar文件的问题。

This is not a decompiler problem, but the question how it is possible to have a working .jar file with classes that violate naming conventions.

EDIT2:好​​的,我猜测字节码级别这样命名是可能的,因此使用更智能的反编译器(自动重命名类并修复其引用)可以解决这个问题。

Okay, i guess on bytecode level such naming is possible, so with a smarter decompiler (who automatically renames the classes and fixes their references) this problem could be solved.

推荐答案

Java的导入机制提供了命名事项的简写,但是当发生冲突时你显然无法使用它。您始终可以在代码中使用完全限定名称,例如

Java's import mechanism provides a shorthand for naming things, but you obviously cannot use it when there are collisions. You can always use the fully qualified name in your code, e.g.

package org.foo; class Bar { private com.foo.Bar aDifferentBar; ... }

编辑:

我想可能有类文件符合JVM规范但是不能由符合JLS规范的Java程序生成。如果是这样,那么你肯定需要一个更聪明的反编译器。

I suppose there could be class files that comply with the JVM spec but which cannot be produced by a Java program that complies with the JLS spec. If so then you'll definitely need a smarter decompiler.

更多推荐

如何反编译混淆的java程序,避免类/包名冲突

本文发布于:2023-11-07 19:33:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1567227.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:反编译   冲突   程序   java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!