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

Add Tab URL's and MIME type to download record #429

Merged
merged 2 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 5 additions & 2 deletions dissect/target/plugins/browsers/chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
GENERIC_HISTORY_RECORD_FIELDS,
BrowserPlugin,
)
from dissect.target.plugins.browsers.chromium import ChromiumMixin
from dissect.target.plugins.browsers.chromium import (
CHROMIUM_DOWNLOAD_RECORD_FIELDS,
ChromiumMixin,
)


class ChromePlugin(ChromiumMixin, BrowserPlugin):
Expand All @@ -27,7 +30,7 @@ class ChromePlugin(ChromiumMixin, BrowserPlugin):
"Library/Application Support/Google/Chrome/Default",
]
BrowserDownloadRecord = create_extended_descriptor([UserRecordDescriptorExtension])(
"browser/chrome/download", GENERIC_DOWNLOAD_RECORD_FIELDS
"browser/chrome/download", GENERIC_DOWNLOAD_RECORD_FIELDS + CHROMIUM_DOWNLOAD_RECORD_FIELDS
)
BrowserExtensionRecord = create_extended_descriptor([UserRecordDescriptorExtension])(
"browser/chrome/extension", GENERIC_EXTENSION_RECORD_FIELDS
Expand Down
14 changes: 13 additions & 1 deletion dissect/target/plugins/browsers/chromium.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@
)
from dissect.target.plugins.general.users import UserDetails

CHROMIUM_DOWNLOAD_RECORD_FIELDS = [
("uri", "tab_url"),
("uri", "tab_referrer_url"),
("string", "mime_type"),
]


class ChromiumMixin:
"""Mixin class with methods for Chromium-based browsers."""

DIRS = []
BrowserDownloadRecord = create_extended_descriptor([UserRecordDescriptorExtension])(
"browser/chromium/download", GENERIC_DOWNLOAD_RECORD_FIELDS
"browser/chromium/download", GENERIC_DOWNLOAD_RECORD_FIELDS + CHROMIUM_DOWNLOAD_RECORD_FIELDS
)
BrowserExtensionRecord = create_extended_descriptor([UserRecordDescriptorExtension])(
"browser/chromium/extension", GENERIC_EXTENSION_RECORD_FIELDS
Expand Down Expand Up @@ -117,7 +123,10 @@ def downloads(self, browser_name: str = None) -> Iterator[BrowserDownloadRecord]
id (string): Record ID.
path (string): Download path.
url (uri): Download URL.
tab_url (string): Tab URL.
tab_referrer_url (string): Referrer URL.
size (varint): Download file size.
mime_type (string): MIME type.
state (varint): Download state number.
source: (path): The source file of the download record.
Raises:
Expand Down Expand Up @@ -151,9 +160,12 @@ def downloads(self, browser_name: str = None) -> Iterator[BrowserDownloadRecord]
ts_end=webkittimestamp(row.end_time) if row.end_time else None,
browser=browser_name,
id=row.get("id"),
tab_url=try_idna(row.get("tab_url")),
tab_referrer_url=try_idna(row.get("tab_referrer_url")),
path=download_path,
url=url,
size=row.get("total_bytes"),
mime_type=row.get("mime_type"),
state=row.get("state"),
source=db_file,
_target=self.target,
Expand Down
7 changes: 5 additions & 2 deletions dissect/target/plugins/browsers/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
GENERIC_HISTORY_RECORD_FIELDS,
BrowserPlugin,
)
from dissect.target.plugins.browsers.chromium import ChromiumMixin
from dissect.target.plugins.browsers.chromium import (
CHROMIUM_DOWNLOAD_RECORD_FIELDS,
ChromiumMixin,
)


class EdgePlugin(ChromiumMixin, BrowserPlugin):
Expand All @@ -25,7 +28,7 @@ class EdgePlugin(ChromiumMixin, BrowserPlugin):
"Library/Application Support/Microsoft Edge/Default",
]
BrowserDownloadRecord = create_extended_descriptor([UserRecordDescriptorExtension])(
"browser/edge/download", GENERIC_DOWNLOAD_RECORD_FIELDS
"browser/edge/download", GENERIC_DOWNLOAD_RECORD_FIELDS + CHROMIUM_DOWNLOAD_RECORD_FIELDS
)
BrowserExtensionRecord = create_extended_descriptor([UserRecordDescriptorExtension])(
"browser/edge/extension", GENERIC_EXTENSION_RECORD_FIELDS
Expand Down