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. Codeforces 10C Digital Root 法冠军

    主题链接:点击打开链接 #include<stdio.h> #include<iostream> #include<string.h> #include<se ...

  2. iOS 开发小技巧

    1.Xcode配置 1.1> 安装Alcatraz包管理器 打开Terminal终端命令行 curl -fsSL https://raw.github.com/supermarin/Alcatr ...

  3. POJ 2187: Beauty Contest(旋转卡)

    id=2187">Beauty Contest Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 27218   ...

  4. Socket 由浅入深系列--------- 简单实现编程(三)

    socket 由浅入深 原理(一)介绍了一些,以下也就是简单实现,并未考虑其它性能化! 使用TCP的server客户机举例 server 设置一个简单的TCPserver涉及下列步骤: 调用 sock ...

  5. 动画云创始人胥克谦&amp;课程格子创始人李天放分享创业经历

    原文地址:http://student.csdn.net/mcd/topic/163587/955044 2014年10月18日在北京科技大学成功举办了CSDN高校俱乐部全国巡讲,现场參会学生有一百余 ...

  6. easyui datagrid load 封装 参数问题 js 作用域

    var temp = { LoginAccount: $('#LoginAccount').val(), ShopName: $('#ShopName').val() }; function doSe ...

  7. 利用EntityFramework获得双色球数据库

    原文 利用EntityFramework获得双色球数据库 双色球想必大家都很熟悉了,尽管屡买屡不中,但还是会买.以前就想过利用双色球的走势图得到双色球的数据库,至于得到数据库干什么倒没想过,不过对以往 ...

  8. SSH深度历险记(两) Jboss+EJB一审

    学习感悟:每次学习新知识.通过初审会从小事做起,获得成就感.经典Hello Workd我们成功的例子奠定了门哈,呢.非常好的理解了.Ejb的核心. 今天主要以这个小实例,来学习EJB的分布式,我们能够 ...

  9. 远程调用之RMI技术

    ---恢复内容开始--- RMI已经不是什么新的技术了,但是相对于webservice来说,rmi比较简单,比较适合一些小的应用,下面的helloword列子可以介绍rmi的相关技术 服务器端代码: ...

  10. Linux---江湖

    Linux江湖13:我该如何备份系统 Posted on 2014-12-18 10:39 京山游侠 阅读(497) 评论(3) 编辑 收藏 在前面的一些文章中,我反复提到经常会把系统搞崩溃,所以备份 ...