Android混淆字典 附带生成脚本 |
您所在的位置:网站首页 › 安卓包名怎么写 › Android混淆字典 附带生成脚本 |
初到掘金 多多指教 看还没怎么有人说过 我来写个关于混淆字典的博文 1.什么是混淆字典?其实就是一个txt文件dictionarytext.txt 例如内容如下: IiII1I1iI iiIiI1 1IIII11i 1IIIiI111 iiiIII iIIIIi1 1II11IiiI II1i1 ....//大概5000行 每行都不重复在 proguard-rules中设置: -obfuscationdictionary dictionarytext.txt -classobfuscationdictionary dictionarytext.txt -packageobfuscationdictionary dictionarytext.txt这样混淆打包出来的代码就用上字典里的内容啦 辨识度直线down 拆包截图: 这样混淆后,是可以包括类名,方法名,一起混淆的,非常难辨认 但是如果你的字典是那种丧心病狂的内容比如阿拉伯文梵文不符合命名规则了,就只会改变包路径名,而不会类名方法名不会采用此字典 2.怎么获得(生成)混淆字典如果想拥有自己独一无二的字典 我用java写了一个脚本: import java.io.File; import java.io.FileOutputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Random; /** * Created by tomato 2021/12 * JAVA生成混淆字典 */ public class ProguardGenerateClass { //字典样本 private static List SOURCE = Arrays.asList("i", "I", "1", "l"); //字典行数 private static int LENGTH = 5000; //输出路径 private static final String ROOT_PATH = System.getProperty("user.dir") + "/app/"; //输出名称 private static final String FILE_NAME = "output_dict.txt"; private static Random random = new Random(); public static void main(String[] args) { List unicodeList = new ArrayList(SOURCE); List outputList = new ArrayList(); Collections.sort(unicodeList); File file = new File(ROOT_PATH, FILE_NAME); if (file.exists()) { System.out.println("文件已存在,删除"); file.delete(); } else { System.out.println("文件不存在"); } String encoding = "UTF-8"; int repeatCount = 0; try { FileOutputStream fileOutputStream = new FileOutputStream(file); int i = 0; while (i < LENGTH) { String tmp = ""; int width = random.nextInt(7) + 4; for (int j = 0; j < width; j++) { tmp = tmp + getRandomString(unicodeList); } if (!outputList.contains(tmp)) { i++; outputList.add(tmp); fileOutputStream.write(tmp.getBytes(encoding)); if (i < LENGTH) { //最后一行不输入回车 fileOutputStream.write('\n'); } repeatCount = 0; } else { repeatCount++; System.out.println("重复生成的字符串当前行数--->" + i + " 内容---> " + tmp); if (repeatCount == 10000) { System.out.println("连续重复次数超过10000次 已达到最大行数 无法继续生成"); break; } } } fileOutputStream.flush(); fileOutputStream.close(); } catch (Exception e) { e.printStackTrace(); } } private static String getRandomString(List list) { String tm; int s = random.nextInt(list.size()); tm = list.get(s); return tm; } }设定好想要的行数,源字符,输出路径和输出文件名 在Android studio中运行就ok了 你可能会遇到如下问题: Could not create task ':app:ProguardGenerateClass.main()'. > SourceSet with 在.idea的gradle.xlm下 添加一句话就好了 ...另外 github上很多现成的字典 我随便推荐一个 github.com/ysrc/Androi… |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |