Java code obfuscation and encryption-jocky

Source: Internet
Author: User

 

1.1 What is jocky?

We know that Java is a cross-platform programming language. Its source code (. Java file) is compiled into a bytecode (. Class file) unrelated to the platform, and then dynamically linked at runtime. In this way, the compiled class file will contain a signed table, so that the Java program is easily decompiled. I believe that every Java developer has used anti-compilers such as Jad to decompile Java class files, so as to observe the program structure and implementation details. As a result, developers often need to address how to effectively protect customers' business investment for Java applications that require strict intellectual property protection. As a result, the Java obfuscation compiler is used to disrupt the symbolic information in the class file, making reverse engineering very difficult. Jocky is such an excellent Java obfuscation compiler.

1.2 Why do I need jocky?

At present, there are many commercial or open-source obfuscation compilers in the industry, but they generally have some problems. In general, the existing obfuscators confuse compiled class files. In this way, the compilation and obfuscation steps are required. In fact, not all symbols need to be confused. If you are developing a class library or some classes need to be dynamically loaded, those public APIs (or the APIs that are published by publish) must keep the symbols unchanged, other people can use your class library. The existing obfuscators provide a GUI or script to configure the symbol names to be retained. However, if the program is large, the configuration becomes complicated. Once the program is modified, the configuration must be performed again. Some obfuscators can adjust the byte code sequence to make decompilation more difficult. However, I have experienced program running errors after obfuscation. The biggest difference between jocky and other obfuscation compilers is that it is directly written from the source code, that is, the compilation process itself is a obfuscation process.

1.3 How does jocky work?

The jocky obfuscation compiler is based on the Java compiler (javac) provided by Sun JDK. It modifies the code generation process and obfuscation the intermediate code generated by the compiler, finally, generate the class file. In this way, only one step is required for compilation and obfuscation. In addition, you can insert the symbol retention command in the source program to control which symbols need to be retained, and combine the obfuscation process with the development process without separate configuration.

The above is an excerpt

Download and configure jocky

The download link on operamasks has expired. Please go to csdn to search for the download link.

1. After the download is complete, decompress the package named org. apusic. jocky_1.0.3 and place the folder in the plugins folder of the eclipse root directory (similar to myeclipse and eclipse ).

2. Restart eclipse, right-click a project file, and the jocky option is displayed.

 

3. Set jocky settings first, and then perform jocky now !. The following figure shows the settings page.

Enable jocky multiple selection box selected

Jocky Build File creates an XML file in the project and obfuscated according to the configuration in it.

Scramble level is the code level for obfuscation, including none, Private, package, protected, public, and all. It obfuscation the method code modified by the corresponding modifier in the Java file according to the settings.

Target VM is a Java Virtual Machine version with 1.4 and 1.5. Generally, 1.5 is used.

Output directory is the Output Folder under the project root directory.

Click "OK" to automatically generate an XML file based on the project settings.

4. jocky_build.xml is actually an ant build file which is automatically generated by the system.

  1. <Pathelement location = "bin"/> <pathelement location = "XXX. jar "/> this type of label indicates the jar package required for project compilation. Because it is automatically generated, you should ignore this. If an error such as the relevant package cannot be found, there may be a problem with the location path.If you set the user name to the Chinese name when installing the system and use Maven, the download path of the maven jar package is set to the default $ {user }/. m2/Repository/, the path here in jocky may be faulty, and the username of the Chinese name may be garbled or disappear, modify the maven configuration XML file to modify the download path <localrepository> [Self-specified path] </localrepository>.
  2. <Javac destdir = "$ {jocky. Output. dir}/bin" target = "$ {target }"Encoding = "UTF-8"> If there is a Chinese name in the code, you must manually set the encoding. By default, no.
  3. <SRC Path = "src"/> set the directory of the source file, because sometimes we only want to output some packages in the src directory instead of all.

5. Last jocky now! The generated. Class file should be packaged by command. The next article will briefly introduce it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.