Skip to content
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

Impovements for SMS module #438

Merged
merged 3 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions mvt/ios/modules/mixed/sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,25 @@ def __init__(
def serialize(self, record: dict) -> Union[dict, list]:
text = record["text"].replace("\n", "\\n")
sms_data = f"{record['service']}: {record['guid']} \"{text}\" from {record['phone_number']} ({record['account']})"
return [
sms_data = [
{
"timestamp": record["isodate"],
"module": self.__class__.__name__,
"event": "sms_received",
"data": sms_data,
},
{
"timestamp": record["isodate_read"],
"module": self.__class__.__name__,
"event": "sms_read",
"data": sms_data,
},
]
# If the message was read, we add an extra event.
if record["isodate_read"]:
sms_data.append(
{
"timestamp": record["isodate_read"],
"module": self.__class__.__name__,
"event": "sms_read",
"data": sms_data,
}
)
return sms_data

def check_indicators(self) -> None:
for message in self.results:
Expand Down
5 changes: 5 additions & 0 deletions mvt/ios/modules/mixed/sms_attachments.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ def serialize(self, record: dict) -> Union[dict, list]:

def check_indicators(self) -> None:
for attachment in self.results:
# Check for known malicious filenames.
if self.indicators.check_file_path(attachment["filename"]):
print("Found malicious filename", attachment["filename"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use a logger instance?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh, yes thanks! Not sure how I missed theprint() when committing. The indicators.check_file_path() already logs the detection. We can just append the attachment to the detections without adding an additional log line.

self.detected.append(attachment)

if (
attachment["filename"].startswith("/var/tmp/")
and attachment["filename"].endswith("-1")
Expand Down
2 changes: 1 addition & 1 deletion tests/ios_backup/test_sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_sms(self):
m = SMS(target_path=get_ios_backup_folder())
run_module(m)
assert len(m.results) == 1
assert len(m.timeline) == 2 # SMS received and read events.
assert len(m.timeline) == 1
assert len(m.detected) == 0

def test_detection(self, indicator_file):
Expand Down
Loading