Android 自定义混淆字典

添加下面的代码,用新的混淆字典,随机大小写字母组合

c 复制代码
package com.jiuhong.mbtirgtest.util;

import java.io.FileWriter;
import java.io.IOException;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;

public class ObfuscationDictionaryGeneratorUtil {

    public static void generateObfuscationDictionary(String filePath, int count) {
        Set<String> uniqueWords = new HashSet<>();  // 使用 Set 确保唯一性

        while (uniqueWords.size() < count) {
            uniqueWords.add(generateRandomWord(3, 10));
        }

        try (FileWriter writer = new FileWriter(filePath)) {
            for (String word : uniqueWords) {
                writer.write(word + "\n");
            }
            System.out.println("混淆字典已生成: " + filePath);
        } catch (IOException e) {
            System.err.println("生成混淆字典失败: " + e.getMessage());
        }
    }

    private static String generateRandomWord(int minLength, int maxLength) {
        Random random = new Random();
        int wordLength = random.nextInt(maxLength - minLength + 1) + minLength;
        StringBuilder word = new StringBuilder(wordLength);
        for (int i = 0; i < wordLength; i++) {
            char randomChar = (char) (random.nextBoolean() ? 'A' + random.nextInt(26) : 'a' + random.nextInt(26));
            word.append(randomChar);
        }
        return word.toString();
    }
}

生成字典文件

c 复制代码
        // 调用方法生成混淆字典
        String filePath = this.getFilesDir().getAbsolutePath() + "/obfuscation_dictionary.txt";
        
        int count = 10000; // 生成 10000 条记录
        ObfuscationDictionaryGeneratorUtil.generateObfuscationDictionary(filePath, count);

在Device Explorer找到这个文件

c 复制代码
/data/user/0/com.j.mt/files/obfuscation_dictionary.txt

拖到APP目录下

在混淆文件中添加规则

c 复制代码
#用于字段名和方法名混淆。
-obfuscationdictionary obfuscation_dictionary.txt
#用于类名混淆。
-classobfuscationdictionary obfuscation_dictionary.txt
#用于包名混淆。
-packageobfuscationdictionary obfuscation_dictionary.txt
相关推荐
alexhilton9 小时前
面向开发者的系统设计:像建筑师一样思考
android·kotlin·android jetpack
CYRUS_STUDIO18 小时前
用 Frida 控制 Android 线程:kill 命令、挂起与恢复全解析
android·linux·逆向
CYRUS_STUDIO18 小时前
Frida 实战:Android JNI 数组 (jobjectArray) 操作全流程解析
android·逆向
用户091 天前
Gradle Cache Entries 深度探索
android·java·kotlin
循环不息优化不止1 天前
安卓 View 绘制机制深度解析
android
叽哥1 天前
Kotlin学习第 9 课:Kotlin 实战应用:从案例到项目
android·java·kotlin
雨白1 天前
Java 线程通信基础:interrupt、wait 和 notifyAll 详解
android·java
诺诺Okami2 天前
Android Framework-Launcher-UI和组件
android
潘潘潘2 天前
Android线程间通信机制Handler介绍
android
潘潘潘2 天前
Android动态链接库So的加载
android