Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mobile App Reverse Engineering

You're reading from   Mobile App Reverse Engineering Get started with discovering, analyzing, and exploring the internals of Android and iOS apps

Arrow left icon
Product type Paperback
Published in May 2022
Publisher Packt
ISBN-13 9781801073394
Length 166 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Abhinav Mishra Abhinav Mishra
Author Profile Icon Abhinav Mishra
Abhinav Mishra
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Section 1: Basics of Mobile App Reverse Engineering, Common Tools and Techniques, and Setting up the Environment
2. Chapter 1: Basics of Reverse Engineering – Understanding the Structure of Mobile Apps FREE CHAPTER 3. Chapter 2: Setting Up a Mobile App Reverse Engineering Environment Using Modern Tools 4. Section 2: Mobile Application Reverse Engineering Methodology and Approach
5. Chapter 3: Reverse Engineering an Android Application 6. Chapter 4: Reverse Engineering an iOS Application 7. Chapter 5: Reverse Engineering an iOS Application (Developed Using Swift) 8. Section 3: Automating Some Parts of the Reverse Engineering Process
9. Chapter 6: Open Source and Commercial Reverse Engineering Tools 10. Chapter 7: Automating the Reverse Engineering Process 11. Chapter 8: Conclusion 12. Other Books You May Enjoy

iOS application fundamentals

Similar to Android, iOS applications also come in a specific zipped format called IPA, or an iOS App Store Package. iOS application packages can also be renamed by changing the extension to ZIP and then the components can be extracted, though the components of an iOS application package differ from those of an Android one.

iOS apps are mainly built using Objective-C and Swift, both of which can be disassembled using a disassembler such as Hopper or Ghidra. In Objective-C applications, methods are called via dynamic function pointers, which are resolved by name during runtime. These names are stored intact in the binary, making the disassembled code more readable. Unlike Android, in iOS, the application code is compiled to machine code that can be analyzed using a disassembler.

The following are the major components of an iOS application package:

  • Info.plist: Similar to the Android manifest file in an APK, this information property list file contains key-value pairs that specify essential runtime-configuration information for the application. The iOS operating system relies on the presence of this file to identify relevant information about the application and related files.
  • Executable: The file that runs on the device, containing the application's main entry point and code that was statically linked to the application target.
  • Resource files: Files that are required by the executable file, and are required for the application to properly run. This may contain images, nib files, string files, and configuration files.

The following diagram illustrates the iOS architecture overview:

Figure 1.13 – iOS architecture

Figure 1.13 – iOS architecture

Let's see how to create a simple hello world application for iOS and then unzip it and look at its components:

  1. iOS apps are developed using Xcode. Download the latest version of Xcode from the App Store on Mac.
Figure 1.14 – Creating an Xcode project

Figure 1.14 – Creating an Xcode project

  1. On the next screen, choose the default App template for your new project:
Figure 1.15 – Selecting the project template

Figure 1.15 – Selecting the project template

  1. On the next screen, provide a product name (any name you like), select a team, and provide an organization identifier. To create and export an IPA from Xcode, you need to have an Apple Developer license:
Figure 1.16 – Providing project details

Figure 1.16 – Providing project details

  1. Select a location to save the project on your computer.

Xcode will now create a simple hello world application and you will see the following default code in the Xcode window:

Figure 1.17 – Project details

Figure 1.17 – Project details

  1. Now you can try and run this app on one of the built-in iOS simulators. To do so, select one of the available simulators (just click on the name of simulator from top bar, and a list will open) as shown in the following screenshot:
Figure 1.18 – Selecting a simulator

Figure 1.18 – Selecting a simulator

The app should run on the selected simulator:

Figure 1.19 – App running on the simulator

Figure 1.19 – App running on the simulator

  1. Now, let's export the IPA from this Xcode project. To do so, select the Any iOS Device (arm64) option from the simulator options.
  2. Then, go to Product | Archive and select the Distribute App option:
Figure 1.20 – Exporting the application package

Figure 1.20 – Exporting the application package

  1. On the next screen, select Development and leave the options on the subsequent screens at their defaults.
  2. Finally, you will be able to export the IPA together with some other compiled project files:
Figure 1.21 – Exporting the application package (cont.)

Figure 1.21 – Exporting the application package (cont.)

  1. Once the IPA is exported, simply change the extension of the file to .zip:
Figure 1.22 – Diagram explaining the application (IPA) extraction process via renaming

Figure 1.22 – Diagram explaining the application (IPA) extraction process via renaming

  1. Use any tool to unzip the file and extract its contents:
    # unzip MARE-Chapter-1.zip

The following screenshot shows the results for reference:

Figure 1.23 – Extracting the content of the IPA after renaming it to ZIP

Figure 1.23 – Extracting the content of the IPA after renaming it to ZIP

  1. Go into the Payload directory and then inside the MobileAppReverseEngg-App-1.app file:
    # cd Payload 
    # cd MobileAppReverseEngg-App-1.app
  2. Let's analyze the components inside the IPA and compare it with the list here (iOS application fundamentals):
Figure 1.24 – Extracted content of the IPA

Figure 1.24 – Extracted content of the IPA

The following diagram illustrates the process of reverse engineering an iOS application:

Figure 1.25 – Overview of the reverse engineering process of an IPA

Figure 1.25 – Overview of the reverse engineering process of an IPA

Have a look at Figure 1.3 to understand how a disassembled binary looks in Hopper disassembler.

You have been reading a chapter from
Mobile App Reverse Engineering
Published in: May 2022
Publisher: Packt
ISBN-13: 9781801073394
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image