scieee AI-readable full text Open interactive document viewer

iOS Forensic artifact analysis automation

López Álamo, Daniel

Abstract

This work focuses on the development of an artifact analysis tool for iOS devices using Python. The main objective is to provide an automated solution for the forensic analysis of these devices, which allows extracting relevant information quickly and efficiently. The developed tool allows the extraction of data for subsequent visual representation of the results in an Elasticsearch dashboard with Kibana. The data extracted through the analysis tool allows visualization of user-generated activity on the iOS device. This includes information such as app activity, messages sent and received, calls made and received, web searches, among others. The representation of this data in a dashboard allows the user to explore and visualize this information interactively, which can help identify patterns of user behavior and possible clues that may be relevant in a forensic investigation.

Full text

IOS Forensic artifact analysis automation Master Thesis submitted to the Faculty of the Escola T`ecnica d’Enginyeria de Telecomunicaci´o de Barcelona Universitat Polit`ecnica de Catalunya by Daniel L´opez ´ Alamo In partial fulfillment of the requirements for the master in Cybersecurity Advisor: Sebastien Kanj Barcelona, Date 08/07/2023 Contents List of Figures 3 List of Tables 3 1 Introduction 6 1.1 GanttDiagram ................................. 7 2 State of the art 8 2.1 ForensicAnalysisiOS.............................. 8 2.2 ForensicTools.................................. 9 2.3 Artifacts..................................... 10 3 Project development 10 3.1 ArtifactsSelection ............................... 10 3.2 CodeFlow .................................... 13 3.3 BackupManager ................................ 14 3.4 Modules ..................................... 16 3.5 Parser ...................................... 16 3.6 DataRepresentation .............................. 18 4 Results 20 5 Conclusions and future development 24 References 25 Appendices 27 2 List of Figures 1 Project’sGanttdiagram ............................ 7 2 CodeFlowdiagram ............................... 14 3 ELKDockerStructure ............................. 18 4 Output file .csv WIFIDATA . . . . . . . . . . . . . . . . . . . . . . . . . . 20 5 MediaDashboard................................ 22 6 WANbytestrasnfer............................... 23 7 ExecutedProcesses............................... 23 8 DFIR - iOS Artifacts paths cheatsheet . . . . . . . . . . . . . . . . . . . . 30 9 SANS - Thirdparty applications artifacts paths . . . . . . . . . . . . . . . 30 Listings List of Tables 1 Mainprogramfilesoutput ........................... 21 3 Revision history and approval record Revision Date Purpose 0 18/01/2023 Project Description 1 15/02/2023 Control of progress and doubts with backup access 2 19/04/2023 Control of progress and doubts with plist files access 3 03/05/2023 Control of progress and doubts about timestamps formats 4 14/06/2023 Project revision and set up of the memory DOCUMENT DISTRIBUTION LIST Name e-mail Daniel L´opez ´ Alamo [email protected] Sebastien Kanj [email protected] Written by: Reviewed and approved by: Date 08/07/2023 Date 08/07/2023 Name Daniel L´opez ´ Alamo Name Sebastien Kanj Position Project Author Position Project Supervisor 4 Abstract This work focuses on the development of an artifact analysis tool for iOS devices using Python. The main objective is to provide an automated solution for the forensic analysis of these devices, which allows extracting relevant information quickly and efficiently. The developed tool allows the extraction of data for subsequent visual representation of the results in an Elasticsearch dashboard with Kibana. The data parsed through the analysis tool allows visualization of user-generated activity on the iOS device. This includes information such as app activity, messages sent and received, calls made and received, web searches, among others. The representation of this data in a dashboard allows the user to explore and visualize this information interactively, which can help identify patterns of user behavior and possible clues that may be relevant in a forensic research. 5 1 Introduction Research in the field of digital forensics has a great importance nowadays due to the increasing number of electronic devices we use in our daily lives. The analysis of forensic artifacts on iOS devices has become increasingly complex due to updates in the operating system and data encryption, which makes the extraction of relevant information a challenge for professionals in this field. In this context, the motivation for this thesis focuses on the development of an automated artifact analysis tool for iOS devices that enables fast and efficient data selection and visual representation in an Elasticsearch dashboard with Kibana. This tool could be of great use to professionals in the field of digital forensics, as it would allow them to save time in data selection and provide them with a clear and accurate visualization of the results obtained, which could help in the identification of relevant patterns and clues in an investigation. Furthermore, the development of this tool in Python[1] allows it to be customized and adapted to the specific needs of each case study, which increases its potential for application in different forensic contexts. These are the objectives set for the project development: 1. Identify useful artifacts that determine the use or activity generated on the device. 2. Triage and analysis of relevant artifacts. 3. Parse the information and save it in csv files. 4. Setting up an environment for the representation of information for the analysis of device activity. 5. Process automation. This project comes from another application that manages backups of iOS devices. This software extracted from Github[2] is from a repository called iOSbackup[3], and is used in this project to load and mount an encrypted backup and access its contents. In addition, there are several projects or programs similar to the idea of this project, however, this one focuses specifically on collecting data to record the usage activity of a device, it is important to keep in mind that there are a multitude of backlog processes that are constantly running and it is necessary to discard the information they generate and focus attention only on those generated by the user. To do this, a specific set of data is parsed that can determine that information. Regarding the initial approach, the only drawback found is the lack of some files in the backup of the device, which may be given by the version of the device. That is because the files may not exist or may be in that location depending on the iOS version and if the backup is encrypted or not [4]. 6 1.1 Gantt Diagram As a result of establishing the objectives, the project has been separated into 3 phases: •Project Planning: It is composed by the tasks of project analysis, design of the codeflow diagram and finally the analysis of the tools to be used (libraries, software, etc.). •Process: It is composed of project development tasks such as backup management, file access and processing, and dashboard creation. •Documentation: Finally, this part is focused on the documentation and research of information about the executed steps for the report transcription. Phases of the Project 2023 Jan Feb Mar Apr May Jun Jul Planning P. Analysis CodeFlow D. T. Analysis Process Backup M. Files A. Files P. Dashboard C. Doc. Research Report Figure 1: Gantt diagram of the project 7 2 State of the art 2.1 Forensic Analysis iOS Forensic analysis of iOS devices is a topic of great interest to computer security research. The big amount of information that iOS devices can contain makes artifact analysis crucial for forensic investigation. The following is a state of the art on the most relevant forensic artifacts in iOS device analysis: •Call and message logs: Call and message logs can provide valuable information about user interactions with others and, in some cases, can be used as evidence in criminal investigations. •Location data: iOS devices store information about the user’s location at various times, which can be useful in forensic investigations. However, it is important to note that the accuracy of this information may change depending on environmental conditions and device settings. •Application data: Apps installed on an iOS device may contain valuable information about the user, such as their web browsing history, interactions with social networks, and other usage data. •Wi-Fi network data: iOS devices can store information about the Wi-Fi networks they have connected to, which can be useful in determining the user’s location at specific times. •User account data: iOS devices can store user account information, such as usernames and passwords, which can be used as evidence in criminal investigations. In general, analyzing forensic artifacts on iOS devices is a complex process that requires specialized tools and techniques for data extraction and analysis. The constant evolution of operating systems and mobile applications makes artifact analysis a constantly evolving and updating field. The SANS Institute[5] was created as an initiative to provide high quality, specialized training to cybersecurity professionals. It also offers a number of free resources, such as newsletters and risk assessment tools, with the goal of educating the general public about cybersecurity risks and how to mitigate them. The SANS Institute also conducts research in the field of cybersecurity, publishing reports and studies on the latest trends and threats. Related to this project, the SANS Institute several resources for analyzing iOS and Android device artifacts, providing information on the location of the artifacts and how to access their information: 1. DFIR Advanced Smartphone Forensics, 2020, updated in April 2023[6]. 2. iOS Forensics en Aplicaciones de Terceros, May 2021[7]. 8 2.2 Forensic Tools On the other hand, there are several tools for forensic analysis of iOS devices: 1. Cellebrite UFED[8]: It is a forensic data extraction tool that supports a wide variety of iOS devices. It allows data extraction and analysis of apps, messages, emails, call logs, contacts, locations and more. 2. Oxygen Forensic Detective[9]: A digital forensic analysis tool that supports iOS devices, allowing data extraction from apps, messages, emails, call logs, contacts, locations and more. It also includes a social network analysis function and a module for password recovery. 3. Elcomsoft iOS Forensic Toolkit[10]: This is a forensic data extraction tool that allows data recovery from locked or disabled iOS devices, including password extraction and decryption of iTunes backups. 4. Magnet AXIOM[11]: This is a digital forensic analysis tool that supports iOS devices, enabling data extraction and analysis of apps, messages, emails, call logs, contacts, locations and more. It also includes a social network analysis function and a module for password recovery. 5. GrayKey[12]: This is a forensic data extraction tool that focuses on extracting data from locked or disabled iOS devices. It allows the extraction of data from apps, messages, emails, call logs, contacts, locations and more. 6. iLEAPP[13]: This tool automates much of the extraction process and presents the data in a readable and easily understandable format. iLEAPP allows investigators to extract various types of data, including system logs, events, properties, and messages. It is particularly useful for examining data within popular messaging and social media applications. 7. APOLLO iOS[14]: This tool allows you to execute queries and mutations against a GraphQL server, and returns results as query-specific Swift types. This means you don’t have to deal with parsing JSON, or passing around dictionaries and making clients cast values to the right type manually. You also don’t have to write model types yourself, because these are generated from the GraphQL definitions your UI uses. 9 3.4 Modules The execution of the main program is divided into modules, which are responsible for obtaining the data from the artifacts. The created modules obtain the information related to the name: •SafariHistory, collects information about the browser and its history. •ActivityThrottling, which collects information about the system overwhelm and its activity. •ApplicationTraces, collects the status of running processes and applications. •SeenBluetoothDevices, collects information about seen bluetooth devices •Siri, collects information related to iOS assistant •NetworkStatistics, collects information about incoming and outgoing data traffic. •DiskUsage, collects information related to storage. •AppleCar •Media, collects media file metadata. •Keyboard, collects keyboard usage information. •LastLocation, collects information about the last location of the device •CallHistory, collects call log information. The operation of these modules is simple, each one has indicated the path of the files to be analyzed separated in three formats: log type files, database type files and finally, plist type files. Once the module is called, it receives the backup by parameter and opens the files inside it calling the fileParser functions that will be responsible of processing the files of each existing format. And so on until all the modules are finished. 3.5 Parser Finally the fileParser is called, sending the backup and the list of files along with the destination folder of the processed data files. The function of this module is to obtain a copy of the original file and store it locally. Then, thanks to the previously explained libraries (pandas, sqlite, json and plistlib) we can access these files and extract their contents. For database type files, a connection has been established using sqlite by specifying the file we want to access. To be able to extract all the tables of the database we execute the function getTables that will return the list with the name of these, which are stored in a table called ”sqlite master”. Once we know their name, we only need to extract all the 16 data with their columns in .csv files. These files are named with the name of the table and saved in the appropriate domain/module. For the plist files, since their structure differs quite a lot from that of a database, we have therefore accessed and parsed the data using the plistlib library. On the other hand, it has been necessary to export the data in json files generated through its library. There is also the possibility of generating XML files, the disadvantage is that these files are more difficult to interpret and if it is necessary to reprocess them to extract some specific information it can be more complicated. Finally the log files do not require much complication and by means of delimiters and regex you can easily obtain the data of interest. The objective of the project as mentioned before is to analyze the activity recorded by the device, therefore most files store information related to time (first execution, last execution, creation date, modification date...). Normally dates are given in timestamp format, for that reason, a function called convert timestamp has been implemented. This function analyzes the columns of the dataframe received by parameter (which corresponds to the database table being exported) and detects those that are related to time and date, finally converts the timestamp value to datetime to be interpreted in an understandable format. It is important to consider that the iOS timestamp format is not the same as the UNIX one, since the first one starts from 2001 (known as Cocoa Core Data Time), while the other one starts from 1970. To resolve this conflict and to be able to use the UNIX format, the difference between the start dates of both formats has been calculated. Once the difference is calculated, we convert the timestamp to date format (interpreting it as if it were UNIX format) and add it to the obtained value. For example, the UNIX timestamp for September 17, 2022 at 00:00h would be 1663372800, while for the Cocoa Core Data format it would be 685058400, as previously described this is due to the difference in start time between formats and can be transformed with a conversion factor by calculating the difference between the start time between the two. cocoa0timestamp =datetime.timestamp(datetime(2001,1,1)) (1) date =datetime(2022,9,17) (2) unix timestamp =datetime.timestamp(date) = 1663372800 (3) cocoa timestamp =datetime.timestamp(date)−cocoa0timestamp = 685058400 (4) 17 3.6 Data Representation Once the program execution is finished, you can visualize all the .csv and .json files that have been generated with the data parsed from the backup. Elastic Stack on Docker has been used for their representation. Docker[22], is a container platform that allows you to package, distribute and run applications in isolated, reproducible environments. The combination of Elastic Stack and Docker is very popular for efficiently deploying and managing Elastic Stack environments. Using Docker to deploy ELK Stack offers several benefits, such as easy configuration, portability, scalability and isolation. Docker allows you to define the entire Elastic Stack environment as code and quickly create the necessary containers. Elastic Stack, also known as ELK Stack, is a software package that combines different tools developed by Elastic for real-time data processing and analysis. The acronym ELK refers to three main components: Elasticsearch, Logstash and Kibana[20][21]. •Elasticsearch: It is a scalable, distributed search and data analysis engine. It provides efficient storage and indexing for structured and unstructured data. In Docker, Elasticsearch can be run in a container, configuring networking options, volumes and resources as needed. •Logstash: It is a data processing pipeline that ingests, transforms and enriches data from various sources before sending it to Elasticsearch. Logstash can be deployed in a Docker container, where you can define input plugins to collect data, filter plugins for data transformation and output plugins to send data to Elasticsearch. •Kibana: It is a web-based visualization and exploration tool for analyzing data stored in Elasticsearch. With Kibana, you can create visualizations, dashboards and perform ad hoc queries. You can also run Kibana in a Docker container and configure it to connect to the Elasticsearch container. Figure 3: Containers infrastructure in ELK with Docker. 18 To create the dashboards, first the datasource must be imported, for this we will import the .csv file from which we want to visualize the data and once imported we will create the dashboard. Once Elastic has processed the file, it makes a precompute of the columns that can be selected. Once this is done, columns will be added, as the project is oriented to record the activity, only those that provide data related to time will be used. When adding them, Elastic suggests several types of graphs that could be interesting: bar charts, line graphs, total counts of records, etc. In addition, it is possible to apply formulas to these fields such as: •Average •Count •Last Value •Maximum •Minimum •Sum •Custom Formulas •... With this great variety of options there are many possibilities for the representation of the data, in the case of this project the most used is the count. Finally, we will adjust the time frame in which we want to display the data. For example, it is possible to generate a panel only for the data of 2021, another for 2022 and so on. 19 4 Results After running the program, the data files have been generated as expected, all the tables in the database files have been analyzed. From the .plist and .log files all the information has been collected without formatting errors and creating files with clear data. Each folder corresponding to a domain stores the .csv and .json files from the analyzed data and inside you can see how the dates have been correctly converted from timestamp format to date format. Figure 4: Output file .csv WIFIDATA. In the case of the multimedia files, the original metadata has been successfully extracted, this was achieved thanks to a function that allowed to extract the metadata from the backup files without the need to copy them previously in local. Finally, the data files have been imported correctly to Elastic for dashboard generation. The date type fields are correct and have allowed to generate understandable graphs for the analysis of the device usage, clearly distinguishing the user interaction by days, months and years. 20 Table 1: Indicates the files generated in each domain and its type. Domain Subdomain Files1Output Type ActivityThrottling com.apple.contextstored.plist .json com.apple.coreduetd.plist .json AppleCar com.apple.carplay.plist .json Aplication Traces DataUsage ZCHECKUPEVENT .csv DataUsage ZDEMOLIVEUSAGE .csv DataUsage ZEVENT .csv DataUsage ZEVENTSCENE .csv DataUsage ZLIVEUSAGE .csv DataUsage ZPEER .csv DataUsage ZPROCESS .csv DataUsage ZTSHOOTINGDATA .csv DataUsage ZWIFIDATA .csv ApplicationState application identifier tab .csv ApplicationState key tab .csv ApplicationState ksv .csv ApplicationState schema .csv InteractionC ZATTACHMENT .csv InteractionC ZCONTACTS .csv InteractionC ZINTERACTIONS .csv InteractionC ZKEYWORDS .csv InteractionC ZVERSION .csv InteractionC Z 1INTERACTIONS .csv InteractionC Z 2INTERACTIONRECIPIENT .csv InteractionC Z 3KEYWORDS .csv ITunesStored ZMICROPAYMENTBASE .csv ITunesStored ZMICROPAYMENTCLIENT .csv ITunesStored ZMICROPAYMENTCLIENT .csv ITunesStored ZMICROPAYMENTDOWNLOAD .csv clients.plist .json com.apple.corespotlightui.plist .json CallHistory ZCALLDBPROPERTIES .csv ZCALLRECORD .csv ZHANDLE .csv Z 2REMOTEPARTICIPANTHANDLES .csv DiskUsage com.apple.Preferences.plist .json Keyboard langlikelihood EmojiByApp .csv langlikelihood MetaData .csv langlikelihood OfflineAdaptationTimeByApp .csv langlikelihood RecipientByLangMatrix .csv user model database properties .csv user model database sqlite sequence .csv user model database usermodeldurablerecords .csv user model database usermodeltransientrecords .csv LastLocation com.apple.Maps.plist .json Media media .csv NetworkStatistics com.apple.CommCenter.counts.plist .json 21 Domain Subdomain Files Output Type NetworkStatistics history client versions .csv history event listeners .csv history events .csv history items .csv history items to tags .csv history tags .csv history tombstones .csv history visits .csv metadata .csv sqlite sequence .csv SeenBluetoothDevices OtherDevices .csv SqliteDatabaseProperties.csv .csv Siri com.apple.assistant.backedup.plist .json com.apple.assistant.support.plist .json Figure 5: Media created in January 2023. 1Some of them were generated from each table of a database file. 22 Figure 6: In/Out WAN bytes transfered from 11th to 17th August 2022. Figure 7: Executed Processes during 19th September. 23 5 Conclusions and future development This project describes an automatic forensic tool that allows the extraction of artifacts related to the system activity and allows their subsequent graphical representation in the Elastic tool. In addition, contributes to the field of iOS device forensics analysis by providing a tool that facilitates the acquisition of artifacts related to user activity and allowing for easy representation of the data. This tool is public and free to use, which means that it is subject to the opportunity for improvements and suggestions from the community. This gives the opportunity to extend its results and to explore and expand its dimensions in the field of forensic analysis. All phases of the project have been successfully completed, despite minor setbacks with time formats and some problems with access to files, but thanks to some libraries it could be manage and solved easily. Nevertheless, the expected results have been obtained and even so, this project has many options for future development: •Precompute a list of artifacts of generic interest and allow the user to choose which ones to get. For this it would be necessary to improve the aspect of file availability. •Add new functions that allow to extract data of interest from json files and assemble tables to be represented. •Create a generic dashboard template via json to automate the creation of dashboards with the ElasticSearch API, in this way an initial graphical version would be obtained and then could be modified. With these improvements the project would gain a lot of value demonstrating that the interaction is minimal and that is something attractive to the user. 24 References [1] Python — python.org. https://www.python.org/. [2] Github — github.com. https://github.com/. [3] GitHub - avibrazil/iOSbackup: A Python 3 class that reads and extracts files from a password-encrypted iOS backup created by iTunes on Mac and Windows. Compatible with iOS 14. Class works on Linux too. — github.com. https://github.com/ avibrazil/iOSbackup. [4] About encrypted backups on your iPhone, iPad, or iPod touch — support.apple.com. https://support.apple.com/en-us/HT205220. [5] Cyber Security Training — SANS Courses, Certifications amp; Research — sans.org. https://www.sans.org/emea/. [6] DFIR Advanced Smartphone Forensics — SANS Posters — sans.org. https://www. sans.org/posters/dfir-advanced-smartphone-forensics/. [7] Analisis Forense de Aplicaciones de Terceros de iOS — sans.org. https://www. sans.org/posters/En-Espanol-iOS-Aplicaciones-Forenses-de-Terceros/. [8] Cellebrite UFED — cellebrite.com. https://cellebrite.com/es/ cellebrite-ufed-es/. [9] Oxygen Forensic Detective — oxygenforensics.com. https://oxygenforensics. com/en/products/oxygen-forensic-detective/. [10] Elcomsoft Co.Ltd. Elcomsoft iOS Forensic Toolkit — Elcomsoft Co.Ltd. — elcomsoft.com. https://www.elcomsoft.com/eift.html. [11] Magnet AXIOM — Digital Forensic Software — Magnet Forensics — magnetforensics.com. https://www.magnetforensics.com/products/magnet-axiom/. [12] GrayKey Cell Phone Forensics Tool — Grayshift — grayshift.com. https://www. grayshift.com/graykey/. [13] GitHub - abrignoni/iLEAPP: iOS Logs, Events, And Plist Parser — github.com. https://github.com/abrignoni/iLEAPP. [14] GitHub - apollographql/apollo-ios: A strongly-typed, caching GraphQL client for iOS, written in Swift. — github.com. https://github.com/apollographql/ apollo-ios. [15] pandas - Python Data Analysis Library — pandas.pydata.org. https://pandas. pydata.org/. [16] sqlite3 — DB-API 2.0 interfaz para bases de datos SQLite — docs.python.org. https: //docs.python.org/es/3/library/sqlite3.html. [17] plistlib — Generate and parse Apple .plist files — docs.python.org. https://docs. python.org/3/library/plistlib.html. 25