惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
V
Visual Studio Blog
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
B
Blog
I
InfoQ
博客园 - 三生石上(FineUI控件)
阮一峰的网络日志
阮一峰的网络日志
F
Fortinet All Blogs
H
Help Net Security
博客园 - Franky
宝玉的分享
宝玉的分享
博客园 - 司徒正美
C
Check Point Blog
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
MongoDB | Blog
MongoDB | Blog
云风的 BLOG
云风的 BLOG
A
About on SuperTechFans
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家

Wener Live & Life Blog

工具 - 工 与 具 《我把我的矜持都给了她》:第二章 - 故事的重新开始 我记录思考的方式简单总结 第一次尝试机器学习 为什么选择 Alpine Linux? 基于 SNI 实现无感全局代理 恢复群晖数据盘 迁移阿里云 CDN 到 Cloudflare CRM 实现经历 大师之路 2022上海封城日记 企业建站的基本前提考量 Love the World 数据同步模式 组建你自己的 NAS 服务器 2021 总结 从新学习 系统盘恢复 PostgreSQL ORDER BY+LIMIT 时的索引选择
解密 ClassFinal 加密的 Java Jar 包
2024-09-18 · via Wener Live & Life Blog
package main;

import net.roseboy.classfinal.JarDecryptor;
import net.roseboy.classfinal.util.EncryptUtils;
import net.roseboy.classfinal.util.StrUtils;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

public class DecryptClassFinal {
public static void main(String[] args) throws IOException {
String src =System.getProperty("user.dir") + "/tmp/META-INF/.classes";
String dst = System.getProperty("user.dir") + "/src/main/class";

File srcDir = new File(src);
JarDecryptor.getInstance();
// 默认 password 位置
String pass = Files.readString(Path.of(src+"/org.springframework.config.Pass"));
char[] password = EncryptUtils.md5(pass.toCharArray());

System.out.printf("src:%s\n", src);
System.out.printf("dst:%s\n", dst);
System.out.printf("password:%s\n", pass);

if (srcDir.isDirectory()) {
for (File file : srcDir.listFiles()) {
String fp = file.getName();
if (fp.startsWith("org.springframework")) {
continue;
}

byte[] fileBytes = Files.readAllBytes(file.toPath());
byte[] out = dec(password, fp, fileBytes);

String[] split = fp.split("[.]");
String fn = split[split.length-1];

String p = dst+"/"+ fp.substring(0, fp.lastIndexOf('.')).replaceAll("[.]", "/");
new File(p).mkdirs();
String f = p+"/"+ fn +".class";

System.out.println("Write to: "+f+" Len:"+out.length);
Files.write(new File(f).toPath(), out);
}
}

}

public static byte[] dec(char[] password, String fileName, byte[] bytes){
char[] pass;
pass = StrUtils.merger(new char[][]{password, fileName.toCharArray()});
return EncryptUtils.de(bytes, pass, 1);
}
}