Android动态混淆字典,渠道包随机生成不同的混淆字典

262 阅读1分钟

参考:juejin.cn/user/290234…

  • 增加aab、apk反编译的难度
  • 极大降低aab包查重率,避免上架Google Play因查重率过高,导致下架或封号问题
  • 每次生成字典不一致

每次混淆产生不一样的结果

java 在打包中和 CICD 中没有 python 方便,改写为 python 脚本。 设定好想要的行数,源字符,输出路径和输出文件名,和渠道标示 (类似渠道名称)

# coding=utf-8
import os
import pprint
import random
import io


NEED_GENERAL_LAGNUGAE = ['i','I','1','l']

LENGTH = 500
RES_PATH = "/Users/syan/temp/output_dict.txt"

count = 0
repeatCount = 0
list = []
while (count < LENGTH):
   width = random.randint(1, 7) + 4
   i = 0
   count +=1
   #用来区分渠道的 text ,传入 相关的 text 
   temp = "alipay"
   while (i < width):
      i += 1
      temp = temp + random.choice(NEED_GENERAL_LAGNUGAE)
   print("当前字母: %s" % temp)
   if temp in list:
       repeatCount += 1
       print("重复字母: %s" % temp)
       if repeatCount == 100:
           print("连续重复次数超过100次 已达到最大行数 无法继续生成")
           break
   else:
       list.append(temp)
       repeatCount = 0
f = io.open(r"/Users/syan/temp/output_dict.txt","w",encoding="utf-8")
for index in range(len(list)):
    f.write(list[i].decode('utf8'))
    f.write("\n".decode('utf8'))
f.close()