iOS Application Security
全书介绍了iOS Application开发过程中安全需要注意的地方。也有一些关于越狱相关知识的介绍。
otool -fh Snapchat 查看有几种架构
lipo -thin armv7 myBinary -output myBinary-thin 只保留armv7架构
otool -arch armv7s -l Snapchat 查看各段信息
cryptoff 16384
cryptsize 7995392
cryptid 1
iOS设备上启用debugserver, 并加载进程
./debugserver *:666 --attach=Snapchat
Mac设备lldb连接debugserver
lldb
platform select remote-ios
process connect connect://de.vi.ce.ip:666
也可以用usbmuxd
brew install usbmuxd
iproxy 1234 1234 &
process connect connect://127.0.0.1:1234
image list 查看内存地址
memory read --force --outfile /tmp/mem.bin --binary 0x00008000 0x007a8000 导出内存数据(未加密数据)
然后再开发机器上将未加密的数据替换加密部分数据
dd bs=1 seek=0x8000 conv=notrunc if=/tmp/mem.bin of=Snapchat-decrypted
otool -oV MobileMail 窥探二进制包
killall -HUP SpringBoard
数据安全
NSLog敏感信息,
Pasteboards清空
Cache清空,磁盘,禁用Cache, 设置Cache大小为nil
UITextField 自动补全泄露信息 setAutocorrectionType
UITextView setSecureTextEntry
滥用 NSUserDefaults
重要页面放后台后,会截图保存到磁盘,所以再放后台的时候要模糊处理。
禁用State Preservation. encodeRestorableStateWithCoder 与decodeRestorableStateWithCoder 否则会保存屏幕。
关闭iCloud
缓冲区溢出,堆,栈溢出
strcpy, strcat目标缓存去小于源缓冲区,就会溢出。使用的时候检测大小,或者使用安全的函数比如scrlcpy, strlcat
注意有符号为与无符号为的最大最小值,超过就会值溢出。比如不同类型直接强行转换一定注意。
分配内存的时候,一定要注意大小,必须是大于0,切小于INT_MAX
注入安全
输入内容要合法性验证
输出内容要encoding
注意sql注入,不要用format的sql字符串,要用?
谓词Predicate注入,不要用predicateWithFormat如, 要对pin进行合法性验证,或者不适应谓词
pred = [NSPredicate predicateWithFormat:@“pin LIKE %@”, [self.pin text]]; 当pin是*
pred = [NSPredicate predicateWithFormat:@“pin MATCHES %@”, [self.pin text]]; 当pin是.*
sqlite文件加密保护
值得大家阅读。