是否有用于编辑指令的 java 类文件/字节码编辑器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3308351/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a java classfile / bytecode editor to edit instructions?
提问by MRalwasser
Is there a utility (or eclipse plugin) for editing java class files? I'd like to manipulate the bytecode of a java class file without recompiling it nor having a complete buildpath.
是否有用于编辑 java 类文件的实用程序(或 eclipse 插件)?我想在不重新编译它也没有完整的构建路径的情况下操作 java 类文件的字节码。
E.g. to rename methods, add/delete instructions, change constants etc.
例如重命名方法、添加/删除指令、更改常量等。
The only utilities I found are:
我发现的唯一实用程序是:
classeditorbut it's very limited in functionality (e.g. renaming of things and manipulating instructions isn't possible).
jbedoesn't save changes (maybe because class verifying fails - before I made any changes, although the class runs perfectly)
(jbe initially had a classpath issue, adding the class path to the jbe.bat file helped)
classeditor但它的功能非常有限(例如,不可能重命名事物和操纵指令)。
jbe不保存更改(可能是因为类验证失败 - 在我进行任何更改之前,尽管类运行完美)
(jbe 最初有一个类路径问题,将类路径添加到 jbe.bat 文件有帮助)
采纳答案by Thorbj?rn Ravn Andersen
I have not seen any byte code -> byte code frontends, but plenty backends.
我还没有看到任何字节码 -> 字节码前端,但有很多后端。
I would suggest that you have a look at the many byte code manipulation libraries like javassist
which allow loading byte code, manipulate it, and save it back to disk, and then write a small main that does exactly that.
我建议您查看许多字节码操作库,例如javassist
它们允许加载字节码,对其进行操作,然后将其保存回磁盘,然后编写一个执行此操作的小型 main。
回答by Guy Sensei
回答by nahsra
回答by Antimony
I wrote an open source Java assembler and dissasembleryou may find useful.
我编写了一个开源 Java 汇编器和反汇编器,您可能会发现它很有用。
It lets you disassemble a classfile into human readable assembly, edit it, and then reassemble it into a class. It was originally designed for writing obfuscated crackmes, so there are a lot of obscure features it supports that many other tools don't. If you need any features it doesn't currently support, feel free to contact me and I'll see what I can do.
它允许您将类文件分解为人类可读的程序集,对其进行编辑,然后将其重新组装为一个类。它最初是为编写混淆的破解程序而设计的,因此它支持许多其他工具不支持的模糊功能。如果您需要它目前不支持的任何功能,请随时与我联系,我会看看我能做些什么。