Use proguard to confuse Java source code 1-interface operation usage

Source: Internet
Author: User

Java code is easily decompiled. The following uses proguard to protect our code:

Proguard has many options and is easy to confuse. Now I will write down my configuration (in actual use) for your reference.

 

1. Download proguard to http://proguard.sourceforge.net

(If you cannot download the proguardprogram, go to http://download.csdn.net/detail/odian1/4103373to download it)

2. Prepare your jar package. For example, test. jar.

3. Decompress proguard and run proguardgui. bat in the bin directory.

1



 

4. Run, click the "input/output" menu on the left, 2

 

5. Click "add input" on the right to add the jar package we want to mix, test. Jar

Click "add output" on the right to fill in the jar package we want to output (named casually). Here I write test_out.jar.

Note that you must manually enter the jar package.

6. Add the support library, and the box "library jars, wars, ears..." below.

Click "add" on the right ".

Note: It is best to copy the jar packages of all libraries of libraries in Java project in myeclipse to a directory, and then add these jar packages here, the myeclipse Environment supports jar packages in general, 3

 

 

7. After completing the above steps, it should be like 4, so it's almost the same

 

 

8. Click "shrinking" and set it to 5. (Set as needed. Here is my configuration)

 

 

9. Click "obfuscation" and set 6. (Set as needed. Here is my configuration)



 

10. Click "optimization" to set 7. (Set as needed. Here is my configuration)



 

11. click "process", and then click "Save configuration". In the displayed dialog box, enter the name of the configuration file to be saved (here my name is test. pro), and click "save ". 8



 

Some graphical settings have been completed.

 

12. Finally, add the class and method to be retained.

Use the editor to edit the saved "test. Pro". You can use Notepad for everything. After opening it, it should look like the following.

 

-Injars test. Jar
-Outjars test_out.jar

 

-Libraryjars 'C: \ Program Files (x86) \ Java \ jdk1.6.0 _ 10 \ JRE \ Lib \ RT. jar'
-Libraryjars Lib \ ant. Jar
-Libraryjars Lib \ aopalliance-1.0.jar
-Libraryjars Lib \ commons-dbcp-1.4.jar
-Libraryjars Lib \ commons-fileupload-1.2.1.jar
-Libraryjars Lib \ commons-io-1.4.jar

Support library package set by..., omitted

 

-Dontskipnonpubliclibraryclassmembers
-Dontshrink
-Useuniqueclassmembernames
-Keeppackagenames
-Keepattributes exceptions, innerclasses, signature, deprecated, sourcefile, linenumbertable, localvariable * Table, * annotation *, synthetic, enclosingmethod
-Keepparameternames
-Ignorewarnings

... We add the classes and methods to be maintained here. The statement is as follows. The red part is added.

 

-Keep class org. Bl. SOA. components. Constant .*{
Public <fields>;
Public <Methods>;
* ** Set *(***);
* ** Get *();

}

-Keep class org. Bl. hibernate .*{
Public <fields>;
Public <Methods>;
* ** Set *(***);
* ** Get *();
}

 

... Continue to add other classes and methods to be retained, and how much to write. I added all classes in test. jar.

 

... There are some automatically generated configurations later, so you don't need to worry about them.

...

 

 

13. Save the settings.

Open progrard again and run proguardgui. bat in the bin directory.

Click the first option "proguard", click "load configuration", and select the saved "test. Pro" for loading.

For example



 

14. Start mixing the code, click "process" on the right, and then click "Process !", For example



 

15. After the processing is complete, the output "test_out.jar" is a mixed jar package. You can use xjad anti-encoding to check the effect.

 

16. If there is a problem in the processing process, it is generally prompted that most of them are missing association classes. If there are fewer related classes, in the figure in step 1, add the missing support package.

Source: http://java-server.iteye.com/blog/1166114

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.