Book Image

iOS Forensics Cookbook

By : Bhanu Birani, Mayank Birani
Book Image

iOS Forensics Cookbook

By: Bhanu Birani, Mayank Birani

Overview of this book

Mobile device forensics is a branch of digital forensics that involves the recovery of evidence or data in a digital format from a device without affecting its integrity. With the growing popularity of iOS-based Apple devices, iOS forensics has developed immense importance. To cater to the need, this book deals with tasks such as the encryption and decryption of files, various ways to integrate techniques withsocial media, and ways to grab the user events and actions on the iOS app. Using practical examples, we’ll start with the analysis keychain and raw disk decryption, social media integration, and getting accustomed to analytics tools. You’ll also learn how to distribute the iOS apps without releasing them to Apple’s App Store. Moving on, the book covers test flights and hockey app integration, the crash reporting system, recovery tools, and their features. By the end of the book, using the aforementioned techniques, you will be able to successfully analyze iOS-based devices forensically.
Table of Contents (13 chapters)

Saving data using the RAW file


In the previous section, you learned about the Document directories. Now, in this section we will explore this in more detail. You will learn about saving RAW files in our application's document directory.

Getting ready

We will use the preceding project for this section as well. So, open the project and follow the next section.

How to do it...

Perform the following steps to write data into your Documents directory:

  1. Now, we will create a .txt file in our folder (which we created in the document directory). Customize the code in viewDidLoad: as follows:

    dataPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"myfile.txt"];
    NSLog(@"%@", dataPath);

    The preceding code will create a .txt file of name myfile.txt.

  2. To write something into the file, add the following code:

    NSError *error;
    NSString *stringToWrite = @"1\n2\n3\n4";
    dataPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"myfile.txt"];
    [stringToWrite writeToFile:dataPath atomically:YES encoding:NSUTF8StringEncoding error:&error];

    The writeToFile method is used to write data in our file.

  3. Now, to read the data from the file, there's the stringWithContentsOfFile method. So add the following method inside the code:

    NSString *str = [NSString stringWithContentsOfFile:dataPath encoding:NSUTF8StringEncoding error:&error];
    NSLog(@"%@", str);
  4. To see the mayflies.txt file in the Documents directory, go to the GoToFolder finder and paste dataPath from the console. It will take you to mayflies.txt. The final file should look something like the following screenshot:

  5. In the screenshot, you can see the two files have been created. As per our code, we have created myfile.txt and myfile.pdf. We have also created MyFolder in the same Documents folder of the app.