dissect.target 3.20.dev36__py3-none-any.whl → 3.20.dev39__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- dissect/target/filesystems/config.py +1 -1
- dissect/target/helpers/compat/path_common.py +5 -5
- dissect/target/helpers/configutil.py +31 -29
- dissect/target/helpers/cyber.py +2 -0
- dissect/target/helpers/docs.py +1 -1
- dissect/target/helpers/keychain.py +2 -0
- dissect/target/helpers/mount.py +2 -1
- dissect/target/plugin.py +15 -13
- dissect/target/plugins/apps/av/mcafee.py +2 -0
- dissect/target/plugins/apps/av/sophos.py +2 -0
- dissect/target/plugins/apps/av/trendmicro.py +2 -0
- dissect/target/plugins/apps/browser/chromium.py +27 -6
- dissect/target/plugins/apps/editor/editor.py +23 -0
- dissect/target/plugins/apps/{texteditor → editor}/windowsnotepad.py +40 -31
- dissect/target/plugins/apps/shell/powershell.py +6 -2
- dissect/target/plugins/apps/shell/wget.py +1 -1
- dissect/target/plugins/apps/ssh/openssh.py +2 -0
- dissect/target/plugins/apps/ssh/opensshd.py +2 -0
- dissect/target/plugins/apps/vpn/wireguard.py +9 -9
- dissect/target/plugins/apps/webhosting/cpanel.py +2 -0
- dissect/target/plugins/apps/webserver/caddy.py +2 -0
- dissect/target/plugins/apps/webserver/nginx.py +2 -0
- dissect/target/plugins/child/esxi.py +3 -1
- dissect/target/plugins/child/virtuozzo.py +12 -8
- dissect/target/plugins/filesystem/acquire_hash.py +2 -1
- dissect/target/plugins/filesystem/icat.py +15 -11
- dissect/target/plugins/filesystem/ntfs/mft.py +2 -0
- dissect/target/plugins/filesystem/ntfs/mft_timeline.py +3 -1
- dissect/target/plugins/filesystem/ntfs/usnjrnl.py +2 -0
- dissect/target/plugins/filesystem/ntfs/utils.py +3 -1
- dissect/target/plugins/filesystem/unix/suid.py +4 -1
- dissect/target/plugins/filesystem/walkfs.py +2 -0
- dissect/target/plugins/general/example.py +2 -2
- dissect/target/plugins/general/loaders.py +1 -1
- dissect/target/plugins/general/network.py +7 -0
- dissect/target/plugins/general/osinfo.py +1 -0
- dissect/target/plugins/general/plugins.py +4 -0
- dissect/target/plugins/os/unix/_os.py +2 -1
- dissect/target/plugins/os/unix/bsd/citrix/history.py +2 -0
- dissect/target/plugins/os/unix/bsd/osx/network.py +2 -0
- dissect/target/plugins/os/unix/bsd/osx/user.py +4 -0
- dissect/target/plugins/os/unix/cronjobs.py +8 -4
- dissect/target/plugins/os/unix/etc/etc.py +4 -0
- dissect/target/plugins/os/unix/generic.py +2 -0
- dissect/target/plugins/os/unix/history.py +27 -25
- dissect/target/plugins/os/unix/linux/cmdline.py +2 -0
- dissect/target/plugins/os/unix/linux/debian/apt.py +4 -1
- dissect/target/plugins/os/unix/linux/debian/dpkg.py +3 -3
- dissect/target/plugins/os/unix/linux/environ.py +2 -0
- dissect/target/plugins/os/unix/linux/fortios/generic.py +2 -0
- dissect/target/plugins/os/unix/linux/fortios/locale.py +2 -0
- dissect/target/plugins/os/unix/linux/modules.py +2 -0
- dissect/target/plugins/os/unix/linux/netstat.py +2 -0
- dissect/target/plugins/os/unix/linux/processes.py +2 -0
- dissect/target/plugins/os/unix/linux/redhat/yum.py +4 -1
- dissect/target/plugins/os/unix/linux/services.py +5 -3
- dissect/target/plugins/os/unix/linux/sockets.py +2 -0
- dissect/target/plugins/os/unix/linux/suse/zypper.py +4 -1
- dissect/target/plugins/os/unix/locale.py +2 -0
- dissect/target/plugins/os/unix/locate/gnulocate.py +4 -2
- dissect/target/plugins/os/unix/locate/mlocate.py +2 -0
- dissect/target/plugins/os/unix/locate/plocate.py +3 -1
- dissect/target/plugins/os/unix/log/atop.py +2 -0
- dissect/target/plugins/os/unix/log/audit.py +3 -1
- dissect/target/plugins/os/unix/log/auth.py +4 -2
- dissect/target/plugins/os/unix/log/lastlog.py +5 -3
- dissect/target/plugins/os/unix/log/messages.py +2 -0
- dissect/target/plugins/os/unix/log/utmp.py +4 -2
- dissect/target/plugins/os/unix/packagemanager.py +4 -37
- dissect/target/plugins/os/unix/shadow.py +3 -1
- dissect/target/plugins/os/unix/trash.py +1 -1
- dissect/target/plugins/os/windows/activitiescache.py +9 -4
- dissect/target/plugins/os/windows/adpolicy.py +2 -1
- dissect/target/plugins/os/windows/amcache.py +16 -13
- dissect/target/plugins/os/windows/defender.py +3 -3
- dissect/target/plugins/os/windows/dpapi/keyprovider/credhist.py +3 -0
- dissect/target/plugins/os/windows/dpapi/keyprovider/empty.py +3 -0
- dissect/target/plugins/os/windows/dpapi/keyprovider/keychain.py +3 -0
- dissect/target/plugins/os/windows/dpapi/keyprovider/lsa.py +3 -0
- dissect/target/plugins/os/windows/env.py +1 -2
- dissect/target/plugins/os/windows/exchange/exchange.py +6 -4
- dissect/target/plugins/os/windows/generic.py +20 -18
- dissect/target/plugins/os/windows/lnk.py +2 -0
- dissect/target/plugins/os/windows/locale.py +9 -3
- dissect/target/plugins/os/windows/log/etl.py +5 -4
- dissect/target/plugins/os/windows/log/evt.py +12 -8
- dissect/target/plugins/os/windows/log/evtx.py +9 -7
- dissect/target/plugins/os/windows/log/pfro.py +2 -1
- dissect/target/plugins/os/windows/network.py +2 -0
- dissect/target/plugins/os/windows/notifications.py +6 -4
- dissect/target/plugins/os/windows/prefetch.py +7 -2
- dissect/target/plugins/os/windows/regf/7zip.py +9 -1
- dissect/target/plugins/os/windows/regf/auditpol.py +2 -1
- dissect/target/plugins/os/windows/regf/bam.py +3 -1
- dissect/target/plugins/os/windows/regf/cit.py +14 -12
- dissect/target/plugins/os/windows/regf/clsid.py +6 -3
- dissect/target/plugins/os/windows/regf/firewall.py +2 -1
- dissect/target/plugins/os/windows/regf/mru.py +9 -8
- dissect/target/plugins/os/windows/regf/nethist.py +6 -3
- dissect/target/plugins/os/windows/regf/recentfilecache.py +3 -1
- dissect/target/plugins/os/windows/regf/regf.py +5 -1
- dissect/target/plugins/os/windows/regf/shimcache.py +1 -1
- dissect/target/plugins/os/windows/regf/usb.py +2 -1
- dissect/target/plugins/os/windows/regf/userassist.py +2 -1
- dissect/target/plugins/os/windows/registry.py +11 -0
- dissect/target/plugins/os/windows/services.py +3 -2
- dissect/target/plugins/os/windows/startupinfo.py +7 -2
- dissect/target/plugins/os/windows/syscache.py +3 -1
- dissect/target/plugins/os/windows/tasks.py +1 -1
- dissect/target/plugins/os/windows/thumbcache.py +11 -5
- dissect/target/plugins/os/windows/ual.py +12 -9
- dissect/target/plugins/os/windows/wua_history.py +0 -1
- dissect/target/tools/dump/utils.py +4 -0
- dissect/target/tools/shell.py +2 -1
- {dissect.target-3.20.dev36.dist-info → dissect.target-3.20.dev39.dist-info}/METADATA +1 -1
- {dissect.target-3.20.dev36.dist-info → dissect.target-3.20.dev39.dist-info}/RECORD +122 -123
- dissect/target/plugins/apps/texteditor/texteditor.py +0 -13
- dissect/target/plugins/os/unix/etc.py +0 -9
- /dissect/target/plugins/apps/{texteditor → editor}/__init__.py +0 -0
- {dissect.target-3.20.dev36.dist-info → dissect.target-3.20.dev39.dist-info}/COPYRIGHT +0 -0
- {dissect.target-3.20.dev36.dist-info → dissect.target-3.20.dev39.dist-info}/LICENSE +0 -0
- {dissect.target-3.20.dev36.dist-info → dissect.target-3.20.dev39.dist-info}/WHEEL +0 -0
- {dissect.target-3.20.dev36.dist-info → dissect.target-3.20.dev39.dist-info}/entry_points.txt +0 -0
- {dissect.target-3.20.dev36.dist-info → dissect.target-3.20.dev39.dist-info}/top_level.txt +0 -0
@@ -1,3 +1,5 @@
|
|
1
|
+
from typing import Iterator
|
2
|
+
|
1
3
|
from dissect.target.exceptions import UnsupportedPluginError
|
2
4
|
from dissect.target.helpers.record import ChildTargetRecord
|
3
5
|
from dissect.target.plugin import ChildTargetPlugin
|
@@ -9,13 +11,15 @@ class VirtuozzoChildTargetPlugin(ChildTargetPlugin):
|
|
9
11
|
Virtuozzo conatiners are by default registered in the folder ``vz/root/$VEID``,
|
10
12
|
where VEID will be substituted with the actual container UUID.
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
.. code-block::
|
15
|
+
|
16
|
+
/
|
17
|
+
etc/
|
18
|
+
var/
|
19
|
+
vz/
|
20
|
+
root/
|
21
|
+
<container-uuid>/
|
22
|
+
<container-uuid>/
|
19
23
|
|
20
24
|
References:
|
21
25
|
- https://docs.virtuozzo.com/virtuozzo_hybrid_server_7_command_line_reference/managing-system/configuration-files.html
|
@@ -29,7 +33,7 @@ class VirtuozzoChildTargetPlugin(ChildTargetPlugin):
|
|
29
33
|
if not self.target.fs.path(self.PATH).exists():
|
30
34
|
raise UnsupportedPluginError("No Virtuozzo path found")
|
31
35
|
|
32
|
-
def list_children(self):
|
36
|
+
def list_children(self) -> Iterator[ChildTargetRecord]:
|
33
37
|
for container in self.target.fs.path(self.PATH).iterdir():
|
34
38
|
yield ChildTargetRecord(
|
35
39
|
type=self.__type__,
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import csv
|
2
2
|
import gzip
|
3
|
+
from typing import Iterator
|
3
4
|
|
4
5
|
from dissect.target.exceptions import UnsupportedPluginError
|
5
6
|
from dissect.target.helpers.record import TargetRecordDescriptor
|
@@ -27,7 +28,7 @@ class AcquireHashPlugin(Plugin):
|
|
27
28
|
raise UnsupportedPluginError("No hash file found")
|
28
29
|
|
29
30
|
@export(record=AcquireHashRecord)
|
30
|
-
def acquire_hashes(self):
|
31
|
+
def acquire_hashes(self) -> Iterator[AcquireHashRecord]:
|
31
32
|
"""Return file hashes collected by Acquire.
|
32
33
|
|
33
34
|
An Acquire file container contains a file hashes csv when the hashes module was used. The content of this csv
|
@@ -1,3 +1,5 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
1
3
|
import shutil
|
2
4
|
import sys
|
3
5
|
|
@@ -27,24 +29,26 @@ class ICatPlugin(Plugin):
|
|
27
29
|
)
|
28
30
|
@arg("--ads", type=str, default="", help="Alternate Data Stream name")
|
29
31
|
@export(output="none")
|
30
|
-
def icat(self, inum, fs, ads):
|
32
|
+
def icat(self, inum: int, fs: int | None, ads: str) -> None:
|
31
33
|
"""Output the contents of a file based on its MFT segment or inode number. Supports Alternate Data Streams
|
32
34
|
|
33
35
|
Example:
|
34
|
-
|
35
|
-
|
36
|
+
.. code-block::
|
37
|
+
|
38
|
+
# outputs contents of segment defaults to 'sysvol'
|
39
|
+
target-query <TARGET> -f icat --segment 96997
|
36
40
|
|
37
|
-
|
38
|
-
|
41
|
+
# outputs contents of inode defaults to '/'
|
42
|
+
target-query <TARGET> -f icat --inode 50947
|
39
43
|
|
40
|
-
|
41
|
-
|
44
|
+
# outputs contents of segment's ADS
|
45
|
+
target-query <TARGET> -f icat --segment 96997 --ads Zone.Identifier
|
42
46
|
|
43
|
-
|
44
|
-
|
47
|
+
# outputs contents of segment in filesystem 3 of target
|
48
|
+
target-query <TARGET> -f icat --fs 3 --segment 96997
|
45
49
|
|
46
|
-
|
47
|
-
|
50
|
+
# outputs contents of inode in filesystem 2 of target
|
51
|
+
target-query <TARGET> -f icat --fs 2 --inode 50947
|
48
52
|
"""
|
49
53
|
|
50
54
|
open_as = None
|
@@ -123,6 +123,8 @@ COMPACT_RECORD_TYPES = {
|
|
123
123
|
|
124
124
|
|
125
125
|
class MftPlugin(Plugin):
|
126
|
+
"""NTFS MFT plugin."""
|
127
|
+
|
126
128
|
def __init__(self, target):
|
127
129
|
super().__init__(target)
|
128
130
|
self.ntfs_filesystems = {index: fs for index, fs in enumerate(self.target.filesystems) if fs.__type__ == "ntfs"}
|
@@ -93,6 +93,8 @@ def format_info(
|
|
93
93
|
|
94
94
|
|
95
95
|
class MftTimelinePlugin(Plugin):
|
96
|
+
"""NTFS MFT timeline plugin."""
|
97
|
+
|
96
98
|
def check_compatible(self) -> None:
|
97
99
|
ntfs_filesystems = [fs for fs in self.target.filesystems if fs.__type__ == "ntfs"]
|
98
100
|
if not len(ntfs_filesystems):
|
@@ -100,7 +102,7 @@ class MftTimelinePlugin(Plugin):
|
|
100
102
|
|
101
103
|
@export(output="yield")
|
102
104
|
@arg("--ignore-dos", action="store_true", help="ignore DOS file names")
|
103
|
-
def mft_timeline(self, ignore_dos: bool = False):
|
105
|
+
def mft_timeline(self, ignore_dos: bool = False) -> Iterator[str]:
|
104
106
|
"""Return the MFT records of all NTFS filesystems in a human readable format (unsorted).
|
105
107
|
|
106
108
|
The Master File Table (MFT) contains metadata about every file and folder on a NFTS filesystem.
|
@@ -13,12 +13,14 @@ DRIVE_LETTER_RE = re.compile(r"[a-zA-Z]:")
|
|
13
13
|
|
14
14
|
|
15
15
|
class InformationType(Enum):
|
16
|
+
"""Valid information types"""
|
17
|
+
|
16
18
|
STANDARD_INFORMATION = auto()
|
17
19
|
FILE_INFORMATION = auto()
|
18
20
|
ALTERNATE_DATA_STREAM = auto()
|
19
21
|
|
20
22
|
|
21
|
-
def get_drive_letter(target: Target, filesystem: NtfsFilesystem):
|
23
|
+
def get_drive_letter(target: Target, filesystem: NtfsFilesystem) -> str:
|
22
24
|
"""Retrieve the drive letter from the loaded mounts
|
23
25
|
|
24
26
|
When the drive letter is not available for that filesystem it returns empty.
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import stat
|
2
|
+
from typing import Iterator
|
2
3
|
|
3
4
|
from dissect.target.exceptions import UnsupportedPluginError
|
4
5
|
from dissect.target.helpers.record import TargetRecordDescriptor
|
@@ -12,12 +13,14 @@ SuidRecord = TargetRecordDescriptor(
|
|
12
13
|
|
13
14
|
|
14
15
|
class SuidPlugin(Plugin):
|
16
|
+
"""Unix SUID binary plugin."""
|
17
|
+
|
15
18
|
def check_compatible(self) -> None:
|
16
19
|
if not self.target.has_function("walkfs") or self.target.os == "windows":
|
17
20
|
raise UnsupportedPluginError("Unsupported plugin")
|
18
21
|
|
19
22
|
@export(record=SuidRecord)
|
20
|
-
def suid_binaries(self):
|
23
|
+
def suid_binaries(self) -> Iterator[SuidRecord]:
|
21
24
|
"""Return all SUID binaries.
|
22
25
|
|
23
26
|
A SUID binary allows all users to run it with the permissions of its owner. This means that a
|
@@ -27,6 +27,8 @@ FilesystemRecord = TargetRecordDescriptor(
|
|
27
27
|
|
28
28
|
|
29
29
|
class WalkFSPlugin(Plugin):
|
30
|
+
"""Filesystem agnostic walkfs plugin."""
|
31
|
+
|
30
32
|
def check_compatible(self) -> None:
|
31
33
|
if not len(self.target.filesystems):
|
32
34
|
raise UnsupportedPluginError("No filesystems to walk")
|
@@ -69,7 +69,7 @@ class ExamplePlugin(Plugin):
|
|
69
69
|
"""
|
70
70
|
pass
|
71
71
|
|
72
|
-
@export
|
72
|
+
@export(output="default")
|
73
73
|
@arg("--flag", action="store_true", help="optional example flag")
|
74
74
|
def example(self, flag: bool = False) -> str:
|
75
75
|
"""Example plugin function.
|
@@ -117,7 +117,7 @@ class ExamplePlugin(Plugin):
|
|
117
117
|
To include registry or user information in a record, you must create a new record descriptor using
|
118
118
|
:func:`~dissect.target.helpers.record.create_extended_descriptor` with
|
119
119
|
:class:`~dissect.target.helpers.descriptor_extensions.RegistryRecordDescriptorExtension` and/or
|
120
|
-
:class:`~dissect.target.helpers.descriptor_extensions.UserRecordDescriptorExtension as extensions.
|
120
|
+
:class:`~dissect.target.helpers.descriptor_extensions.UserRecordDescriptorExtension` as extensions.
|
121
121
|
"""
|
122
122
|
for key in self.target.registry.keys("HKCU\\SOFTWARE"):
|
123
123
|
user = self.target.registry.get_user(key)
|
@@ -17,6 +17,8 @@ InterfaceRecord = Union[UnixInterfaceRecord, WindowsInterfaceRecord, MacInterfac
|
|
17
17
|
|
18
18
|
|
19
19
|
class NetworkPlugin(Plugin):
|
20
|
+
"""Generic implementation for network interfaces plugin."""
|
21
|
+
|
20
22
|
__namespace__ = "network"
|
21
23
|
|
22
24
|
def __init__(self, target: Target):
|
@@ -41,6 +43,7 @@ class NetworkPlugin(Plugin):
|
|
41
43
|
|
42
44
|
@export(record=InterfaceRecord)
|
43
45
|
def interfaces(self) -> Iterator[InterfaceRecord]:
|
46
|
+
"""Yield interfaces."""
|
44
47
|
# Only search for the interfaces once
|
45
48
|
if self._interface_list is None:
|
46
49
|
self._interface_list = list(self._interfaces())
|
@@ -49,18 +52,22 @@ class NetworkPlugin(Plugin):
|
|
49
52
|
|
50
53
|
@export
|
51
54
|
def ips(self) -> list[IPAddress]:
|
55
|
+
"""Return IP addresses as list of :class:`IPAddress`."""
|
52
56
|
return list(self._get_record_type("ip"))
|
53
57
|
|
54
58
|
@export
|
55
59
|
def gateways(self) -> list[IPAddress]:
|
60
|
+
"""Return gateways as list of :class:`IPAddress`."""
|
56
61
|
return list(self._get_record_type("gateway"))
|
57
62
|
|
58
63
|
@export
|
59
64
|
def macs(self) -> list[str]:
|
65
|
+
"""Return MAC addresses as list of :class:`str`."""
|
60
66
|
return list(self._get_record_type("mac"))
|
61
67
|
|
62
68
|
@export
|
63
69
|
def dns(self) -> list[str]:
|
70
|
+
"""Return DNS addresses as list of :class:`str`."""
|
64
71
|
return list(self._get_record_type("dns"))
|
65
72
|
|
66
73
|
@internal
|
@@ -22,6 +22,7 @@ class OSInfoPlugin(plugin.Plugin):
|
|
22
22
|
|
23
23
|
@plugin.export(record=OSInfoRecord)
|
24
24
|
def osinfo(self) -> Iterator[Union[OSInfoRecord, GroupedRecord]]:
|
25
|
+
"""Yield grouped records with target OS info."""
|
25
26
|
for os_func in self.target._os.__functions__:
|
26
27
|
if os_func in ["is_compatible", "get_all_records"]:
|
27
28
|
continue
|
@@ -98,12 +98,16 @@ def get_description_dict(
|
|
98
98
|
|
99
99
|
|
100
100
|
class PluginListPlugin(Plugin):
|
101
|
+
"""Plugin list plugin (so meta)."""
|
102
|
+
|
101
103
|
def check_compatible(self) -> None:
|
102
104
|
pass
|
103
105
|
|
104
106
|
@export(output="none", cache=False)
|
105
107
|
@arg("--docs", dest="print_docs", action="store_true")
|
106
108
|
def plugins(self, plugins: list[dict] = None, print_docs: bool = False) -> None:
|
109
|
+
"""Print all registered plugins to stdout."""
|
110
|
+
|
107
111
|
categorized_plugins = dict(sorted(categorize_plugins(plugins).items()))
|
108
112
|
plugin_descriptions = output_plugin_description_recursive(categorized_plugins, print_docs)
|
109
113
|
|
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|
3
3
|
import logging
|
4
4
|
import re
|
5
5
|
import uuid
|
6
|
+
from pathlib import Path
|
6
7
|
from struct import unpack
|
7
8
|
from typing import Iterator
|
8
9
|
|
@@ -145,7 +146,7 @@ class UnixPlugin(OSPlugin):
|
|
145
146
|
def os(self) -> str:
|
146
147
|
return OperatingSystem.UNIX.value
|
147
148
|
|
148
|
-
def _parse_rh_legacy(self, path):
|
149
|
+
def _parse_rh_legacy(self, path: Path) -> str | None:
|
149
150
|
hostname = None
|
150
151
|
file_contents = path.open("rt").readlines()
|
151
152
|
for line in file_contents:
|
@@ -44,6 +44,8 @@ CITRIX_NETSCALER_BASH_HISTORY_RE = re.compile(
|
|
44
44
|
|
45
45
|
|
46
46
|
class CitrixCommandHistoryPlugin(CommandHistoryPlugin):
|
47
|
+
"""Citrix command history plugin."""
|
48
|
+
|
47
49
|
COMMAND_HISTORY_ABSOLUTE_PATHS = (("citrix-netscaler-bash", "/var/log/bash.log*"),)
|
48
50
|
COMMAND_HISTORY_RELATIVE_PATHS = CommandHistoryPlugin.COMMAND_HISTORY_RELATIVE_PATHS + (
|
49
51
|
("citrix-netscaler-cli", ".nscli_history"),
|
@@ -20,6 +20,8 @@ AccountPolicyRecord = create_extended_descriptor([UserRecordDescriptorExtension]
|
|
20
20
|
|
21
21
|
|
22
22
|
class UserPlugin(Plugin):
|
23
|
+
"""MacOS / OSX user plugin."""
|
24
|
+
|
23
25
|
# TODO: Parse additional user data like: HeimdalSRPKey, KerberosKeys, ShadowHashData, LinkedIdentity,
|
24
26
|
# inputSources, smartCardSecureTokenData, smartCardSecureTokenUUID, unlockOptions, smb_sid
|
25
27
|
|
@@ -31,6 +33,8 @@ class UserPlugin(Plugin):
|
|
31
33
|
|
32
34
|
@export(record=AccountPolicyRecord)
|
33
35
|
def account_policy(self) -> Iterator[AccountPolicyRecord]:
|
36
|
+
"""Yield user account policy information"""
|
37
|
+
|
34
38
|
# The data is not retrieved from the home folder of the user
|
35
39
|
for user_details in self.target.user_details.all():
|
36
40
|
user = plistlib.load(self.target.fs.path(user_details.user.source).open())
|
@@ -1,4 +1,7 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
1
3
|
import re
|
4
|
+
from typing import Iterator
|
2
5
|
|
3
6
|
from dissect.target.helpers.record import TargetRecordDescriptor
|
4
7
|
from dissect.target.plugin import Plugin, export
|
@@ -28,10 +31,12 @@ EnvironmentVariableRecord = TargetRecordDescriptor(
|
|
28
31
|
|
29
32
|
|
30
33
|
class CronjobPlugin(Plugin):
|
34
|
+
"""Unix cronjob plugin."""
|
35
|
+
|
31
36
|
def check_compatible(self) -> None:
|
32
37
|
pass
|
33
38
|
|
34
|
-
def parse_crontab(self, file_path):
|
39
|
+
def parse_crontab(self, file_path) -> Iterator[CronjobRecord | EnvironmentVariableRecord]:
|
35
40
|
for line in file_path.open("rt"):
|
36
41
|
line = line.strip()
|
37
42
|
if line.startswith("#") or not len(line):
|
@@ -67,9 +72,8 @@ class CronjobPlugin(Plugin):
|
|
67
72
|
)
|
68
73
|
|
69
74
|
@export(record=[CronjobRecord, EnvironmentVariableRecord])
|
70
|
-
def cronjobs(self):
|
71
|
-
"""
|
72
|
-
Return all cronjobs.
|
75
|
+
def cronjobs(self) -> Iterator[CronjobRecord | EnvironmentVariableRecord]:
|
76
|
+
"""Yield cronjobs on the unix system.
|
73
77
|
|
74
78
|
A cronjob is a scheduled task/command on a Unix based system. Adversaries may use cronjobs to gain
|
75
79
|
persistence on the system.
|
@@ -23,6 +23,8 @@ UnixConfigTreeRecord = TargetRecordDescriptor(
|
|
23
23
|
|
24
24
|
|
25
25
|
class EtcTree(ConfigurationTreePlugin):
|
26
|
+
"""Unix etc configuration tree plugin."""
|
27
|
+
|
26
28
|
__namespace__ = "etc"
|
27
29
|
|
28
30
|
def __init__(self, target: Target):
|
@@ -64,6 +66,8 @@ class EtcTree(ConfigurationTreePlugin):
|
|
64
66
|
@arg("--glob", dest="pattern", required=False, default="*", type=str, help="Glob-style pattern to search for")
|
65
67
|
@arg("--root", dest="root", required=False, default="/", type=str, help="Path to use as root for search")
|
66
68
|
def etc(self, pattern: str, root: str) -> Iterator[UnixConfigTreeRecord]:
|
69
|
+
"""Yield etc configuration records."""
|
70
|
+
|
67
71
|
for entry, subs, items in self.config_fs.walk(root):
|
68
72
|
for item in items:
|
69
73
|
try:
|
@@ -26,6 +26,8 @@ RE_FISH = re.compile(r"- cmd: (?P<command>.+?)\s+when: (?P<ts>\d+)")
|
|
26
26
|
|
27
27
|
|
28
28
|
class CommandHistoryPlugin(Plugin):
|
29
|
+
"""Unix command history plugin."""
|
30
|
+
|
29
31
|
COMMAND_HISTORY_RELATIVE_PATHS = (
|
30
32
|
("bash", ".bash_history"),
|
31
33
|
("fish", ".local/share/fish/fish_history"),
|
@@ -59,7 +61,7 @@ class CommandHistoryPlugin(Plugin):
|
|
59
61
|
|
60
62
|
@alias("bashhistory")
|
61
63
|
@export(record=CommandHistoryRecord)
|
62
|
-
def commandhistory(self):
|
64
|
+
def commandhistory(self) -> Iterator[CommandHistoryRecord]:
|
63
65
|
"""Return shell history for all users.
|
64
66
|
|
65
67
|
When using a shell, history of the used commands is kept on the system.
|
@@ -81,12 +83,12 @@ class CommandHistoryPlugin(Plugin):
|
|
81
83
|
def parse_generic_history(self, file, user: UnixUserRecord, shell: str) -> Iterator[CommandHistoryRecord]:
|
82
84
|
"""Parse bash_history contents.
|
83
85
|
|
84
|
-
Regular .bash_history files contain one plain command per line.
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
Regular .bash_history files contain one plain command per line. Extended ``.bash_history`` files look like this:
|
87
|
+
|
88
|
+
.. code-block::
|
89
|
+
|
90
|
+
#1648598339
|
91
|
+
echo "this is a test"
|
90
92
|
|
91
93
|
Resources:
|
92
94
|
- http://git.savannah.gnu.org/cgit/bash.git/tree/bashhist.c
|
@@ -121,12 +123,12 @@ class CommandHistoryPlugin(Plugin):
|
|
121
123
|
def parse_zsh_history(self, file, user: UnixUserRecord) -> Iterator[CommandHistoryRecord]:
|
122
124
|
"""Parse zsh_history contents.
|
123
125
|
|
124
|
-
Regular
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
126
|
+
Regular ``.zsh_history`` lines are just the plain commands. Extended ``.zsh_history`` files look like this:
|
127
|
+
|
128
|
+
.. code-block::
|
129
|
+
|
130
|
+
: 1673860722:0;sudo apt install sl
|
131
|
+
: :;
|
130
132
|
|
131
133
|
Resources:
|
132
134
|
- https://sourceforge.net/p/zsh/code/ci/master/tree/Src/hist.c
|
@@ -157,18 +159,18 @@ class CommandHistoryPlugin(Plugin):
|
|
157
159
|
def parse_fish_history(self, history_file: TargetPath, user: UnixUserRecord) -> Iterator[CommandHistoryRecord]:
|
158
160
|
"""Parses the history file of the fish shell.
|
159
161
|
|
160
|
-
The fish history file is formatted as pseudo-YAML.
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
162
|
+
The fish history file is formatted as pseudo-YAML. An example of such a file:
|
163
|
+
|
164
|
+
.. code-block::
|
165
|
+
|
166
|
+
- cmd: ls
|
167
|
+
when: 1688642435
|
168
|
+
- cmd: cd home/
|
169
|
+
when: 1688642441
|
170
|
+
paths:
|
171
|
+
- home/
|
172
|
+
- cmd: echo "test: test"
|
173
|
+
when: 1688986629
|
172
174
|
|
173
175
|
Note that the last `- cmd: echo "test: test"` is not valid YAML,
|
174
176
|
which is why we cannot safely use the Python yaml module.
|
@@ -10,13 +10,16 @@ from dissect.target.helpers.fsutil import open_decompress
|
|
10
10
|
from dissect.target.plugins.os.unix.packagemanager import (
|
11
11
|
OperationTypes,
|
12
12
|
PackageManagerLogRecord,
|
13
|
+
PackageManagerPlugin,
|
13
14
|
)
|
14
15
|
|
15
16
|
APT_LOG_OPERATIONS = ["Install", "Reinstall", "Upgrade", "Downgrade", "Remove", "Purge"]
|
16
17
|
REGEX_PACKAGE_NAMES = re.compile(r"(.*?\)),?")
|
17
18
|
|
18
19
|
|
19
|
-
class AptPlugin(
|
20
|
+
class AptPlugin(PackageManagerPlugin):
|
21
|
+
"""Apt package manager plugin."""
|
22
|
+
|
20
23
|
__namespace__ = "apt"
|
21
24
|
|
22
25
|
LOG_DIR_PATH = "/var/log/apt"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import gzip
|
2
2
|
from datetime import datetime
|
3
|
-
from typing import Dict, Generator, List, TextIO
|
3
|
+
from typing import Dict, Generator, Iterator, List, TextIO
|
4
4
|
|
5
5
|
from dissect.target.exceptions import UnsupportedPluginError
|
6
6
|
from dissect.target.helpers.record import TargetRecordDescriptor
|
@@ -59,7 +59,7 @@ class DpkgPlugin(Plugin):
|
|
59
59
|
raise UnsupportedPluginError("No DPKG files found")
|
60
60
|
|
61
61
|
@export(record=DpkgPackageStatusRecord)
|
62
|
-
def status(self):
|
62
|
+
def status(self) -> Iterator[DpkgPackageStatusRecord]:
|
63
63
|
"""Yield records for packages in dpkg's status database"""
|
64
64
|
|
65
65
|
status_file_path = self.target.fs.path(STATUS_FILE_NAME)
|
@@ -82,7 +82,7 @@ class DpkgPlugin(Plugin):
|
|
82
82
|
yield DpkgPackageStatusRecord(_target=self.target, **record_fields)
|
83
83
|
|
84
84
|
@export(record=DpkgPackageLogRecord)
|
85
|
-
def log(self):
|
85
|
+
def log(self) -> Iterator[DpkgPackageLogRecord]:
|
86
86
|
"""Yield records for actions logged in dpkg's logs"""
|
87
87
|
|
88
88
|
for log_file in self.target.fs.glob(LOG_FILES_GLOB):
|
@@ -9,6 +9,8 @@ from dissect.target.plugins.os.unix.generic import calculate_last_activity
|
|
9
9
|
|
10
10
|
|
11
11
|
class GenericPlugin(Plugin):
|
12
|
+
"""Generic FortiOS plugin."""
|
13
|
+
|
12
14
|
def check_compatible(self) -> None:
|
13
15
|
if self.target.os != "fortios":
|
14
16
|
raise UnsupportedPluginError("FortiOS specific plugin loaded on non-FortiOS target")
|
@@ -5,6 +5,8 @@ from dissect.target.plugin import Plugin, export
|
|
5
5
|
|
6
6
|
|
7
7
|
class LocalePlugin(Plugin):
|
8
|
+
"""FortiOS locale plugin."""
|
9
|
+
|
8
10
|
def check_compatible(self) -> None:
|
9
11
|
if self.target.os != "fortios":
|
10
12
|
raise UnsupportedPluginError("FortiOS specific plugin loaded on non-FortiOS target")
|
@@ -7,13 +7,16 @@ from dissect.target.helpers.utils import year_rollover_helper
|
|
7
7
|
from dissect.target.plugins.os.unix.packagemanager import (
|
8
8
|
OperationTypes,
|
9
9
|
PackageManagerLogRecord,
|
10
|
+
PackageManagerPlugin,
|
10
11
|
)
|
11
12
|
|
12
13
|
YUM_LOG_KEYWORDS = ["Installed", "Updated", "Erased", "Obsoleted"]
|
13
14
|
RE_TS = re.compile(r"(\w+\s{1,2}\d+\s\d{2}:\d{2}:\d{2})")
|
14
15
|
|
15
16
|
|
16
|
-
class YumPlugin(
|
17
|
+
class YumPlugin(PackageManagerPlugin):
|
18
|
+
"""Yum package manager plugin."""
|
19
|
+
|
17
20
|
__namespace__ = "yum"
|
18
21
|
|
19
22
|
LOG_DIR_PATH = "/var/log"
|
@@ -18,6 +18,8 @@ LinuxServiceRecord = TargetRecordDescriptor(RECORD_NAME, DEFAULT_ELEMENTS)
|
|
18
18
|
|
19
19
|
|
20
20
|
class ServicesPlugin(Plugin):
|
21
|
+
"""Linux services plugin."""
|
22
|
+
|
21
23
|
SYSTEMD_PATHS = [
|
22
24
|
"/etc/systemd/system",
|
23
25
|
"/lib/systemd/system",
|
@@ -35,9 +37,9 @@ class ServicesPlugin(Plugin):
|
|
35
37
|
"""Return information about all installed systemd and init.d services.
|
36
38
|
|
37
39
|
References:
|
38
|
-
|
39
|
-
|
40
|
-
|
40
|
+
- https://geeksforgeeks.org/what-is-init-d-in-linux-service-management
|
41
|
+
- http://0pointer.de/blog/projects/systemd-for-admins-3.html
|
42
|
+
- https://www.freedesktop.org/software/systemd/man/latest/systemd.syntax.html
|
41
43
|
"""
|
42
44
|
|
43
45
|
return chain(self.systemd(), self.initd())
|