使用 proguard 进行混淆

发布于 2024-12-24 03:29:00 字数 2076 浏览 1 评论 0原文

嗨,我已经使用 proguard 来混淆我的 java 类。完成混淆过程后,我使用 java 反编译器来反编译我的 java 类,当时我的类名、方法和变量没有重命名,并且打开时没有任何名称更改。在我编写代码时给出。我不知道我在哪里做错了配置文件

injars 'E:\vsd_02\workplace\pro\dist\pro.jar'
-outjars 'E:\vsd_02\workplace\pro\dist\pro_out.jar'

-libraryjars 'C:\Program Files\Java\jre7\lib\rt.jar'

-forceprocessing
-printmapping 'E:\vsd_02\workplace\pro\dist\pro.map'
-repackageclasses ''
-renamesourcefileattribute SourceFile
-verbose
-dontwarn


# Keep - Applications. Keep all application classes, along with their 'main'
# methods.
-keepclasseswithmembers public class * {
    public static void main(java.lang.String[]);
}

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

# Also keep - Serialization code. Keep all fields and methods that are used for
# serialization.
-keepclassmembers class * extends java.io.Serializable {
    static final long serialVersionUID;
    static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

# Also keep - Bean classes. Keep all specified classes, along with their getters
# and setters.
-keep class * {
    void set*(***);
    void set*(int,***);
    boolean is*();
    boolean is*(int);
    *** get*();
    *** get*(int);
}

# 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>;
}

hi i have used proguard to obfuscate my java class.After completing the obfuscation process i used java decompiler to decompile my java class at that time my class names,methods and variables did not renamed and it was opened without any change in the names what i given while i writting the code.i don't know where i did wrong the congiguration file was

injars 'E:\vsd_02\workplace\pro\dist\pro.jar'
-outjars 'E:\vsd_02\workplace\pro\dist\pro_out.jar'

-libraryjars 'C:\Program Files\Java\jre7\lib\rt.jar'

-forceprocessing
-printmapping 'E:\vsd_02\workplace\pro\dist\pro.map'
-repackageclasses ''
-renamesourcefileattribute SourceFile
-verbose
-dontwarn


# Keep - Applications. Keep all application classes, along with their 'main'
# methods.
-keepclasseswithmembers public class * {
    public static void main(java.lang.String[]);
}

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

# Also keep - Serialization code. Keep all fields and methods that are used for
# serialization.
-keepclassmembers class * extends java.io.Serializable {
    static final long serialVersionUID;
    static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

# Also keep - Bean classes. Keep all specified classes, along with their getters
# and setters.
-keep class * {
    void set*(***);
    void set*(int,***);
    boolean is*();
    boolean is*(int);
    *** get*();
    *** get*(int);
}

# 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>;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

徒留西风 2024-12-31 03:29:00

此设置已经保留了所有类的原始名称(如文档所示):

# Also keep - Bean classes. Keep all specified classes, along with their getters
# and setters.
-keep class * {
    .....
}

另请检查 ProGuard 手册 >故障排除>>处理后的意外观察结果> 变量名称未被混淆

This setting already keeps all classes with their original names (as documented):

# Also keep - Bean classes. Keep all specified classes, along with their getters
# and setters.
-keep class * {
    .....
}

Also check the ProGuard manual > Troubleshooting > Unexpected observations after processing > Variable names not being obfuscated.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文