然后将混淆脚本写入confuse.sh文件里面
!/usr/bin/env bash
TABLENAME=symbols
SYMBOL_DB_FILE="$PROJECT_DIR/$PROJECT_NAME/Config/symbols"
STRING_SYMBOL_FILE="$PROJECT_DIR/$PROJECT_NAME/Config/func.list"
HEAD_FILE="$PROJECT_DIR/$PROJECT_NAME/Config/TestCodeConfuscation.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 TestCodeConfuseUse_TestCodeConfuscation_h
define TestCodeConfuseUse_TestCodeConfuscation_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
-------------此脚本来自念茜的微博
2.然后将此Config导入Xcode项目里面,在设置Run Script
3.然后command + B ,发现运行报错(Permission denied)
解决方案:
5.最后通过class-dump反编译回来的方法名是混淆之后的方法名。
网友评论