DMF L05 Android File Systems and Data Structures
DMF L05 Android File Systems and Data Structures
Lecture 3
DIGITALMEDIA
FORENSICS
( CDF2C02)
2
Acknowledgement
• Contents are taught in conjunction with Internet
resources from:
• Hoog, A. (2011). Android Forensics: Investigation, Analysis, and Mobile
Security for Google Android. Syngress Publishing.
• Available as hardcopy book at TP library and softcopy on 24x7 at TP library web
portal
• Cellebrite. (2014). Participant Guide: Cellebrite Certified Logical
Operator. Cellebrite USA Inc.
• Cellebrite. (2014). Participant Guide: Cellebrite Certified Physical
Analyst. Cellebrite USA Inc.
• Android Forensics: Exploring Android Internals and Android Apps
(source: www.slideshare.net)
3
Slides Resources
• Slide resource credits:
• Hoog, A. (2011). Android Forensics: Investigation, Analysis, and Mobile
Security for Google Android. Syngress Publishing.
• Available in TP library
• Hardcopy
• eBook (7 days loan availability)
4
Shared Preferences
• Shared preferences
• Allow a developer to store key-value pairs of primitive
data types in a lightweight XML format.
• Primitive data types that can be stored in a
preferences file include the following:
1. boolean: true or false
2. float: single-precision 32-bit IEEE 754 floating point
3. int: 32-bit signed two’s complement integer
4. long: 64-bit signed two’s complement integer
5. strings: string value, typically as a UTF-8
7
shared_prefs folder
• Typically stored in an application’s data directory in the
shared_pref folder and end with .xml.
• E.g. On HTC Incredible, the Android phone shared
preferences directory contains five XML files:
root@ubuntu:~/data/data/com.android.phone/shared_prefs$ ls -l
total 20
-rw-r----- 1 root root 104 2011-01-23 18:05 cdma_msg_id.xml
-rw-r----- 1 root root 214 2011-01-20 09:34 com.android.phone_preferences.xml
-rw-r----- 1 root root 126 1980-01-06 09:42 _has_set_default_values.xml
-rw-r----- 1 root root 152 2010-09-10 09:46 htc_cdma_settings.xml
-rw-r----- 1 root root 102 2010-09-10 09:48 updateAreaCode.xml
Internal Storage
• Files allow storage of complicated data structures.
• Stored in the app’s /data/data subdirectory.
• Developer has control over the file type, name, and
location.
• By default, the files can only be read by the application
and even the device owner is prevented from viewing the
files unless they have root access.
• Developer can override security settings to allow other
processes to read / update app files.
• App-created files may be of forensic value.
• E.g. Google Maps’ cache may give away location history.
10
External Storage
• Files on external storage devices have far fewer security and
location constraints compared to files on internal storage
• E.g. SD cards or emulated SD cards stored directly on NAND
• To facilitate mounting SD card on desktop computers to share
files, SD cards are generally FAT32-formatted.
• While FAT32 is widely supported, it lacks the fine grained
security mechanism built into file systems such as ext3, ext4,
yaffs2, hfsplus, and more. Thus, by default, the files cannot
enforce permissions.
• App developers have greater control over the name, format,
and location of files on external and emulated SD cards.
11
SQLite
• SQLite database - another NAND/SD card-based storage that developers leverage on.
• Popular database format appearing in many mobile systems as well as traditional operating systems.
• Entire code base is of high quality, open source, and released to the public domain.
• File format and program itself are very compact and pack significant functionality in less than a few hundred KBs.
• Entire database is contained in a single cross-platform file.
• Android provides dedicated APIs that allow developers to use SQLite DBs in their apps.
• SQLite files are generally stored on the internal storage under /data/data/<packageName>/databases. But
there are no restrictions on creating databases elsewhere.
• SQLite databases are a rich source of forensic data.
Network
• Apps can use the network (when it is available) to store
and retrieve data on your own web-based services. To do
network operations, use classes in the following packages:
• java.net.*
• android.net.*
• Packages referenced in the documentation essentially
provide developers with the low-level APIs needed to
interact with the network, web servers, and more.
• While all of the forensically interesting data may not be
stored on the device, often important configuration and
database files are recoverable.
13
Android Memory
14
Types of Memory
• Android devices have two primary types of memory:
• Volatile (RAM)
• Non-volatile (NAND flash)
15
YAFFS2
• What is YAFFS2? (Yet Another Flash File System v2).
• Log Structured
• Data is never written to the same place twice.
• Data is strictly sequential.
24
YAFFS2
• YAFFS2 was built specifically for the growing NAND
flash devices and has a number of important
features that address the stringent needs of this
medium:
• a log-structured file system (which protects data even
through unexpected power outages)
• provides built in wear-leveling and error correction
• capable of handling bad blocks
• fast and has a small footprint in RAM
• Android uses YAFFS2 prior to Android v2.3.
• EXT4 is adopted for NAND storage from v2.3 onwards.
25
YAFFS2
• In the 64-byte OOB/spare area, YAFFS2 not only stores critical
information about the chunk but also shares the area with
the MTD subsystem. The critical YAFFS2 tags are as follows:
• 1 byte: block state (0xFF if block is good, any other value for a bad
block)
• 4 bytes: 32-bit chunk ID (0 indicates that chunk is storing a
yaffs_ObjectHeader, else data)
• 4 bytes: 32-bit Object ID (similar to traditional Unix inode)
• 2 bytes: number of data blocks in this chunk (all but final chunk will
be fully allocated)
• 4 bytes: sequence number for this block
• 3 bytes: ECC for tags (in Android, handled by MTD)
• 12 bytes: ECC for data (in Android, handled by MTD)
26
YAFFS2
Only ever sequential writes within a block
Data is never written in the same place but
appended.
27
YAFFS explained
Quiz 1
I have a text file, file A and I update the contents of file A and save it.
What happens in YAFFS2?
YAFFS2 in Forensics
• Data written in Pages but deleted in blocks during
garbage collection.
• Magnetic Disks vs NAND flash
• Does YAFFS2 hinder or help in forensics
investigation?
30
Quiz 2
Does YAFFS2 hind or help with Digital Forensics?