dissect.target 3.14.dev28__py3-none-any.whl → 3.15.dev1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,8 +20,11 @@ class VhdContainer(Container):
20
20
 
21
21
  @staticmethod
22
22
  def _detect_fh(fh: BinaryIO, original: Union[list, BinaryIO]) -> bool:
23
- fh.seek(-512, io.SEEK_END)
24
- return b"conectix" in fh.read(9)
23
+ try:
24
+ fh.seek(-512, io.SEEK_END)
25
+ return b"conectix" in fh.read(9)
26
+ except OSError:
27
+ return False
25
28
 
26
29
  @staticmethod
27
30
  def detect_path(path: Path, original: Union[list, BinaryIO]) -> bool:
@@ -1572,3 +1572,4 @@ register("exfat", "ExfatFilesystem")
1572
1572
  register("squashfs", "SquashFSFilesystem")
1573
1573
  register("zip", "ZipFilesystem")
1574
1574
  register("ad1", "AD1Filesystem")
1575
+ register("jffs", "JFFSFilesystem")
@@ -0,0 +1,122 @@
1
+ from typing import BinaryIO, Iterator, Optional
2
+
3
+ from dissect.jffs import jffs2
4
+ from dissect.jffs.c_jffs2 import c_jffs2
5
+
6
+ from dissect.target.exceptions import (
7
+ FileNotFoundError,
8
+ FilesystemError,
9
+ IsADirectoryError,
10
+ NotADirectoryError,
11
+ NotASymlinkError,
12
+ )
13
+ from dissect.target.filesystem import Filesystem, FilesystemEntry
14
+ from dissect.target.helpers import fsutil
15
+
16
+
17
+ class JFFSFilesystem(Filesystem):
18
+ __type__ = "jffs"
19
+
20
+ def __init__(self, fh: BinaryIO, *args, **kwargs):
21
+ super().__init__(fh, *args, **kwargs)
22
+ self.jffs2 = jffs2.JFFS2(fh)
23
+
24
+ @staticmethod
25
+ def _detect(fh: BinaryIO) -> bool:
26
+ return int.from_bytes(fh.read(2), "little") in (
27
+ c_jffs2.JFFS2_MAGIC_BITMASK,
28
+ c_jffs2.JFFS2_OLD_MAGIC_BITMASK,
29
+ )
30
+
31
+ def get(self, path: str) -> FilesystemEntry:
32
+ return JFFSFilesystemEntry(self, path, self._get_node(path))
33
+
34
+ def _get_node(self, path: str, node: Optional[jffs2.INode] = None) -> jffs2.INode:
35
+ try:
36
+ return self.jffs2.get(path, node)
37
+ except jffs2.FileNotFoundError as e:
38
+ raise FileNotFoundError(path, cause=e)
39
+ except jffs2.NotADirectoryError as e:
40
+ raise NotADirectoryError(path, cause=e)
41
+ except jffs2.NotASymlinkError as e:
42
+ raise NotASymlinkError(path, cause=e)
43
+ except jffs2.Error as e:
44
+ raise FileNotFoundError(path, cause=e)
45
+
46
+
47
+ class JFFSFilesystemEntry(FilesystemEntry):
48
+ fs: JFFSFilesystem
49
+ entry: jffs2.INode
50
+
51
+ def get(self, path: str) -> FilesystemEntry:
52
+ entry_path = fsutil.join(self.path, path, alt_separator=self.fs.alt_separator)
53
+ entry = self.fs._get_node(path, self.entry)
54
+ return JFFSFilesystemEntry(self.fs, entry_path, entry)
55
+
56
+ def open(self) -> BinaryIO:
57
+ if self.is_dir():
58
+ raise IsADirectoryError(self.path)
59
+ return self._resolve().entry.open()
60
+
61
+ def _iterdir(self) -> Iterator[tuple[str, jffs2.INode]]:
62
+ if not self.is_dir():
63
+ raise NotADirectoryError(self.path)
64
+
65
+ if self.is_symlink():
66
+ yield from self.readlink_ext().iterdir()
67
+ else:
68
+ yield from self.entry.iterdir()
69
+
70
+ def iterdir(self) -> Iterator[str]:
71
+ for name, _ in self._iterdir():
72
+ yield name
73
+
74
+ def scandir(self) -> Iterator[FilesystemEntry]:
75
+ for name, entry in self._iterdir():
76
+ entry_path = fsutil.join(self.path, name, alt_separator=self.fs.alt_separator)
77
+ yield JFFSFilesystemEntry(self.fs, entry_path, entry)
78
+
79
+ def is_dir(self, follow_symlinks: bool = False) -> bool:
80
+ try:
81
+ return self._resolve(follow_symlinks).entry.is_dir()
82
+ except FilesystemError:
83
+ return False
84
+
85
+ def is_file(self, follow_symlinks: bool = False) -> bool:
86
+ try:
87
+ return self._resolve(follow_symlinks).entry.is_file()
88
+ except FilesystemError:
89
+ return False
90
+
91
+ def is_symlink(self) -> bool:
92
+ return self.entry.is_symlink()
93
+
94
+ def readlink(self) -> str:
95
+ if not self.is_symlink():
96
+ raise NotASymlinkError()
97
+
98
+ return self.entry.link
99
+
100
+ def stat(self, follow_symlinks: bool = False) -> fsutil.stat_result:
101
+ return self._resolve(follow_symlinks).lstat()
102
+
103
+ def lstat(self) -> fsutil.stat_result:
104
+ node = self.entry.inode
105
+
106
+ # mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime
107
+ st_info = fsutil.stat_result(
108
+ [
109
+ self.entry.mode,
110
+ self.entry.inum,
111
+ id(self.fs),
112
+ 1, # TODO: properly calculate nlink in dissect.jffs
113
+ node.uid,
114
+ node.gid,
115
+ node.isize,
116
+ self.entry.atime.timestamp(),
117
+ self.entry.mtime.timestamp(),
118
+ self.entry.ctime.timestamp(),
119
+ ]
120
+ )
121
+
122
+ return st_info
@@ -20,6 +20,8 @@ class GenericPlugin(Plugin):
20
20
 
21
21
  last_seen = 0
22
22
  for f in var_log.iterdir():
23
+ if not f.exists():
24
+ continue
23
25
  if f.stat().st_mtime > last_seen:
24
26
  last_seen = f.stat().st_mtime
25
27
 
@@ -86,7 +86,8 @@ def main():
86
86
  print("-" * 70)
87
87
  print_target_info(target)
88
88
  except Exception as e:
89
- target.log.error("Exception in retrieving information for target: `%s`", target, exc_info=e)
89
+ target.log.error("Exception in retrieving information for target: `%s`. Use `-vv` for details.", target)
90
+ target.log.debug("", exc_info=e)
90
91
 
91
92
 
92
93
  def get_target_info(target: Target) -> dict[str, Union[str, list[str]]]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dissect.target
3
- Version: 3.14.dev28
3
+ Version: 3.15.dev1
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
@@ -46,6 +46,7 @@ Requires-Dist: dissect.etl <4.0.dev,>=3.0.dev ; extra == 'full'
46
46
  Requires-Dist: dissect.extfs <4.0.dev,>=3.0.dev ; extra == 'full'
47
47
  Requires-Dist: dissect.fat <4.0.dev,>=3.0.dev ; extra == 'full'
48
48
  Requires-Dist: dissect.ffs <4.0.dev,>=3.0.dev ; extra == 'full'
49
+ Requires-Dist: dissect.jffs <2.0.dev,>=1.0.dev ; extra == 'full'
49
50
  Requires-Dist: dissect.shellitem <4.0.dev,>=3.0.dev ; extra == 'full'
50
51
  Requires-Dist: dissect.squashfs <2.0.dev,>=1.0.dev ; extra == 'full'
51
52
  Requires-Dist: dissect.sql <4.0.dev,>=3.0.dev ; extra == 'full'
@@ -1,7 +1,7 @@
1
1
  dissect/target/__init__.py,sha256=Oc7ounTgq2hE4nR6YcNabetc7SQA40ldSa35VEdZcQU,63
2
2
  dissect/target/container.py,sha256=9ixufT1_0WhraqttBWwQjG80caToJqvCX8VjFk8d5F0,9307
3
3
  dissect/target/exceptions.py,sha256=VVW_Rq_vQinapz-2mbJ3UkxBEZpb2pE_7JlhMukdtrY,2877
4
- dissect/target/filesystem.py,sha256=8qbXNbhnE9Y1cz-5OH-67Z5eDJMXKQwy7dNYTw1ST5o,53410
4
+ dissect/target/filesystem.py,sha256=oCPNw09I3odf69HKkqph6EM5-AywAQIn9UPO-BxtbpY,53445
5
5
  dissect/target/loader.py,sha256=4ZdX-QJY83NPswTyNG31LUwYXdV1tuByrR2vKKg7d5k,7214
6
6
  dissect/target/plugin.py,sha256=5EtUEU8feYSak7NRWocByPFWKsU0yeUJio6L72Ekw5c,40914
7
7
  dissect/target/report.py,sha256=06uiP4MbNI8cWMVrC1SasNS-Yg6ptjVjckwj8Yhe0Js,7958
@@ -16,7 +16,7 @@ dissect/target/containers/qcow2.py,sha256=FtXLZA-Xkegbv--dStusQntUiDqM1idSFWMtJR
16
16
  dissect/target/containers/raw.py,sha256=1etzdlHSoO77HDaBZcKINTY5MermtKjdKnG7EKwpFrw,1087
17
17
  dissect/target/containers/split.py,sha256=mgCoSdtEMs_JK3OOlSB0aEIZEwfUDECAHlxIermwlyM,2402
18
18
  dissect/target/containers/vdi.py,sha256=Dqv--Pp8XHtHApOhSludeX8N7qDAzy2MW5E1BWGKKLo,1065
19
- dissect/target/containers/vhd.py,sha256=ShtvSnWUPkk-4lpjfawA_The01c4Qok5CZeCIzObGsg,1053
19
+ dissect/target/containers/vhd.py,sha256=l6ODEPK1Z8HZpK3T0Ty2Dp7O7RPr9qnqi_N82ERY2q8,1123
20
20
  dissect/target/containers/vhdx.py,sha256=h03uhQBhwdixSwCeHbZ2LKcycBIek-_fEUl7uV3yM74,960
21
21
  dissect/target/containers/vmdk.py,sha256=5fQGkJy4esXONXrKLbhpkQDt8Fwx19YENK2mOm7kIEk,1000
22
22
  dissect/target/data/autocompletion/target_bash_completion.sh,sha256=wrOQ_ED-h8WFcjCmY6n4qKl84tWJv9l8ShFHDfJqJyA,3592
@@ -31,6 +31,7 @@ dissect/target/filesystems/extfs.py,sha256=9Cke-H0CL-SPd3-xvdAgfc3YA5hYso0sq6hm0
31
31
  dissect/target/filesystems/fat.py,sha256=ZSw-wS57vo5eIXJndfI1rZkGu_qh-vyioMzCZFZ_UTE,4611
32
32
  dissect/target/filesystems/ffs.py,sha256=Wu8sS1jjmD0QXXcAaD2h_zzfvinjco8qvj0hErufZ-4,4555
33
33
  dissect/target/filesystems/itunes.py,sha256=6LPUHSf2qpHacMgA4bdlEKUIV_BaLxmIxyLESXqNexI,6345
34
+ dissect/target/filesystems/jffs.py,sha256=Ceqa5Em2pepnXMH_XZFmSNjQyWPo1uWTthBFSMWfKRo,3926
34
35
  dissect/target/filesystems/ntfs.py,sha256=fGgCKjdO5GrPC21DDr0SwIxmwR7KruNIqGUzysboirA,7068
35
36
  dissect/target/filesystems/smb.py,sha256=uxfcOWwEoDCw8Qpsa94T5Pn-SKd4WXs4OOrzVVI55d8,6406
36
37
  dissect/target/filesystems/squashfs.py,sha256=ehzlThXB7n96XUvQnsK5tWLsA9HIxYN-Zxl7aO9D7ts,3921
@@ -164,7 +165,7 @@ dissect/target/plugins/os/unix/_os.py,sha256=hAb0Ta0fWSABb5cTa-VQaCSH5k0byjSL_Jd
164
165
  dissect/target/plugins/os/unix/cronjobs.py,sha256=2ssj97UVJueyATVl7NMJmqd9uHflQ2tXUqdOCFIEje8,3182
165
166
  dissect/target/plugins/os/unix/datetime.py,sha256=gKfBdPyUirt3qmVYfOJ1oZXRPn8wRzssbZxR_ARrtk8,1518
166
167
  dissect/target/plugins/os/unix/etc.py,sha256=HoPEC1hxqurSnAXQAK-jf_HxdBIDe-1z_qSw_n-ViI4,258
167
- dissect/target/plugins/os/unix/generic.py,sha256=RHfIjKVqyUpw68fTdIT-KEwow9pd_BT6Xad72804KpM,1961
168
+ dissect/target/plugins/os/unix/generic.py,sha256=g9g-7qbUluaT3os7TB05iTcyCAppI6YbgjpoMMkAJCw,2017
168
169
  dissect/target/plugins/os/unix/history.py,sha256=1o6ZLQTDimo9FSm9h_8QpCWlg8_qTb8ewDMgDqdAeV8,6619
169
170
  dissect/target/plugins/os/unix/locale.py,sha256=V3R7mEyrH3f-h7SGAucByaYYDA2SIil9Qb-s3dPmDEA,3961
170
171
  dissect/target/plugins/os/unix/packagemanager.py,sha256=Wm2AAJOD_B3FAcZNXgWtSm_YwbvrHBYOP8bPmOXNjG4,2427
@@ -285,7 +286,7 @@ dissect/target/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
285
286
  dissect/target/tools/build_pluginlist.py,sha256=5fomcuMwsVzcnYx5Htf5f9lSwsLeUUvomLUXNA4t7m4,849
286
287
  dissect/target/tools/dd.py,sha256=Nlh2CFOCV0ksxyedFp7BuyoQ3tBFi6rK6UO0_k5GR_8,1758
287
288
  dissect/target/tools/fs.py,sha256=IL71ntXA_oS92l0NPpqyOVrHOZ-bf3qag1amZzAaeHc,3548
288
- dissect/target/tools/info.py,sha256=LcR0WLBo2w0QiOmM0llQfcF0a_hfrqImbJ_QNW1mtbo,5174
289
+ dissect/target/tools/info.py,sha256=wgLBn8Vj-In8HtqBDOQYD4FXThKkrEVXudopMHuY3KI,5231
289
290
  dissect/target/tools/logging.py,sha256=5ZnumtMWLyslxfrUGZ4ntRyf3obOOhmn8SBjKfdLcEg,4174
290
291
  dissect/target/tools/mount.py,sha256=m6Ise8H82jgIW2FN0hXKO4l9t3emKiOi55O4LyEqvxk,2581
291
292
  dissect/target/tools/query.py,sha256=qbQI2kAeFP0_1CxT3UbTIZZ1EZIhotD0rRNXqihZcy4,14926
@@ -304,10 +305,10 @@ dissect/target/volumes/luks.py,sha256=v_mHW05KM5iG8JDe47i2V4Q9O0r4rnAMA9m_qc9cYw
304
305
  dissect/target/volumes/lvm.py,sha256=wwQVR9I3G9YzmY6UxFsH2Y4MXGBcKL9aayWGCDTiWMU,2269
305
306
  dissect/target/volumes/md.py,sha256=j1K1iKmspl0C_OJFc7-Q1BMWN2OCC5EVANIgVlJ_fIE,1673
306
307
  dissect/target/volumes/vmfs.py,sha256=-LoUbn9WNwTtLi_4K34uV_-wDw2W5hgaqxZNj4UmqAQ,1730
307
- dissect.target-3.14.dev28.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
308
- dissect.target-3.14.dev28.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
309
- dissect.target-3.14.dev28.dist-info/METADATA,sha256=_zhtgUzUBxUk8l5xp15AhDR2HdYpCZZ-iJz33FV5LV0,11042
310
- dissect.target-3.14.dev28.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
311
- dissect.target-3.14.dev28.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
312
- dissect.target-3.14.dev28.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
313
- dissect.target-3.14.dev28.dist-info/RECORD,,
308
+ dissect.target-3.15.dev1.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
309
+ dissect.target-3.15.dev1.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
310
+ dissect.target-3.15.dev1.dist-info/METADATA,sha256=e9SaIApd-227QmSBIKlQP_Xs_q8RwOPtPMneRvqebOQ,11106
311
+ dissect.target-3.15.dev1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
312
+ dissect.target-3.15.dev1.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
313
+ dissect.target-3.15.dev1.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
314
+ dissect.target-3.15.dev1.dist-info/RECORD,,