本地存储安全
本地数据存储考虑的两个问题
如何存储信息
何时存储信息
NSUserDafaults
folder/to/AppData/Library/Preferences/[BundleID].plist
配置信息
用户数据
KeyChain
网络请求缓存
URL Loading API
HyBird
NSURLRequestReloadlgnoringLocalCacheData
NSURLRequestReloadlgnoringCacheData
离线网站缓存
网站源码泄露
关键业务逻辑
加密
验证
NSURLConnectionDelegate
1
connection didFailWithError:(NSError*)error
该方法为连接失败的回调,若证书验证失败,会触发该方法。
2
connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpae*)protectionSpac;
声明对连接作认证,返回YES。
3
connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge*)challenge
当收到HTTPS服务端认证的challenge时回调方法,在该方法中实现对服务端证书的认证。
4
-(BOOL)shouldTrustProtectionSpace:(NSURLProtectionSpace*)protectionSpace;
证书认证的具体表现,非协议方法,需自行实现。
AFNetworkinng
1
[AFHTTPSessionManager manager].securityPolicy = [self cutomSeucurityPolicyWithCertName@"pa18"];
设定安全策略未读取指定证书文件进行证书验证
2
AFSecurityPolicy*securityPolicy = [AFSecurityPolicy policyWithPinning Mode:AFSSLPinningModeCertificate];
进行SSL证书认证
源码安全
日志打印的抹除
无论设备是否越狱,都可以轻松获取设备日志信息,可使用宏定义在Release版本中抹除打印语句
代码混淆
Control Flow Flattening
Instructions Substitution
Bogus Control Flow
方法名混淆
字符串加密
Strings
所有的字符串 @“”
加密后编码,使用时动态解密。
反调试
lldb
ptrace()
实时监控应用进程加载的动态库
检测方法
开发者自查
/Application/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/路径下有无Library文件夹
在Gatekeeper打开的情况下执行spctl --assess --verbose /Applications/Xcode.app
ipa静态检测
strings [executable file] | grep "http://init.iCloud-analysis.com"