ProGuard 4.2 处理SSH项目源码

本文介绍了如何使用ProGuard 4.2工具处理SSH项目的源码。详细步骤包括:设置输入输出路径、选择库文件、设置缩小、混淆和保留属性等选项,以及处理后的效果和可能出现的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

假设Java安装在C:\Program Files\Java,Tomcat安装在:D:\apache-tomcat-6.0.35,要处理的SSH项目部署在D:\apache-tomcat-6.0.35\webapps\MySSHWeb。首先解压ProGuard 4.2,得到其lib目录下的proguardgui.jar、proguard.jar和retrace.jar三个文件;在同一目录下建立脚本文件start.bat,文件内容为:java -Xms512m -Xmx512m -jar proguardgui.jar。运行start.bat打开ProGuard,然后开始设置:

1:在Input/Output页进行设置:
   Add input...,输入D:\apache-tomcat-6.0.35\webapps\MySSHWeb\WEB-INF\classes
   Add output...,输入D:\apache-tomcat-6.0.35\webapps\MySSHWeb\WEB-INF\classes_ok
   Add...,输入D:\apache-tomcat-6.0.35\lib
   Add...,输入D:\apache-tomcat-6.0.35\webapps\MySSHWeb\WEB-INF\lib

2: 在Shrinking页进行设置:
   取消Applications,选中Library
   Add...,Comments为Keep Hibernate PO,Extends/implements class为java.io.Serializable
   Add field...,点OK
   Add method...,点OK
   最后点OK

3: 在Obfuscation页进行设置:
   选中Keep attributes

4: 在Information页进行设置:
   选中Target,下拉选择1.5

5: 在Process页,点击Process!开始处理

最后可以得到处理后的classes,覆盖到D:\apache-tomcat-6.0.35\webapps\MySSHWeb\WEB-INF\classes下即可。偶尔会出现个别文件有错,可以直接将对应的原文件覆盖过来。最终处理的效果不是很好,有待进一步研究。最终的配置文件如下所示:

-injars 'D:\apache-tomcat-6.0.35\webapps\MySSHWeb\WEB-INF\classes_bak'
-outjars classes_bak_yes

-libraryjars 'C:\Program Files\Java\jre6\lib\rt.jar'
-libraryjars 'D:\apache-tomcat-6.0.35\lib'
-libraryjars 'D:\apache-tomcat-6.0.35\webapps\MySSHWeb\WEB-INF\lib'

-target 1.5
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod


# Keep Hibernate PO
-keep class * extends java.io.Serializable {
    <fields>;
    <methods>;
}

# Keep - Library. Keep all public and protected classes, fields, and methods.
-keep public class * {
    public protected <fields>;
    public protected <methods>;
}

# Also keep - Enumerations. Keep the special static methods that are required in
# enumeration classes.
-keepclassmembers class * extends java.lang.Enum {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

# Also keep - Database drivers. Keep all implementations of java.sql.Driver.
-keep class * extends java.sql.Driver

# Also keep - Swing UI L&F. Keep all extensions of javax.swing.plaf.ComponentUI,
# along with the special 'createUI' method.
-keep class * extends javax.swing.plaf.ComponentUI {
    public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent);
}

# Keep names - Native method names. Keep all native class/method names.
-keepclasseswithmembers,allowshrinking class * {
    native <methods>;
}

# Remove - System method calls. Remove all invocations of System
# methods without side effects whose return values are not used.
-assumenosideeffects public class java.lang.System {
    public static long currentTimeMillis();
    static java.lang.Class getCallerClass();
    public static int identityHashCode(java.lang.Object);
    public static java.lang.SecurityManager getSecurityManager();
    public static java.util.Properties getProperties();
    public static java.lang.String getProperty(java.lang.String);
    public static java.lang.String getenv(java.lang.String);
    public static java.lang.String mapLibraryName(java.lang.String);
    public static java.lang.String getProperty(java.lang.String,java.lang.String);
}

# Remove - Math method calls. Remove all invocations of Math
# methods without side effects whose return values are not used.
-assumenosideeffects public class java.lang.Math {
    public static double sin(d

Proguard4.2.zip(java编码混淆器)<br>doc是4.0的doc<br>jar包是1.4.2<br><br><br>ProGuard, Java class file shrinker, optimizer, and obfuscator<br>=============================================================<br><br>This distribution contains the following directories:<br><br>- lib : the main jars, compiled and ready to use with "java -jar ...."<br>- docs : the complete documentation, licenses, etc. in html format<br>- examples : some example configuration files<br>- src : the source code<br><br><br>The best place to start is docs/index.html<br><br><br>Example<br>=======<br><br>If you want to give ProGuard a spin right away, try processing the jar itself:<br><br> cd examples<br> java -jar ../lib/proguard.jar @proguard.pro<br><br>The resulting proguard_out.jar contains the same application, but it's a lot<br>smaller!<br><br><br>Development<br>===========<br><br>If you're interested in changing and extending ProGuard, you can start by<br>compiling the source code yourself:<br><br> mkdir classes<br> javac -sourcepath src -d classes src/proguard/ProGuard.java<br> javac -sourcepath src -d classes src/proguard/retrace/ReTrace.java<br> javac -sourcepath src -d classes src/proguard/gui/ProGuardGUI.java<br><br>If you want to compile the ProGuard Ant task as well:<br><br> javac -sourcepath src -d classes -classpath lib/ant.jar \<br> src/proguard/ant/ProGuardTask.java<br><br>If you want to compile the JME WTK obfuscator plug-in:<br><br> javac -sourcepath src -d classes -classpath wtklib/kenv.zip \<br> src/proguard/wtk/ProGuardObfuscator.java<br><br>Note that you'll have to install Ant and the J2ME WTK yourself.<br><br>Enjoy!<br><br>http://proguard.sourceforge.net/<br><br>Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值