How to obfuscate code without compiling the projec

2020-07-30 06:04发布

Is there a way to obfuscate the code directly in editor?

At this moment, if I want to see the obfuscated code of my project, I have to compile the project, do reverse engineering and then view the code via tools like jd-gui.

Possible to achieve all this via some add-on so that I can compile obfuscated code, i.e. make it work just like before obfuscation.

NOTE

To clarify, I do not need to obfuscate code on export as this feature is already present. I need to obfuscate the code on live without compiling it or at least without having to export it to apk.

3条回答
爷的心禁止访问
2楼-- · 2020-07-30 06:27

I dont know about any pre-compile obfuscator , however i think what you desire can be achieved by following steps :

  1. Create a one-to-one mapping file of your function names to some gibberish text names . Similarly have same sort of mapping for variables . Define some useless loops / codeblocks which are ignored by JVM's on compilation and can be executed upon the start or end of methods (This will be stripped by compiler anyway ) .
  2. Now since you have mentioned Intellij Idea in your tags , you can use the Macro functionality in your ide and create a macro which replaces all the variable names and function names (or starting parentheses with useless code blocks ) .
  3. Save the macro with any name and whenever you want to view your code obfuscated , just execute the macro for obfuscation .
  4. Have a similar macro for unobfuscating as well so that you can revert back whenever you want . Meanwhile i haven't worked in intellij idea plugin much however you can create plugin which does the same work as macro quite comfortably .
查看更多
够拽才男人
3楼-- · 2020-07-30 06:27

If you are using Eclipse, you may want to install JadClipse to ease your workflow. It will open any binary class file in your workspace directly in the decompiled textual format.

Whether or not that class file is an obfuscated binary or not, depends on your remaining tool chain, of course.

查看更多
爷、活的狠高调
4楼-- · 2020-07-30 06:28

In your android-sdk directory, check the tools/proguard/bin directory: this includes some proguard executables (proguard is the tool used for obfuscation). I have never used them, but I'm convinced one of these executables can help you with your question (there is even one with a gui interface!).

查看更多
登录 后发表回答