标签:art mod 不显示 ls命令 function 新建 blog and line
代码编译阶段将符号(方法名、属性名等)替换成随机生成的字符串
长话短说,直接上步骤。
TABLENAME=symbols
SYMBOL_DB_FILE="$PROJECT_DIR/CodeObfuscation/symbols"
STRING_SYMBOL_FILE="$PROJECT_DIR/CodeObfuscation/func.list"
HEAD_FILE="$PROJECT_DIR/CodeObfuscation/codeObfuscation.h"
export LC_CTYPE=C
#维护数据库方便日后作排重
createTable(){
echo "create table $TABLENAME(src text, des text);" | sqlite3 $SYMBOL_DB_FILE
}
insertValue(){
echo "insert into $TABLENAME values(‘$1‘ ,‘$2‘);" | sqlite3 $SYMBOL_DB_FILE
}
query(){
echo "select * from $TABLENAME where src=‘$1‘;" | sqlite3 $SYMBOL_DB_FILE
}
ramdomString(){
openssl rand -base64 64 | tr -cd ‘a-zA-Z‘ |head -c 16
}
rm -f $SYMBOL_DB_FILE
rm -f $HEAD_FILE
createTable
touch $HEAD_FILE
echo ‘#ifndef Demo_codeObfuscation_h
#define Demo_codeObfuscation_h‘ >> $HEAD_FILE
echo "//confuse string at `date`" >> $HEAD_FILE
cat "$STRING_SYMBOL_FILE" | while read -ra line; do
if [[ ! -z "$line" ]]; then
ramdom=`ramdomString`
echo $line $ramdom
insertValue $line $ramdom
echo "#define $line $ramdom" >> $HEAD_FILE
fi
done
echo "#endif" >> $HEAD_FILE
sqlite3 $SYMBOL_DB_FILE .dump
如何知道替换成功了呢?我们找到替换的方法名或属性名,点击跳转到定义,会跳转到codeObfuscation.h中,说明替换成功。
标签:art mod 不显示 ls命令 function 新建 blog and line
原文地址:https://www.cnblogs.com/Acee/p/11490944.html