Coder Social home page Coder Social logo

miscellaneous's Introduction

Miscellaneous

This repository contains stuff which would be helpful for jailbroken iOS development.

This is a script to simply studying of Mach-O files on ARM architecture using Objective-C ABI 2.0 for IDA Pro 5.5 and above. Currently, the script mainly does the following:

  • Add comments to all selectors so it becomes clear which selector _objc_msgSend is using.

  • Check all Objective-C methods and create functions for them. This is particularly useful for files with symbols stripped because IDA Pro usually can't recognize those functions as code.

  • Add name to all ivars and classes.

dyld_decache

Starting from iPhone OS 3.1, the individual libraries files supplied by the system are smashed together into a giant cache file (dyld_shared_cache_armvX) to improve performance. This makes development difficult when one only has the IPSW but not the SDK (e.g. Apple TV 2G), because there is no file to link to or reverse engineer.

dyldcache.cc, originally written by D. Howett, was created to unpack files from the dyld_shared_cache_armvX file. Unfortunately, this tool does not try to untangle the interconnection between libraries in the cache, so each extracted file is over 20 MiB in size (as the whole __LINKEDIT segment is duplicated) and often the file cannot be correctly class-dump'ed (as some data are actually outside of that library).

dyld_decache is a complete rewrite of the tool to solve the above problems. It correctly excludes irrelevant parts of the __LINKEDIT segments, and pulls in sections which are placed outside of the file due to dyld's optimization. As a result, the generated files take only roughly 200 MiB totally in size instead of over 4 GiB previously, and they can be correctly analyzed by class-dump.

The 64-bit dyld_decache for Mac OS X 10.6 can be downloaded from https://github.com/kennytm/Miscellaneous/downloads. It is a command line tool, the options are:

Usage:
  dyld_decache [-p] [-o folder] [-f name [-f name] ...] path/to/dyld_shared_cache_armvX

Options:
  -o folder : Extract files into 'folder'. Default to './libraries'
  -p        : Print the content of the cache file and exit.
  -f name   : Only extract the file with filename 'name', e.g. '-f UIKit' or
              '-f liblockdown'. This option may be specified multiple times to
              extract more than one file. If not specified, all files will be
              extracted.

This is a small Python script that adds the necessary headers to turn a raw binary file (e.g. the decrypted iBoot) into a Mach-O file. This is useful for tools that cannot work with raw binary files, like otool -tv or the IDA Pro demo.

This script is a collection of utilities to dump information from different libraries. Currently it supports dumping of CAAtom and UISound.

CAAtom is an internal data type in Core Animation which creates a mapping between strings and an integer index. This optimizes string comparison operation over known strings since they are already perfectly hashed. However, this poses a difficulty in reverse-engineering because the relevant strings are all replaced with some unrelated numbers. This script supports reading the table that defines the mappings of the internal atoms.

UISound is a directory in iOS containing .caf files for system alert sounds. These sounds are indiced by a constant number and can be used as the SoundID in AudioServices to play them. This script supports interpreting the sound IDs and categories for these files.

Often executables or kernels are stripped, so guessing what a function does would require heavy analysis of its content. Nevertheless, developers usually will leave a logging function which accepts __FUNCTION__, i.e. the function name, as an input parameter. If such a function is found, the function names can be assigned systematically.

The log_rename.idc script is written to take advantage of this. Once you have identified any function that takes a C string function name as an input parameter (via register r0 to r3), you could start this script to locate all analyzed functions calling this. Then the script will coservatively try to rename the function based on the input.

This is a convenient script to extract, decrypt and decompress files in an IPSW file in one pass. This script is only intended for decoding those files for analysis, but not for building a jailbroken IPSW. The standard jailbreaking software like PwnageTool or XPwn should be used instead for the latter purpose.

The script can perform the following:

  • Extract the encrypted files from an IPSW
  • Download decryption keys from http://theiphonewiki.com/
  • Perform AES decryption / VFDecrypt using these keys
  • Decompress the kernel into a Mach-O file, and iBootIm images into raw data.

This script requires the executables openssl (for AES decryption) and vfdecrypt (for decrypting the OS DMG) to run. It also requires the lxml module to be installed for HTML parsing.

miscellaneous's People

Contributors

0xced avatar kennytm avatar markshep avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

miscellaneous's Issues

dyld_decache failing for iOS version "8.0 (12A365)"

Using the -p option gives an image list that seems to have the name getting more and more offset from where it actually starts. For example for dyld_shared_cache_arm64 it starts like this:

Images (878):
  ---------address  filename
         180008000  System/Library/AccessibilityBundles/AXSpeechImplementation.bundle/AXSpeechImplementation
         180010000  System/Library/AccessibilityBundles/AccessibilitySettingsLoader.bundle/AccessibilitySettingsLoader
         18001c000  System/Library/AccessibilityBundles/AccountsUI.axbundle/AccountsUI
         180020000  System/Library/AccessibilityBundles/AddressBookUIFramework.axbundle/AddressBookUIFramework
         180028000  System/Library/AccessibilityBundles/CameraKit.axbundle/CameraKit
         180038000  System/Library/AccessibilityBundles/HearingAidUIServer.axuiservice/HearingAidUIServer
         180048000  System/Library/AccessibilityBundles/MapKitFramework.axbundle/MapKitFramework
         180050000  ystem/Library/AccessibilityBundles/MediaPlayerFramework.axbundle/MediaPlayerFramework
         18005c000  ystem/Library/AccessibilityBundles/MediaPlayerUIFramework.axbundle/MediaPlayerUIFramework
         180064000  ystem/Library/AccessibilityBundles/MessageUIFramework.axbundle/MessageUIFramework
         180070000  stem/Library/AccessibilityBundles/PassKitFramework.axbundle/PassKitFramework
         180078000  stem/Library/AccessibilityBundles/PhotoLibraryFramework.axbundle/PhotoLibraryFramework
         180084000  stem/Library/AccessibilityBundles/PhotoLibraryServices.axbundle/PhotoLibraryServices
         180088000  stem/Library/AccessibilityBundles/PhotosFramework.axbundle/PhotosFramework
         18008c000  stem/Library/AccessibilityBundles/PhotosUIFramework.axbundle/PhotosUIFramework
         18009c000  stem/Library/AccessibilityBundles/PreferencesFramework.axbundle/PreferencesFramework
         1800a4000  em/Library/AccessibilityBundles/QuickLook.axbundle/QuickLook
         1800a8000  em/Library/AccessibilityBundles/QuickSpeak.bundle/QuickSpeak
         1800b4000  /Library/AccessibilityBundles/RemoteUIFramework.axbundle/RemoteUIFramework
         1800b8000  /Library/AccessibilityBundles/SocialFramework.axbundle/SocialFramework
         1800bc000  /Library/AccessibilityBundles/StoreKitFramework.axbundle/StoreKitFramework
         1800c0000  /Library/AccessibilityBundles/StoreKitUI.axbundle/StoreKitUI
         1800d4000  /Library/AccessibilityBundles/UIKit.axbundle/UIKit
         18015c000  Library/AccessibilityBundles/VoiceMemosFramework.axbundle/VoiceMemosFramework

then eventually gets into garbage. Using the -u option gives Bus error: 10 as the only output :-(.

fix_pcrel.idc issue

Seems that this fix for PC-relative offsets sometimes fails and MOV MOVW MOVT instructions just stay as they are instead of pointing to the right offset. I tried to apply a couple of changes to the idc but nothing worked :-/
I can show you an example binary if you wish.

Supporting arm64 dyld_shared_cache

What would be required to get support for 64-bit? Perhaps I can help?

tigerblood:/Users/samy/Code/jb/misc-jevinskie$ ./dyld_decache ../ios-root/dyld_shared_cache_arm64
  0/1293: Dumping '/usr/lib/libSystem.B.dylib'...
Error: Cannot dump 'libraries/usr/lib/libSystem.B.dylib'. Only 32-bit little-endian single-file
       Mach-O objects are supported.
**** Failed: Undefined error: 0
  1/1293: Dumping '/usr/lib/libc++.1.dylib'...
Error: Cannot dump 'libraries/usr/lib/libc++.1.dylib'. Only 32-bit little-endian single-file
       Mach-O objects are supported.
**** Failed: Undefined error: 0

Segmentation fault

I hope that I'm not doing anything wrong in obtaining the cache from the device, but with iOS 7.0.6 the program crashes with a segmentation fault at the second library that gets extracted

The cache is extracted right, I obtain the same result with the one obtained from a restore dmg

0/675: Dumping '/System/Library/AccessibilityBundles/AXSpeechImplementation.bundle/AXSpeechImplementation'...
1/675: Dumping '/System/Library/AccessibilityBundles/AccessibilitySettingsLoader.bundle/AccessibilitySettingsLoader'...
Segmentation fault: 11

dyld_decache segfault

dyld_decache is giving a segmentation fault: 11 when using it to decache dyld_shared_cache_armv7 for iOS5 (final) from iPhone 4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.