dissect.target 3.20.dev36__py3-none-any.whl → 3.20.dev38__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/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.dev38.dist-info}/METADATA +1 -1
- {dissect.target-3.20.dev36.dist-info → dissect.target-3.20.dev38.dist-info}/RECORD +119 -120
- dissect/target/plugins/os/unix/etc.py +0 -9
- {dissect.target-3.20.dev36.dist-info → dissect.target-3.20.dev38.dist-info}/COPYRIGHT +0 -0
- {dissect.target-3.20.dev36.dist-info → dissect.target-3.20.dev38.dist-info}/LICENSE +0 -0
- {dissect.target-3.20.dev36.dist-info → dissect.target-3.20.dev38.dist-info}/WHEEL +0 -0
- {dissect.target-3.20.dev36.dist-info → dissect.target-3.20.dev38.dist-info}/entry_points.txt +0 -0
- {dissect.target-3.20.dev36.dist-info → dissect.target-3.20.dev38.dist-info}/top_level.txt +0 -0
@@ -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())
|
@@ -7,10 +7,13 @@ from dissect.target.helpers.fsutil import open_decompress
|
|
7
7
|
from dissect.target.plugins.os.unix.packagemanager import (
|
8
8
|
OperationTypes,
|
9
9
|
PackageManagerLogRecord,
|
10
|
+
PackageManagerPlugin,
|
10
11
|
)
|
11
12
|
|
12
13
|
|
13
|
-
class ZypperPlugin(
|
14
|
+
class ZypperPlugin(PackageManagerPlugin):
|
15
|
+
"""Zypper package manager plugin."""
|
16
|
+
|
14
17
|
__namespace__ = "zypper"
|
15
18
|
|
16
19
|
LOG_DIR_PATH = "/var/log/zypp"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
-
from typing import BinaryIO, Iterable
|
3
|
+
from typing import BinaryIO, Iterable, Iterator
|
4
4
|
|
5
5
|
from dissect.cstruct import cstruct
|
6
6
|
|
@@ -69,6 +69,8 @@ class GNULocateFile:
|
|
69
69
|
|
70
70
|
|
71
71
|
class GNULocatePlugin(BaseLocatePlugin):
|
72
|
+
"""GNU locate plugin."""
|
73
|
+
|
72
74
|
__namespace__ = "gnulocate"
|
73
75
|
|
74
76
|
path = "/var/cache/locate/locatedb"
|
@@ -78,7 +80,7 @@ class GNULocatePlugin(BaseLocatePlugin):
|
|
78
80
|
raise UnsupportedPluginError(f"No locatedb file found at {self.path}")
|
79
81
|
|
80
82
|
@export(record=GNULocateRecord)
|
81
|
-
def locate(self) -> GNULocateRecord:
|
83
|
+
def locate(self) -> Iterator[GNULocateRecord]:
|
82
84
|
"""Yield file and directory names from GNU findutils' locatedb file.
|
83
85
|
|
84
86
|
Resources:
|
@@ -163,6 +163,8 @@ class PLocateFile:
|
|
163
163
|
|
164
164
|
|
165
165
|
class PLocatePlugin(BaseLocatePlugin):
|
166
|
+
"""Unix plocate plugin."""
|
167
|
+
|
166
168
|
__namespace__ = "plocate"
|
167
169
|
|
168
170
|
path = "/var/lib/plocate/plocate.db"
|
@@ -177,7 +179,7 @@ class PLocatePlugin(BaseLocatePlugin):
|
|
177
179
|
)
|
178
180
|
|
179
181
|
@export(record=PLocateRecord)
|
180
|
-
def locate(self) -> PLocateRecord:
|
182
|
+
def locate(self) -> Iterator[PLocateRecord]:
|
181
183
|
"""Yield file and directory names from the plocate.db.
|
182
184
|
|
183
185
|
``plocate`` is the default package on Ubuntu 22 and newer to locate files.
|
@@ -24,6 +24,8 @@ AUDIT_REGEX = re.compile(r"^type=(?P<audit_type>.*) msg=audit\((?P<ts>.*):(?P<au
|
|
24
24
|
|
25
25
|
|
26
26
|
class AuditPlugin(Plugin):
|
27
|
+
"""Unix audit log plugin."""
|
28
|
+
|
27
29
|
def __init__(self, target):
|
28
30
|
super().__init__(target)
|
29
31
|
self.log_paths = self.get_log_paths()
|
@@ -51,7 +53,7 @@ class AuditPlugin(Plugin):
|
|
51
53
|
|
52
54
|
return log_paths
|
53
55
|
|
54
|
-
@export(record=
|
56
|
+
@export(record=AuditRecord)
|
55
57
|
def audit(self) -> Iterator[AuditRecord]:
|
56
58
|
"""Return CentOS and RedHat audit information stored in /var/log/audit*.
|
57
59
|
|
@@ -22,17 +22,19 @@ RE_TS_AND_HOSTNAME = re.compile(_TS_REGEX + r"\s\S+\s")
|
|
22
22
|
|
23
23
|
|
24
24
|
class AuthPlugin(Plugin):
|
25
|
+
"""Unix auth log plugin."""
|
26
|
+
|
25
27
|
def check_compatible(self) -> None:
|
26
28
|
var_log = self.target.fs.path("/var/log")
|
27
29
|
if not any(var_log.glob("auth.log*")) and not any(var_log.glob("secure*")):
|
28
30
|
raise UnsupportedPluginError("No auth log files found")
|
29
31
|
|
30
|
-
@export(record=
|
32
|
+
@export(record=AuthLogRecord)
|
31
33
|
def securelog(self) -> Iterator[AuthLogRecord]:
|
32
34
|
"""Return contents of /var/log/auth.log* and /var/log/secure*."""
|
33
35
|
return self.authlog()
|
34
36
|
|
35
|
-
@export(record=
|
37
|
+
@export(record=AuthLogRecord)
|
36
38
|
def authlog(self) -> Iterator[AuthLogRecord]:
|
37
39
|
"""Return contents of /var/log/auth.log* and /var/log/secure*."""
|
38
40
|
|