Source Link: http://www.saurik.com/id/8

Due to popular demand, I am putting some of the content I have written for the Cydia information portal here on my website so people can link to it directly. Given the original distribution medium, the material is therefore quite condensed. If I have time I may flesh out more details.

Starting with the recent beta releases of the iPhoneOS, Apple has started requiring that all code on the device is signed. This is mostly to make it impossible for programs running through Apple's AppStore to download more software and run it (so no competition for AppStore).

In order to get around this (and thereby to install our own code onto the device) the iPhone Dev Team has patched the signature verification out of the kernel. However, another half of the codesign problem is that the binary contains a number of SHA1 verification hashes that are checked in numerous locations throughout the kernel. Patching this out is A) difficult (especially to track as Apple makes changes) and B) of marginal benefit as adding these hashes is easy. This means you do still have to at least pay lipservice to the code signature process. There are currently three viable options.

Option #1: Self-Signing

This method is the simplest to understand: using Apple's codesign tool to sign the binary. Because the signature verification checks have been hacked out of the kernel, you can use any signature to do this, not just ones that are approved by Apple's developer program. For instructions on how to make a self-signing certificate you can read this article from Apple's website: Obtaining a Signing Identity.

mac$ platform=/Developer/Platforms/iPhoneOS.platform mac$ allocate=${platform}/Developer/usr/bin/codesign_allocate mac$ export CODESIGN_ALLOCATE=${allocate} mac$ codesign -fs "Name" Program mac$ scp Program mobile@iphone:

Option #2: Pseudo-Signing

For me, the previous option just doesn't work. I do not use Macs to do my development and the entire codesign path requires not only a Mac but console access because codesign is, at some level, a graphical utility (the way it uses Keychain to get the signatures may prompt, with dialogs, for passwords). To get around this, I wrote a tool called ldid that, among other things, can generate the SHA1 hashes that are checked by Apple's iPhoneOS kernel. This tool is easily installed on the iPhone using Cydia or APT.

iphone# apt-get install ldid iphone$ scp user@desktop:Program . iphone$ ldid -S Program

Supposedly you actually can run codesign over SSH by first running security unlock-keychain. Thanks goes to Sam Clegg for pointing this out! (I will be honest and say I haven't tested this yet.

Option #3: Disable Checks

Finally, an option that is really convenient for development purposes is just to disable the check. Now, technically, this disables a lot more than just the codesign check, and its also more disabling the penalty than the check itself. I have run my phone for a while in this state, but I have heard that in some (many?) configurations it causes problems: being unable to connect to insecure WiFi networks being the largest. This is done by using sysctl to deactivate the enforcement and can be undone either by resetting the variables back on or by rebooting the phone.

sysctl -w security.mac.proc_enforce=0 sysctl -w security.mac.vnode_enforce=0

As this does seem to cause some problems, I'll make a note about how to undo this (as it's really simple). You just need to reset the variables back to 1 or reboot the device (every time the phone starts these default back to on).

sysctl -w security.mac.proc_enforce=1 sysctl -w security.mac.vnode_enforce=1

Entitlements

Every executable also has an XML file (specifically an Objective-C Property List) that is signed into it that is its block of "entitlements". This area is read (I'm not certain by who, but I'd guess the kernel) to determine what seatbelt profile to apply to that process and what extra abilities it gets.

To dump or set the entitlements of a binary we can use ldid. Dumping uses -e and setting involves passing an argument to -S as you sign the file. You can also pass --entitlements to codesign.

iphone$ ldid -e Program iphone$ ldid -Sblock.xml Program mac$ codesign -fs "Name" --entitlements block.xml Program

As an example of where this comes up, programs that wish to use [UIApplication launchApplicationWithIdentifier:suspended:], as of iPhoneOS 2.1, get the error message Entitlement com.apple.springboard.launchapplications required to use _SBXXLaunchApplication. To fix this, we can sign our program with the following entitlement block.

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>com.apple.springboard.launchapplications</key> <true/> </dict> </plist>

Have more questions about code signatures? Send them to me and I might put up more information (if I have it) here. One thing I do intend to discuss more is entitlements.

 

[转]Bypassing iPhone Code Signatures的更多相关文章

  1. Bypassing iPhone Code Signatures

    [Bypassing iPhone Code Signatures] Starting with the recent beta releases of the iPhoneOS, Apple has ...

  2. Code Sign error: Provisioning profile XXXX can't be found

    [iphone]Code Sign error: Provisioning profile XXXX can't be found 如果你更新了profile,再编译iphone项目,发现下面的错误, ...

  3. iPhone较为基础的代码片段

    Iphone代码片段导航 1.给UITableViewController添加ToolBar. self.navigationController.toolbarHidden = NO; //默认是隐 ...

  4. ipa重签名

    为什么要研究重签名问题?将程序打包成ipa包后,ipa包中会包含Provisioning Profile和_CodeSignature等文件,里面包含了对整个ipa的签名信息. 一旦改动ipa中的不论 ...

  5. An iOS zero-click radio proximity exploit odyssey

    NOTE: This specific issue was fixed before the launch of Privacy-Preserving Contact Tracing in iOS 1 ...

  6. github上所有大于800 star OC框架

    https://github.com/XCGit/awesome-objc-frameworks#awesome-objc-frameworks awesome-objc-frameworks ID ...

  7. IOS常用加密GTMBase64

    GTMDefines.h // // GTMDefines.h // // Copyright 2008 Google Inc. // // Licensed under the Apache Lic ...

  8. 验证Xcode真伪的方法,来自苹果官网

    验证Xcode真伪的方法,来自苹果官网   Xcode的验证你的版本 2015年9月22日    注意:中文为有道翻译,看下验证方法即可.   我们最近将应用程序从应用程序商店,还建有Xcode的假冒 ...

  9. iOS使用MD5 - 字符串加密至MD5&获取文件MD5

    iOS 字符串加密至MD5 + (NSString *) md5:(NSString *)str { unsigned ]; CC_MD5( cStr, strlen(cStr), result ); ...

随机推荐

  1. Unity该插件NGUI学习(1)—— 环境结构

    Unity官方网站http://unity3d.com/unity/download下载最新版本4.5.4 发现在神圣的论坛裂纹(Windows)版本号http://game.ceeger.com/f ...

  2. T4模板使用技巧

    =============C#.Net 篇目录============== 示例代码:示例代码__你必须懂的T4模板:浅入深出.rar (一)什么是T4模板? T4,即4个T开头的英文字母组合:Tex ...

  3. vim温馨提示

    (一)各种文本操作 各种跳转 h,j,k,l h左移一个字符,j下移一行,k上移一行,l右移一个字符 w.b w 下一个单词,b上一个单词 0,$   行首,行尾 G,gg.30% 3G跳到第3行,g ...

  4. android 应用程序框架

    携带Android软件开发时间,由开发商开发Android应用程序是通过应用程序框架和Android底层交互,因此,发展以达到最大的部分是应用程序框架. 应用集成框架 那里4一个重要组成部分,以下. ...

  5. 求解决!!!SystemVerilog于ModelSim在编译和执行

    我们正在学习SV流程,样品执行书.. 功能:函数返回数组. Code1: /*书上提供的样例.存在错误,不可执行 function void init(ref int f[5], int start) ...

  6. HDU 2612 -Find a way (注重细节BFS)

    主题链接:Find a Way 题目不难,前几天做,当时准备写双向BFS的,后来处理细节上出了点问题,赶上点事搁置了.今天晚上重写的,没用双向,用了两次BFS搜索,和双向BFS 道理差点儿相同.仅仅是 ...

  7. Linux 解决文件删除,但并没有改变磁盘可用性

    昨天收到zabbix警报邮件,有一个server的 /home 文件夹的使用达成90%以上.检查,发现MongoDB数据文件到这个文件夹.高.而这个MongoDB的数据如今又都不用了.于是就直接把它的 ...

  8. Java设计模式偷跑系列(六)Singleton模式的建模与实现

    转载请注明出处:http://blog.csdn.net/lhy_ycu/article/details/39784403 单例模式(Singleton):是一种经常使用的设计模式. 在Java应用中 ...

  9. 在vi中使用perltidy格式化perl代码

    格式优美的perl代码不但让人赏心悦目,并且能够方便阅读. perltidy的是sourceforge的一个小项目,在我们写完乱七八糟的代码后,他能像变魔术一样把代码整理得漂美丽亮,快来体验一下吧!! ...

  10. 一个只能用在Win下的密码验证函数(显示星号,可删除)

    以前做小程序时图好玩在网上找的代码.输入的密码会以星号显示出来,并且输入错了可以删除.因为用了专有库函数,所以只能在Windows平台使用,少用为好,不过可能还有点用.嗯…就这样了 #include ...