dissect.target 3.20.dev14__py3-none-any.whl → 3.20.dev16__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,13 +3,13 @@ from __future__ import annotations
3
3
  import logging
4
4
 
5
5
  from dissect.target.filesystem import Filesystem
6
- from dissect.target.helpers.network_managers import (
7
- LinuxNetworkManager,
8
- parse_unix_dhcp_log_messages,
9
- )
10
6
  from dissect.target.plugin import OperatingSystem, export
11
7
  from dissect.target.plugins.os.unix._os import UnixPlugin
12
8
  from dissect.target.plugins.os.unix.bsd.osx._os import MacPlugin
9
+ from dissect.target.plugins.os.unix.linux.network_managers import (
10
+ LinuxNetworkManager,
11
+ parse_unix_dhcp_log_messages,
12
+ )
13
13
  from dissect.target.plugins.os.windows._os import WindowsPlugin
14
14
  from dissect.target.target import Target
15
15
 
@@ -7,15 +7,17 @@ from configparser import ConfigParser, MissingSectionHeaderError
7
7
  from io import StringIO
8
8
  from itertools import chain
9
9
  from re import compile, sub
10
- from typing import Any, Callable, Iterable, Iterator, Match, Optional
10
+ from typing import TYPE_CHECKING, Any, Callable, Iterable, Iterator, Match
11
11
 
12
12
  from defusedxml import ElementTree
13
13
 
14
14
  from dissect.target.exceptions import PluginError
15
- from dissect.target.helpers.fsutil import TargetPath
16
- from dissect.target.plugins.os.unix.log.journal import JournalRecord
17
- from dissect.target.plugins.os.unix.log.messages import MessagesRecord
18
- from dissect.target.target import Target
15
+
16
+ if TYPE_CHECKING:
17
+ from dissect.target.helpers.fsutil import TargetPath
18
+ from dissect.target.plugins.os.unix.log.journal import JournalRecord
19
+ from dissect.target.plugins.os.unix.log.messages import MessagesRecord
20
+ from dissect.target.target import Target
19
21
 
20
22
  log = logging.getLogger(__name__)
21
23
 
@@ -57,7 +59,7 @@ class Template:
57
59
  """Sets the name of the the used parsing template to the name of the discovered network manager."""
58
60
  self.name = name
59
61
 
60
- def create_config(self, path: TargetPath) -> Optional[dict]:
62
+ def create_config(self, path: TargetPath) -> dict | None:
61
63
  """Create a network config dictionary based on the configured template and supplied path.
62
64
 
63
65
  Args:
@@ -81,7 +83,7 @@ class Template:
81
83
  config = self._parse_configparser_config(path)
82
84
  return config
83
85
 
84
- def _parse_netplan_config(self, path: TargetPath) -> Optional[dict]:
86
+ def _parse_netplan_config(self, path: TargetPath) -> dict | None:
85
87
  """Internal function to parse a netplan YAML based configuration file into a dict.
86
88
 
87
89
  Args:
@@ -286,7 +288,7 @@ class Parser:
286
288
  if option in translation_values and value:
287
289
  return translation_key
288
290
 
289
- def _get_option(self, config: dict, option: str, section: Optional[str] = None) -> Optional[str | Callable]:
291
+ def _get_option(self, config: dict, option: str, section: str | None = None) -> str | Callable | None:
290
292
  """Internal function to get arbitrary options values from a parsed (non-translated) dictionary.
291
293
 
292
294
  Args:
@@ -334,7 +336,7 @@ class NetworkManager:
334
336
  self.config_globs = (config_globs,) if isinstance(config_globs, str) else config_globs
335
337
  self.detection_globs = (detection_globs,) if isinstance(detection_globs, str) else detection_globs
336
338
 
337
- def detect(self, target: Optional[Target] = None) -> bool:
339
+ def detect(self, target: Target | None = None) -> bool:
338
340
  """Detects if the network manager is active on the target
339
341
 
340
342
  Returns:
@@ -95,6 +95,7 @@ class ExtendedCmd(cmd.Cmd):
95
95
  """
96
96
 
97
97
  CMD_PREFIX = "cmd_"
98
+ _runtime_aliases = {}
98
99
 
99
100
  def __init__(self, cyber: bool = False):
100
101
  cmd.Cmd.__init__(self)
@@ -164,6 +165,11 @@ class ExtendedCmd(cmd.Cmd):
164
165
  return None
165
166
 
166
167
  def default(self, line: str) -> bool:
168
+ com, arg, _ = self.parseline(line)
169
+ if com in self._runtime_aliases:
170
+ expanded = " ".join([self._runtime_aliases[com], arg])
171
+ return self.onecmd(expanded)
172
+
167
173
  if (should_exit := self._handle_command(line)) is not None:
168
174
  return should_exit
169
175
 
@@ -230,6 +236,43 @@ class ExtendedCmd(cmd.Cmd):
230
236
  def complete_man(self, *args) -> list[str]:
231
237
  return cmd.Cmd.complete_help(self, *args)
232
238
 
239
+ def do_unalias(self, line: str) -> bool:
240
+ """delete runtime alias"""
241
+ aliases = list(shlex.shlex(line, posix=True))
242
+ for aliased in aliases:
243
+ if aliased in self._runtime_aliases:
244
+ del self._runtime_aliases[aliased]
245
+ else:
246
+ print(f"alias {aliased} not found")
247
+ return False
248
+
249
+ def do_alias(self, line: str) -> bool:
250
+ """create a runtime alias"""
251
+ args = list(shlex.shlex(line, posix=True))
252
+
253
+ if not args:
254
+ for aliased, command in self._runtime_aliases.items():
255
+ print(f"alias {aliased}={command}")
256
+ return False
257
+
258
+ while args:
259
+ alias_name = args.pop(0)
260
+ try:
261
+ equals = args.pop(0)
262
+ # our parser works different, so we have to stop this
263
+ if equals != "=":
264
+ raise RuntimeError("Token not allowed")
265
+ expanded = args.pop(0) if args else "" # this is how it works in bash
266
+ self._runtime_aliases[alias_name] = expanded
267
+ except IndexError:
268
+ if alias_name in self._runtime_aliases:
269
+ print(f"alias {alias_name}={self._runtime_aliases[alias_name]}")
270
+ else:
271
+ print(f"alias {alias_name} not found")
272
+ pass
273
+
274
+ return False
275
+
233
276
  def do_clear(self, line: str) -> bool:
234
277
  """clear the terminal screen"""
235
278
  os.system("cls||clear")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dissect.target
3
- Version: 3.20.dev14
3
+ Version: 3.20.dev16
4
4
  Summary: This module ties all other Dissect modules together, it provides a programming API and command line tools which allow easy access to various data sources inside disk images or file collections (a.k.a. targets)
5
5
  Author-email: Dissect Team <dissect@fox-it.com>
6
6
  License: Affero General Public License v3
@@ -58,7 +58,6 @@ dissect/target/helpers/loaderutil.py,sha256=4cS0RKGgsljQYYc5uGzmnWJ_NXt7QfWJ1jvt
58
58
  dissect/target/helpers/localeutil.py,sha256=Y4Fh4jDSGfm5356xSLMriUCN8SZP_FAHg_iodkAxNq4,1504
59
59
  dissect/target/helpers/mount.py,sha256=JxhUYyEbDnHfzPpfuWy4nV9OwCJPoDSGdHHNiyvd_l0,3949
60
60
  dissect/target/helpers/mui.py,sha256=i-7XoHbu4WO2fYapK9yGAMW04rFlgRispknc1KQIS5Q,22258
61
- dissect/target/helpers/network_managers.py,sha256=ByBSe2K3c8hgQC6dokcf-hHdmPcD8PmrOj0xs1C3yhs,25743
62
61
  dissect/target/helpers/polypath.py,sha256=h8p7m_OCNiQljGwoZh5Aflr9H2ot6CZr6WKq1OSw58o,2175
63
62
  dissect/target/helpers/protobuf.py,sha256=b4DsnqrRLrefcDjx7rQno-_LBcwtJXxuKf5RdOegzfE,1537
64
63
  dissect/target/helpers/record.py,sha256=7Se6ZV8cvwEaGSjRd9bKhVnUAn4W4KR2eqP6AbQhTH4,5892
@@ -219,12 +218,13 @@ dissect/target/plugins/os/unix/esxi/_os.py,sha256=s6pAgUyfHh3QcY6sgvk5uVMmLvqK1t
219
218
  dissect/target/plugins/os/unix/etc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
220
219
  dissect/target/plugins/os/unix/etc/etc.py,sha256=px_UwtPuk_scD-3nKJQZ0ao5lus9-BrSU4lPZWelYzI,2541
221
220
  dissect/target/plugins/os/unix/linux/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
222
- dissect/target/plugins/os/unix/linux/_os.py,sha256=ktEx_VhRB9vvZePo3-np2_L3yzUPq1Cc_D_1lnPq4-4,3023
221
+ dissect/target/plugins/os/unix/linux/_os.py,sha256=W5ok4TS0nZfR6x9vk12FAjGhZyS5cNrdxFeFpQkVOrQ,3037
223
222
  dissect/target/plugins/os/unix/linux/cmdline.py,sha256=AyMfndt3UsmJtoOyZYC8nWq2GZg9oPvn8SiI3M4NxnE,1622
224
223
  dissect/target/plugins/os/unix/linux/environ.py,sha256=UOQD7Xmu754u2oAh3L5g5snuz-gv4jbWbVy46qszYjo,1881
225
224
  dissect/target/plugins/os/unix/linux/iptables.py,sha256=qTzY5PHHXA33WnPYb5NESgoSwI7ECZ8YPoEe_Fmln-8,6045
226
225
  dissect/target/plugins/os/unix/linux/modules.py,sha256=H1S5CkpXttCVwzE2Ylz3jkvrCptN2f-fXcQ_hCB0FG0,2443
227
226
  dissect/target/plugins/os/unix/linux/netstat.py,sha256=MAC4ZdeNqcKpxT2ZMh1-7rjt4Pt_WQIRy7RChr7nlPk,1649
227
+ dissect/target/plugins/os/unix/linux/network_managers.py,sha256=nr0gA3hBqsvP9k6xAYmRYwGRB1kMtXB1k0pe78jWdFI,25768
228
228
  dissect/target/plugins/os/unix/linux/proc.py,sha256=jm35fAasnNbObN2tpflwQuCfVYLDkTP2EDrzYG42ZSk,23354
229
229
  dissect/target/plugins/os/unix/linux/processes.py,sha256=rvDJWAp16WAJZ91A8_GJJIj5y0U7BNnU8CW_47AueKY,1967
230
230
  dissect/target/plugins/os/unix/linux/services.py,sha256=-d2y073mOXUM3XCzRgDVCRFR9eTLoVuN8FsZVewHzRg,4075
@@ -350,7 +350,7 @@ dissect/target/tools/logging.py,sha256=5ZnumtMWLyslxfrUGZ4ntRyf3obOOhmn8SBjKfdLc
350
350
  dissect/target/tools/mount.py,sha256=8GRYnu4xEmFBHxuIZAYhOMyyTGX8fat1Ou07DNiUnW4,3945
351
351
  dissect/target/tools/query.py,sha256=e-yAN9zdQjuOiTuoOQoo17mVEQGGcOgaA9YkF4GYpkM,15394
352
352
  dissect/target/tools/reg.py,sha256=FDsiBBDxjWVUBTRj8xn82vZe-J_d9piM-TKS3PHZCcM,3193
353
- dissect/target/tools/shell.py,sha256=dmshIriwdd_UwrdUcTfWkcYD8Z0mjzbDqwyZG-snDdM,50482
353
+ dissect/target/tools/shell.py,sha256=7jur65pFugpZHyfA0MkaMPCYWZPUSFjhkFQZO8IBYXQ,52077
354
354
  dissect/target/tools/utils.py,sha256=JJZDSso1CEK2sv4Z3HJNgqxH6G9S5lbmV-C3h-XmcMo,12035
355
355
  dissect/target/tools/yara.py,sha256=70k-2VMulf1EdkX03nCACzejaOEcsFHOyX-4E40MdQU,2044
356
356
  dissect/target/tools/dump/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -365,10 +365,10 @@ dissect/target/volumes/luks.py,sha256=OmCMsw6rCUXG1_plnLVLTpsvE1n_6WtoRUGQbpmu1z
365
365
  dissect/target/volumes/lvm.py,sha256=wwQVR9I3G9YzmY6UxFsH2Y4MXGBcKL9aayWGCDTiWMU,2269
366
366
  dissect/target/volumes/md.py,sha256=7ShPtusuLGaIv27SvEETtgsuoQyAa4iAAeOR1NEaajI,1689
367
367
  dissect/target/volumes/vmfs.py,sha256=-LoUbn9WNwTtLi_4K34uV_-wDw2W5hgaqxZNj4UmqAQ,1730
368
- dissect.target-3.20.dev14.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
369
- dissect.target-3.20.dev14.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
370
- dissect.target-3.20.dev14.dist-info/METADATA,sha256=yLrkWdIhYUoYMdbxfNR2byfx4W0uKfC0LWE9ldpzZVg,12897
371
- dissect.target-3.20.dev14.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
372
- dissect.target-3.20.dev14.dist-info/entry_points.txt,sha256=BWuxAb_6AvUAQpIQOQU0IMTlaF6TDht2AIZK8bHd-zE,492
373
- dissect.target-3.20.dev14.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
374
- dissect.target-3.20.dev14.dist-info/RECORD,,
368
+ dissect.target-3.20.dev16.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
369
+ dissect.target-3.20.dev16.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
370
+ dissect.target-3.20.dev16.dist-info/METADATA,sha256=RLzyPf8gnwZFIOTzoWItUBwzSzdMYkdoBdJnENDslDk,12897
371
+ dissect.target-3.20.dev16.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
372
+ dissect.target-3.20.dev16.dist-info/entry_points.txt,sha256=BWuxAb_6AvUAQpIQOQU0IMTlaF6TDht2AIZK8bHd-zE,492
373
+ dissect.target-3.20.dev16.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
374
+ dissect.target-3.20.dev16.dist-info/RECORD,,