[转]Disabling ASLR on individual iOS applications when using iOS 6.0.1
ASLR: Address Space Layout Randomization
查看应用是否进行了 ASLR 保护的方法:otool -hv ${File-Path}
I recently encountered issues decrypting applications for security analysis using iOS 6.0.1. Previously this was trivial using the previous version (5.1.1), yet when performing the same procedure on 6.0.1 i was encountering decrypted binaries which were full of zeros.
After a while I discovered these issues were related to ASLR being used in applications compiled for later versions of iOS.
In this blog I will show the process of disabling ASLR on the free "Facebook" app available off the app store. This application has ASLR enabled which complicates decryption of the application using automated tools.
Tools required
otool
ldid for OS X
GDB for iOS
changemacho_flags.py
a jailbroken iphone and a copy of facebook off the app store
Details
Running the command
Desktop# otool -l Facebook |grep -A4 "LCENCRYPTIONINFO"
outputs:
cmd LCENCRYPTIONINFO
cmdsize 20
cryptoff 8192
cryptsize 10027008
cryptid 1
Indicating that the app is encrypted and when decrypted it is located in virtual memory from 0x3000(0x1000 + 0x2000) to 0x993000. However when we start the app, attach GDB and try to access the start address we find it throws an error:
(gdb) x/20x 0x3000
0x3000: Cannot access memory at address 0x3000
listing the memory that is mapped by the application:
(gdb) info mach-region 0x3000
Region from 0x94000 to 0xa26000 (r-x, max r-x; copy, private, not-reserved) (2 sub-regions)
This shows the executable is not located in memory where it should be indicating that ASLR is used.
ASLR is enabled for individual applications using the MHPIE flag located in the applications MACH-O header. By flipping this flag we turn off ASLR.
Copy the Facebook binary from the device to your desktop from the device directory
iPhone#/private/var/mobile/Application/[UUID]/Facebook.app
where [UUID] is the unique number of the directory for the app on the device.
Extract the entitlement xml file of the app:
Desktop# ldid -e Facebook > entitlements.xml
Disable the MHPIE bit using the changemachoflags.py
Desktop# python changemachoflags.py --no-pie Facebook
Re-sign the app
Desktop# ldid -Sentitlements.xml Facebook
backup the old copy on the device
iPhone# cp Facebook Facebook.bak
Copy the altered binary back to the device
now we reattach gdb and inspect the application memory again:
(gdb) x/20x 0x3000
0x3000: 0x00000000 0x00000000 0x00000000 0x00000000
0x3010: 0x00000000 0x00000000 0x00000000 0x00000000
0x3020: 0x00000000 0x00000000 0x00000000 0x00000000
0x3030: 0x00000000 0x00000000 0x00000000 0x00000000
0x3040: 0xe59d0000 0xe28d1004 0xe2804001 0xe0812104
(gdb) info mach-region 0x3000
Region from 0x3000 to 0x993000 (r-x, max r-x; copy, private, not-reserved)
Which confirms that ASLR is now disabled and we can now decrypt the application for further analysis.
[转]Disabling ASLR on individual iOS applications when using iOS 6.0.1的更多相关文章
- Execute Javascript in iOS Applications
In this tutorial, I have covered How to execute JavaScript in iOS / Objective-C. You can execute Jav ...
- iOS开发UI篇—ios应用数据存储方式(XML属性列表-plist)
iOS开发UI篇—ios应用数据存储方式(XML属性列表-plist) 一.ios应用常用的数据存储方式 1.plist(XML属性列表归档) 2.偏好设置 3.NSKeydeArchiver归档(存 ...
- ios标准开发者账号 ios企业开发者账号的区别总结
ios标准开发者账号 ios企业开发者账号的区别总结 ios标准开发者项目 1.ios标准开发者项目账号可以发布到app store 2.ios标准开发者项目分为两种:①个人开发者②公司/机构开发 ...
- iOS学习7:iOS沙盒(sandBox)机制(一)之获取沙盒路径及目录说明(转)
转:http://my.oschina.net/joanfen/blog/151145 一.iOS沙盒机制 iOS的应用只能访问为该应用创建的区域,不可访问其他区域,应用的其他非代码文件都存在此目录下 ...
- iOS开发UI篇—IOS开发中Xcode的一些使用技巧
iOS开发UI篇—IOS开发中Xcode的一些使用技巧 一.快捷键的使用 经常用到的快捷键如下: 新建 shift + cmd + n 新建项目 cmd + n 新建文 ...
- iOS开发UI篇—iOS开发中三种简单的动画设置
iOS开发UI篇—iOS开发中三种简单的动画设置 [在ios开发中,动画是廉价的] 一.首尾式动画 代码示例: // beginAnimations表示此后的代码要“参与到”动画中 [UIView b ...
- iOS开发UI篇—ios应用数据存储方式(偏好设置)
iOS开发UI篇—ios应用数据存储方式(偏好设置) 一.简单介绍 很多iOS应用都支持偏好设置,比如保存用户名.密码.字体大小等设置,iOS提供了一套标准的解决方案来为应用加入偏好设置功能 每个应用 ...
- iOS开发UI篇—ios应用数据存储方式(归档)
iOS开发UI篇—ios应用数据存储方式(归档) 一.简单说明 在使用plist进行数据存储和读取,只适用于系统自带的一些常用类型才能用,且必须先获取路径相对麻烦: 偏好设置(将所有的东西都保存在同 ...
- Xamarin.iOS调试提示需要iOS SDK
Xamarin.iOS调试提示需要iOS SDK 错误信息:The version of Xamarin.iOS requires th iOS 9.3 SDK (shipped with Xco ...
随机推荐
- 至尊快速,国产语言RPP 1.83强势来袭
以下是 R++的性能測试数据:(奔腾 1.86GHZ,測试 3 次取平均值) 执行效率: R++的内部结构和 C++大致同样,所以理论上 R++能够达到和 C++一样的执行速度,眼下 R++已开启汇编 ...
- 插件式Web框架
转载构建高性能插件式Web框架 基于MVC插件模式构建支持数据库集群.数据实时同步.数据发布与订阅的Web框架系统.如下图: 1.基于插件式开发 采用插件模式开发的优点是使得系统框架和业务模式有效地进 ...
- Zepto Code Rush 2014——Dungeons and Candies
题目链接 题意: k个点,每一个点都是一个n * m的char型矩阵.对与每一个点,权值为n * m或者找到一个之前的点,取两个矩阵相应位置不同的字符个数乘以w.找到一个序列,使得全部点的权值和最小 ...
- UIDocumentInteractionController 文件预览
//创建并从底部弹出来 - (void)viewDidLoad { [super viewDidLoad]; [self setupDocumentControllerWithURL:fileURL] ...
- ThinkPHP神秘应用架构扩展
ThinkPHP应用模式提供了机会,改变核心框架.它可以让你的应用程序,以适应环境和其他许多不同的需求. 每一个应用模式都有自己的模式定义文件,相对与ThinkPHP3.1版本号.ThinkPHP3. ...
- 【百度地图API】如何批量转换为百度经纬度
原文:[百度地图API]如何批量转换为百度经纬度 摘要: 百度地图API的官网上提供了常用坐标转换的示例.但是,一次只能转换一个,真的非常麻烦!!这里结合了官方的示例,自制一个批量转换工具,供大家参考 ...
- REUSEADDR 选项
一般而言,对于处理2MSL状态的套接字(一般为服务端套接字)是不允许接受从同一客户端重新发起一个新的连接的,但是套接字编程系统接口允许应用程序通过设置一个REUSEADDR选项,使处于2MSL状态的套 ...
- iOS_22自定义键盘工具栏
最后效果图: Main.storyboard KeyboardTool.xib watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcHJlX2VtaW5lbnQ ...
- asp.net mvc3 的数据验证(一)
原文:asp.net mvc3 的数据验证(一) 对于web开发人员来说,对用户输入的信息进行验证是一个重要但是繁琐的工作,而且很多开发者都会忽略.asp.net mvc3框架使用的是叫做“ ...
- Postman (Chrome插件)
接口测试从未如此简单 - Postman (Chrome插件) Posted on 2015-01-16 15:50 WadeXu 阅读(468) 评论(7) 编辑 收藏 接口测试从未如此简单 - P ...