Chapter 3. File system and data storage
Information in this chapter:
• iPhone Data Storage
• File System
This chapter discusses the type of data that is stored on the iPhone, the general locations where this data is stored, and the format in which it is stored. Information can be recovered from the device's internal memory, database files, and commonly used configuration files known as property lists. These common file types are described in detail in order to provide the examiner with an understanding of how the data is stored so that he or she can more efficiently recover data from these files. The type of memory contained on an iPhone is also outlined, including volatile and nonvolatile memory. The following sections focus on the operating system and file system type used by the iPhone, the unique features of the file system, and the disk partitions contained in the device.
Keywords: iPhone RAM, NAND Flash memory, property lists, SQLite database, HFS Plus, disk partitions

Introduction

A key aspect of a mobile forensic analysis is understanding what data can be recovered, where the data is stored, and more importantly, how to access that data. Certain mobile devices contain alternative storage locations in addition to the Flash memory on the device, such as external or embedded SD cards. This chapter covers the type of data that can be stored on an iPhone, where one must look for this data, and how the data is being stored behind the scenes.

What data is stored

It is reasonable to assume that any information that can be viewed on an iPhone will be permanently stored on the device until it becomes overwritten. Most of this data is stored as part of an application installed on the device. There are various types of applications, including those that ship with the iPhone, those that are installed by the manufacturer, those installed by the wireless carrier, and those installed by the user through the iTunes App Store (or those installed on a jailbroken phone through other sources).
Chapter 6, which covers Data and Application Analysis, explores in detail the files and data stored for individual applications; in brief, some of the general information that can be recovered from an iPhone is as follows:
• Default application data (Calendar, Call Logs, Voicemail, Text and Multimedia Messages, Photos, Videos, YouTube, Google Maps, Voice Memos, Notes, Contacts, Web History, and Bookmarks);
• Geographical location information (global positioning system (GPS) coordinates for photos and videos taken from the device and applications that store location data);
• Synchronized data (videos, songs, and pictures synced via iTunes; e-mail accounts and content setup through the mail application on the device);
• General device settings (Wi-Fi and Bluetooth information; firmware and software versions on the device);
• Downloaded application data (any application that was downloaded through the iTunes app store or an alternative source typically stores data relevant to that application);
• User names, e-mail addresses, and some passwords.

Where data is stored

The iPhone has a standard directory structure in which various files are stored (refer to Appendix C for a full listing of the folders and files recovered from an iPhone). Because it does not contain an external storage slot, all data are stored internally on the device (as opposed to other mobile devices that contain external SD cards or emulated SD cards). To display the iPhone's hierarchy, a jailbroken phone is remotely connected through Wi-Fi, using the same techniques as described in Chapter 5– Imaging a Jail-broken Device. From a Macintosh computer, the phone is connected through SSH in order to navigate through the file system. Immediately upon logging in to the device, the “ls” command is used to list the directory contents.
3GS-40:/ root# ls -l
total 58
lrwxr-xr-x 1 root admin 23 Sep 17 12:11 Applications -> /var/stash/Applications/
drwxrwxr-x 2 root admin 68 May 31 2010 Developer/
drwxrwxr-x 14 root admin 680 Sep 17 12:11 Library/
drwxr-xr-x 3 root wheel 102 Jul 30 2010 System/
lrwxr-xr-x 1 root admin 11 Mar 4 10:20 User -> /var/mobile/
drwxr-xr-x 2 root wheel 2108 Sep 28 11:28 bin/
drwxr-xr-x 2 root wheel 68 Oct 28 2006 boot/
drwxrwxr-t 2 root admin 68 May 19 2010 cores/
dr-xr-xr-x 3 root wheel 1555 Mar 4 10:20 dev/
lrwxr-xr-x 1 root wheel 12 Sep 17 12:11 etc -> private/etc//
drwxr-xr-x 2 root wheel 68 Oct 28 2006 lib/
drwxr-xr-x 2 root wheel 68 Oct 28 2006 mnt/
drwxr-xr-x 4 root wheel 136 Feb 25 11:57 private/
-rw-r--r-- 1 root admin 15290 Sep 16 17:43 restore.log
drwxr-xr-x 2 root wheel 1326 Sep 17 12:11 sbin/
lrwxr-xr-x 1 root wheel 16 Sep 17 12:11 tmp -> private/var/tmp//
drwxr-xr-x 6 root wheel 306 Sep 17 12:12 usr/
lrwxr-xr-x 1 root wheel 12 Sep 17 12:12 var -> private/var//
Most of the data that an examiner would be interested in is stored in the “private/var/mobile/” path (on an iPhone disk image, the “mobile” folder will be at the root of the mounted image); however, valuable forensic evidence can also be found in other locations. Within the Mobile directory, there are three subfolders: Applications, Library, and Media. Any downloaded apps will be stored in the Applications folder in a format similar to that shown in Figure 3.1. Each downloaded application has an application identifier, which becomes the folder name and is the same across all devices, as shown in Figure 3.1.
B9781597496599000031/f03-01-9781597496599.jpg is missing
Figure 3.1
Applications Directory.
The contents of each application folder are generally the same among all apps. Some standard folders and files include the following:
• A Documents folder containing relevant files for that particular app, such as plists, text documents, or images;
• A Library folder containing Cached data, Cookies, Preferences, and if applicable, WebKit data. “Preferences” is where user login data is commonly stored if that is required for the application being used;
• The application bundle, which can be extracted to view individual files containing code and other files on which the application is dependent;
• A “tmp” folder, which is empty in most cases.
In the following listing, the contents of the Yahoo! iPhone application are displayed, with some file names (such as logos and icons) removed for simplicity. This structure represents a standard application directory. Looking at the top-level directories, one can see the Documents, Library, and tmp folders, as well as the Yahoo!app folder outlined above. The “iTunes Artwork” and “iTunesMetadata.plist” files are standard files found in all downloads installed through the iTunes App Store. The actual application bundle can be extracted to view more details on the development of that particular application. In this example, the “Info.plist” may contain application version numbers, release dates, or perhaps user login data. Depending on the application, varying configuration files will be found. This is a popular area to look for stored application data.
kstrzempka@linux-wks-001:~/Desktop/iPhoneapp-mount/mobile/Applications$ tree FA06A4AA-0EC9-4E0C-B947-9CAA16698F19/
FA06A4AA-0EC9-4E0C-B947-9CAA16698F19/
├── Documents
├── last_location.txt
└── OKURLCache
├── Dictionary.plist
├── E8117953-62EF-454C-8FC6-6EE60E8FCA31
├── EC699560-327D-45DE-8B6C-4D5544095B99
└── F2A80C4D-5859-4C2F-A9DB-BCD1527B6BCE
├── iTunesArtwork
├── iTunesMetadata.plist
├── Library
├── Caches
├── Cookies
└── Cookies.plist
├── Preferences
├── com.apple.PeoplePicker.plist -> /private/var/mobile/Library/Preferences/com.apple.PeoplePicker.plist
└── com.yahoo.frontpage.plist
└── WebKit
├── Databases [error opening dir]
└── LocalStorage
└── http_m.mg.mail.yahoo.com_0.localstorage
├── tmp
└── Yahoo!.app
├── blueprint.xsd
├── bpResourcesVoice.bundle
└── Info.plist
├── CodeResources -> _CodeSignature/CodeResources
├── _CodeSignature
└── CodeResources
├── config.xml
├── config.xsd
├── Default.png
├── de.lproj
├── en.lproj
├── Entitlements.plist
├── es.lproj
├── fr.lproj
├── Icon.png
├── Info.plist
├── it.lproj
├── oneKit
├── PkgInfo
├── pt.lproj
├── ResourceRules.plist
├── SC_Info
├── Settings.bundle
├── en.lproj
└── Root.strings
└── Root.plist
├── SettingsGenericSelectionView.nib
├── SettingsGenericTextView.nib
├── SettingsView.nib
├── Sounds
├── Yahoo!
└── zh_tw.lproj
Outside of the downloaded applications, the more common data is typically stored in either the “Library” or “Media” folder within specific subfolders. For example, text messages are stored under Library > SMS, in a file named “sms.db.” The iPhone file system is structured in an intuitive manner for most of the data.
There are, however, other files on the root of the device which have required a bit more research to understand the data within them. One example of this involves GPS location information stored on the device. Many different applications often ask the user if they wish to enable GPS for that particular app, including the on-board camera and video camera. For this reason, GPS data can often be found for pictures or videos that were taken from the device. When iOS 4.0 was released, changes were made to part of the iPhone's file system layout. One of the major transformations involved a file called “consolidated.db.” This database contains a wide array of GPS data and includes latitude and longitude coordinates, time stamps, cell tower locations, and Wi-Fi/Bluetooth connections from that device. There is only one instance of this file and it is not stored within an individual application folder, despite the fact that this database may contain information about individual applications. More details on recovering GPS data from consolidated.db and other locations can be found in Chapter 6.

How data is stored

Data on the iPhone is stored in a number of ways. In the following sections, each form of data storage is covered in order to provide examiners with an understanding of how potential evidence can be located or recovered.
1. Internal storage
2. SQLite database files
3. Property lists
4. Network
5. Other

Internal storage

Unlike many of the code division multiple access (CDMA) devices, which have an SD card slot, the iPhone does not contain any form of external storage (other than a SIM card). All data is stored in the internal NAND Flash memory. In the “iPhone Disk Partitions” section later in this chapter, slice 2 (or “rdisk0s2”) is where all the user data files are stored. It is this partition that is imaged during a physical acquisition of the device. A listing of the top-level files and directories in which much of the user data is stored is listed below. A significant portion of Chapter 6 focuses on these main directories, as well as other portions of the file system.
├── Applications
├── 3CD749AD-701F-46E2-951A-AC9C51D426FF
├── A80398AA-1B36-4810-A3C5-90EE31F3BA3C
├── C86D1767-9EAC-43CE-99BD-BF018AED024F
├── C9636536-582E-43EF-AEA5-3C9C05ABF812
└── FA06A4AA-0EC9-4E0C-B947-9CAA16698F19
├── Library
├── AddressBook
├── Caches
├── Calendar
├── CallHistory
├── Carrier Bundle.bundle -> /System/Library/Carrier Bundles/310410
├── com.apple.iTunesStore
├── com.apple.itunesstored
├── ConfigurationProfiles
├── Cookies
├── Keyboard
├── Logs
├── Mail
├── Maps
├── MobileInstallation
├── Operator Bundle.bundle -> /System/Library/Carrier Bundles/310410
├── Preferences
├── RemoteNotification
├── Safari
├── SMS
├── Voicemail
├── WebClips
└── WebKit
└── Media
├── com.apple.itdbprep.postprocess.lock
├── com.apple.itunes.lock_sync
├── DCIM
├── Downloads
├── iTunes_Control
├── Photos
├── Podcasts
├── Purchases
├── Recordings
└── Safari
As all data are stored on the internal device, having the ability to image the iPhone in a way that pulls off both allocated and unallocated data can be crucial in an investigation. Deleted text messages, photos, or videos can often make or break a case, thus making a physical acquisition of the user data partition (rdisk0s2) ideal.

SQLite database files

One of the more common types of data storage used by many mobile application developers is the use of a SQLite database. Databases are used for structured data storage and SQLite is a popular database format that appears in many mobile systems as well as traditional operating systems.
SQLite is popular for many reasons. Notably, the entire code base is high quality, open source, and released to the public domain. The file format and the program itself is very compact and contains significant functionality in less than a few hundred kilobytes. Unlike more traditional relational database management systems (RDBMS), such as Oracle, MySQL, and Microsoft's SQL Server, with SQLite the entire database is contained in a single cross-platform file.
Applications need to be able to store and retrieve data in an efficient manner. Developers have commonly created their own individual file formats for this purpose; however, many are now turning to SQLite because it is free, open-source, high quality, and efficient. Even after a system crash, SQLite transactions are still available.
Apple developers have leveraged SQLite databases for data storage within the iPhone. Many of the popular default applications are stored in this format such as the Address Book, Calendar, Notes, Text Messages, Photos, Voicemails, and more. Data within these files is broken up into tables, which contain the actual data. Figure 3.2 displays the SMS SQLite database structure within SQLite Database Browser on a Mac. A listing of all the tables is shown, with the “Message” table actually selected.
B9781597496599000031/f03-02-9781597496599.jpg is missing
Figure 3.2
SMS Database Structure.
Information on SQLite files can also be retrieved through command line. On a Linux Ubuntu workstation, a database file can be viewed and modified. The following command opens the SMS.db file using SQLite version 3:
kstrzempka@linux-001:~/sqlite$ ./sqlite3 sms.db
SQLite version 3.7.4
Enter “.help” for instructions
Enter SQL statements terminated with a ‘’
sqlite>
Once open, various commands can be run in order to retrieve data. For example, the following lists all tables in the database:
sqlite> .tables
_SqliteDatabaseProperties msg_group
group_member msg_pieces
message
The next command describes the structure of the message table, referred to as the “schema.” The schema describes the way in which the database will be organized in its own special language.
sqlite> .schema messages
CREATE TABLE message (ROWID INTEGER PRIMARY KEY AUTOINCREMENT, address TEXT, date INTEGER, text TEXT,
flags INTEGER, replace INTEGER, svc_center TEXT, group_id INTEGER, association_id INTEGER, height INTEGER,
UIFlags INTEGER, version INTEGER, subject TEXT, country TEXT, headers BLOB, recipients BLOB, read INTEGER);
Looking at the schema of the messages table is just another way of understanding the different fields within that table as well as all data types associated with that field. Another way of looking at this information is through the SQLite Database Browser that was used earlier. This software is a free, open-source tool used to create, design, and edit database files that support SQLite. SQLite Database Browser is available for Mac, Linux, and Windows platforms, and can be downloaded at http://sqlitebrowser.sourceforge.net. Other SQLite database viewing options are also available at http://www.sqlite.org/cvstrac/wiki?p=ManagementTools
Since such a significant amount of iPhone data can be found within SQLite files, an examiner should make it a priority to understand how these databases are leveraged. Details on recovering information from these files will be covered in Chapter 6.

Property lists

Property lists are used by applications to store, organize, and access various data types on iOS devices as well as Mac OS X. More commonly referred to as “plists,” these files are made up of a hierarchy of three classes, all bundled up into one “list.” These three classes consist of the Cocoa Foundation, Core Foundation, and XML. When a plist is created in XML format, an application is then able to read from it, while at the same time converting the XML properties into their appropriate objects to be used in both the Cocoa and Core Foundations (Apple Inc., 2010). A property list in XML format, opened on a Mac using TextWrangler, looks similar to the text displayed below. This is a portion of the “com.apple.Maps.plist” file. In it, latitude and longitude coordinates, and other data (not necessarily shown here) can be easily identified.
<?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>DirectionsMode</key>
<integer>2</integer>
<key>DirectionsRouteStartStepIsActive</key>
<false/>
<key>DirectionsStepIndex</key>
<integer>-1</integer>
<key>DirectionsViewType</key>
<integer>0</integer>
<key>LastViewMode</key>
<integer>0</integer>
<key>LastViewedLatitude</key>
<real>41.871318817138672</real>
<key>LastViewedLongitude</key>
<real>-87.721084594726562</real>
<key>LastViewedZoomScale</key>
<real>13.778828620910645</real>
<key>RouteEndStringIsAtom</key>
<false/>
<key>RouteStartStringIsAtom</key>
<false/>
<key>SearchMode</key>
<integer>1</integer>
<key>SearchStringIsAtom</key>
<false/>
<key>SelectedEndSearchResult</key>
<integer>0</integer>
<key>SelectedSearchResultType</key>
<integer>0</integer>
<key>SelectedStartSearchResult</key>
<integer>0</integer>
<key>TrafficEnabled</key>
<false/>
A property list can be stored in either XML format or binary format (which is used by the Cocoa Class OS layer). Apple began storing certain preference files in binary format in order to reduce the file size and make application access more efficient. As an example, repeated values within a file need to be stored only once and can be referenced when needed later in the file. Also, data can be stored in bytes rather than in a string. These are just a few examples of how binary plists (or bplists) can reduce the file size of a property list (Caithness, 2010).
If a property list is formatted as XML, the file can be viewed using any standard text editor. If stored in binary format, which is essentially a more compact version of the XML plist, the file must be opened by an application that can convert it to ASCII. Plutil, which stands for “property list utility” is one of these applications. This tool converts plist files between binary and text formats when run against a property list file. It also has the capability to scan a property list file and check it for proper XML syntax. Plutil is purely command-line driven and can be run on Windows, Linux, or Mac OS X (PERL, 2008). By default, plutil is installed on a Mac in the directory /usr/bin/plutil, and is available for download on the Internet for Windows and Linux. Prior to conversion, a binary plist is unreadable and shows something like “bplist00” followed by any number of unrecognizable characters.
To convert this file to ASCII format, the following command can be run using plutil:
$ /usr/bin/plutil -convert xml1 Bookmarks.plist
To convert from XML to binary format, run the following:
$ /usr/bin/plutil -convert binary1 Bookmarks.plist
No output will be shown, but when the user attempts to open the file, the format will have been converted to either binary or XML, depending on the command that was run. Another helpful option that can be run against a property list file is the “-lint” option. When incorporating this option into the command, the utility will let the user know whether the plist contains syntax errors:
$ /usr/bin/plutil -lint Bookmarks.plist
Bookmarks.plist: OK
Data within a property list can be of various types, including strings, numbers, binary data, dates, and Boolean values. Because a property list consists of three classes of data, this data must be represented in three different ways. The various data types as well as the ways in which they are represented to each class are demonstrated in Table 3.1 (Apple Inc., 2010).
Table 3.1 Property List Data Types
Data TypeXML ElementCocoa ClassCore Foundation Type
array<array>NSArrayCFArray (CFArrayRef)
dictionary<dict>NSDictionaryCFDictionary (CFDictionaryRef)
string<string>NSStringCFString (CFStringRef)
data<data>NSDataCFData (CFDataRef)
date<date>NSDateCFDate (CFDateRef)
number-integer<integer>NSNumber (intValue)CFNumber (CFNumberRef, integer value)
number-floating point<real>NSNumber(floatValue)CFNumber (CFNumberRef,floating-point value)
Boolean<true/> or <false/>NSNumber(boolValue==YES or boolValue==NO)CFBoolean (CFBooleanRef; kCFBooleanTrue or kCFBooleanFalse)
On the iPhone in particular, property lists are commonly used by applications on the device in order to present options to the user. In particular, Safari web history and bookmarks, YouTube data, Favorites, and many other preference files are stored within property lists. Property list use has simplified mobile application development. Programmers can use these configuration files in order to modify features and functions within the application. Changes can be made to an application by simply modifying the plist and updating this file on the device.
For more details on binary and ASCII plists, refer to CCL Forensics presentation on “Property Lists in Digital Forensics.” This document contains the history of property lists, the structure of both XML and binary format, the algorithm used to convert between the two formats, and how to carve and parse property list files and content.

Network

Another option that developers have is storing data in the cloud rather than on the device itself. Initially, very few applications took advantage of the network as a storage option; however, as devices and applications mature, network storage is gaining leverage. There are many applications available on the iTunes store that allow file sharing and network access. Some examples of these include My Network Folders, Air Sharing, QMobile, and Dropbox. These applications operate in several ways. One method allows the device to upload or download stored files through a web browser. Another option involves connecting the device to a computer, mounting it as a drive, and then copying files to and from the device. As an example of a file sharing app, Dropbox has become a widely popular file sharing website, which has mobile applications for iOS, Blackberry, and Android devices. The current application, version 1.3, was updated on November 10, 2010 and has over 1100 mostly positive ratings. After it is installed and used, all user activity is stored within the “Applications” folder. More details on the analysis of this particular application is reviewed in Chapter 6.

Memory types

iPhone devices have two primary types of memory, volatile (RAM) and nonvolatile (NAND Flash) memory. Each provides a different insight into the device's data.

RAM

RAM is used by the system to load, execute, and manipulate key parts of the operating system, applications, or data, and is not saved on reboot. Like traditional computers, RAM can contain very important information which applications use to process data. Some examples include:
• passwords,
• encryption keys,
• user names,
• app data, and
• data from system processes and services.
The ability to acquire RAM from a device can be crucial in an investigation; however, it is important to get this information prior to the device being shut down or rebooted. While examining memory from a standard Windows hard drive, Linux workstation, or even Android device is possible, there is currently no method to recover memory from a live iPhone device. Up until early 2011, RAM acquisition of Mac OS X could be accomplished to some extent by recovering the “sleepimage” file, located in /private/var/vm/sleepimage. The purpose of this file is to store what the Mac had in its memory when the system went to sleep. When the computer is “woken,” the information contained in the sleepimage file is re-distributed to memory in order to allow the Mac to return to its original state prior to sleeping (Sleepimage, 2010).
In early 2011, Mac Memory Reader was released. This is a command line utility that performs a memory dump on a Mac OS device and outputs the results onto an external device (Valenzuela, 2011). Unfortunately, Mac Memory Reader does not apply to iOS devices yet.

NAND Flash

Unlike RAM, NAND Flash is nonvolatile and thus data is preserved even when the device is without power or it is rebooted. The NAND Flash is used to store not only system files but significant portions of the user's data as well.
NAND Flash memory has characteristics very different from the magnetic media found in modern hard drives. These properties make NAND Flash ideal storage for mobile devices, while at the same time presenting a number of challenges for programmers and opportunities for forensic analysts.
First, NAND Flash has no mechanical moving parts like the spinning platters and arms found in traditional magnetic hard drives. This improves the durability and reduces both the size and power consumption of the device. The memory is distributed as one or multiple chips, which often integrate both NAND Flash and RAM and are directly integrated into the circuit board of the device.
NAND Flash also has very high density and is cost effective to the manufacturer. This, of course, makes it very popular with manufacturers. One side effect of the manufacturing process and technology in general is that NAND Flash literally ships with bad blocks directly from the manufacturer. The manufacturer will generally test the memory as part of the manufacturing process and mark bad blocks in a specific structure on the NAND, which is described in their documentation. Software that then directly interacts with the NAND Flash can read the manufacturer's bad block markers and will often implement a bad block table that can logically track the bad blocks on the system and remove them from operation. This greatly speeds up bad block detection and management. So, while NAND Flash is more physically durable than spinning platters, its error rate is much higher and must be accounted for in development and use.
Another significant limitation of NAND Flash is that it has a very limited write/erase lifespan before the block is no longer capable of storing data. The lifespan varies by device and is largely impacted by the amount of data stored per NAND Flash cell, the central building block for storing the 1 or 0 bit(s). If the cell stores only a single bit (single-level cell or SLC), then the NAND Flash supports around 100,000 write/erase cycles for a 1-year data retention. However, NAND Flash rarely uses SLC, as manufacturers (and consumers) demand more data storage in devices that are of similar size or smaller. The technology has moved to multilevel cells (MLCs), where a cell can store 2, 3, or even more bits per cell. However, this not only complicates the manufacturing process and slows down the write/erase cycle but also significantly reduces the endurance of the device. A typical MLC NAND Flash storing 2 bits per cell experiences a 10-fold reduction in endurance (measured as a 1-year data retention) with a value of approximately 10,000 write/erase cycles. As the bit density per cell increases, the endurance continues to drop, which must obviously be addressed by the controlling device.
Unlike RAM and NOR Flash (which also has Flash memory and is typically used in systems such as a computer's basic input output system or BIOS), NAND Flash cannot be accessed randomly. Instead, access to data is achieved via an allocation unit, called a page, which is typically between 512 and 2048 bytes, but generally increases as the overall size of NAND Flash increases. As an example, on one 32 GB iPhone 4 device, there were shown to be 8192 bytes per page. Even though NAND Flash does not provide the fast random access like RAM, access time is still quite fast since it does not require the mechanical platter and arm movements used in traditional spinning hard drives. The pages are then organized into a larger logical unit called a block, which is typically much larger than a traditional 512 GB hard drive sector. When a block is allocated for writing, the pages inside the block are written sequentially.
Within the iPhone's file system, there is a file called “ADDataStore.sqlitedb” that contains specific details related to the NAND Flash contained within that device. With some of the earlier models, this database was empty. However, when populated, the “Scalar” table will contain information similar to the following:
key = com.apple.NANDInfo.NumVirtualBlocks
daysSince1970 = 15008
value = 1952
key = com.apple.NANDInfo.PagesPerVirtualBlock
daysSince1970 = 15008
value = 1024
key = com.apple.NANDInfo.BytesPerPage
daysSince1970 = 15008
value = 8192
key = com.apple.NANDInfo.NumLogicalReads
daysSince1970 = 15008
value = 6224374
key = com.apple.NANDInfo.NumLogicalWrites
daysSince1970 = 15008
value = 9026722
key = com.apple.NANDInfo.NumFreeVirtualBlocks
daysSince1970 = 15008
value = 1804
key = com.apple.NANDInfo.NumWearLevelOps
daysSince1970 = 15008
value = 726518
key = com.apple.NANDInfo.NumPhysicalReads
daysSince1970 = 15008
value = 6420028
key = com.apple.NANDInfo.NumPhysicalWrites
daysSince1970 = 15008
value = 10489657
key = com.apple.NANDInfo.NumPhysicalErases
daysSince1970 = 15008
value = 12266
Key characteristics of NAND Flash are the operations available for reading and writing:
• Read (page)
• Write (page)
• Erase (block)
While individual pages can be read or written, the erase operation only functions at the block level. When a block is erased, the entire block is written over with 1's (or 0xFF in hex). The erase operation is the only mechanism by which a 0 can be changed to a 1 in NAND Flash. This point is worth belaboring. In a traditional hard drive, if a value is changed from a 0 to a 1 (or vice versa), the program simply seeks the value on the hard drive and applies the appropriate voltage to change and store the new value. However, the fundamental architecture of NAND Flash provides only one mechanism to change a 0 to a 1 and that is via the erase function which is applied at the block level, not an individual page level. For this reason, a page can be written only once, and if the value of the page needs to be changed, the entire block must be erased and then the page rewritten.
Here is a specific example using a single byte for simplicity: Let us say this particular byte holds the decimal value 179 and we want to add 39 for a total value of 218. For those unfamiliar with converting numbers between base10, hex (base16), and binary (base2), the built-in calculator programs in Windows, Mac OS X, and Ubuntu Linux, all provide a programmer mode that will perform the conversions. For the numbers above, we have the conversions between numbering systems shown in Table 3.2.
Table 3.2 Decimal, Hex, and Binary Representation of Integers
Decimal (base10)Hex (base16)Binary (base2)
1790xB31011 0011
2180xDA1101 1010
So the value 179 contains three 0's and two of them need to change to 1's to present our new value of 218. However, NAND Flash cannot make that change without erasing the entire block. So, if this single byte were attempted without the erase, the result would be 146, not 218. Here is how this happens:
1011 0011 (original byte, 0xB3 or 179 decimal)
1101 1010 (new byte to write, 0xDA or 218 decimal)
---------
1001 0010 (resulting byte, 0x92 or 146 decimal)
As the byte does not contain all 1's (0xFF), the only portions of the write cycle that will succeed are 1's either remaining a 1 or changing to a 0. Whenever the write function encounters a 0 and is requested to change to a 1, it fails and simply retains the 0 value. The resulting byte is 0x92 or 146 base10 – clearly not the value intended. Another way to describe the write function is that it only changes the changed 1 values to a 0 when requested, the equivalent of the “logical and” of the two values.
In summary, a page can be written only once and, if it needs to be rewritten, the entire block must first be erased.
As one can tell, NAND Flash imposes various restrictions and limitations and thus developers and file systems must be Flash-aware to effectively work within the constraints. Two important techniques deployed are error-correcting code (ECC) and wear leveling. Both have significant implications for forensics and data recovery.
First, ECC is a technique in which an algorithm is used to detect data errors on read or write operations and correct some errors on the fly. Since NAND Flash degrades over time through usage, the system must be able to detect when a page or block is going bad and recover the data stored there. After a number of errors or failed operations is exceeded (typically three failed operations), the page or block will be marked bad and added to the bad block table.
The second important algorithm used to effectively manage NAND Flash on the iPhone is the wear-leveling code. Wear leveling spreads the writing of data across the entire NAND Flash to avoid overutilization of a single area, which would wear those blocks out more quickly. It is built into HFS Plus (Hierarchical File System Plus) with the goal of reducing writes and deletes to the NAND so that the data is preserved as long as possible. Wear-leveling is also the reason why so much information can be recovered from the device. Old data copies are not deleted, but instead marked as “unallocated.” For this reason, there are latent copies of sensitive iPhone data that can be analyzed for information but may have been deleted days, weeks, or months earlier. This analysis is discussed further in Chapter 6.

iPhone operating system

iOS is the operating system that was developed specifically for the iPhone, but now it is also used to run applications on other Apple devices including the iPad, iPod Touch, and Apple TV. There are many similarities between iOS and Mac OS X though the former was developed specifically with mobile devices in mind (Apple Developer, 2010).
Apple's developer site dedicates an entire section to the iOS Dev Center. As mentioned in Chapter 1, the iOS software development kit (SDK) contains tools needed to create and test mobile applications within an iOS environment. These Xcode tools also allow developers to test their code within an iOS Simulator to ensure the app is functioning properly.

iOS layers

The iOS kernel is loosely based on the Mac OS X kernel, and contains several layers that are used to run applications. The layers include Core OS, Core Services, Media, Cocoa Touch, and Applications. The following is a description of each of the architecture layers within iOS (Apple Developer, 2010):
Core OS: This layer sits directly on top of the device hardware and provides services including low-level networking, access to external accessories, and memory management/file system handling. The “Common Crypto” is an example of one of the dynamic libraries stored at this layer. It helps to create and manage certificates and is called upon by the Keychain Services (within the Core Services layer) in order to provide encryption/decryption functions for the Keychain files.
Core Services: In conjunction with the Core OS, this layer provides the fundamental system services that all applications use. It contains fundamental interfaces, mostly C-based, in order to allow for file access and low-level data types. These interfaces include functions such as Core Foundation, CFNetwork, SQLite, and more. Security Services are found at this layer, including Keychain Services, which are used to implement data storage and cryptographic functions within the keychain database on the device.
Media: The Media layer is where graphics, audio, and video technologies are contained.
Cocoa Touch: The Cocoa Touch layer contains technologies that provide the infrastructure needed to implement the visual interface for applications. Here, most of the technologies use Objective-C.

File system

The file system used by iPhones and other Apple devices, including Mac computers, is HFS Plus. Originally, HFS was used; however, many enhancements have been made for the HFS Plus volume format including disk space efficiency, international-friendly file names, future support for named forks, and the ability to boot on operating systems other than Mac OS. The information provided in Table 3.3 contains some of the differences between the original HFS file system and HFS Plus (Apple Developer, 2004).
Table 3.3 HFS versus HFS Plus
HFSHFS PlusDescription
16 bits of allocation blocks32 bits of allocation blocksA larger number of files allocated per volume
File name encoding is in MacRomanFile name encoding is in UnicodeUnicode allows for international-friendly file names
System Folder ID startup supportSupports a dedicated startup fileAllows Operating Systems other than Mac OS to boot from HFS Plus volumes
512 byte catalog node4 KB catalog nodeLarger catalog improves efficiency
2 31 byte maximum file size2 63 byte maximum file sizeIncreased user benefit
HFS Plus contains allocation units referred to as “allocation blocks.” A typical block size stores 4 KB of data; however, the block size will vary depending on the physical disk. If an allocation block is too large, there is the risk of wasting storage space. As an example, if a file is 9 KB in size (with allocation blocks of 4 KB), that particular file will use up three blocks, even though a significant portion of the third block will contain no data. No other files can store data on that third block because it is already being used (Kubasiak, Morris key, & Varsalone, 2009).
A tool known as fsstat was developed as part of Brian Carrier's Sleuth Kit. This particular tool displays details about a file system contained on an image file. In the following, the fsstat command is run against an iPhone disk image file. The output displays the type of file system, name of the volume, and other information about that image, such as when it was created and modified (Carrier, n.d.).
Katie-Strzempkas-MacBook:fstools kstrzemp$ fsstat iPhone-3G-313.dmg
FILE SYSTEM INFORMATION
--------------------------------------------
File System Type: HFSX
File System Version: HFSX
Volume Name: Data
Volume Identifier: 79d2d6f99b3ca938
Last Mounted By: fsck_hfs
Volume Unmounted Improperly
Mount Count: 79534
Creation Date: Tue Jan 11 21:00:26 2011
Last Written Date: Thu Feb 3 12:16:34 2011
Last Backup Date: Wed Dec 31 18:00:00 1969
Last Checked Date: Tue Jan 11 15:00:26 2011
METADATA INFORMATION
--------------------------------------------
Range: 2 - 16815
Bootable Folder ID: 0
Startup App ID: 0
Startup Open Folder ID: 0
Mac OS 8/9 Blessed System Folder ID: 0
Mac OS X Blessed System Folder ID: 0
Number of files: 1826
Number of folders: 408
CONTENT INFORMATION
--------------------------------------------
Block Range: 0 - 3836825
Total Range in Image: 0 - 3836824
Allocation Block Size: 4096
Number of Free Blocks: 3819106
Various arguments can be run with the fsstat command to retrieve specific information about the file system. One example of these arguments is the listing of the various file system types recognized by fsstat:
kstrzempka@linux-wks-001:/$ fsstat -f list
Supported file system types:
ntfs (NTFS)
fat (FAT (Auto Detection))
ext (ExtX (Auto Detection))
iso9660 (ISO9660 CD)
hfs (HFS+)
ufs (UFS (Auto Detection))
raw (Raw Data)
swap (Swap Space)
fat12 (FAT12)
fat16 (FAT16)
fat32 (FAT32)
ext2 (Ext2)
ext3 (Ext3)
ufs1 (UFS1)
ufs2 (UFS2)
The Disk Utility program on a Mac can also be used to obtain information about a hard disk or disk image. This program is commonly used to erase, format, partition, or repair a drive. It can also be used to mount disk images, such as an iPhone DMG file. Disk Utility is stored under /Applications/Utilities and can be run through a GUI (Graphical User Interface) or via command line. To simply get information about an iPhone disk image, the “diskutil” command can be run against a mounted image. The output of that command is shown below. Because the image was mounted on a Mac, some of the information is applicable to the workstation rather than the iPhone itself. For example, the Volume Name, Mount Location, etc. all relates to the Mac on which the iPhone image was mounted. The total and available size applies to the image of the iPhone.
Katie-Strzempkas-MacBook:Desktop kstrzemp$ diskutil info /Volumes/Data/
Device Identifier: disk2
Device Node: /dev/disk2
Part Of Whole: disk2
Device / Media Name: Apple read/write Media
Volume Name: Data
Escaped with Unicode: Data
Mounted: Yes
Mount Point: /Volumes/Data
Escaped with Unicode: /Volumes/Data
File System: Case-sensitive HFS+
Type: hfs
Name: Mac OS Extended (Case-sensitive)
Owners: Disabled
Partition Type: None
Bootable: Not bootable
Media Type: Generic
Protocol: Disk Image
SMART Status: Not Supported
Volume UUID: 292F1301-EDBD-3D2E-8721-5731386E9E6D
Total Size: 15.7 GB (15715635200 Bytes) (exactly 30694600 512-Byte-Blocks)
Volume Free Space: 15.6 GB (15642976256 Bytes) (exactly 30552688 512-Byte-Blocks)
Read-Only Media: No
Read-Only Volume: Yes
Ejectable: Yes
Whole: Yes
Internal: No
OS 9 Drivers: No
Low Level Format: Not Supported

Volumes

Each HFS Plus system is made up of volumes, which represent a portion of the physical disk. Each system can be made up of one or more volumes, with each volume consisting of a header, and alternate header, and five special files. Three out of the five special files contain a B-tree structure: Catalog File, Extents Overflow File, and Attributes File. A B-tree is a data structure that allows data to be efficiently searched, viewed, modified, or removed. It is made up of nodes that store key information, allowing for fast searches (Kubasiak et al., 2009).
Volume Header/Alternate Volume Header: The header contains volume information, including allocation block size as well as which blocks are available for use. It also contains metadata about each of the five special files (Kubasiak et al., 2009).
Startup File: Contains information required for booting the device (Kubasiak et al., 2009).
Allocation File: This file is used to track used versus unused blocks. The format of this file consists of one bit for every allocation block. If the bit is set, the block is in use; if it is not set, the block is available for use.
Catalog File: The catalog file contains file and folder information, which is used to locate any file and folder within the volume. It stores the hierarchy of directories and files, each having its own 32-bit catalog node ID (CNID). Apple has reserved certain CNIDs for certain files in an HFS Plus volume (Kubasiak et al., 2009).
Extents Overflow File: This file contains data on fragmented files as well as those with bad blocks (Kubasiak et al., 2009).
Attributes File: The attributes file allows the association of a data stream with a particular file or folder (Kubasiak et al., 2009).

Journaling

One attribute of the HFS Plus file system is that it allows the option of “journaling.” When journaling is enabled, a log of changes is kept, which keeps track of the changes it plans to make prior to making them in the main file system. In the event of a system or hardware component failure, the journal is used to help restore the disk back to its original state prior to the failure. Instead of having to check the entire file system, the OS just looks at recent journal transactions, allowing for a fast recovery.

iPhone disk partitions

Two disk partitions exist on the NAND Flash. The first is the system, or firmware partition, which is where the OS as well as basic applications resides. When firmware upgrades are performed on the device, the system partition is updated. With few applications actually installed here, the system partition takes up only a small portion of storage space on the device. It is configured to be read-only by default, except while performing a software upgrade. During this process, the entire partition is formatted by iTunes, without affecting any of the user data.
The user data partition, also referred to as “Slice 2,” takes up most of the space on the NAND. This is where most, if not all, evidentiary data can be found. Information on the default applications, those downloaded through the iTunes App Store, and other stored data can all be found on this partition. This image, after being forensically acquired, can be renamed as a “.dmg” file and mounted on a Mac for analysis (more on this in Chapter 6). While both slices can be imaged and analyzed, the user data, or “Media” partition, is what is typically acquired. This partition is mounted on the device at “/private/var.”
Table 3.4 provides a breakdown of the two disk partitions and provides information on mount points, information stored, and more.
Table 3.4 iPhone Disk Partitions
Partition 1 “System”Partition 2 “User Data”
Referred to asSystem or firmware partition; Slice 1User Data or Media partition; Slice 2
Storage on device0.93/8 GB; 1.4/16 GB; 2.7/32 GB7.07/8 GB; 14.6/16 GB; 29.3/32 GB
Mount location on iPhone“/” (root)“/private/var”
Type of data storedOperating system, basic applications, firmware upgradesAll user data (SMS, Call Logs, Photos, iTunes files, etc.)
As a test iPhone that had previously been jailbroken was available, the device could be connected in order to view the mounted partitions. The phone was connected through SSH, and the “mount” command was run on the root of the device. The System partition is shown first as being mounted on “/” (or root) as well as the User Data partition mounted on /private/var. Both partitions show HFS as the file system, and the User Data partition even shows that journaling is enabled.
3GS-40:~ root# mount
/dev/disk0s1 on / (hfs, local, noatime)
devfs on /dev (devfs, local, nobrowse)
/dev/disk0s2s1 on /private/var (hfs, local, journaled, noatime, protect)
The above information showed block devices, while the following are the raw disk images on the iPhone. Rdisk0 is the entire disk, including all partitions. Rdisk0s1 is the firmware partition, or Slice 1 as described above, just as Rdisk0s2 is the User Data partition. On a 3GS device, “rdisk0s2s1” is also shown.
3GS-40:/dev root# ls -lh rdisk*
crw-r---- 1 root operator 14, 0 Feb 9 10:53 rdisk0
crw-r---- 1 root operator 14, 0 Feb 9 10:54 rdisk0s1
crw-r---- 1 root operator 14, 0 Feb 9 10:53 rdisk0s2
crw-r---- 1 root operator 14, 0 Feb 9 10:54 rdisk0s2s1

Summary

Understanding where, and more importantly how, data is stored on a device can play an important role in recovering all potential data. This chapter has outlined the type of data that could potentially be stored as well as its location and the format in which it is saved on the device. While other mobile devices may contain external data storage in the form of SD cards, the iPhone stores all data to its internal NAND Flash memory. Here, data is stored in common file types such as SQLite databases and Property Lists. The NAND implements features such as wear-leveling, which spread writes and deletes out across the device in order to extend the lifespan.
While data recovery from the device at rest has several potential methods, there is no ideal way to recover volatile memory from an iPhone. A method of recovering RAM from a Mac OS workstation was recently developed, so it is possible that iPhone RAM recovery is not far behind.
The previous sections covered both the operating system and the file system used by Apple iOS devices. This file system, HFS Plus, added improvements to its original version in order to increase efficiency. Journaling is a feature within HFS Plus, which is used to log changes and allow the device to quickly recover from a system failure.
Finally, the disk partitions contained on the iPhone were discussed. The firmware partition is where the operating system and basic applications are located and also where firmware upgrades are performed. The User Data partition contains the rest of the data stored on the device. It is this second partition, or Slice 2, where data recovery is performed. The acquisition and analysis of this User Data partition are covered in Chapters 5 and Chapter 6, respectively.
References
Apple Developer, HFS Plus volume format. Mac OS X reference library: Technical Note TN1150, Retrieved February 5, 2011, fromhttp://developer.apple.com/library/mac/#technotes/tn/tn1150.html ( 2004, March 5).
Apple Developer, iOS overview. iOS reference library, Retrieved February 21, 2011, from ( 2010, July 8).
Apple Inc, Introduction to property lists. Apple developer, Retrieved February 3, 2011, fromhttp://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/PropertyLists/Introduction/Introduction.html ( 2010, March 24).
Caithness, A., Property Lists in Digital Forensics. Computer forensics, digital forensics, computer analysis, evidence – CCL Forensics, Retrieved February 10, 2011, fromhttp://www.ccl-forensics.com/pdf/property_lists_in_digital_forensics_web.pdf ( 2010, December).
Carrier Carrier, B., FSSTAT(1) manual page. The Sleuth Kit (TSK) & autopsy: Open source digital investigation tools, Retrieved February 7, 2011, fromhttp://www.sleuthkit.org/sleuthkit/man/fsstat.html; (n.d.)..
Kubasiak, R.R.; Morris key, S.; Varsalone, J., Macintosh OS X, iPod, and iPhone forensic analysis DVD toolkit. ( 2009)Syngress Pub, Burlington, MA.
PERL Implementation of OS/X Plutil, Starlight computer wizardry home page, Retrieved January 10, 2011, fromhttp://scw.us/iPhone/plutil/ ( March 2008).
Sleepimage – The Mac OS X sleepimage file explained, OS X daily, Retrieved February 10, 2011, fromhttp://osxdaily.com/2010/10/11/sleepimage-mac/ ( 2010, October 11).
Valenzuela, I., Mac OS forensics how-to: Simple RAM acquisition and analysis with Mac memory reader. SANS – Computer forensics and incident response with Rob Lee, Retrieved February 10, 2011, fromhttp://computer-forensics.sans.org/blog/2011/01/28/mac-os-forensics-howto-simple-ram-acquisition-analysis-mac-memory-reader-part-1 ( 2011, January 28).
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset