iOS Application Security Part 30 - Attacking URL schemes
Mar 7, 2014
In this article, we will look at how we can use a feature in iOS named url schemes to exploit an application. URL schemes are used by applications to communicate with each other. Every application can register for a particular url scheme. For e.g, the Damn Vulnerable iOS application registers for the url scheme dvia. This means that any url starting with dvia:// protocol will open up the dvia application. Depending on the parameters and the endpoint in this url, the dvia application can decide what to do it. Another example is the phone...
GDB segmentation fault issue fix with jailbroken device
Mar 6, 2014
If you have been experiencing segmentation fault issues with GDB while attaching to a process on a jailbroken iOS device, it is because the GDB that comes with Cydia is broken and you need to install a proper version. You can download a proper working version of GDB from here. You need to copy this executable into /usr/bin on your jailbroken iOS device and give it executable permissions. If it still doesn’t work, let me know what issue you are facing by writing a comment below.
iOS Application Security Part 29 - Insecure or Broken Cryptography
Jan 17, 2014
In this article we will look at an example of Insecure or Broken Cryptography which is a common vulnerability found in most iOS applications. This vulnerability occurs when the data stored on the device is not encrypted properly thereby allowing a malicious user to gain access to that information. There could be many reasons for an improper implementaion of encrytption, using hardcoded keys for encryption, bad algorithms etc can all be the cause for an implementation that is not secure. I would recommend you have a look at Apple’s documentation on Encrypting and hashing...
iOS Application Security Part 28 - Patching iOS Application with Hopper
Jan 17, 2014
In Part 26 of this series, we looked at how we can use IDA Pro and Hex Fiend to patch an iOS application and modify its implementation. Patching an application has the specific advantage that once a change has been made, it is permanent. However, if you look back at the article on IDA Pro, you will realize that the process of patching the application was a bit tedious, mainly because we didn’t have a licensed version of IDA Pro which costs a lot. In this article, we will look at a utility named...
iOS Application Security Part 27 - Setting up a mobile pentesting environment with iOS 7 Jailbreak
Jan 17, 2014
In this article we will look at how we can set up a mobile pentesting platform on our device with the new iOS 7 jailbreak. There has been quite a lot of discussion on the web about whether it is safe for a user to jailbreak their devices yet. However, if you are really interested in iOS pentesting then there is no absolutely no reason now why you shouldn’t jailbreak your device. Since this jailbreak was launched by the evasi0n team without any prior notice to the developers, most of the tweaks didn’t work...
iOS Application Security Part 26 – Patching iOS Applications using IDA Pro and Hex Fiend
Dec 17, 2013
In the previous applications we have looked at how we can hijack method implementations during runtime using Cycript, and even change the logic of the code rather than changing the complete implementation using GDB. All of these things have been done to serve a purpose, which is to make the application do what we want. However, using Cycript or GDB is a bit of a pain as one has to do repeat the same process everytime after you restart the application. This is where patching the application is useful. Once a change has been...
iOS Application Security Part 25 – Secure Coding Practices for iOS Development
Dec 17, 2013
In this article, we will look at some of the best practices an iOS developer should follow in order to make sure that their application is not easily exploitable by hackers. Local Data Storage It is extremely important for developers to know what kind of data they should be storing locally in their application. Frankly speaking, no data is secure when stored locally in the application. In part 20 of this series, we have looked at Local Data Storage in great detail. Important data like Passwords, Session ID’s etc should never be stored locally...
iOS Application Security Part 24 – Jailbreak Detection and Evasion
Dec 17, 2013
In this article, we will look at the checks a developer can incorporate in his application to check whether the device on which the application is running is jailbroken or not. Checking whether a device is jailbroken or not can have many advantages for your application. As we have already seen, an attacker can run tools like Cycript, GDB, Snoop-it etc to perform runtime analysis and steal sensitive data from within your application. If you are really looking to add an extra layer of security for your application, you should not allow your application...
iOS Application Security Part 23 – Defending against runtime analysis and manipulation
Dec 17, 2013
In the previous articles, we have looked at how we can use debuggers and tools like Cycript to do runtime analysis and manipulation of iOS Applications. We have looked at how we can modify the actual implementation of a method during runtime by changing the values in the registers using GDB, and also looked at how we can completely swizzle method implementations using tools like Cycript. With tools like Cycript and GDB in his arsenal and with a copy of your application’s binary, the attacker is is complete control. However, there are certain techniques...
iOS Application Security Part 22 – Runtime Analysis and Manipulation using GDB
Dec 17, 2013
In this article, we will look at how we can use GDB to perform runtime analysis of iOS applications. In the previous articles, we have looked at how we can use Cycript to analyze and manipulate the runtime behaviour of iOS applications. We have learnt how we can perform method swizzling and have our own methods being called instead of the original implementations. So why we do need GDB ? Well, what Cycript doesn’t allow us to do yet is set breakpoints and alter the values of variables and registers after a particular instruction....
iOS Application Security Part 21 – ARM and GDB Basics
Nov 8, 2013
All the iOS devices released uptil now are based on the ARM architecture. All the Objective-C code that we write while developing iOS applications is first converted into ARM assembly before being converted to machine code (1s and 0s). With good understanding of the ARM assembly language and with good knowledge of debugging using GDB, it is possible for a hacker to decipher the Objective-C code during runtime and even modify it. For this article, we will be using a sample application GDB-Demo from my github account. Make sure to install and run it...
iOS Application Security Part 20 – Local Data Storage (NSUserDefaults
Oct 26, 2013
In this article, we will look at the different ways in which applicatons can store data locally on the device and look at how secure these methods are. We will be performing some of these demonstrations in a sample app that you can download from my github account. For the CoreData example, you can download the sample app from here One of the other things that we will doing different in this example is that we will be running the application on the iOS simulator using Xcode rather than on the device and hence...
iOS Application Security Part 19 – Programmatical Usage of Introspy
Oct 26, 2013
In this article, we will look at how we can Introspy as a python module in our scripts. The first thing to do is to import the introspy module and Namespace from argparse module. We then create an instance of the Introspy class. The arguments that we need to provide are the database name, the group name, the subgroup name and the list. Now, for this case, lets provide all the parameters as None except the database path. Introspy will hence include all the groups rather than just including a particular group. Let’s create...
IOS Dev - Encrypting images and saving them in App Sandbox
Sep 26, 2013
One of the requirements in my latest project was to encrypt an image and save it on the device in the application’s sandbox, then decrypt is during runtime and upload it to the server. I looked at the documentation for Apple’s CommonCrypto Framework, but it was taking me plenty of time to implement it so instead i decided to use some wrappers that would get the job done for me. I found the RNCryptor library on Github that uses AES encrypton. It was pretty simple to implement it. First, download the files from its...
iOS Application Security Part 18 – Detecting custom signatures with Introspy
Sep 26, 2013
In the previous article, we looked at how we can use Introspy for Black-box assessment of iOS applications. In this article, we will look at how we can use Introspy to set up our own custom signatures and detect them in an application trace. Setting up our own predefined signatures could be useful for cases where you have a found a method in a particular application that seems of particular interest to you and you want to know when it is being called. Introspy already has a list of predefined signatures that it uses...
iOS Application Security Part 17 – Black-Box Assessment of iOS Applications using INTROSPY
Sep 23, 2013
In this article, we will look at how we can use Introspy for Black-box assessment of iOS applications. Introspy is developed by ISEC partners and its github page can be found here. Introspy consists of two seperate modules, a tracer and an analyzer. It is undoubtedly one of the most powerful tools for analyzing the security of iOS applications. The first step is to install the Introspy tracer on your device. You can download the debian package from here. Once it is downloaded, just upload it and install on your device. The image below...
IOS Dev - Storing Info in Keychain with NSUserDefaults like syntax
Sep 17, 2013
Recently, i decided to improve the security of one of my applications by storing some of the information that i was previously saving in NSUserDefaults in the Keychain. Basically, this doesn’t make that much of a difference if your device is jailbroken. However, if your device is not jailbroken then it is possible to fetch the information saved by NSUserDefaults but not from the Keychain. This is because NSUserDefaults saves the information in an unencrypted format in a plist file inside the application sandbox which can be easily fetched. It can also be fetched...
iOS Application Security Part 16 – Runtime Analysis of iOS Applications using iNalyzer
Sep 17, 2013
In the previous article, we looked at how we can perform static analysis of iOS Applications using iNalyzer. In this article, we will look at how we can use iNalyzer to perform runtime analysis of iOS applications. We can invoke methods during runtime, find the value of a particular instance variable at a particular time in the app, and basically do anything that we can do with Cycript. In the last article, we were successfully able to generate the html files via Doxygen and open it up to view class information and other information...
iOS Application Security Part 15 – Static Analysis of iOS Applications using iNalyzer
Sep 17, 2013
In the previous article, we looked at how we can use Sogeti Data protection tools to boot an iDevice using a custom ramdisk with the help of a bootrom exploit. In this article, we will look at a tool named iNalyzer than we can use for black box assessment of iOS applications. iNalyzer allows us to view the class information, perform runtime analysis and many other things. Basically it automates the efforts of decrypting the application, dumping class information and presents it in a much more presentable way. We can also hook into a...
iOS Application Security Part 14 – Gathering information using Sogeti Data Protection tools
Sep 17, 2013
In the previous article, we looked at how we can boot a device using a custom ramdisk using Sogeti Data protection tools. In this article, we will look at how we can use some of their tools to gather information from the device like fetching the keychain information, dumping the entire filesystem or even bruteforcing the passcode. Until the previous article, we had successfully set up a connection to the device using usbmux, ssh’ed into the device and had mounted the partitions. Here is what these partitions contain. Now we are free to navigate...