iOS 探讨之 代码混淆

本文详细剖析了iOS应用中代码混淆的实践,通过使用confuse.sh工具,结合func.list文件进行函数混淆,以增强应用的安全性。在过程中可能会遇到权限问题,如'Permission denied',但通过调整权限设置可以解决,确保混淆过程顺利进行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

阐述
没有绝对安全的系统,也没有黑客破不掉的系统,所需要的只是时间而已… But,当时间成本大于收益成本,聪明人是不会进行尝试。
为了所谓的“相对安全”,研究代码混淆也是必要的。

探讨
Step 1
创建 confuse.sh、 func.list
终端(Terminal)可以键入
touch confuse.sh
touch func.sh


Step 2
将 confuse.sh 、func.list 添加到工程中


Step 3
在 Build Phases 中添加 Run Script 来设置 程序启动时执行 confuse.sh
$PROJECT_DIR/confuse.sh


Step 4
在程序PCH中引入混淆作用的头文件
(如果程序没有PCH文件,可参考 https://blog.youkuaiyun.com/yanglei3kyou/article/details/45891267 )


Step 5
在 confuse.sh 文件中填写以下内容
#!/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 Project_codeObfuscation_h'
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

Step 6
在 func.list 中写出要混淆的函数名、变量名


Step 7
程序编译
若 Build 成功,可在 Show the Report navigator 选项卡中查看结果


如果Build 失败,提示 Permission denied,可在终端中修改 confuse.sh 的权限,再将程序编译进行结果确认
chmod 777 confuse.sh



资料
淘宝花钱买的最新版!需要的拿去! This asset obfuscates your code to make it harder for bad guys to reverse engineer your projects. Specifically designed for Unity, it seamlessly links in with its build process. The top priority of this package is to work straight out of the box with no extra steps required. While other obfuscators can stop a game from working, Beebyte's obfuscator looks for specific Unity related code that must be protected. The contents of your source files are unchanged, the obfuscation targets the compiled assembly. Features: - Supports IL2CPP - Supports Assembly Definition Files (Unity 2017.3+) - Removes Namespaces without any conflicts - Recognises Unity related code that must not be changed - Renames Classes (including MonoBehaviours) - Renames Methods - Renames Parameters - Renames Fields - Renames Properties - Renames Events - String literal obfuscation - Adds fake methods - Easy and extensive customisation using the Unity inspector window - Consistent name translations are possible across multiple builds and developers - Semantically secure cryptographic naming convention for renamed members The asset works for both Unity Free and Unity Pro version 4.2.0 onwards (including Unity 5 & 2017 & 2018). Build targets include Standalone, Android, iOS, WebGL, UWP. Other platforms are not guaranteed or supported but may become supported at a future date. IL2CPP builds are much harder to reverse engineer but strings and member information (class, method names etc) are visible in the global-metadata.dat file. Obfuscation will apply to this file adding further security. Why not complement your security with the Anti-Cheat Toolkit - a great third party asset. For more information about the Obfuscator, please see the FAQ
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值