65 lines
2.3 KiB
Bash
Executable File
65 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
||
# 遍历当前文件下所有子目录,生成dir_mapping对应的K -> V
|
||
|
||
# 过滤条件:需包含的路径&&
|
||
include_path=("src/" "java/")
|
||
|
||
# 过滤条件:不能包含的路径||
|
||
exclude_path=("com/nnbc123/app" "com/example/lib_encrypt" "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
|