chore:调整混淆脚本
This commit is contained in:
@@ -279,14 +279,14 @@ android.applicationVariants.all { variant ->
|
||||
print("variant.name=" + variant.name)
|
||||
if (variant.name.contains("release") || variant.name.contains("Release")) {
|
||||
androidJunkCode.configMap.put(variant.name, {
|
||||
packageBase = "app.yinm.plugin.ui" //生成java类根包名
|
||||
packageBase = "app.yinm.a.u" //生成java类根包名
|
||||
packageCount = 30 //生成包数量
|
||||
activityCountPerPackage = 30 //每个包下生成Activity类数量
|
||||
excludeActivityJavaFile = false
|
||||
//是否排除生成Activity的Java文件,默认false(layout和写入AndroidManifest.xml还会执行),主要用于处理类似神策全埋点编译过慢问题
|
||||
otherCountPerPackage = 50 //每个包下生成其它类的数量
|
||||
methodCountPerClass = 20 //每个类下生成方法数量
|
||||
resPrefix = "yinmchat_" //生成的layout、drawable、string等资源名前缀
|
||||
resPrefix = "ymc_" //生成的layout、drawable、string等资源名前缀
|
||||
drawableCount = 300 //生成drawable资源数量
|
||||
stringCount = 300 //生成string数量
|
||||
})
|
||||
@@ -299,5 +299,15 @@ xmlClassGuard {
|
||||
//用于增量混淆的 mapping 文件
|
||||
mappingFile = file("xml-class-mapping.txt")
|
||||
//更改manifest文件的package属性,即包名
|
||||
packageChange = ["com.nnbc123.app": "app.yinm.chat"]
|
||||
packageChange = ["com.nnbc123.app" : "app.yinm.chat",
|
||||
"com.nnbc123.core" : "app.yinm.cc",
|
||||
"com.nnbc123.library": "app.yinm.ll"]
|
||||
|
||||
moveDir = []
|
||||
|
||||
generateObfuscateClassStartName = "ZZZZ"
|
||||
|
||||
randomObfuscatePackageNamePlaceholder = ["app.yinm.a.#", "app.yinm.a.a.#", "app.yinm.a.b.#", "app.yinm.a.c.#", "app.yinm.a.d.#", "app.yinm.a.e.#"]
|
||||
|
||||
randomObfuscateClassNamePlaceholder = ["#", "#1", "#2", "#3", "#4", "#5", "#6", "#7", "#8", "#9"]
|
||||
}
|
||||
|
2
app/xml-class-mapping.txt
Normal file
2
app/xml-class-mapping.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
dir mapping:
|
||||
class mapping:
|
64
gen_dir_mapping.sh
Executable file
64
gen_dir_mapping.sh
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
# 遍历当前文件下所有子目录,生成dir_mapping对应的K -> V
|
||||
|
||||
# 过滤条件:需包含的路径&&
|
||||
include_path=("src/" "java/")
|
||||
|
||||
# 过滤条件:不能包含的路径||
|
||||
exclude_path=("com/nnbc123/app" "bean" "entity" "result" "ktx" "ext" "src/test" "src/androidTest")
|
||||
|
||||
# 过滤条件:判断是否需要混淆(包中包含这些文件)
|
||||
file_extensions=("java" "kt")
|
||||
|
||||
# 决定了输出位置(K):输出这个路径后的路径
|
||||
start_path="java/"
|
||||
|
||||
# 混淆后的包前缀(随机获取)
|
||||
package_array=("app.yinm.b." "app.yinm.b.a." "app.yinm.b.b." "app.yinm.b.c." "app.yinm.b.d." "app.yinm.b.e." "app.yinm.b.f." "app.yinm.b.g.")
|
||||
#package_array=("app.yinm.ll." "app.yinm.ll.aa." "app.yinm.ll.bb." "app.yinm.ll.cc." "app.yinm.ll.dd." "app.yinm.ll.ee.")
|
||||
#package_array=("app.yinm.cc." "app.yinm.cc.aa." "app.yinm.cc.bb." "app.yinm.cc.cc." "app.yinm.cc.dd." "app.yinm.cc.ee.")
|
||||
#package_array=("app.yinm.cu." "app.yinm.cu.aa." "app.yinm.cu.bb." "app.yinm.cu.cc." "app.yinm.cu.dd." "app.yinm.cu.ee.")
|
||||
|
||||
touch dir_mapping.txt
|
||||
touch move_dir.txt
|
||||
|
||||
find_include=""
|
||||
for a in "${include_path[@]}"; do
|
||||
find_include+=" -path \"*$a*\""
|
||||
done
|
||||
|
||||
find_exclude=""
|
||||
for b in "${exclude_path[@]}"; do
|
||||
find_exclude+=" -not -path \"*$b*\""
|
||||
done
|
||||
|
||||
# 构造文件扩展名参数
|
||||
file_ext_args=()
|
||||
for ext in "${file_extensions[@]}"; do
|
||||
file_ext_args+=("-o" "-name" "*.$ext")
|
||||
done
|
||||
# 删除第一个 -o
|
||||
file_ext_args=("${file_ext_args[@]:1}")
|
||||
|
||||
# 将 file_ext_args 转换为字符串
|
||||
file_ext_args_str=$(IFS=" "; echo "${file_ext_args[*]}")
|
||||
|
||||
# 使用find命令遍历子目录,找到符合条件的目录
|
||||
eval "find . -type d $find_include $find_exclude -exec sh -c 'test -n \"\$(find "{}" -maxdepth 1 -type f \( $file_ext_args_str \))\"' \; -print" | while IFS= read -r dir; do
|
||||
if [[ "$dir" == *"$start_path"* ]]; then
|
||||
key=$(echo "$dir" | awk -F "$start_path" '{print $NF}' | tr '/' '.')
|
||||
else
|
||||
key=$(echo "$dir" | tr '/' '.')
|
||||
fi
|
||||
|
||||
value=$(echo "$key" | md5 | sed 's/[0-9]//g')
|
||||
|
||||
random_index=$((RANDOM % ${#package_array[@]}))
|
||||
random_package=${package_array[$random_index]}
|
||||
result="$key -> $random_package$value"
|
||||
echo $result
|
||||
echo $result >> dir_mapping.txt
|
||||
move_dir="\"$key : $random_package$value\","
|
||||
echo $move_dir
|
||||
echo $move_dir >> move_dir.txt
|
||||
done
|
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
package_array=("" "app.yinm.chat.a1." "app.yinm.chat.b2." "app.yinm.room.aa." "app.yinm.room.aa.bd." "app.yinm.room.aa.db." "app.yinm.room.bb." "app.yinm.room.bb.ww." "app.yinm.room.bb.mm.")
|
||||
package_array=("app.yinm.b." "app.yinm.b.a." "app.yinm.b.b." "app.yinm.b.c." "app.yinm.b.d." "app.yinm.b.e.")
|
||||
same_name_files=$(cat same_name_file.txt)
|
||||
touch move_dir_map.txt
|
||||
cat /dev/null > move_dir_map.txt
|
||||
|
Reference in New Issue
Block a user