20.1 关于ldid的一个知识

对于ldid的重点是:
是可执行文件进行签名,以便在iPhone上面执行。
另外需要比较与codesign的区别;

On the newer versions of iOS (v5) running this tool ends up with killed 9 error.
The problem here is iOS kernel signature checks the binary file at several places. Jailbreak tools cannot patch all these signature checks because it is difficult for them to patch each and every signature check. When we copy keychaindumper to iPhone, it does not have a signature. So running the binary exits with killed 9 message because iOS kernel does not have the signature of keychain_dumper.
To get rid of this problem add the signature of keychain_dumper to kernel cache (list of hashes) by running the below command. After adding the signature, you can run the rest of commands to dump the keychain entries.

ldid -S keychain_dumper

大概意思:为执行文件添加签名,以便在手机上进行运行。如同app需要签名一样,直接拷贝到手机系统需要直接运行的可执行文件则也需要被签名;

iPhone: keychain dumper – killed 9 problem

Github Keychain-Dumper

原文如下:

In iPhone, keychain is a sqllite database which stores sensitive data on the device. Apple’s keychain service is a library/API provided by Apple that developers can use to store sensitive information on an iOS device securely. Instead of storing sensitive information in plaintext configuration files, developers can leverage the keychain services to have the operating system store sensitive information securely on their behalf.

Keychain is encrypted with a hardware key. Hardware key is unique per device and not even accessible to OS running on the device. So even if some one get access to the keychain db file in a remote attack (Remember android malware, which steal sqlite.db files and sent it to the remote server), they cannot decrypt and view the content. Keychain also restricts the application access to the stored data. Each application on your device has a unique application-identifier (also called as entitlements). The keychain service restricts which data an application can access based on this identifier. By default, applications can only access data associated with their own application-identifier. Later apple introduced keychain groups. Now applications which belong to same group can share the keychain items.

On a jailbroken device, all keychain entries can be accessed by writing an application and making it as a member of all application group.

One such tool designed to grab all the keychain entries is keychain dumper – https://github.com/ptoomey3/Keychain-Dumper

Copy keychain_dumper to iPhone over ssh. Run the below command on SSH Terminal. This extracts all the keychain groups from keychain-2.db and stores in an xml file.

./keychain_dumper -e /var/tmp/entitlements.xml

Using ldid and entitlement xml file, we can make keychain_dumper program as a member of all keychain groups.

ldid -S/var/tmp/entitlements.xml keychain_dumper

Now running keychain dumper reads all the entries from keychain and displays it on the terminal.

./keychain_dumper

On the newer versions of iOS (v5) running this tool ends up with killed 9 error.

The problem here is iOS kernel signature checks the binary file at several places. Jailbreak tools cannot patch all these signature checks because it is difficult for them to patch each and every signature check. When we copy keychaindumper to iPhone, it does not have a signature. So running the binary exits with killed 9 message because iOS kernel does not have the signature of keychain_dumper.

To get rid of this problem add the signature of keychain_dumper to kernel cache (list of hashes) by running the below command. After adding the signature, you can run the rest of commands to dump the keychain entries.

ldid -S keychain_dumper

But in the newer versions (5.0.1), this workaround is not working. Because we have to run ldid command twice with -S option. This tries to overwrite the binary hash on kernel cache and fails. So follow the below listed steps to use the keychain_dumper on newer versions of iOS.

1. Copy keychain_dumper to iPhone over SSH.
2. Manually dump keychain groups with the help of sqlite3 command.

Sqlite3 /var/Keychains/keychain-2.db “select agrp from genp”
Running this command on my phone listed three access groups.
– apple, com.apple.apsd, com.apple.cfnetwork
3. Create a XML file similar to the sample shown below with all the keychain groups listed by above command
(paste the keychain group name in the string tags).
Sample.xml

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd“><plist version=”1.0”>
<dict>
<key>keychain-access-groups</key>
<array>
<string>apple</string>
<string>com.apple.apsd</string>
<string>com.apple.cfnetwork</string>
</array>
</dict>
</plist>

4. Copy sample.xml to /var/tmp folder on iPhone.
5. Run below commands to dump the keychain entries.

ldid –S/var/tmp/ent.xml keychian_dumper
./keychain_dumper

To run the keychain_dumper again, follow all the steps.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 7,590评论 0 3
  • 西罗菲尔[爱心]幸福满家 作者-江名会 家是生命的驿站,漂泊的归所,温暖的所在,家更是心灵的港湾,力量的源...
    布步为赢阅读 3,652评论 0 0
  • 2018年6月14日,天气晴朗,我的心情也是晴朗朗的。 夏天到了,要做小手工,今日手工主题时做一双...
    吾生jun未老阅读 1,885评论 0 2
  • 当年少时 青梅未煮酒 竹马床前绕 天涯明月沧海笑 风吹人飘摇
    fancyice阅读 1,475评论 0 0