Project

General

Profile

Feature #1724

BS端代码优化-代码加密

Added by yanwei li about 3 years ago. Updated over 1 year ago.

Status:
Resolved
Priority:
Normal
Assignee:
yanwei li
Target version:
Start date:
10/18/2021
Due date:
10/22/2021
% Done:

0%

Estimated time:
Defect version:

Description

加密有两种方法
1、对class文件进行加密,加密方式有很多种,简单的可以进行异或加密,也可以进行RSA加密,但是加密后需要自定义ClassLoader,
且解密过程这部分代码无法加密,所以反编译这部分代码后即可找到揭秘过程
2、使用混淆器,使用最多的工具是ProGuard。
ProGuard是一个免费的Java类文件的压缩,优化,混肴器。它删除没有用的类,字段,方法与属性。使字节码最大程度地优化,
使用简短且无意义的名字来重命名类、字段和方法。

可行性分析:
ProGuard在网上有大量的使用教程,先学习使用ProGuard工具,看看混淆后的效果如何


Files

压缩前.jpg (88.6 KB) 压缩前.jpg 加密前包下的类名 yanwei li, 10/26/2021 03:19 PM
压缩后.jpg (68.9 KB) 压缩后.jpg 加密后包下的类名 yanwei li, 10/26/2021 03:20 PM
加密.jpg (104 KB) 加密.jpg 加密后类中的成员变量 yanwei li, 10/26/2021 03:23 PM

History

#1

Updated by yanwei li about 3 years ago

  • Status changed from New to In Progress
#2

Updated by yanwei li about 3 years ago

ProGuard用到的语法配置:
-keep public class com.demo.listener.** {*;}
-keep public class com.demo.ykyt.** {*;}
-keep public class com.demo.servlet.** {*;}
-keep public class com.demo.sql.JDBCUtils
-keep public class com.demo.tools.IdWorker
-keep public class com.demo.tools.GetIPTool
-keep public class com.demo.tools.ExcelException
-keep public class com.demo.tools.FromDbToExcel
-keep public class com.demo.tools.ExcelUtils
-keep class WebServer.** {*;}

#3

Updated by yanwei li about 3 years ago

类名及其成员变量、方法名的加密替换目前已实现,后续需要对加密后的文件进行替换测试

#4

Updated by yanwei li about 3 years ago

测试结果:
志显示加载C3P0数据库连接池出现问题,如下
A C3P0Registry mbean is already registered. This probably means that an application using c3p0 was undeployed, but not all PooledDataSources were closed prior to undeployment. This may lead to resource leaks over time. Please take care to close all PooledDataSources.

猜测原因可能是涉及到C3P0数据库连接的类因为被加密替换了变量、方法名后,配置文件无法识别并加载导致
在选择哪些类需要混淆替换需要考虑清楚

#5

Updated by xiangyang li over 1 year ago

  • Status changed from In Progress to Resolved

Also available in: Atom PDF