dissect.target 3.17.dev36__py3-none-any.whl → 3.18__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- dissect/target/exceptions.py +4 -0
- dissect/target/filesystem.py +0 -10
- dissect/target/helpers/cache.py +3 -1
- dissect/target/helpers/hashutil.py +0 -40
- dissect/target/helpers/protobuf.py +6 -10
- dissect/target/helpers/record_modifier.py +4 -1
- dissect/target/helpers/ssh.py +3 -4
- dissect/target/loaders/mqtt.py +147 -2
- dissect/target/loaders/raw.py +7 -0
- dissect/target/plugins/apps/av/mcafee.py +3 -0
- dissect/target/plugins/apps/av/sophos.py +6 -0
- dissect/target/plugins/apps/av/symantec.py +6 -0
- dissect/target/plugins/apps/av/trendmicro.py +8 -3
- dissect/target/plugins/apps/browser/chromium.py +12 -0
- dissect/target/plugins/apps/browser/firefox.py +13 -1
- dissect/target/plugins/apps/browser/iexplore.py +6 -0
- dissect/target/plugins/apps/container/docker.py +1 -1
- dissect/target/plugins/os/unix/etc/__init__.py +0 -0
- dissect/target/plugins/os/unix/etc/etc.py +77 -0
- dissect/target/plugins/os/unix/history.py +1 -1
- dissect/target/plugins/os/unix/linux/cmdline.py +3 -0
- dissect/target/plugins/os/unix/linux/environ.py +3 -0
- dissect/target/plugins/os/unix/linux/processes.py +3 -0
- dissect/target/plugins/os/unix/linux/sockets.py +15 -0
- dissect/target/plugins/os/unix/locate/gnulocate.py +1 -2
- dissect/target/plugins/os/unix/locate/mlocate.py +3 -4
- dissect/target/plugins/os/unix/locate/plocate.py +34 -25
- dissect/target/plugins/os/unix/log/atop.py +6 -4
- dissect/target/plugins/os/unix/log/journal.py +5 -4
- dissect/target/plugins/os/unix/log/lastlog.py +2 -3
- dissect/target/plugins/os/unix/log/utmp.py +6 -7
- dissect/target/plugins/os/windows/_os.py +17 -6
- dissect/target/plugins/os/windows/activitiescache.py +3 -0
- dissect/target/plugins/os/windows/adpolicy.py +3 -4
- dissect/target/plugins/os/windows/catroot.py +6 -0
- dissect/target/plugins/os/windows/credhist.py +1 -2
- dissect/target/plugins/os/windows/datetime.py +3 -4
- dissect/target/plugins/os/windows/defender.py +221 -5
- dissect/target/plugins/os/windows/defender_helpers/__init__.py +0 -0
- dissect/target/plugins/os/windows/defender_helpers/defender_patterns.py +282 -0
- dissect/target/plugins/os/windows/defender_helpers/defender_records.py +191 -0
- dissect/target/plugins/os/windows/dpapi/blob.py +1 -2
- dissect/target/plugins/os/windows/dpapi/master_key.py +2 -3
- dissect/target/plugins/os/windows/lnk.py +3 -0
- dissect/target/plugins/os/windows/log/etl.py +9 -0
- dissect/target/plugins/os/windows/log/evt.py +3 -0
- dissect/target/plugins/os/windows/log/evtx.py +3 -0
- dissect/target/plugins/os/windows/log/pfro.py +3 -0
- dissect/target/plugins/os/windows/log/schedlgu.py +5 -2
- dissect/target/plugins/os/windows/notifications.py +1 -2
- dissect/target/plugins/os/windows/prefetch.py +32 -27
- dissect/target/plugins/os/windows/recyclebin.py +13 -8
- dissect/target/plugins/os/windows/regf/appxdebugkeys.py +3 -0
- dissect/target/plugins/os/windows/regf/auditpol.py +4 -5
- dissect/target/plugins/os/windows/regf/bam.py +5 -3
- dissect/target/plugins/os/windows/regf/cit.py +1 -2
- dissect/target/plugins/os/windows/regf/clsid.py +3 -0
- dissect/target/plugins/os/windows/regf/firewall.py +3 -0
- dissect/target/plugins/os/windows/regf/muicache.py +3 -0
- dissect/target/plugins/os/windows/regf/recentfilecache.py +6 -4
- dissect/target/plugins/os/windows/regf/regf.py +6 -0
- dissect/target/plugins/os/windows/regf/runkeys.py +9 -4
- dissect/target/plugins/os/windows/regf/shellbags.py +9 -7
- dissect/target/plugins/os/windows/regf/shimcache.py +5 -3
- dissect/target/plugins/os/windows/regf/trusteddocs.py +3 -0
- dissect/target/plugins/os/windows/regf/usb.py +3 -0
- dissect/target/plugins/os/windows/regf/userassist.py +8 -6
- dissect/target/plugins/os/windows/sam.py +7 -5
- dissect/target/plugins/os/windows/services.py +3 -0
- dissect/target/plugins/os/windows/task_helpers/tasks_job.py +3 -4
- dissect/target/plugins/os/windows/wer.py +3 -0
- dissect/target/target.py +6 -1
- dissect/target/tools/shell.py +30 -19
- {dissect.target-3.17.dev36.dist-info → dissect.target-3.18.dist-info}/METADATA +50 -25
- {dissect.target-3.17.dev36.dist-info → dissect.target-3.18.dist-info}/RECORD +80 -75
- {dissect.target-3.17.dev36.dist-info → dissect.target-3.18.dist-info}/WHEEL +1 -1
- {dissect.target-3.17.dev36.dist-info → dissect.target-3.18.dist-info}/COPYRIGHT +0 -0
- {dissect.target-3.17.dev36.dist-info → dissect.target-3.18.dist-info}/LICENSE +0 -0
- {dissect.target-3.17.dev36.dist-info → dissect.target-3.18.dist-info}/entry_points.txt +0 -0
- {dissect.target-3.17.dev36.dist-info → dissect.target-3.18.dist-info}/top_level.txt +0 -0
dissect/target/exceptions.py
CHANGED
dissect/target/filesystem.py
CHANGED
@@ -6,7 +6,6 @@ import logging
|
|
6
6
|
import os
|
7
7
|
import pathlib
|
8
8
|
import stat
|
9
|
-
import warnings
|
10
9
|
from collections import defaultdict
|
11
10
|
from typing import TYPE_CHECKING, Any, BinaryIO, Callable, Iterator, Optional, Type
|
12
11
|
|
@@ -67,15 +66,6 @@ class Filesystem:
|
|
67
66
|
def __repr__(self) -> str:
|
68
67
|
return f"<{self.__class__.__name__}>"
|
69
68
|
|
70
|
-
@classmethod
|
71
|
-
@property
|
72
|
-
def __fstype__(cls) -> str:
|
73
|
-
warnings.warn(
|
74
|
-
"The __fstype__ attribute is deprecated and will be removed in dissect.target 3.15. Use __type__ instead",
|
75
|
-
category=DeprecationWarning,
|
76
|
-
)
|
77
|
-
return cls.__type__
|
78
|
-
|
79
69
|
def path(self, *args) -> fsutil.TargetPath:
|
80
70
|
"""Instantiate a new path-like object on this filesystem."""
|
81
71
|
return fsutil.TargetPath(self, *args)
|
dissect/target/helpers/cache.py
CHANGED
@@ -147,7 +147,9 @@ class Cache:
|
|
147
147
|
if os.access(cache_file, os.R_OK, effective_ids=bool(os.supports_effective_ids)):
|
148
148
|
if os.stat(cache_file).st_size != 0:
|
149
149
|
try:
|
150
|
-
|
150
|
+
reader = self.open_reader(cache_file, output)
|
151
|
+
target.log.info("Using cache for function: %s", self.fname)
|
152
|
+
return reader
|
151
153
|
except Exception as e:
|
152
154
|
target.log.warning("Cache will NOT be used. Error opening cache file: %s", cache_file)
|
153
155
|
target.log.debug("", exc_info=e)
|
@@ -1,18 +1,11 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
import hashlib
|
4
|
-
import warnings
|
5
4
|
from typing import TYPE_CHECKING, BinaryIO, Union
|
6
5
|
|
7
|
-
from flow.record import Record
|
8
|
-
|
9
|
-
from dissect.target.exceptions import FileNotFoundError
|
10
|
-
|
11
6
|
if TYPE_CHECKING:
|
12
7
|
from hashlib._hashlib import HASH
|
13
8
|
|
14
|
-
from dissect.target.target import Target
|
15
|
-
|
16
9
|
BUFFER_SIZE = 32768
|
17
10
|
|
18
11
|
|
@@ -52,36 +45,3 @@ def custom(fh: BinaryIO, algos: list[Union[str, HASH]]) -> tuple[str]:
|
|
52
45
|
ctx = algos
|
53
46
|
|
54
47
|
return _hash(fh, ctx)
|
55
|
-
|
56
|
-
|
57
|
-
def hash_uri(target: Target, path: str) -> tuple[str, str]:
|
58
|
-
"""Hash the target path."""
|
59
|
-
warnings.warn(
|
60
|
-
(
|
61
|
-
"The hash_uri() function is deprecated, and will be removed in dissect.target 3.15. "
|
62
|
-
"Use target.fs.hash() instead"
|
63
|
-
),
|
64
|
-
DeprecationWarning,
|
65
|
-
)
|
66
|
-
|
67
|
-
if path is None:
|
68
|
-
raise FileNotFoundError()
|
69
|
-
|
70
|
-
path = str(target.resolve(path))
|
71
|
-
return (path, target.fs.hash(path))
|
72
|
-
|
73
|
-
|
74
|
-
def hash_uri_records(target: Target, record: Record) -> Record:
|
75
|
-
"""Hash uri paths inside the record."""
|
76
|
-
|
77
|
-
from dissect.target.helpers.record_modifier import Modifier, get_modifier_function
|
78
|
-
|
79
|
-
warnings.warn(
|
80
|
-
(
|
81
|
-
"The hash_uri_records() function is deprecated, and will be removed in dissect.target 3.15. "
|
82
|
-
"Use hash_path_records() instead"
|
83
|
-
),
|
84
|
-
DeprecationWarning,
|
85
|
-
)
|
86
|
-
func = get_modifier_function(Modifier.HASH)
|
87
|
-
return func(target, record)
|
@@ -3,30 +3,26 @@ from __future__ import annotations
|
|
3
3
|
from typing import Any, BinaryIO
|
4
4
|
|
5
5
|
from dissect.cstruct.types.base import BaseType
|
6
|
-
from dissect.cstruct.types.bytesinteger import BytesInteger
|
7
6
|
|
8
7
|
|
9
|
-
class ProtobufVarint(
|
8
|
+
class ProtobufVarint(BaseType):
|
10
9
|
"""Implements a protobuf integer type for dissect.cstruct that can span a variable amount of bytes.
|
11
10
|
|
12
|
-
|
13
|
-
to support protobuf's msb varint implementation.
|
11
|
+
Supports protobuf's msb varint implementation.
|
14
12
|
|
15
13
|
Resources:
|
16
14
|
- https://protobuf.dev/programming-guides/encoding/
|
17
15
|
- https://github.com/protocolbuffers/protobuf/blob/main/python/google/protobuf/internal/decoder.py
|
18
16
|
"""
|
19
17
|
|
20
|
-
|
18
|
+
@classmethod
|
19
|
+
def _read(cls, stream: BinaryIO, context: dict[str, Any] = None) -> int:
|
21
20
|
return decode_varint(stream)
|
22
21
|
|
23
|
-
|
22
|
+
@classmethod
|
23
|
+
def _write(cls, stream: BinaryIO, data: int) -> int:
|
24
24
|
return stream.write(encode_varint(data))
|
25
25
|
|
26
|
-
_read_array = BaseType._read_array
|
27
|
-
|
28
|
-
_write_array = BaseType._write_array
|
29
|
-
|
30
26
|
|
31
27
|
def decode_varint(stream: BinaryIO) -> int:
|
32
28
|
"""Reads a varint from the provided buffer stream.
|
@@ -62,13 +62,16 @@ MODIFIER_MAPPING = {
|
|
62
62
|
|
63
63
|
def _resolve_path_types(target: Target, record: Record) -> Iterator[tuple[str, TargetPath]]:
|
64
64
|
for field_name, field_type in record._field_types.items():
|
65
|
-
if not issubclass(field_type, fieldtypes.path):
|
65
|
+
if not issubclass(field_type, (fieldtypes.path, fieldtypes.command)):
|
66
66
|
continue
|
67
67
|
|
68
68
|
path = getattr(record, field_name, None)
|
69
69
|
if path is None:
|
70
70
|
continue
|
71
71
|
|
72
|
+
if isinstance(path, fieldtypes.command):
|
73
|
+
path = path.executable
|
74
|
+
|
72
75
|
yield field_name, target.resolve(str(path))
|
73
76
|
|
74
77
|
|
dissect/target/helpers/ssh.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import base64
|
2
2
|
import binascii
|
3
3
|
|
4
|
-
from dissect import cstruct
|
4
|
+
from dissect.cstruct import cstruct
|
5
5
|
|
6
|
-
|
6
|
+
rfc4716_def = """
|
7
7
|
struct ssh_string {
|
8
8
|
uint32 length;
|
9
9
|
char value[length];
|
@@ -23,8 +23,7 @@ struct ssh_private_key {
|
|
23
23
|
}
|
24
24
|
"""
|
25
25
|
|
26
|
-
c_rfc4716 = cstruct
|
27
|
-
c_rfc4716.load(c_rfc4716_def)
|
26
|
+
c_rfc4716 = cstruct(endian=">").load(rfc4716_def)
|
28
27
|
|
29
28
|
RFC4716_MARKER_START = b"-----BEGIN OPENSSH PRIVATE KEY-----"
|
30
29
|
RFC4716_MARKER_END = b"-----END OPENSSH PRIVATE KEY-----"
|
dissect/target/loaders/mqtt.py
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
+
import atexit
|
3
4
|
import logging
|
5
|
+
import math
|
6
|
+
import os
|
4
7
|
import ssl
|
8
|
+
import sys
|
5
9
|
import time
|
6
10
|
import urllib
|
7
11
|
from dataclasses import dataclass
|
8
12
|
from functools import lru_cache
|
9
13
|
from pathlib import Path
|
10
14
|
from struct import pack, unpack_from
|
15
|
+
from threading import Thread
|
11
16
|
from typing import Any, Callable, Iterator, Optional, Union
|
12
17
|
|
13
18
|
import paho.mqtt.client as mqtt
|
@@ -51,6 +56,34 @@ class SeekMessage:
|
|
51
56
|
data: bytes = b""
|
52
57
|
|
53
58
|
|
59
|
+
class MQTTTransferRatePerSecond:
|
60
|
+
def __init__(self, window_size: int = 10):
|
61
|
+
self.window_size = window_size
|
62
|
+
self.timestamps = []
|
63
|
+
self.bytes = []
|
64
|
+
|
65
|
+
def record(self, timestamp: float, byte_count: int) -> MQTTTransferRatePerSecond:
|
66
|
+
while self.timestamps and (timestamp - self.timestamps[0] > self.window_size):
|
67
|
+
self.timestamps.pop(0)
|
68
|
+
self.bytes.pop(0)
|
69
|
+
|
70
|
+
self.timestamps.append(timestamp)
|
71
|
+
self.bytes.append(byte_count)
|
72
|
+
return self
|
73
|
+
|
74
|
+
def value(self, current_time: float) -> float:
|
75
|
+
if not self.timestamps:
|
76
|
+
return 0
|
77
|
+
|
78
|
+
elapsed_time = current_time - self.timestamps[0]
|
79
|
+
if elapsed_time == 0:
|
80
|
+
return 0
|
81
|
+
|
82
|
+
total_bytes = self.bytes[-1] - self.bytes[0]
|
83
|
+
|
84
|
+
return total_bytes / elapsed_time
|
85
|
+
|
86
|
+
|
54
87
|
class MQTTStream(AlignedStream):
|
55
88
|
def __init__(self, stream: MQTTConnection, disk_id: int, size: Optional[int] = None):
|
56
89
|
self.stream = stream
|
@@ -62,12 +95,108 @@ class MQTTStream(AlignedStream):
|
|
62
95
|
return data
|
63
96
|
|
64
97
|
|
98
|
+
class MQTTDiagnosticLine:
|
99
|
+
def __init__(self, connection: MQTTConnection, total_peers: int):
|
100
|
+
self.connection = connection
|
101
|
+
self.total_peers = total_peers
|
102
|
+
self._columns, self._rows = os.get_terminal_size(0)
|
103
|
+
atexit.register(self._detach)
|
104
|
+
self._attach()
|
105
|
+
|
106
|
+
def _attach(self) -> None:
|
107
|
+
# save cursor position
|
108
|
+
sys.stderr.write("\0337")
|
109
|
+
# set top and bottom margins of the scrolling region to default
|
110
|
+
sys.stderr.write("\033[r")
|
111
|
+
# restore cursor position
|
112
|
+
sys.stderr.write("\0338")
|
113
|
+
# move cursor down one line in the same column; if at the bottom, the screen scrolls up
|
114
|
+
sys.stderr.write("\033D")
|
115
|
+
# move cursor up one line in the same column; if at the top, screen scrolls down
|
116
|
+
sys.stderr.write("\033M")
|
117
|
+
# save cursor position again
|
118
|
+
sys.stderr.write("\0337")
|
119
|
+
# restrict scrolling to a region from the first line to one before the last line
|
120
|
+
sys.stderr.write(f"\033[1;{self._rows - 1}r")
|
121
|
+
# restore cursor position after setting scrolling region
|
122
|
+
sys.stderr.write("\0338")
|
123
|
+
|
124
|
+
def _detach(self) -> None:
|
125
|
+
# save cursor position
|
126
|
+
sys.stderr.write("\0337")
|
127
|
+
# move cursor to the specified position (last line, first column)
|
128
|
+
sys.stderr.write(f"\033[{self._rows};1H")
|
129
|
+
# clear from cursor to end of the line
|
130
|
+
sys.stderr.write("\033[K")
|
131
|
+
# reset scrolling region to include the entire display
|
132
|
+
sys.stderr.write("\033[r")
|
133
|
+
# restore cursor position
|
134
|
+
sys.stderr.write("\0338")
|
135
|
+
# ensure the written content is displayed (flush output)
|
136
|
+
sys.stderr.flush()
|
137
|
+
|
138
|
+
def display(self) -> None:
|
139
|
+
# prepare: set background color to blue and text color to white at the beginning of the line
|
140
|
+
prefix = "\x1b[44m\x1b[37m\r"
|
141
|
+
# reset all attributes (colors, styles) to their defaults afterwards
|
142
|
+
suffix = "\x1b[0m"
|
143
|
+
# separator to set background color to red and text style to bold
|
144
|
+
separator = "\x1b[41m\x1b[1m"
|
145
|
+
logo = "TARGETD"
|
146
|
+
|
147
|
+
start = time.time()
|
148
|
+
transfer_rate = MQTTTransferRatePerSecond(window_size=7)
|
149
|
+
|
150
|
+
while True:
|
151
|
+
time.sleep(0.05)
|
152
|
+
peers = "?"
|
153
|
+
try:
|
154
|
+
peers = len(self.connection.broker.peers(self.connection.host))
|
155
|
+
except Exception:
|
156
|
+
pass
|
157
|
+
|
158
|
+
recv = self.connection.broker.bytes_received
|
159
|
+
now = time.time()
|
160
|
+
transfer = transfer_rate.record(now, recv).value(now) / 1000 # convert to KB/s
|
161
|
+
failures = self.connection.retries
|
162
|
+
seconds_elapsed = round(now - start) % 60
|
163
|
+
minutes_elapsed = math.floor((now - start) / 60) % 60
|
164
|
+
hours_elapsed = math.floor((now - start) / 60**2)
|
165
|
+
timer = f"{hours_elapsed:02d}:{minutes_elapsed:02d}:{seconds_elapsed:02d}"
|
166
|
+
display = f"{timer} {peers}/{self.total_peers} peers {transfer:>8.2f} KB p/s {failures:>4} failures"
|
167
|
+
rest = self._columns - len(display)
|
168
|
+
padding = (rest - len(logo)) * " "
|
169
|
+
|
170
|
+
# save cursor position
|
171
|
+
sys.stderr.write("\0337")
|
172
|
+
# move cursor to specified position (last line, first column)
|
173
|
+
sys.stderr.write(f"\033[{self._rows};1H")
|
174
|
+
# disable line wrapping
|
175
|
+
sys.stderr.write("\033[?7l")
|
176
|
+
# reset all attributes
|
177
|
+
sys.stderr.write("\033[0m")
|
178
|
+
# write the display line with prefix, calculated display content, padding, separator, and logo
|
179
|
+
sys.stderr.write(prefix + display + padding + separator + logo + suffix)
|
180
|
+
# enable line wrapping again
|
181
|
+
sys.stderr.write("\033[?7h")
|
182
|
+
# restore cursor position
|
183
|
+
sys.stderr.write("\0338")
|
184
|
+
# flush output to ensure it is displayed
|
185
|
+
sys.stderr.flush()
|
186
|
+
|
187
|
+
def start(self) -> None:
|
188
|
+
t = Thread(target=self.display)
|
189
|
+
t.daemon = True
|
190
|
+
t.start()
|
191
|
+
|
192
|
+
|
65
193
|
class MQTTConnection:
|
66
194
|
broker = None
|
67
195
|
host = None
|
68
196
|
prev = -1
|
69
197
|
factor = 1
|
70
198
|
prefetch_factor_inc = 10
|
199
|
+
retries = 0
|
71
200
|
|
72
201
|
def __init__(self, broker: Broker, host: str):
|
73
202
|
self.broker = broker
|
@@ -125,6 +254,7 @@ class MQTTConnection:
|
|
125
254
|
# message might have not reached agent, resend...
|
126
255
|
self.broker.seek(self.host, disk_id, offset, flength, optimization_strategy)
|
127
256
|
attempts = 0
|
257
|
+
self.retries += 1
|
128
258
|
|
129
259
|
return message.data
|
130
260
|
|
@@ -138,6 +268,8 @@ class Broker:
|
|
138
268
|
mqtt_client = None
|
139
269
|
connected = False
|
140
270
|
case = None
|
271
|
+
bytes_received = 0
|
272
|
+
monitor = False
|
141
273
|
|
142
274
|
diskinfo = {}
|
143
275
|
index = {}
|
@@ -217,6 +349,9 @@ class Broker:
|
|
217
349
|
if casename != self.case:
|
218
350
|
return
|
219
351
|
|
352
|
+
if self.monitor:
|
353
|
+
self.bytes_received += len(msg.payload)
|
354
|
+
|
220
355
|
if response == "DISKS":
|
221
356
|
self._on_disk(hostname, msg.payload)
|
222
357
|
elif response == "READ":
|
@@ -238,9 +373,12 @@ class Broker:
|
|
238
373
|
self.mqtt_client.publish(f"{self.case}/{host}/INFO")
|
239
374
|
|
240
375
|
def topology(self, host: str) -> None:
|
241
|
-
self.topo
|
376
|
+
if host not in self.topo:
|
377
|
+
self.topo[host] = []
|
242
378
|
self.mqtt_client.subscribe(f"{self.case}/{host}/ID")
|
243
379
|
time.sleep(1) # need some time to avoid race condition, i.e. MQTT might react too fast
|
380
|
+
# send a simple clear command (invalid, just clears the prev. msg) just in case TOPO is stale
|
381
|
+
self.mqtt_client.publish(f"{self.case}/{host}/CLR")
|
244
382
|
self.mqtt_client.publish(f"{self.case}/{host}/TOPO")
|
245
383
|
|
246
384
|
def connect(self) -> None:
|
@@ -272,6 +410,7 @@ class Broker:
|
|
272
410
|
@arg("--mqtt-crt", dest="crt", help="client certificate file")
|
273
411
|
@arg("--mqtt-ca", dest="ca", help="certificate authority file")
|
274
412
|
@arg("--mqtt-command", dest="command", help="direct command to client(s)")
|
413
|
+
@arg("--mqtt-diag", action="store_true", dest="diag", help="show MQTT diagnostic information")
|
275
414
|
class MQTTLoader(Loader):
|
276
415
|
"""Load remote targets through a broker."""
|
277
416
|
|
@@ -292,6 +431,7 @@ class MQTTLoader(Loader):
|
|
292
431
|
def find_all(path: Path, **kwargs) -> Iterator[str]:
|
293
432
|
cls = MQTTLoader
|
294
433
|
num_peers = 1
|
434
|
+
|
295
435
|
if cls.broker is None:
|
296
436
|
if (uri := kwargs.get("parsed_path")) is None:
|
297
437
|
raise LoaderError("No URI connection details have been passed.")
|
@@ -299,8 +439,13 @@ class MQTTLoader(Loader):
|
|
299
439
|
cls.broker = Broker(**options)
|
300
440
|
cls.broker.connect()
|
301
441
|
num_peers = int(options.get("peers", 1))
|
442
|
+
cls.connection = MQTTConnection(cls.broker, path)
|
443
|
+
if options.get("diag", None):
|
444
|
+
cls.broker.monitor = True
|
445
|
+
MQTTDiagnosticLine(cls.connection, num_peers).start()
|
446
|
+
else:
|
447
|
+
cls.connection = MQTTConnection(cls.broker, path)
|
302
448
|
|
303
|
-
cls.connection = MQTTConnection(cls.broker, path)
|
304
449
|
cls.peers = cls.connection.topo(num_peers)
|
305
450
|
yield from cls.peers
|
306
451
|
|
dissect/target/loaders/raw.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
from pathlib import Path
|
2
2
|
|
3
3
|
from dissect.target import container
|
4
|
+
from dissect.target.exceptions import TargetPathNotFoundError
|
4
5
|
from dissect.target.loader import Loader
|
5
6
|
from dissect.target.target import Target
|
6
7
|
|
@@ -8,6 +9,12 @@ from dissect.target.target import Target
|
|
8
9
|
class RawLoader(Loader):
|
9
10
|
"""Load raw container files such as disk images."""
|
10
11
|
|
12
|
+
def __init__(self, path: Path, **kwargs):
|
13
|
+
if not path.exists():
|
14
|
+
raise TargetPathNotFoundError("Provided target path does not exist")
|
15
|
+
|
16
|
+
super().__init__(path, **kwargs)
|
17
|
+
|
11
18
|
@staticmethod
|
12
19
|
def detect(path: Path) -> bool:
|
13
20
|
return not path.is_dir()
|
@@ -71,6 +71,9 @@ class McAfeePlugin(Plugin):
|
|
71
71
|
"""Return msc log history records from McAfee.
|
72
72
|
|
73
73
|
Yields McAfeeMscLogRecord with the following fields:
|
74
|
+
|
75
|
+
.. code-block:: text
|
76
|
+
|
74
77
|
hostname (string): The target hostname.
|
75
78
|
domain (string): The target domain.
|
76
79
|
ts (datetime): timestamp.
|
@@ -56,6 +56,9 @@ class SophosPlugin(Plugin):
|
|
56
56
|
"""Return alert log records from Sophos Hitman Pro/Alert.
|
57
57
|
|
58
58
|
Yields HitmanAlertRecord with the following fields:
|
59
|
+
|
60
|
+
.. code-block:: text
|
61
|
+
|
59
62
|
ts (datetime): Timestamp.
|
60
63
|
alert (string): Type of Alert.
|
61
64
|
description (string): Short description of the alert.
|
@@ -85,6 +88,9 @@ class SophosPlugin(Plugin):
|
|
85
88
|
"""Return log history records from Sophos Home.
|
86
89
|
|
87
90
|
Yields SophosLogRecord with the following fields:
|
91
|
+
|
92
|
+
.. code-block:: text
|
93
|
+
|
88
94
|
ts (datetime): Timestamp.
|
89
95
|
description (string): Short description of the alert.
|
90
96
|
path (path): Path to the infected file (if available).
|
@@ -293,6 +293,9 @@ class SymantecPlugin(Plugin):
|
|
293
293
|
"""Return log records.
|
294
294
|
|
295
295
|
Yields SEPLogRecord with the following fields:
|
296
|
+
|
297
|
+
.. code-block:: text
|
298
|
+
|
296
299
|
ts (datetime): Timestamp associated with the event.
|
297
300
|
virus (string): Name of the virus.
|
298
301
|
user (string): Name of the user associated with the event.
|
@@ -326,6 +329,9 @@ class SymantecPlugin(Plugin):
|
|
326
329
|
"""Return log firewall records.
|
327
330
|
|
328
331
|
Yields SEPFirewallRecord with the following fields:
|
332
|
+
|
333
|
+
.. code-block:: text
|
334
|
+
|
329
335
|
ts (datetime): Timestamp associated with the event.
|
330
336
|
protocol (string): Protocol name associated with the firewall record.
|
331
337
|
local_ip ("net.ipaddress"): Local IP address associated with the event.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from typing import Iterator
|
2
2
|
|
3
|
-
from dissect import cstruct
|
3
|
+
from dissect.cstruct import cstruct
|
4
4
|
from dissect.util.ts import from_unix
|
5
5
|
|
6
6
|
from dissect.target import Target
|
@@ -47,8 +47,7 @@ struct firewall_entry {
|
|
47
47
|
char _pad3[10];
|
48
48
|
};
|
49
49
|
"""
|
50
|
-
c_pfwlog = cstruct.
|
51
|
-
c_pfwlog.load(pfwlog_def)
|
50
|
+
c_pfwlog = cstruct().load(pfwlog_def)
|
52
51
|
|
53
52
|
|
54
53
|
class TrendMicroPlugin(Plugin):
|
@@ -71,6 +70,9 @@ class TrendMicroPlugin(Plugin):
|
|
71
70
|
"""Return Trend Micro Worry-free log history records.
|
72
71
|
|
73
72
|
Yields TrendMicroWFLogRecord with the following fields:
|
73
|
+
|
74
|
+
.. code-block:: text
|
75
|
+
|
74
76
|
hostname (string): The target hostname.
|
75
77
|
domain (string): The target domain.
|
76
78
|
ts (datetime): timestamp.
|
@@ -94,6 +96,9 @@ class TrendMicroPlugin(Plugin):
|
|
94
96
|
"""Return Trend Micro Worry-free firewall log history records.
|
95
97
|
|
96
98
|
Yields TrendMicroWFFirewallRecord with the following fields:
|
99
|
+
|
100
|
+
.. code-block:: text
|
101
|
+
|
97
102
|
hostname (string): The target hostname.
|
98
103
|
domain (string): The target domain.
|
99
104
|
ts (datetime): timestamp.
|
@@ -148,6 +148,9 @@ class ChromiumMixin:
|
|
148
148
|
browser_name: The name of the browser as a string.
|
149
149
|
|
150
150
|
Yields:
|
151
|
+
|
152
|
+
.. code-block:: text
|
153
|
+
|
151
154
|
Records with the following fields:
|
152
155
|
ts (datetime): Visit timestamp.
|
153
156
|
browser (string): The browser from which the records are generated from.
|
@@ -209,6 +212,9 @@ class ChromiumMixin:
|
|
209
212
|
browser_name: The name of the browser as a string.
|
210
213
|
|
211
214
|
Yields:
|
215
|
+
|
216
|
+
.. code-block:: text
|
217
|
+
|
212
218
|
Records with the following fields:
|
213
219
|
ts_created (datetime): Cookie created timestamp.
|
214
220
|
ts_last_accessed (datetime): Cookie last accessed timestamp.
|
@@ -284,6 +290,9 @@ class ChromiumMixin:
|
|
284
290
|
browser_name: The name of the browser as a string.
|
285
291
|
|
286
292
|
Yields:
|
293
|
+
|
294
|
+
.. code-block:: text
|
295
|
+
|
287
296
|
Records with the following fields:
|
288
297
|
ts_start (datetime): Download start timestamp.
|
289
298
|
ts_end (datetime): Download end timestamp.
|
@@ -344,6 +353,9 @@ class ChromiumMixin:
|
|
344
353
|
browser_name (str): Name of the browser to scan for extensions.
|
345
354
|
|
346
355
|
Yields:
|
356
|
+
|
357
|
+
.. code-block:: text
|
358
|
+
|
347
359
|
Records with the following fields:
|
348
360
|
ts_install (datetime): Extension install timestamp.
|
349
361
|
ts_update (datetime): Extension update timestamp.
|
@@ -132,6 +132,9 @@ class FirefoxPlugin(BrowserPlugin):
|
|
132
132
|
"""Return browser history records from Firefox.
|
133
133
|
|
134
134
|
Yields BrowserHistoryRecord with the following fields:
|
135
|
+
|
136
|
+
.. code-block:: text
|
137
|
+
|
135
138
|
ts (datetime): Visit timestamp.
|
136
139
|
browser (string): The browser from which the records are generated from.
|
137
140
|
id (string): Record ID.
|
@@ -193,6 +196,9 @@ class FirefoxPlugin(BrowserPlugin):
|
|
193
196
|
browser_name: The name of the browser as a string.
|
194
197
|
|
195
198
|
Yields:
|
199
|
+
|
200
|
+
.. code-block:: text
|
201
|
+
|
196
202
|
Records with the following fields:
|
197
203
|
ts_created (datetime): Cookie created timestamp.
|
198
204
|
ts_last_accessed (datetime): Cookie last accessed timestamp.
|
@@ -232,6 +238,9 @@ class FirefoxPlugin(BrowserPlugin):
|
|
232
238
|
"""Return browser download records from Firefox.
|
233
239
|
|
234
240
|
Yields BrowserDownloadRecord with the following fields:
|
241
|
+
|
242
|
+
.. code-block:: text
|
243
|
+
|
235
244
|
ts_start (datetime): Download start timestamp.
|
236
245
|
ts_end (datetime): Download end timestamp.
|
237
246
|
browser (string): The browser from which the records are generated from.
|
@@ -315,7 +324,10 @@ class FirefoxPlugin(BrowserPlugin):
|
|
315
324
|
def extensions(self) -> Iterator[BrowserExtensionRecord]:
|
316
325
|
"""Return browser extension records for Firefox.
|
317
326
|
|
318
|
-
Yields BrowserExtensionRecord with the following fields
|
327
|
+
Yields BrowserExtensionRecord with the following fields:
|
328
|
+
|
329
|
+
.. code-block:: text
|
330
|
+
|
319
331
|
ts_install (datetime): Extension install timestamp.
|
320
332
|
ts_update (datetime): Extension update timestamp.
|
321
333
|
browser (string): The browser from which the records are generated.
|
@@ -131,6 +131,9 @@ class InternetExplorerPlugin(BrowserPlugin):
|
|
131
131
|
"""Return browser history records from Internet Explorer.
|
132
132
|
|
133
133
|
Yields BrowserHistoryRecord with the following fields:
|
134
|
+
|
135
|
+
.. code-block:: text
|
136
|
+
|
134
137
|
ts (datetime): Visit timestamp.
|
135
138
|
browser (string): The browser from which the records are generated from.
|
136
139
|
id (string): Record ID.
|
@@ -183,6 +186,9 @@ class InternetExplorerPlugin(BrowserPlugin):
|
|
183
186
|
"""Return browser downloads records from Internet Explorer.
|
184
187
|
|
185
188
|
Yields BrowserDownloadRecord with the following fields:
|
189
|
+
|
190
|
+
.. code-block:: text
|
191
|
+
|
186
192
|
ts_start (datetime): Download start timestamp.
|
187
193
|
ts_end (datetime): Download end timestamp.
|
188
194
|
browser (string): The browser from which the records are generated from.
|
@@ -88,7 +88,7 @@ struct entry {
|
|
88
88
|
"""
|
89
89
|
|
90
90
|
c_local = cstruct(endian=">")
|
91
|
-
c_local.
|
91
|
+
c_local.add_custom_type("varint", ProtobufVarint, size=None, alignment=1, signed=False)
|
92
92
|
c_local.load(local_def, compiled=False)
|
93
93
|
|
94
94
|
RE_DOCKER_NS = re.compile(r"\.(?P<nanoseconds>\d{7,})(?P<postfix>Z|\+\d{2}:\d{2})")
|
File without changes
|