:py:mod:`acquire.acquire.hashes` ================================ .. py:module:: acquire.acquire.hashes Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: acquire.acquire.hashes.HashFunc Functions ~~~~~~~~~ .. autoapisummary:: :nosignatures: acquire.acquire.hashes.get_paths_from_dir acquire.acquire.hashes.get_path_details acquire.acquire.hashes.filter_out_nonfiles acquire.acquire.hashes.filter_out_huge_files acquire.acquire.hashes.filter_out_by_value_match acquire.acquire.hashes.filter_out_by_path_match acquire.acquire.hashes.collect_hashes acquire.acquire.hashes.serialize_into_csv Attributes ~~~~~~~~~~ .. autoapisummary:: acquire.acquire.hashes.log acquire.acquire.hashes.PROGRESS_LOG_STEP acquire.acquire.hashes.CSV_COLUMNS .. py:data:: log .. py:class:: HashFunc Bases: :py:obj:`acquire.utils.StrEnum` Sortable and serializible string-based enum .. py:attribute:: MD5 :value: 'md5' .. py:attribute:: SHA1 :value: 'sha1' .. py:attribute:: SHA256 :value: 'sha256' .. py:method:: as_hashlib_method() .. py:data:: PROGRESS_LOG_STEP :value: 10000 .. py:data:: CSV_COLUMNS .. py:function:: get_paths_from_dir(target: dissect.target.Target, glob: str, extensions: Optional[Set[str]] = None) -> Generator[pathlib.Path, None, None] Yield paths that match provided `glob` pattern and `extensions` values .. py:function:: get_path_details(path: dissect.target.helpers.fsutil.TargetPath, hash_funcs: Optional[Iterable[HashFunc]] = None) -> Tuple Calculate and return the details for specified path. The details include file size and hashes, calculated for hash functions provided in `hash_funcs`. .. py:function:: filter_out_nonfiles(paths: Iterable[pathlib.Path]) -> Generator[pathlib.Path, None, None] Filter out paths that are not files .. py:function:: filter_out_huge_files(paths: Iterable[pathlib.Path], *, max_size_bytes: int) -> Iterable[pathlib.Path] Filter out paths that are larger than `max_size_bytes` value .. py:function:: filter_out_by_value_match(paths: Iterable[pathlib.Path], *, value: bytes, offsets: Iterable[int] = (0, )) -> Generator[pathlib.Path, None, None] Filter out paths where file data matches the provided `value` at the specified offsets .. py:function:: filter_out_by_path_match(paths: Iterable[pathlib.Path], *, re_pattern: str, re_flags: re.RegexFlag = re.IGNORECASE) -> Iterable[pathlib.Path] Filter out paths that match provided regex pattern .. py:function:: collect_hashes(target: dissect.target.Target, specs: Iterable[Iterable[Tuple]], path_filters: Iterable[Callable[[Iterable[pathlib.Path]], Iterable[pathlib.Path]]] = None) -> Generator[Tuple, None, None] Walk through the paths, calculate hashes and return details per path. Spec contains a path selector and a list of hash functions to compute against the paths. For example: [ ("dir", ("sysvol/Windows/", ("exe", "dll", "sys"))), (HashFunc.MD5, HashFunc.SHA1) ] .. py:function:: serialize_into_csv(rows: Iterable[List], compress: bool = True) -> Tuple[int, bytes] Serialize provided rows into normal or gzip-compressed CSV, and return a tuple containing the number of rows processed and the result bytes.