-
Notifications
You must be signed in to change notification settings - Fork 361
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
Add plugin ios_siminfo ke Plaso #4931
Open
fitrianhikma
wants to merge
3
commits into
log2timeline:main
Choose a base branch
from
fitrianhikma: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 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 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 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 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,74 @@ | ||
import logging | ||
from plaso.containers import events | ||
from plaso.parsers.plist_plugins import interface | ||
from plaso.parsers.plist import PlistParser | ||
from dfdatetime import posix_time as dfdatetime_posix_time | ||
|
||
# Setup logging | ||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
|
||
class IOSSIMInfoEventData(events.EventData): | ||
"""Event data untuk iOS SIM Info.""" | ||
DATA_TYPE = 'ios:sim:info' | ||
|
||
def __init__(self): | ||
"""Inisialisasi event data.""" | ||
super(IOSSIMInfoEventData, self).__init__(data_type=self.DATA_TYPE) | ||
self.mdn = None | ||
self.eap_aka = None | ||
self.sim_type = None | ||
self.cb_ver = None | ||
self.label_id = None | ||
self.timestamp = None | ||
|
||
|
||
class IOSSIMInfoPlugin(interface.PlistPlugin): | ||
"""Plugin untuk memproses iOS SIM Info plist.""" | ||
NAME = 'ios_siminfo' | ||
DATA_FORMAT = 'iOS SIM Info plist file' | ||
|
||
PLIST_PATH_FILTERS = frozenset([ | ||
interface.PlistPathFilter('com.apple.commcenter.data.plist') | ||
]) | ||
PLIST_KEYS = frozenset(['PersonalWallet']) | ||
|
||
def _ParsePlist(self, parser_mediator, match=None, **unused_kwargs): | ||
"""Memproses file plist.""" | ||
personal_wallet = match.get('PersonalWallet', {}) | ||
|
||
if not personal_wallet: | ||
logging.warning('PersonalWallet kosong atau tidak ditemukan di match.') | ||
return | ||
|
||
for sim_id, sim_data in personal_wallet.items(): | ||
info = sim_data.get('info', {}) | ||
if not info: | ||
logging.warning(f'Tidak ada info untuk SIM ID: {sim_id}') | ||
continue | ||
|
||
event_data = IOSSIMInfoEventData() | ||
event_data.mdn = info.get('mdn') | ||
event_data.eap_aka = info.get('eap_aka') | ||
event_data.sim_type = info.get('type') | ||
event_data.cb_ver = info.get('cb_ver') | ||
event_data.label_id = info.get('label-id') | ||
event_data.timestamp = dfdatetime_posix_time.PosixTime( | ||
timestamp=info.get('ts', 0) | ||
) | ||
|
||
# Debugging untuk memastikan data diproduksi | ||
logging.debug( | ||
f'Memproduksi event data: MDN={event_data.mdn}, ' | ||
f'SIM Type={event_data.sim_type}, CB Ver={event_data.cb_ver}' | ||
) | ||
|
||
# Pastikan data penting ada sebelum menghasilkan event | ||
if event_data.mdn: | ||
parser_mediator.ProduceEventData(event_data) | ||
else: | ||
logging.warning(f'MDN tidak ditemukan untuk SIM ID: {sim_id}') | ||
|
||
|
||
# Registrasi plugin | ||
PlistParser.RegisterPlugin(IOSSIMInfoPlugin) |
Binary file not shown.
This file contains 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,43 @@ | ||
import unittest | ||
from plaso.parsers.plist_plugins import ios_siminfo | ||
from tests.parsers.plist_plugins import test_lib | ||
|
||
|
||
class IOSSIMInfoPluginTest(test_lib.PlistPluginTestCase): | ||
"""Test untuk plugin iOS SIM Info.""" | ||
|
||
def testProcess(self): | ||
"""Menguji proses parsing plist menggunakan plugin iOS SIM Info.""" | ||
# Nama file plist yang akan diuji | ||
plist_name = 'com.apple.commcenter.data.plist' | ||
|
||
# Membuat instance dari plugin | ||
plugin = ios_siminfo.IOSSIMInfoPlugin() | ||
|
||
# Memproses file plist dengan plugin | ||
storage_writer = self._ParsePlistFileWithPlugin(plugin, [plist_name], plist_name) | ||
|
||
# Mengambil jumlah event_data yang diproses | ||
number_of_event_data = storage_writer.GetNumberOfAttributeContainers('event_data') | ||
|
||
# Memastikan jumlah event_data yang diproses sesuai | ||
self.assertEqual(number_of_event_data, 1) | ||
|
||
# Mengambil daftar event_data | ||
events = list(storage_writer.GetAttributeContainers('event_data')) | ||
|
||
# Memastikan bahwa data di event pertama sesuai dengan yang diharapkan | ||
event = events[0] | ||
self.assertEqual(event.mdn, '+19195794674') | ||
self.assertEqual(event.eap_aka, True) | ||
self.assertEqual(event.sim_type, 'sim') | ||
self.assertEqual(event.cb_ver, '49.0') | ||
self.assertEqual(event.label_id, 'E8B6082D-F391-46CB-9780-0AF46534D89F') | ||
self.assertEqual(event.timestamp.timestamp, 1684326382) | ||
|
||
# Memastikan timestamp diubah ke format yang benar | ||
self.assertEqual(event.timestamp.CopyToDateTimeString(), '2023-05-17 12:26:22') | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Oops, something went wrong.
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.
please remove the unnecessary white-space