简体   繁体   English

如何检测我的iOS应用程序已启用PIE / ASLR?

[英]How to detect that PIE/ASLR has been enabled for my iOS app?

I am enabling PIE (position-independent executable)/ASLR (address space layout randomization) for an iPhone app by using the "-w -pie" linking option flag. 我通过使用"-w -pie"链接选项标志为iPhone应用程序启用PIE(位置无关可执行文件)/ ASLR(地址空间布局随机化)。 Is there any way I can ensure that things are now set to work as advertised? 有什么方法可以确保现在的东西按照宣传的方式工作吗? I tried printing the address of a variable (Edit: and a function) with NSLog and it comes up the same each time. 我尝试用NSLog打印变量的地址(编辑:和一个函数) ,每次都是相同的。 Am I doing it right? 我做得对吗?

I know this thread is old, but there is no good answer yet in case someone else stumbles upon it. 我知道这个帖子已经老了,但是如果别人偶然发现它,那就没有好的答案了。 To check if the PIE flag is set is very simple, just run this command: 要检查PIE标志是否设置非常简单,只需运行以下命令:

otool -hv /path/to/App.app/app

Where [APP] is the executable created after building (not the ipa but the executable, binary file). 其中[APP]是构建后创建的可执行文件(不是ipa,而是可执行文件,二进制文件)。

You should see something like this: 你应该看到这样的东西:

Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
   MH_MAGIC     ARM         V7  0x00     EXECUTE    19       2708   NOUNDEFS DYLDLINK TWOLEVEL PIE

otool should be included in Xcode but if you don't have it you can install it in Xcode preferences > Downloads > Command Line Tools. otool应该包含在Xcode中,但是如果你没有它,你可以在Xcode首选项>下载>命令行工具中安装它。

检查函数地址,而不是变量地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检测用户是否为我的应用启用了iCloud? - How to detect if the user has iCloud enabled for my app? 如何检测在 iOS 8 上的包含应用程序中启用了应用程序扩展? - How to detect an app extension is enabled in containing app on iOS 8? 如何为启用了后台功能的iOS应用程序获取applicationWillTerminate通知? - How to get applicationWillTerminate Notification for an iOS App that has Backgrounding Enabled? iOS:检测WIFI是否已通过身份验证? - iOS: Detect if WIFI has been authenticated? 如何检测我的 iOS 设备是否有 LED 灯? - How do I detect if my iOS device has an LED light or not? 如何检测手机是否被移动 - how to detect if phone has been moved 如果尚未启用用户密码锁,我如何使用iOS磁盘加密保护数据? - How can I protect data using iOS on-disk encryption when the user passcode lock has not been enabled? 如何检测到由于应用程序中的自动锁定时间超出而导致手机被锁定? - How detect the phone has been locked because of autolock time exceeded in an app? 如何检测iOS应用是新安装还是以前已安装和删除 - How can I detect if an iOS app is a new install or had been installed and deleted previously 自上次应用程序启动以来,如何检测iphone是否已重新启动 - How can I detect whether the iphone has been rebooted since last time app started
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM