Last active
January 5, 2019 06:30
-
-
Save zhangkn/dc2f5e5a883cc506d20fc6285775c313 to your computer and use it in GitHub Desktop.
简易的混淆脚本,主要思路是把敏感方法名集中写在一个名叫func.list的文件中,逐一#define成随机字符,追加写入.h。------痛点就是一个一个手写
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
TABLENAME=symbols | |
SYMBOL_DB_FILE="symbols" | |
STRING_SYMBOL_FILE="func.list" | |
HEAD_FILE="$PROJECT_DIR/$PROJECT_NAME/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 | |
echo "#define _$line _$ramdom" >> $HEAD_FILE | |
fi | |
done | |
echo "#endif" >> $HEAD_FILE | |
sqlite3 $SYMBOL_DB_FILE .dump |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://blog.csdn.net/yiyaaixuexi/article/details/29201699