dissect.target 3.19.dev31__py3-none-any.whl → 3.19.dev33__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ import re
5
5
  import urllib
6
6
  from os import PathLike
7
7
  from pathlib import Path
8
- from typing import TYPE_CHECKING, BinaryIO, Optional, Union
8
+ from typing import TYPE_CHECKING, BinaryIO
9
9
 
10
10
  from dissect.target.exceptions import FileNotFoundError
11
11
  from dissect.target.filesystem import Filesystem
@@ -42,12 +42,31 @@ def add_virtual_ntfs_filesystem(
42
42
  fh_sds = _try_open(fs, sds_path)
43
43
 
44
44
  if any([fh_boot, fh_mft]):
45
- ntfs = NtfsFilesystem(boot=fh_boot, mft=fh_mft, usnjrnl=fh_usnjrnl, sds=fh_sds)
46
- target.filesystems.add(ntfs)
47
- fs.ntfs = ntfs.ntfs
45
+ ntfs = None
48
46
 
49
-
50
- def _try_open(fs: Filesystem, path: str) -> BinaryIO:
47
+ try:
48
+ ntfs = NtfsFilesystem(boot=fh_boot, mft=fh_mft, usnjrnl=fh_usnjrnl, sds=fh_sds)
49
+ except Exception as e:
50
+ if fh_boot:
51
+ log.warning("Failed to load NTFS filesystem from %s, retrying without $Boot file", fs)
52
+ log.debug("", exc_info=e)
53
+
54
+ try:
55
+ # Try once more without the $Boot file
56
+ ntfs = NtfsFilesystem(mft=fh_mft, usnjrnl=fh_usnjrnl, sds=fh_sds)
57
+ except Exception:
58
+ log.warning("Failed to load NTFS filesystem from %s without $Boot file, skipping", fs)
59
+ return
60
+
61
+ # Only add it if we have a valid NTFS with an MFT
62
+ if ntfs and ntfs.ntfs.mft:
63
+ target.filesystems.add(ntfs)
64
+ fs.ntfs = ntfs.ntfs
65
+ else:
66
+ log.warning("Opened NTFS filesystem from %s but could not find $MFT, skipping", fs)
67
+
68
+
69
+ def _try_open(fs: Filesystem, path: str) -> BinaryIO | None:
51
70
  paths = [path] if not isinstance(path, list) else path
52
71
 
53
72
  for path in paths:
@@ -61,7 +80,7 @@ def _try_open(fs: Filesystem, path: str) -> BinaryIO:
61
80
  pass
62
81
 
63
82
 
64
- def extract_path_info(path: Union[str, Path]) -> tuple[Path, Optional[urllib.parse.ParseResult]]:
83
+ def extract_path_info(path: str | Path) -> tuple[Path, urllib.parse.ParseResult | None]:
65
84
  """
66
85
  Extracts a ParseResult from a path if it has
67
86
  a scheme and adjusts the path if necessary.
@@ -12,6 +12,7 @@ from dissect.target.exceptions import TargetError
12
12
  from dissect.target.helpers.record import TargetRecordDescriptor
13
13
  from dissect.target.tools.query import record_output
14
14
  from dissect.target.tools.utils import (
15
+ args_to_uri,
15
16
  catch_sigpipe,
16
17
  configure_generic_arguments,
17
18
  process_generic_arguments,
@@ -50,14 +51,14 @@ def main():
50
51
  )
51
52
  parser.add_argument("targets", metavar="TARGETS", nargs="*", help="Targets to display info from")
52
53
  parser.add_argument("--from-file", nargs="?", type=Path, help="file containing targets to load")
53
- parser.add_argument("-d", "--delimiter", default=" ", action="store", metavar="','")
54
54
  parser.add_argument("-s", "--strings", action="store_true", help="print output as string")
55
55
  parser.add_argument("-r", "--record", action="store_true", help="print output as record")
56
56
  parser.add_argument("-j", "--json", action="store_true", help="output records as pretty json")
57
57
  parser.add_argument("-J", "--jsonlines", action="store_true", help="output records as one-line json")
58
+ parser.add_argument("-L", "--loader", action="store", default=None, help="select a specific loader (i.e. vmx, raw)")
58
59
  configure_generic_arguments(parser)
59
60
 
60
- args = parser.parse_args()
61
+ args, rest = parser.parse_known_args()
61
62
 
62
63
  process_generic_arguments(args)
63
64
 
@@ -73,8 +74,10 @@ def main():
73
74
  targets = targets[:-1]
74
75
  args.targets = targets
75
76
 
77
+ targets = args_to_uri(args.targets, args.loader, rest) if args.loader else args.targets
78
+
76
79
  try:
77
- for i, target in enumerate(Target.open_all(args.targets)):
80
+ for i, target in enumerate(Target.open_all(targets)):
78
81
  try:
79
82
  if args.jsonlines:
80
83
  print(json.dumps(get_target_info(target), default=str))
@@ -8,6 +8,7 @@ from dissect.target.exceptions import TargetError
8
8
  from dissect.target.plugins.filesystem.yara import HAS_YARA, YaraPlugin
9
9
  from dissect.target.tools.query import record_output
10
10
  from dissect.target.tools.utils import (
11
+ args_to_uri,
11
12
  catch_sigpipe,
12
13
  configure_generic_arguments,
13
14
  process_generic_arguments,
@@ -27,6 +28,7 @@ def main():
27
28
 
28
29
  parser.add_argument("targets", metavar="TARGETS", nargs="*", help="Targets to load")
29
30
  parser.add_argument("-s", "--strings", default=False, action="store_true", help="print output as string")
31
+ parser.add_argument("-L", "--loader", action="store", default=None, help="select a specific loader (i.e. vmx, raw)")
30
32
  parser.add_argument("--children", action="store_true", help="include children")
31
33
 
32
34
  for args, kwargs in getattr(YaraPlugin.yara, "__args__", []):
@@ -34,7 +36,7 @@ def main():
34
36
 
35
37
  configure_generic_arguments(parser)
36
38
 
37
- args = parser.parse_args()
39
+ args, rest = parser.parse_known_args()
38
40
  process_generic_arguments(args)
39
41
 
40
42
  if not HAS_YARA:
@@ -45,8 +47,10 @@ def main():
45
47
  log.error("No targets provided")
46
48
  parser.exit(1)
47
49
 
50
+ targets = args_to_uri(args.targets, args.loader, rest) if args.loader else args.targets
51
+
48
52
  try:
49
- for target in Target.open_all(args.targets, args.children):
53
+ for target in Target.open_all(targets, args.children):
50
54
  rs = record_output(args.strings, False)
51
55
  for record in target.yara(args.rules, args.path, args.max_size, args.check):
52
56
  rs.write(record)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dissect.target
3
- Version: 3.19.dev31
3
+ Version: 3.19.dev33
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
@@ -54,7 +54,7 @@ dissect/target/helpers/fsutil.py,sha256=tPyH4RBDqM9QXjamIQaDRLUy3b4dKmfrT6k3ZP01
54
54
  dissect/target/helpers/hashutil.py,sha256=bYAGEjyYyxuCTziO4kCx6srzY1Cm-PXmayRRcxt5ca4,1061
55
55
  dissect/target/helpers/keychain.py,sha256=wYH0sf7eaxP0bZTo80RF_BQMWulCWmIQ8Tzt9K5TSNQ,3611
56
56
  dissect/target/helpers/lazy.py,sha256=823VtmdWsbJyVZvNWopDhQdqq2i1xtj6b8IKfveboKw,1771
57
- dissect/target/helpers/loaderutil.py,sha256=kiyMWra_gVxfNSGwLlgxLcuuqAYuCMDc5NiCDprVNnc,2649
57
+ dissect/target/helpers/loaderutil.py,sha256=4cS0RKGgsljQYYc5uGzmnWJ_NXt7QfWJ1jvtEINZmdE,3415
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
@@ -326,14 +326,14 @@ dissect/target/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
326
326
  dissect/target/tools/build_pluginlist.py,sha256=5fomcuMwsVzcnYx5Htf5f9lSwsLeUUvomLUXNA4t7m4,849
327
327
  dissect/target/tools/dd.py,sha256=rTM-lgXxrYBpVAtJqFqAatDz45bLoD8-mFt_59Q3Lio,1928
328
328
  dissect/target/tools/fs.py,sha256=bdFSckOO-dyvvBpxOgPIx_UKGEbWGbOHF7kl6rWyt7U,6654
329
- dissect/target/tools/info.py,sha256=3smHr8I71yj3kCjsQ5nXkOHI9T_N8UwvkVa1CNOxB-s,5461
329
+ dissect/target/tools/info.py,sha256=SXU8_AXeFhw2XZBVQu3XW-ZDAewLvahI6Ag4TSq2-3A,5610
330
330
  dissect/target/tools/logging.py,sha256=5ZnumtMWLyslxfrUGZ4ntRyf3obOOhmn8SBjKfdLcEg,4174
331
331
  dissect/target/tools/mount.py,sha256=L_0tSmiBdW4aSaF0vXjB0bAkTC0kmT2N1hrbW6s5Jow,3254
332
332
  dissect/target/tools/query.py,sha256=ONHu2FVomLccikb84qBrlhNmEfRoHYFQMcahk_y2c9A,15580
333
333
  dissect/target/tools/reg.py,sha256=FDsiBBDxjWVUBTRj8xn82vZe-J_d9piM-TKS3PHZCcM,3193
334
334
  dissect/target/tools/shell.py,sha256=_widEuIRqZhYzcFR52NYI8O2aPFm6tG5Uiv-AIrC32U,45155
335
335
  dissect/target/tools/utils.py,sha256=sQizexY3ui5vmWw4KOBLg5ecK3TPFjD-uxDqRn56ZTY,11304
336
- dissect/target/tools/yara.py,sha256=SZ0lKshWJ0TFTDUYONVKF04TgwmtDAttUPws9j9YSvk,1806
336
+ dissect/target/tools/yara.py,sha256=70k-2VMulf1EdkX03nCACzejaOEcsFHOyX-4E40MdQU,2044
337
337
  dissect/target/tools/dump/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
338
338
  dissect/target/tools/dump/run.py,sha256=aD84peRS4zHqC78fH7Vd4ni3m1ZmVP70LyMwBRvoDGY,9463
339
339
  dissect/target/tools/dump/state.py,sha256=YYgCff0kZZ-tx27lJlc9LQ7AfoGnLK5Gyi796OnktA8,9205
@@ -346,10 +346,10 @@ dissect/target/volumes/luks.py,sha256=OmCMsw6rCUXG1_plnLVLTpsvE1n_6WtoRUGQbpmu1z
346
346
  dissect/target/volumes/lvm.py,sha256=wwQVR9I3G9YzmY6UxFsH2Y4MXGBcKL9aayWGCDTiWMU,2269
347
347
  dissect/target/volumes/md.py,sha256=7ShPtusuLGaIv27SvEETtgsuoQyAa4iAAeOR1NEaajI,1689
348
348
  dissect/target/volumes/vmfs.py,sha256=-LoUbn9WNwTtLi_4K34uV_-wDw2W5hgaqxZNj4UmqAQ,1730
349
- dissect.target-3.19.dev31.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
350
- dissect.target-3.19.dev31.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
351
- dissect.target-3.19.dev31.dist-info/METADATA,sha256=GZuNZDNA6Y6mINzf5sqR_gX4uyq0i5TLvFhCse-bxPc,12719
352
- dissect.target-3.19.dev31.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
353
- dissect.target-3.19.dev31.dist-info/entry_points.txt,sha256=BWuxAb_6AvUAQpIQOQU0IMTlaF6TDht2AIZK8bHd-zE,492
354
- dissect.target-3.19.dev31.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
355
- dissect.target-3.19.dev31.dist-info/RECORD,,
349
+ dissect.target-3.19.dev33.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
350
+ dissect.target-3.19.dev33.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
351
+ dissect.target-3.19.dev33.dist-info/METADATA,sha256=qql1vSsBtkxg9RPKiPg49ssQekDjKwQfE3GKlxWsjCk,12719
352
+ dissect.target-3.19.dev33.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
353
+ dissect.target-3.19.dev33.dist-info/entry_points.txt,sha256=BWuxAb_6AvUAQpIQOQU0IMTlaF6TDht2AIZK8bHd-zE,492
354
+ dissect.target-3.19.dev33.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
355
+ dissect.target-3.19.dev33.dist-info/RECORD,,