dfvfs 20260712__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. dfvfs/__init__.py +7 -0
  2. dfvfs/analyzer/__init__.py +39 -0
  3. dfvfs/analyzer/analyzer.py +431 -0
  4. dfvfs/analyzer/analyzer_helper.py +81 -0
  5. dfvfs/analyzer/apfs_analyzer_helper.py +31 -0
  6. dfvfs/analyzer/apfs_container_analyzer_helper.py +31 -0
  7. dfvfs/analyzer/apm_analyzer_helper.py +47 -0
  8. dfvfs/analyzer/bde_analyzer_helper.py +37 -0
  9. dfvfs/analyzer/bzip2_analyzer_helper.py +34 -0
  10. dfvfs/analyzer/cpio_analyzer_helper.py +43 -0
  11. dfvfs/analyzer/cs_analyzer_helper.py +31 -0
  12. dfvfs/analyzer/ewf_analyzer_helper.py +39 -0
  13. dfvfs/analyzer/ext_analyzer_helper.py +39 -0
  14. dfvfs/analyzer/fat_analyzer_helper.py +49 -0
  15. dfvfs/analyzer/gpt_analyzer_helper.py +42 -0
  16. dfvfs/analyzer/gzip_analyzer_helper.py +31 -0
  17. dfvfs/analyzer/hfs_analyzer_helper.py +45 -0
  18. dfvfs/analyzer/luksde_analyzer_helper.py +31 -0
  19. dfvfs/analyzer/lvm_analyzer_helper.py +34 -0
  20. dfvfs/analyzer/modi_analyzer_helper.py +34 -0
  21. dfvfs/analyzer/ntfs_analyzer_helper.py +39 -0
  22. dfvfs/analyzer/phdi_analyzer_helper.py +31 -0
  23. dfvfs/analyzer/qcow_analyzer_helper.py +37 -0
  24. dfvfs/analyzer/specification.py +155 -0
  25. dfvfs/analyzer/tar_analyzer_helper.py +34 -0
  26. dfvfs/analyzer/tsk_analyzer_helper.py +67 -0
  27. dfvfs/analyzer/tsk_partition_analyzer_helper.py +38 -0
  28. dfvfs/analyzer/vhdi_analyzer_helper.py +34 -0
  29. dfvfs/analyzer/vmdk_analyzer_helper.py +37 -0
  30. dfvfs/analyzer/vshadow_analyzer_helper.py +34 -0
  31. dfvfs/analyzer/xfs_analyzer_helper.py +31 -0
  32. dfvfs/analyzer/xz_analyzer_helper.py +31 -0
  33. dfvfs/analyzer/zip_analyzer_helper.py +31 -0
  34. dfvfs/compression/__init__.py +10 -0
  35. dfvfs/compression/bzip2_decompressor.py +50 -0
  36. dfvfs/compression/decompressor.py +20 -0
  37. dfvfs/compression/manager.py +84 -0
  38. dfvfs/compression/xz_decompressor.py +74 -0
  39. dfvfs/compression/zlib_decompressor.py +73 -0
  40. dfvfs/credentials/__init__.py +7 -0
  41. dfvfs/credentials/apfs_credentials.py +17 -0
  42. dfvfs/credentials/bde_credentials.py +19 -0
  43. dfvfs/credentials/credentials.py +23 -0
  44. dfvfs/credentials/cs_credentials.py +17 -0
  45. dfvfs/credentials/encrypted_stream_credentials.py +16 -0
  46. dfvfs/credentials/keychain.py +86 -0
  47. dfvfs/credentials/luksde_credentials.py +17 -0
  48. dfvfs/credentials/manager.py +74 -0
  49. dfvfs/encoding/__init__.py +5 -0
  50. dfvfs/encoding/base16_decoder.py +39 -0
  51. dfvfs/encoding/base32_decoder.py +39 -0
  52. dfvfs/encoding/base64_decoder.py +43 -0
  53. dfvfs/encoding/decoder.py +20 -0
  54. dfvfs/encoding/manager.py +79 -0
  55. dfvfs/encryption/__init__.py +6 -0
  56. dfvfs/encryption/aes_decrypter.py +105 -0
  57. dfvfs/encryption/blowfish_decrypter.py +107 -0
  58. dfvfs/encryption/decrypter.py +36 -0
  59. dfvfs/encryption/des3_decrypter.py +107 -0
  60. dfvfs/encryption/manager.py +86 -0
  61. dfvfs/encryption/rc4_decrypter.py +49 -0
  62. dfvfs/file_io/__init__.py +0 -0
  63. dfvfs/file_io/apfs_file_io.py +125 -0
  64. dfvfs/file_io/apm_file_io.py +175 -0
  65. dfvfs/file_io/bde_file_io.py +44 -0
  66. dfvfs/file_io/compressed_stream_io.py +333 -0
  67. dfvfs/file_io/cpio_file_io.py +146 -0
  68. dfvfs/file_io/cs_file_io.py +148 -0
  69. dfvfs/file_io/data_range_io.py +195 -0
  70. dfvfs/file_io/encoded_stream_io.py +325 -0
  71. dfvfs/file_io/encrypted_stream_io.py +355 -0
  72. dfvfs/file_io/ewf_file_io.py +89 -0
  73. dfvfs/file_io/ext_file_io.py +126 -0
  74. dfvfs/file_io/fake_file_io.py +140 -0
  75. dfvfs/file_io/fat_file_io.py +137 -0
  76. dfvfs/file_io/file_io.py +158 -0
  77. dfvfs/file_io/file_object_io.py +136 -0
  78. dfvfs/file_io/gpt_file_io.py +181 -0
  79. dfvfs/file_io/gzip_file_io.py +97 -0
  80. dfvfs/file_io/hfs_file_io.py +139 -0
  81. dfvfs/file_io/luksde_file_io.py +44 -0
  82. dfvfs/file_io/lvm_file_io.py +128 -0
  83. dfvfs/file_io/modi_file_io.py +67 -0
  84. dfvfs/file_io/ntfs_file_io.py +142 -0
  85. dfvfs/file_io/os_file_io.py +196 -0
  86. dfvfs/file_io/phdi_file_io.py +127 -0
  87. dfvfs/file_io/qcow_file_io.py +131 -0
  88. dfvfs/file_io/raw_file_io.py +89 -0
  89. dfvfs/file_io/sqlite_blob_file_io.py +263 -0
  90. dfvfs/file_io/tar_file_io.py +157 -0
  91. dfvfs/file_io/tsk_file_io.py +247 -0
  92. dfvfs/file_io/tsk_partition_file_io.py +64 -0
  93. dfvfs/file_io/vhdi_file_io.py +140 -0
  94. dfvfs/file_io/vmdk_file_io.py +122 -0
  95. dfvfs/file_io/vshadow_file_io.py +132 -0
  96. dfvfs/file_io/xfs_file_io.py +126 -0
  97. dfvfs/file_io/zip_file_io.py +287 -0
  98. dfvfs/helpers/__init__.py +0 -0
  99. dfvfs/helpers/command_line.py +917 -0
  100. dfvfs/helpers/data_slice.py +79 -0
  101. dfvfs/helpers/fake_file_system_builder.py +122 -0
  102. dfvfs/helpers/file_system_searcher.py +694 -0
  103. dfvfs/helpers/source_scanner.py +963 -0
  104. dfvfs/helpers/text_file.py +199 -0
  105. dfvfs/helpers/volume_scanner.py +890 -0
  106. dfvfs/helpers/windows_path_resolver.py +279 -0
  107. dfvfs/lib/__init__.py +0 -0
  108. dfvfs/lib/apfs_helper.py +27 -0
  109. dfvfs/lib/apm_helper.py +30 -0
  110. dfvfs/lib/bde_helper.py +55 -0
  111. dfvfs/lib/cpio.py +368 -0
  112. dfvfs/lib/cpio.yaml +200 -0
  113. dfvfs/lib/cs_helper.py +59 -0
  114. dfvfs/lib/data_format.py +119 -0
  115. dfvfs/lib/decorators.py +23 -0
  116. dfvfs/lib/definitions.py +170 -0
  117. dfvfs/lib/errors.py +45 -0
  118. dfvfs/lib/ewf_helper.py +108 -0
  119. dfvfs/lib/glob2regex.py +92 -0
  120. dfvfs/lib/gzipfile.py +600 -0
  121. dfvfs/lib/gzipfile.yaml +90 -0
  122. dfvfs/lib/luksde_helper.py +39 -0
  123. dfvfs/lib/lvm_helper.py +33 -0
  124. dfvfs/lib/raw_helper.py +397 -0
  125. dfvfs/lib/sqlite_database.py +210 -0
  126. dfvfs/lib/tsk_image.py +55 -0
  127. dfvfs/lib/tsk_partition.py +172 -0
  128. dfvfs/lib/vshadow_helper.py +30 -0
  129. dfvfs/mount/__init__.py +0 -0
  130. dfvfs/mount/manager.py +71 -0
  131. dfvfs/path/__init__.py +37 -0
  132. dfvfs/path/apfs_container_path_spec.py +51 -0
  133. dfvfs/path/apfs_path_spec.py +51 -0
  134. dfvfs/path/apm_path_spec.py +51 -0
  135. dfvfs/path/bde_path_spec.py +63 -0
  136. dfvfs/path/compressed_stream_path_spec.py +43 -0
  137. dfvfs/path/cpio_path_spec.py +32 -0
  138. dfvfs/path/cs_path_spec.py +77 -0
  139. dfvfs/path/data_range_path_spec.py +49 -0
  140. dfvfs/path/encoded_stream_path_spec.py +43 -0
  141. dfvfs/path/encrypted_stream_path_spec.py +78 -0
  142. dfvfs/path/ewf_path_spec.py +30 -0
  143. dfvfs/path/ext_path_spec.py +51 -0
  144. dfvfs/path/factory.py +136 -0
  145. dfvfs/path/fake_path_spec.py +36 -0
  146. dfvfs/path/fat_path_spec.py +51 -0
  147. dfvfs/path/gpt_path_spec.py +51 -0
  148. dfvfs/path/gzip_path_spec.py +30 -0
  149. dfvfs/path/hfs_path_spec.py +60 -0
  150. dfvfs/path/location_path_spec.py +34 -0
  151. dfvfs/path/luksde_path_spec.py +46 -0
  152. dfvfs/path/lvm_path_spec.py +51 -0
  153. dfvfs/path/modi_path_spec.py +30 -0
  154. dfvfs/path/mount_path_spec.py +42 -0
  155. dfvfs/path/ntfs_path_spec.py +74 -0
  156. dfvfs/path/os_path_spec.py +49 -0
  157. dfvfs/path/path_spec.py +139 -0
  158. dfvfs/path/phdi_path_spec.py +30 -0
  159. dfvfs/path/qcow_path_spec.py +30 -0
  160. dfvfs/path/raw_path_spec.py +30 -0
  161. dfvfs/path/sqlite_blob_path_spec.py +89 -0
  162. dfvfs/path/tar_path_spec.py +32 -0
  163. dfvfs/path/tsk_partition_path_spec.py +58 -0
  164. dfvfs/path/tsk_path_spec.py +62 -0
  165. dfvfs/path/vhdi_path_spec.py +30 -0
  166. dfvfs/path/vmdk_path_spec.py +30 -0
  167. dfvfs/path/vshadow_path_spec.py +51 -0
  168. dfvfs/path/xfs_path_spec.py +51 -0
  169. dfvfs/path/zip_path_spec.py +32 -0
  170. dfvfs/resolver/__init__.py +0 -0
  171. dfvfs/resolver/context.py +142 -0
  172. dfvfs/resolver/resolver.py +182 -0
  173. dfvfs/resolver_helpers/__init__.py +130 -0
  174. dfvfs/resolver_helpers/apfs_container_resolver_helper.py +29 -0
  175. dfvfs/resolver_helpers/apfs_resolver_helper.py +40 -0
  176. dfvfs/resolver_helpers/apm_resolver_helper.py +40 -0
  177. dfvfs/resolver_helpers/bde_resolver_helper.py +40 -0
  178. dfvfs/resolver_helpers/compressed_stream_resolver_helper.py +42 -0
  179. dfvfs/resolver_helpers/cpio_resolver_helper.py +41 -0
  180. dfvfs/resolver_helpers/cs_resolver_helper.py +40 -0
  181. dfvfs/resolver_helpers/data_range_resolver_helper.py +40 -0
  182. dfvfs/resolver_helpers/encoded_stream_resolver_helper.py +42 -0
  183. dfvfs/resolver_helpers/encrypted_stream_resolver_helper.py +42 -0
  184. dfvfs/resolver_helpers/ewf_resolver_helper.py +27 -0
  185. dfvfs/resolver_helpers/ext_resolver_helper.py +40 -0
  186. dfvfs/resolver_helpers/fake_resolver_helper.py +17 -0
  187. dfvfs/resolver_helpers/fat_resolver_helper.py +40 -0
  188. dfvfs/resolver_helpers/gpt_resolver_helper.py +40 -0
  189. dfvfs/resolver_helpers/gzip_resolver_helper.py +40 -0
  190. dfvfs/resolver_helpers/hfs_resolver_helper.py +40 -0
  191. dfvfs/resolver_helpers/luksde_resolver_helper.py +40 -0
  192. dfvfs/resolver_helpers/lvm_resolver_helper.py +40 -0
  193. dfvfs/resolver_helpers/manager.py +70 -0
  194. dfvfs/resolver_helpers/modi_resolver_helper.py +27 -0
  195. dfvfs/resolver_helpers/ntfs_resolver_helper.py +40 -0
  196. dfvfs/resolver_helpers/os_resolver_helper.py +40 -0
  197. dfvfs/resolver_helpers/phdi_resolver_helper.py +27 -0
  198. dfvfs/resolver_helpers/qcow_resolver_helper.py +27 -0
  199. dfvfs/resolver_helpers/raw_resolver_helper.py +27 -0
  200. dfvfs/resolver_helpers/resolver_helper.py +66 -0
  201. dfvfs/resolver_helpers/sqlite_blob_resolver_helper.py +40 -0
  202. dfvfs/resolver_helpers/tar_resolver_helper.py +40 -0
  203. dfvfs/resolver_helpers/tsk_partition_resolver_helper.py +42 -0
  204. dfvfs/resolver_helpers/tsk_resolver_helper.py +40 -0
  205. dfvfs/resolver_helpers/vhdi_resolver_helper.py +27 -0
  206. dfvfs/resolver_helpers/vmdk_resolver_helper.py +27 -0
  207. dfvfs/resolver_helpers/vshadow_resolver_helper.py +40 -0
  208. dfvfs/resolver_helpers/xfs_resolver_helper.py +40 -0
  209. dfvfs/resolver_helpers/zip_resolver_helper.py +40 -0
  210. dfvfs/serializer/__init__.py +0 -0
  211. dfvfs/serializer/json_serializer.py +165 -0
  212. dfvfs/serializer/serializer.py +34 -0
  213. dfvfs/vfs/__init__.py +0 -0
  214. dfvfs/vfs/apfs_attribute.py +122 -0
  215. dfvfs/vfs/apfs_container_directory.py +33 -0
  216. dfvfs/vfs/apfs_container_file_entry.py +178 -0
  217. dfvfs/vfs/apfs_container_file_system.py +182 -0
  218. dfvfs/vfs/apfs_directory.py +46 -0
  219. dfvfs/vfs/apfs_file_entry.py +289 -0
  220. dfvfs/vfs/apfs_file_system.py +206 -0
  221. dfvfs/vfs/apm_directory.py +43 -0
  222. dfvfs/vfs/apm_file_entry.py +126 -0
  223. dfvfs/vfs/apm_file_system.py +143 -0
  224. dfvfs/vfs/attribute.py +61 -0
  225. dfvfs/vfs/bde_file_entry.py +74 -0
  226. dfvfs/vfs/bde_file_system.py +98 -0
  227. dfvfs/vfs/compressed_stream_file_entry.py +51 -0
  228. dfvfs/vfs/compressed_stream_file_system.py +79 -0
  229. dfvfs/vfs/cpio_directory.py +49 -0
  230. dfvfs/vfs/cpio_file_entry.py +229 -0
  231. dfvfs/vfs/cpio_file_system.py +157 -0
  232. dfvfs/vfs/cs_directory.py +36 -0
  233. dfvfs/vfs/cs_file_entry.py +154 -0
  234. dfvfs/vfs/cs_file_system.py +163 -0
  235. dfvfs/vfs/data_range_file_entry.py +42 -0
  236. dfvfs/vfs/data_range_file_system.py +90 -0
  237. dfvfs/vfs/data_stream.py +44 -0
  238. dfvfs/vfs/directory.py +41 -0
  239. dfvfs/vfs/encoded_stream_file_entry.py +51 -0
  240. dfvfs/vfs/encoded_stream_file_system.py +79 -0
  241. dfvfs/vfs/encrypted_stream_file_entry.py +51 -0
  242. dfvfs/vfs/encrypted_stream_file_system.py +82 -0
  243. dfvfs/vfs/ext_attribute.py +122 -0
  244. dfvfs/vfs/ext_directory.py +46 -0
  245. dfvfs/vfs/ext_file_entry.py +310 -0
  246. dfvfs/vfs/ext_file_system.py +173 -0
  247. dfvfs/vfs/extent.py +27 -0
  248. dfvfs/vfs/fake_directory.py +37 -0
  249. dfvfs/vfs/fake_file_entry.py +168 -0
  250. dfvfs/vfs/fake_file_system.py +179 -0
  251. dfvfs/vfs/fat_directory.py +46 -0
  252. dfvfs/vfs/fat_file_entry.py +254 -0
  253. dfvfs/vfs/fat_file_system.py +199 -0
  254. dfvfs/vfs/file_entry.py +520 -0
  255. dfvfs/vfs/file_system.py +257 -0
  256. dfvfs/vfs/gpt_directory.py +36 -0
  257. dfvfs/vfs/gpt_file_entry.py +129 -0
  258. dfvfs/vfs/gpt_file_system.py +180 -0
  259. dfvfs/vfs/gzip_file_entry.py +60 -0
  260. dfvfs/vfs/gzip_file_system.py +34 -0
  261. dfvfs/vfs/hfs_attribute.py +122 -0
  262. dfvfs/vfs/hfs_data_stream.py +50 -0
  263. dfvfs/vfs/hfs_directory.py +46 -0
  264. dfvfs/vfs/hfs_file_entry.py +334 -0
  265. dfvfs/vfs/hfs_file_system.py +187 -0
  266. dfvfs/vfs/luksde_file_entry.py +66 -0
  267. dfvfs/vfs/luksde_file_system.py +98 -0
  268. dfvfs/vfs/lvm_directory.py +36 -0
  269. dfvfs/vfs/lvm_file_entry.py +132 -0
  270. dfvfs/vfs/lvm_file_system.py +153 -0
  271. dfvfs/vfs/ntfs_attribute.py +157 -0
  272. dfvfs/vfs/ntfs_data_stream.py +50 -0
  273. dfvfs/vfs/ntfs_directory.py +58 -0
  274. dfvfs/vfs/ntfs_file_entry.py +399 -0
  275. dfvfs/vfs/ntfs_file_system.py +185 -0
  276. dfvfs/vfs/os_attribute.py +113 -0
  277. dfvfs/vfs/os_directory.py +54 -0
  278. dfvfs/vfs/os_file_entry.py +304 -0
  279. dfvfs/vfs/os_file_system.py +205 -0
  280. dfvfs/vfs/root_only_file_entry.py +30 -0
  281. dfvfs/vfs/root_only_file_system.py +66 -0
  282. dfvfs/vfs/sqlite_blob_directory.py +56 -0
  283. dfvfs/vfs/sqlite_blob_file_entry.py +145 -0
  284. dfvfs/vfs/sqlite_blob_file_system.py +112 -0
  285. dfvfs/vfs/tar_directory.py +68 -0
  286. dfvfs/vfs/tar_file_entry.py +220 -0
  287. dfvfs/vfs/tar_file_system.py +186 -0
  288. dfvfs/vfs/tsk_attribute.py +151 -0
  289. dfvfs/vfs/tsk_data_stream.py +95 -0
  290. dfvfs/vfs/tsk_directory.py +119 -0
  291. dfvfs/vfs/tsk_file_entry.py +874 -0
  292. dfvfs/vfs/tsk_file_system.py +260 -0
  293. dfvfs/vfs/tsk_partition_directory.py +71 -0
  294. dfvfs/vfs/tsk_partition_file_entry.py +144 -0
  295. dfvfs/vfs/tsk_partition_file_system.py +136 -0
  296. dfvfs/vfs/vshadow_directory.py +36 -0
  297. dfvfs/vfs/vshadow_file_entry.py +145 -0
  298. dfvfs/vfs/vshadow_file_system.py +146 -0
  299. dfvfs/vfs/xfs_attribute.py +122 -0
  300. dfvfs/vfs/xfs_directory.py +46 -0
  301. dfvfs/vfs/xfs_file_entry.py +274 -0
  302. dfvfs/vfs/xfs_file_system.py +175 -0
  303. dfvfs/vfs/zip_directory.py +71 -0
  304. dfvfs/vfs/zip_file_entry.py +218 -0
  305. dfvfs/vfs/zip_file_system.py +177 -0
  306. dfvfs/volume/__init__.py +9 -0
  307. dfvfs/volume/apfs_volume_system.py +53 -0
  308. dfvfs/volume/apm_volume_system.py +51 -0
  309. dfvfs/volume/cs_volume_system.py +52 -0
  310. dfvfs/volume/factory.py +58 -0
  311. dfvfs/volume/gpt_volume_system.py +51 -0
  312. dfvfs/volume/lvm_volume_system.py +52 -0
  313. dfvfs/volume/tsk_volume_system.py +95 -0
  314. dfvfs/volume/volume_system.py +336 -0
  315. dfvfs/volume/vshadow_volume_system.py +73 -0
  316. dfvfs-20260712.dist-info/METADATA +59 -0
  317. dfvfs-20260712.dist-info/RECORD +322 -0
  318. dfvfs-20260712.dist-info/WHEEL +5 -0
  319. dfvfs-20260712.dist-info/licenses/ACKNOWLEDGEMENTS +31 -0
  320. dfvfs-20260712.dist-info/licenses/AUTHORS +14 -0
  321. dfvfs-20260712.dist-info/licenses/LICENSE +202 -0
  322. dfvfs-20260712.dist-info/top_level.txt +1 -0
dfvfs/__init__.py ADDED
@@ -0,0 +1,7 @@
1
+ """Digital Forensics Virtual File System (dfVFS).
2
+
3
+ dfVFS, or Digital Forensics Virtual File System, is a Python module that provides read-
4
+ only access to file-system objects from various storage media types and file formats.
5
+ """
6
+
7
+ __version__ = "20260712"
@@ -0,0 +1,39 @@
1
+ """Imports for the format analyzer."""
2
+
3
+ from dfvfs.analyzer import apfs_analyzer_helper
4
+ from dfvfs.analyzer import apfs_container_analyzer_helper
5
+ from dfvfs.analyzer import apm_analyzer_helper
6
+ from dfvfs.analyzer import bde_analyzer_helper
7
+ from dfvfs.analyzer import bzip2_analyzer_helper
8
+ from dfvfs.analyzer import cpio_analyzer_helper
9
+ from dfvfs.analyzer import cs_analyzer_helper
10
+ from dfvfs.analyzer import ewf_analyzer_helper
11
+ from dfvfs.analyzer import ext_analyzer_helper
12
+ from dfvfs.analyzer import fat_analyzer_helper
13
+ from dfvfs.analyzer import gpt_analyzer_helper
14
+ from dfvfs.analyzer import gzip_analyzer_helper
15
+ from dfvfs.analyzer import hfs_analyzer_helper
16
+ from dfvfs.analyzer import luksde_analyzer_helper
17
+ from dfvfs.analyzer import lvm_analyzer_helper
18
+ from dfvfs.analyzer import modi_analyzer_helper
19
+ from dfvfs.analyzer import ntfs_analyzer_helper
20
+ from dfvfs.analyzer import phdi_analyzer_helper
21
+ from dfvfs.analyzer import qcow_analyzer_helper
22
+ from dfvfs.analyzer import tar_analyzer_helper
23
+
24
+ try:
25
+ from dfvfs.analyzer import tsk_analyzer_helper
26
+ except ImportError:
27
+ pass
28
+
29
+ try:
30
+ from dfvfs.analyzer import tsk_partition_analyzer_helper
31
+ except ImportError:
32
+ pass
33
+
34
+ from dfvfs.analyzer import vhdi_analyzer_helper
35
+ from dfvfs.analyzer import vmdk_analyzer_helper
36
+ from dfvfs.analyzer import vshadow_analyzer_helper
37
+ from dfvfs.analyzer import xfs_analyzer_helper
38
+ from dfvfs.analyzer import xz_analyzer_helper
39
+ from dfvfs.analyzer import zip_analyzer_helper
@@ -0,0 +1,431 @@
1
+ """The format analyzer."""
2
+
3
+ import pysigscan
4
+
5
+ from dfvfs.analyzer import specification
6
+ from dfvfs.lib import definitions
7
+ from dfvfs.resolver import resolver
8
+
9
+
10
+ class Analyzer:
11
+ """Format analyzer."""
12
+
13
+ _SCAN_BUFFER_SIZE = 33 * 1024
14
+
15
+ _analyzer_helpers = {}
16
+
17
+ # The archive format category analyzer helpers that do not have
18
+ # a format specification.
19
+ _archive_remainder_list = None
20
+
21
+ # The archive format category signature scanner.
22
+ _archive_scanner = None
23
+
24
+ # The archive format category specification store.
25
+ _archive_store = None
26
+
27
+ # The compressed stream format category analyzer helpers that do not have
28
+ # a format specification.
29
+ _compressed_stream_remainder_list = None
30
+
31
+ # The compressed stream format category signature scanner.
32
+ _compressed_stream_scanner = None
33
+
34
+ # The compressed stream format category specification store.
35
+ _compressed_stream_store = None
36
+
37
+ # The file system format category analyzer helpers that do not have
38
+ # a format specification.
39
+ _file_system_remainder_list = None
40
+
41
+ # The file system format category signature scanner.
42
+ _file_system_scanner = None
43
+
44
+ # The file system format category specification store.
45
+ _file_system_store = None
46
+
47
+ # The storage media image format category analyzer helpers that do not have
48
+ # a format specification.
49
+ _storage_media_image_remainder_list = None
50
+
51
+ # The storage media image format category signature scanner.
52
+ _storage_media_image_scanner = None
53
+
54
+ # The storage media image format category specification store.
55
+ _storage_media_image_store = None
56
+
57
+ # The volume system format category analyzer helpers that do not have
58
+ # a format specification.
59
+ _volume_system_remainder_list = None
60
+
61
+ # The volume system format category signature scanner.
62
+ _volume_system_scanner = None
63
+
64
+ # The volume system format category specification store.
65
+ _volume_system_store = None
66
+
67
+ @classmethod
68
+ def _FlushCache(cls, format_categories):
69
+ """Flushes the cached objects for the specified format categories.
70
+
71
+ Args:
72
+ format_categories (set[str]): format categories.
73
+ """
74
+ if definitions.FORMAT_CATEGORY_ARCHIVE in format_categories:
75
+ cls._archive_remainder_list = None
76
+ cls._archive_scanner = None
77
+ cls._archive_store = None
78
+
79
+ if definitions.FORMAT_CATEGORY_COMPRESSED_STREAM in format_categories:
80
+ cls._compressed_stream_remainder_list = None
81
+ cls._compressed_stream_scanner = None
82
+ cls._compressed_stream_store = None
83
+
84
+ if definitions.FORMAT_CATEGORY_FILE_SYSTEM in format_categories:
85
+ cls._file_system_remainder_list = None
86
+ cls._file_system_scanner = None
87
+ cls._file_system_store = None
88
+
89
+ if definitions.FORMAT_CATEGORY_STORAGE_MEDIA_IMAGE in format_categories:
90
+ cls._storage_media_image_remainder_list = None
91
+ cls._storage_media_image_scanner = None
92
+ cls._storage_media_image_store = None
93
+
94
+ if definitions.FORMAT_CATEGORY_VOLUME_SYSTEM in format_categories:
95
+ cls._volume_system_remainder_list = None
96
+ cls._volume_system_scanner = None
97
+ cls._volume_system_store = None
98
+
99
+ @classmethod
100
+ def _GetSignatureScanner(cls, specification_store):
101
+ """Initializes a signature scanner based on a specification store.
102
+
103
+ Args:
104
+ specification_store (FormatSpecificationStore): specification store.
105
+
106
+ Returns:
107
+ pysigscan.scanner: signature scanner.
108
+ """
109
+ signature_scanner = pysigscan.scanner()
110
+ signature_scanner.set_scan_buffer_size(cls._SCAN_BUFFER_SIZE)
111
+
112
+ for format_specification in specification_store.specifications:
113
+ for signature in format_specification.signatures:
114
+ pattern_offset = signature.offset
115
+
116
+ if pattern_offset is None:
117
+ signature_flags = pysigscan.signature_flags.NO_OFFSET
118
+ elif pattern_offset < 0:
119
+ pattern_offset *= -1
120
+ signature_flags = pysigscan.signature_flags.RELATIVE_FROM_END
121
+ else:
122
+ signature_flags = pysigscan.signature_flags.RELATIVE_FROM_START
123
+
124
+ signature_scanner.add_signature(
125
+ signature.identifier,
126
+ pattern_offset,
127
+ signature.pattern,
128
+ signature_flags,
129
+ )
130
+
131
+ return signature_scanner
132
+
133
+ @classmethod
134
+ def _GetSpecificationStore(cls, format_category):
135
+ """Retrieves the specification store for specified format category.
136
+
137
+ Args:
138
+ format_category (str): format category.
139
+
140
+ Returns:
141
+ tuple[FormatSpecificationStore, list[AnalyzerHelper]]: a format
142
+ specification store and remaining analyzer helpers that do not have
143
+ a format specification.
144
+ """
145
+ specification_store = specification.FormatSpecificationStore()
146
+ remainder_list = []
147
+
148
+ for analyzer_helper in cls._analyzer_helpers.values():
149
+ if not analyzer_helper.IsEnabled():
150
+ continue
151
+
152
+ if format_category in analyzer_helper.format_categories:
153
+ format_specification = analyzer_helper.GetFormatSpecification()
154
+
155
+ if format_specification is not None:
156
+ specification_store.AddSpecification(format_specification)
157
+ else:
158
+ remainder_list.append(analyzer_helper)
159
+
160
+ return specification_store, remainder_list
161
+
162
+ @classmethod
163
+ def _GetTypeIndicators(
164
+ cls,
165
+ signature_scanner,
166
+ specification_store,
167
+ remainder_list,
168
+ path_spec,
169
+ resolver_context=None,
170
+ ):
171
+ """Determines if a file contains a supported format types.
172
+
173
+ Args:
174
+ signature_scanner (pysigscan.scanner): signature scanner.
175
+ specification_store (FormatSpecificationStore): specification store.
176
+ remainder_list (list[AnalyzerHelper]): remaining analyzer helpers that
177
+ do not have a format specification.
178
+ path_spec (PathSpec): path specification.
179
+ resolver_context (Optional[Context]): resolver context, where None
180
+ represents the built-in context which is not multi process safe.
181
+
182
+ Returns:
183
+ list[str]: supported format type indicators.
184
+ """
185
+ type_indicator_list = []
186
+
187
+ file_object = resolver.Resolver.OpenFileObject(
188
+ path_spec, resolver_context=resolver_context
189
+ )
190
+ scan_state = pysigscan.scan_state()
191
+
192
+ signature_scanner.scan_file_object(scan_state, file_object)
193
+
194
+ for scan_result in iter(scan_state.scan_results):
195
+ format_specification = specification_store.GetSpecificationBySignature(
196
+ scan_result.identifier
197
+ )
198
+
199
+ if format_specification.identifier not in type_indicator_list:
200
+ type_indicator_list.append(format_specification.identifier)
201
+
202
+ for analyzer_helper in remainder_list:
203
+ result = analyzer_helper.AnalyzeFileObject(file_object)
204
+
205
+ if result is not None:
206
+ type_indicator_list.append(result)
207
+
208
+ return type_indicator_list
209
+
210
+ @classmethod
211
+ def DeregisterHelper(cls, analyzer_helper):
212
+ """Deregisters a format analyzer helper.
213
+
214
+ Args:
215
+ analyzer_helper (AnalyzerHelper): analyzer helper.
216
+
217
+ Raises:
218
+ KeyError: if analyzer helper object is not set for the corresponding
219
+ type indicator.
220
+ """
221
+ if analyzer_helper.type_indicator not in cls._analyzer_helpers:
222
+ raise KeyError(
223
+ (
224
+ f"Analyzer helper object not set for type indicator: "
225
+ f"{analyzer_helper.type_indicator:s}."
226
+ )
227
+ )
228
+
229
+ analyzer_helper = cls._analyzer_helpers[analyzer_helper.type_indicator]
230
+
231
+ cls._FlushCache(analyzer_helper.format_categories)
232
+
233
+ del cls._analyzer_helpers[analyzer_helper.type_indicator]
234
+
235
+ @classmethod
236
+ def GetArchiveTypeIndicators(cls, path_spec, resolver_context=None):
237
+ """Determines if a file contains a supported archive types.
238
+
239
+ Args:
240
+ path_spec (PathSpec): path specification.
241
+ resolver_context (Optional[Context]): resolver context, where None
242
+ represents the built-in context which is not multi process safe.
243
+
244
+ Returns:
245
+ list[str]: supported format type indicators.
246
+ """
247
+ if cls._archive_remainder_list is None or cls._archive_store is None:
248
+ specification_store, remainder_list = cls._GetSpecificationStore(
249
+ definitions.FORMAT_CATEGORY_ARCHIVE
250
+ )
251
+ cls._archive_remainder_list = remainder_list
252
+ cls._archive_store = specification_store
253
+
254
+ if cls._archive_scanner is None:
255
+ cls._archive_scanner = cls._GetSignatureScanner(cls._archive_store)
256
+
257
+ return cls._GetTypeIndicators(
258
+ cls._archive_scanner,
259
+ cls._archive_store,
260
+ cls._archive_remainder_list,
261
+ path_spec,
262
+ resolver_context=resolver_context,
263
+ )
264
+
265
+ @classmethod
266
+ def GetCompressedStreamTypeIndicators(cls, path_spec, resolver_context=None):
267
+ """Determines if a file contains a supported compressed stream types.
268
+
269
+ Args:
270
+ path_spec (PathSpec): path specification.
271
+ resolver_context (Optional[Context]): resolver context, where None
272
+ represents the built-in context which is not multi process safe.
273
+
274
+ Returns:
275
+ list[str]: supported format type indicators.
276
+ """
277
+ if (
278
+ cls._compressed_stream_remainder_list is None
279
+ or cls._compressed_stream_store is None
280
+ ):
281
+ specification_store, remainder_list = cls._GetSpecificationStore(
282
+ definitions.FORMAT_CATEGORY_COMPRESSED_STREAM
283
+ )
284
+ cls._compressed_stream_remainder_list = remainder_list
285
+ cls._compressed_stream_store = specification_store
286
+
287
+ if cls._compressed_stream_scanner is None:
288
+ cls._compressed_stream_scanner = cls._GetSignatureScanner(
289
+ cls._compressed_stream_store
290
+ )
291
+
292
+ return cls._GetTypeIndicators(
293
+ cls._compressed_stream_scanner,
294
+ cls._compressed_stream_store,
295
+ cls._compressed_stream_remainder_list,
296
+ path_spec,
297
+ resolver_context=resolver_context,
298
+ )
299
+
300
+ @classmethod
301
+ def GetFileSystemTypeIndicators(cls, path_spec, resolver_context=None):
302
+ """Determines if a file contains a supported file system types.
303
+
304
+ Args:
305
+ path_spec (PathSpec): path specification.
306
+ resolver_context (Optional[Context]): resolver context, where None
307
+ represents the built-in context which is not multi process safe.
308
+
309
+ Returns:
310
+ list[str]: supported format type indicators.
311
+ """
312
+ if cls._file_system_remainder_list is None or cls._file_system_store is None:
313
+ specification_store, remainder_list = cls._GetSpecificationStore(
314
+ definitions.FORMAT_CATEGORY_FILE_SYSTEM
315
+ )
316
+ cls._file_system_remainder_list = remainder_list
317
+ cls._file_system_store = specification_store
318
+
319
+ if cls._file_system_scanner is None:
320
+ cls._file_system_scanner = cls._GetSignatureScanner(cls._file_system_store)
321
+
322
+ return cls._GetTypeIndicators(
323
+ cls._file_system_scanner,
324
+ cls._file_system_store,
325
+ cls._file_system_remainder_list,
326
+ path_spec,
327
+ resolver_context=resolver_context,
328
+ )
329
+
330
+ @classmethod
331
+ def GetStorageMediaImageTypeIndicators(cls, path_spec, resolver_context=None):
332
+ """Determines if a file contains a supported storage media image types.
333
+
334
+ Args:
335
+ path_spec (PathSpec): path specification.
336
+ resolver_context (Optional[Context]): resolver context, where None
337
+ represents the built-in context which is not multi process safe.
338
+
339
+ Returns:
340
+ list[str]: supported format type indicators.
341
+ """
342
+ if (
343
+ cls._storage_media_image_remainder_list is None
344
+ or cls._storage_media_image_store is None
345
+ ):
346
+ specification_store, remainder_list = cls._GetSpecificationStore(
347
+ definitions.FORMAT_CATEGORY_STORAGE_MEDIA_IMAGE
348
+ )
349
+ cls._storage_media_image_remainder_list = remainder_list
350
+ cls._storage_media_image_store = specification_store
351
+
352
+ if cls._storage_media_image_scanner is None:
353
+ cls._storage_media_image_scanner = cls._GetSignatureScanner(
354
+ cls._storage_media_image_store
355
+ )
356
+
357
+ return cls._GetTypeIndicators(
358
+ cls._storage_media_image_scanner,
359
+ cls._storage_media_image_store,
360
+ cls._storage_media_image_remainder_list,
361
+ path_spec,
362
+ resolver_context=resolver_context,
363
+ )
364
+
365
+ @classmethod
366
+ def GetVolumeSystemTypeIndicators(cls, path_spec, resolver_context=None):
367
+ """Determines if a file contains a supported volume system types.
368
+
369
+ Args:
370
+ path_spec (PathSpec): path specification.
371
+ resolver_context (Optional[Context]): resolver context, where None
372
+ represents the built-in context which is not multi process safe.
373
+
374
+ Returns:
375
+ list[str]: supported format type indicators.
376
+ """
377
+ if (
378
+ cls._volume_system_remainder_list is None
379
+ or cls._volume_system_store is None
380
+ ):
381
+ specification_store, remainder_list = cls._GetSpecificationStore(
382
+ definitions.FORMAT_CATEGORY_VOLUME_SYSTEM
383
+ )
384
+ cls._volume_system_remainder_list = remainder_list
385
+ cls._volume_system_store = specification_store
386
+
387
+ if cls._volume_system_scanner is None:
388
+ cls._volume_system_scanner = cls._GetSignatureScanner(
389
+ cls._volume_system_store
390
+ )
391
+
392
+ type_indicators = cls._GetTypeIndicators(
393
+ cls._volume_system_scanner,
394
+ cls._volume_system_store,
395
+ cls._volume_system_remainder_list,
396
+ path_spec,
397
+ resolver_context=resolver_context,
398
+ )
399
+
400
+ if (
401
+ len(type_indicators) > 1
402
+ and definitions.TYPE_INDICATOR_TSK_PARTITION in type_indicators
403
+ ):
404
+ # The TSK partition analyzer is used as a fallback, remove it if
405
+ # an alternative analyzer detected a supported volume system.
406
+ type_indicators.remove(definitions.TYPE_INDICATOR_TSK_PARTITION)
407
+
408
+ return type_indicators
409
+
410
+ @classmethod
411
+ def RegisterHelper(cls, analyzer_helper):
412
+ """Registers a format analyzer helper.
413
+
414
+ Args:
415
+ analyzer_helper (AnalyzerHelper): analyzer helper.
416
+
417
+ Raises:
418
+ KeyError: if analyzer helper object is already set for the corresponding
419
+ type indicator.
420
+ """
421
+ if analyzer_helper.type_indicator in cls._analyzer_helpers:
422
+ raise KeyError(
423
+ (
424
+ f"Analyzer helper object already set for type indicator: "
425
+ f"{analyzer_helper.type_indicator:s}."
426
+ )
427
+ )
428
+
429
+ cls._FlushCache(analyzer_helper.format_categories)
430
+
431
+ cls._analyzer_helpers[analyzer_helper.type_indicator] = analyzer_helper
@@ -0,0 +1,81 @@
1
+ """The analyzer helper interface."""
2
+
3
+ from dfvfs.lib import errors
4
+
5
+
6
+ class AnalyzerHelper:
7
+ """Analyzer helper interface."""
8
+
9
+ # pylint: disable=redundant-returns-doc
10
+
11
+ def __init__(self):
12
+ """Initializes an analyzer helper.
13
+
14
+ Raises:
15
+ ValueError: if a derived analyzer helper class does not define format
16
+ categories or a type indicator.
17
+ """
18
+ super().__init__()
19
+
20
+ if not getattr(self, "TYPE_INDICATOR", None):
21
+ raise ValueError("Missing type indicator.")
22
+
23
+ if not getattr(self, "FORMAT_CATEGORIES", None):
24
+ raise ValueError("Missing format categories.")
25
+
26
+ @property
27
+ def format_categories(self):
28
+ """Retrieves the format categories.
29
+
30
+ The format categories are defined in definitions.FORMAT_CATEGORIES.
31
+
32
+ Returns:
33
+ set[str]: format categories, such as archive file or file system.
34
+ """
35
+ # pylint: disable=no-member
36
+ return self.FORMAT_CATEGORIES
37
+
38
+ @property
39
+ def type_indicator(self):
40
+ """Retrieves the type indicator.
41
+
42
+ Returns:
43
+ str: type indicator or None if not available.
44
+ """
45
+ return getattr(self, "TYPE_INDICATOR", None)
46
+
47
+ def AnalyzeFileObject(self, file_object): # pylint: disable=useless-type-doc
48
+ """Retrieves the format specification.
49
+
50
+ This is the fall through implementation that raises a RuntimeError.
51
+
52
+ Args:
53
+ file_object (FileIO): file-like object.
54
+
55
+ Returns:
56
+ str: type indicator if the file-like object contains a supported format
57
+ or None otherwise.
58
+
59
+ Raises:
60
+ NotSupported: since this is the fall through implementation.
61
+ """
62
+ raise errors.NotSupported("Missing implementation to analyze file-like object.")
63
+
64
+ def GetFormatSpecification(self):
65
+ """Retrieves the format specification.
66
+
67
+ This is the fall through implementation that returns None.
68
+
69
+ Returns:
70
+ FormatSpecification: format specification or None if the format cannot
71
+ be defined by a specification object.
72
+ """
73
+ return None
74
+
75
+ def IsEnabled(self):
76
+ """Determines if the analyzer helper is enabled.
77
+
78
+ Returns:
79
+ bool: True if the analyzer helper is enabled.
80
+ """
81
+ return True
@@ -0,0 +1,31 @@
1
+ """The APFS format analyzer helper implementation."""
2
+
3
+ from dfvfs.analyzer import analyzer
4
+ from dfvfs.analyzer import analyzer_helper
5
+ from dfvfs.analyzer import specification
6
+ from dfvfs.lib import definitions
7
+
8
+
9
+ class APFSAnalyzerHelper(analyzer_helper.AnalyzerHelper):
10
+ """APFS analyzer helper."""
11
+
12
+ FORMAT_CATEGORIES = frozenset([definitions.FORMAT_CATEGORY_FILE_SYSTEM])
13
+
14
+ TYPE_INDICATOR = definitions.TYPE_INDICATOR_APFS
15
+
16
+ def GetFormatSpecification(self):
17
+ """Retrieves the format specification.
18
+
19
+ Returns:
20
+ FormatSpecification: format specification or None if the format cannot
21
+ be defined by a specification object.
22
+ """
23
+ format_specification = specification.FormatSpecification(self.type_indicator)
24
+
25
+ # APFS file system signature.
26
+ format_specification.AddNewSignature(b"APSB", offset=32)
27
+
28
+ return format_specification
29
+
30
+
31
+ analyzer.Analyzer.RegisterHelper(APFSAnalyzerHelper())
@@ -0,0 +1,31 @@
1
+ """The APFS container format analyzer helper implementation."""
2
+
3
+ from dfvfs.analyzer import analyzer
4
+ from dfvfs.analyzer import analyzer_helper
5
+ from dfvfs.analyzer import specification
6
+ from dfvfs.lib import definitions
7
+
8
+
9
+ class APFSContainerAnalyzerHelper(analyzer_helper.AnalyzerHelper):
10
+ """APFS container analyzer helper."""
11
+
12
+ FORMAT_CATEGORIES = frozenset([definitions.FORMAT_CATEGORY_VOLUME_SYSTEM])
13
+
14
+ TYPE_INDICATOR = definitions.TYPE_INDICATOR_APFS_CONTAINER
15
+
16
+ def GetFormatSpecification(self):
17
+ """Retrieves the format specification.
18
+
19
+ Returns:
20
+ FormatSpecification: format specification or None if the format cannot
21
+ be defined by a specification object.
22
+ """
23
+ format_specification = specification.FormatSpecification(self.type_indicator)
24
+
25
+ # APFS container signature.
26
+ format_specification.AddNewSignature(b"NXSB", offset=32)
27
+
28
+ return format_specification
29
+
30
+
31
+ analyzer.Analyzer.RegisterHelper(APFSContainerAnalyzerHelper())
@@ -0,0 +1,47 @@
1
+ """The Apple Partition Map (APM) format analyzer helper implementation."""
2
+
3
+ from dfvfs.analyzer import analyzer
4
+ from dfvfs.analyzer import analyzer_helper
5
+ from dfvfs.analyzer import specification
6
+ from dfvfs.lib import definitions
7
+
8
+
9
+ class APMAnalyzerHelper(analyzer_helper.AnalyzerHelper):
10
+ """APM analyzer helper."""
11
+
12
+ FORMAT_CATEGORIES = frozenset([definitions.FORMAT_CATEGORY_VOLUME_SYSTEM])
13
+
14
+ TYPE_INDICATOR = definitions.TYPE_INDICATOR_APM
15
+
16
+ def GetFormatSpecification(self):
17
+ """Retrieves the format specification.
18
+
19
+ Returns:
20
+ FormatSpecification: format specification or None if the format cannot
21
+ be defined by a specification object.
22
+ """
23
+ format_specification = specification.FormatSpecification(self.type_indicator)
24
+
25
+ # APM signature.
26
+ # Note that technically "PM" at offset 512 is the Apple Partion Map
27
+ # signature but using the partition type is less error prone.
28
+ format_specification.AddNewSignature(
29
+ (
30
+ b"Apple_partition_map\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
31
+ b"\x00"
32
+ ),
33
+ offset=560,
34
+ )
35
+
36
+ return format_specification
37
+
38
+ def IsEnabled(self):
39
+ """Determines if the analyzer helper is enabled.
40
+
41
+ Returns:
42
+ bool: True if the analyzer helper is enabled.
43
+ """
44
+ return definitions.PREFERRED_APM_BACK_END == self.TYPE_INDICATOR
45
+
46
+
47
+ analyzer.Analyzer.RegisterHelper(APMAnalyzerHelper())