-
Notifications
You must be signed in to change notification settings - Fork 411
Add SQLite parser for iOS Accounts (Accounts3.sqlite) file #4926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
studiawan
wants to merge
14
commits into
log2timeline:main
Choose a base branch
from
studiawan:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0d0a6b8
Add parser plugin for iOS accounts SQLite database
studiawan bc84a6f
Add iOS Account artifact: Accounts3.sqlite
studiawan 8929e99
Add unit test for iOS account parser plugin
studiawan 5487e8a
Modify ios.yaml to support iOS account parser plugin
studiawan c22e189
Modify timeliner.yaml to support iOS account parser plugin
studiawan 5375695
Add iOS account parser plugin
studiawan 809d069
Add sqlite/ios_accounts in enabled_parser_names
studiawan f113040
Fix linting issue: remove spaces in an empty line
studiawan eeb9222
Remove ios_accounts from enabled_parser_names
studiawan a31c417
Update the date value to match assertion
studiawan 3eb1256
Fix linting: line too long, bad indentation, trailing whitespace, fin…
studiawan e87f01c
Fix linting
studiawan 321b6b6
Changes after review
joachimmetz fc51758
Changes after review
joachimmetz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| # -*- coding: utf-8 -*- | ||
| """SQLite parser plugin for iOS accounts (Accounts3.db) database files.""" | ||
|
|
||
| from dfdatetime import cocoa_time as dfdatetime_cocoa_time | ||
|
|
||
| from plaso.containers import events | ||
| from plaso.parsers import sqlite | ||
| from plaso.parsers.sqlite_plugins import interface | ||
|
|
||
|
|
||
| class IOSAccountsEventData(events.EventData): | ||
| """iOS accounts event data. | ||
|
|
||
| Attributes: | ||
| account_type (str): account type. | ||
| creation_time (dfdatetime.DateTimeValues): date and time the account | ||
| was created. | ||
| identifier (str): identifier. | ||
| owning_bundle_identifier (str): owning bundle identifier of the | ||
| application managing the account. | ||
| username (str): user name. | ||
| """ | ||
|
|
||
| DATA_TYPE = 'ios:accounts:entry' | ||
|
|
||
| def __init__(self): | ||
| """Initializes event data.""" | ||
| super(IOSAccountsEventData, self).__init__(data_type=self.DATA_TYPE) | ||
| self.account_type = None | ||
| self.creation_time = None | ||
| self.identifier = None | ||
| self.owning_bundle_identifier = None | ||
| self.username = None | ||
|
|
||
|
|
||
| class IOSAccountsPlugin(interface.SQLitePlugin): | ||
| """SQLite parser plugin for iOS accounts (Accounts3.db) database files.""" | ||
|
|
||
| NAME = 'ios_accounts' | ||
| DATA_FORMAT = 'iOS accounts SQLite database (Accounts3.db) file' | ||
|
|
||
| REQUIRED_STRUCTURE = { | ||
| 'ZACCOUNT': frozenset([ | ||
| 'ZACCOUNTTYPE', 'ZDATE', 'ZUSERNAME', 'ZIDENTIFIER', | ||
| 'ZOWNINGBUNDLEID']), | ||
| 'ZACCOUNTTYPE': frozenset([ | ||
| 'Z_PK', 'ZACCOUNTTYPEDESCRIPTION'])} | ||
|
|
||
| QUERIES = [(( | ||
| 'SELECT ZACCOUNT.ZDATE, ZACCOUNTTYPE.ZACCOUNTTYPEDESCRIPTION, ' | ||
| 'ZACCOUNT.ZUSERNAME, ZACCOUNT.ZIDENTIFIER, ZACCOUNT.ZOWNINGBUNDLEID ' | ||
| 'FROM ZACCOUNT LEFT JOIN ZACCOUNTTYPE ' | ||
| 'ON ZACCOUNT.ZACCOUNTTYPE = ZACCOUNTTYPE.Z_PK'), | ||
| 'ParseAccountRow')] | ||
|
|
||
| SCHEMAS = { | ||
| 'ZACCOUNT': ( | ||
| 'CREATE TABLE ZACCOUNT (Z_PK INTEGER PRIMARY KEY, Z_ENT INTEGER, ' | ||
| 'Z_OPT INTEGER, ZACTIVE INTEGER, ZAUTHENTICATED INTEGER, ' | ||
| 'ZSUPPORTSAUTHENTICATION INTEGER, ZVISIBLE INTEGER, ' | ||
| 'ZACCOUNTTYPE INTEGER, ZPARENTACCOUNT INTEGER, ' | ||
| 'ZDATE TIMESTAMP, ZLASTCREDENTIALRENEWALREJECTIONDATE TIMESTAMP, ' | ||
| 'ZACCOUNTDESCRIPTION TEXT, ZAUTHENTICATIONTYPE TEXT, ' | ||
| 'ZCREDENTIALTYPE TEXT, ZIDENTIFIER TEXT, ZOWNINGBUNDLEID TEXT, ' | ||
| 'ZUSERNAME TEXT, ZDATACLASSPROPERTIES BLOB)'), | ||
| 'ZACCOUNTTYPE': ( | ||
| 'CREATE TABLE ZACCOUNTTYPE (Z_PK INTEGER PRIMARY KEY, ' | ||
| 'Z_ENT INTEGER, Z_OPT INTEGER, ZENCRYPTACCOUNTPROPERTIES INTEGER, ' | ||
| 'ZOBSOLETE INTEGER, ZSUPPORTSAUTHENTICATION INTEGER, ' | ||
| 'ZSUPPORTSMULTIPLEACCOUNTS INTEGER, ZVISIBILITY INTEGER, ' | ||
| 'ZACCOUNTTYPEDESCRIPTION TEXT, ZCREDENTIALPROTECTIONPOLICY TEXT, ' | ||
| 'ZCREDENTIALTYPE TEXT, ZIDENTIFIER TEXT, ZOWNINGBUNDLEID TEXT)')} | ||
|
|
||
| REQUIRES_SCHEMA_MATCH = False | ||
|
|
||
| def _GetTimeRowValue(self, query_hash, row, value_name): | ||
| """Retrieves a date and time value from the row. | ||
|
|
||
| Args: | ||
| query_hash (int): hash of the query, that uniquely | ||
| identifies the query that produced the row. | ||
| row (sqlite3.Row): row. | ||
| value_name (str): name of the value. | ||
|
|
||
| Returns: | ||
| dfdatetime.CocoaTime: date and time value or None if not available. | ||
| """ | ||
| timestamp = self._GetRowValue(query_hash, row, value_name) | ||
| if timestamp is None: | ||
| return None | ||
|
|
||
| return dfdatetime_cocoa_time.CocoaTime(timestamp=timestamp) | ||
|
|
||
| # pylint: disable=unused-argument | ||
| def ParseAccountRow(self, parser_mediator, query, row, **unused_kwargs): | ||
| """Parses an account row. | ||
|
|
||
| Args: | ||
| parser_mediator (ParserMediator): mediates interactions between | ||
| parsers and other components, such as storage and dfVFS. | ||
| query (str): query that created the row. | ||
| row (sqlite3.Row): row. | ||
| """ | ||
| query_hash = hash(query) | ||
|
|
||
| event_data = IOSAccountsEventData() | ||
| event_data.account_type = self._GetRowValue( | ||
| query_hash, row, 'ZACCOUNTTYPEDESCRIPTION') | ||
| event_data.creation_time = self._GetTimeRowValue(query_hash, row, 'ZDATE') | ||
| event_data.identifier = self._GetRowValue( | ||
| query_hash, row, 'ZIDENTIFIER') | ||
| event_data.owning_bundle_identifier = self._GetRowValue( | ||
| query_hash, row, 'ZOWNINGBUNDLEID') | ||
| event_data.username = self._GetRowValue(query_hash, row, 'ZUSERNAME') | ||
|
|
||
| parser_mediator.ProduceEventData(event_data) | ||
|
|
||
|
|
||
| sqlite.SQLiteParser.RegisterPlugin(IOSAccountsPlugin) | ||
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # -*- coding: utf-8 -*- | ||
| """Tests for the SQLite parser plugin for iOS accounts database files.""" | ||
|
|
||
| import unittest | ||
|
|
||
| from plaso.parsers.sqlite_plugins import ios_accounts | ||
|
|
||
| from tests.parsers.sqlite_plugins import test_lib | ||
|
|
||
|
|
||
| class IOSAccountsPluginTest(test_lib.SQLitePluginTestCase): | ||
| """Tests for the SQLite parser plugin for iOS accounts database files.""" | ||
|
|
||
| def testParse(self): | ||
| """Tests the ParseAccountRow method.""" | ||
| plugin = ios_accounts.IOSAccountsPlugin() | ||
| storage_writer = self._ParseDatabaseFileWithPlugin( | ||
| ['Accounts3.sqlite'], plugin) | ||
|
|
||
| number_of_event_data = storage_writer.GetNumberOfAttributeContainers( | ||
| 'event_data') | ||
| self.assertEqual(number_of_event_data, 18) | ||
|
|
||
| number_of_warnings = storage_writer.GetNumberOfAttributeContainers( | ||
| 'extraction_warning') | ||
| self.assertEqual(number_of_warnings, 0) | ||
|
|
||
| expected_event_values = { | ||
| 'account_type': 'iCloud', | ||
| 'creation_time': '2020-03-21T21:47:57.068197+00:00', | ||
| 'identifier': '1589F4EC-8F6C-4F37-929F-C6F121B36A59', | ||
| 'owning_bundle_identifier': 'com.apple.purplebuddy', | ||
| 'username': 'thisisdfir@gmail.com'} | ||
|
|
||
| event_data = storage_writer.GetAttributeContainerByIndex( | ||
| 'event_data', 3) | ||
| self.CheckEventData(event_data, expected_event_values) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style guide nit: have 2 empty lines