Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions acquire/acquire.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
filter_out_by_path_match,
filter_out_by_value_match,
filter_out_huge_files,
md5sum,
serialize_into_csv,
sha256sum,
)
from acquire.log import get_file_handler, reconfigure_log_file, setup_logging
from acquire.outputs import OUTPUTS
Expand Down Expand Up @@ -2127,13 +2129,21 @@ def acquire_target(target: Target, args: argparse.Namespace, output_ts: str | No
else:
report_file_name = f"{output_path.name}.report.json"

if args.hash_collection:
hashes = {"md5": md5sum(output.path), "sha256": sha256sum(output.path)}
execution_report["hashes"] = hashes

report_file_path = output_path.parent / report_file_name
persist_execution_report(report_file_path, execution_report)

files.append(report_file_path)
log.info("Acquisition report for %s is written to %s", target, report_file_path)

log.info("Output: %s", output.path)

if args.hash_collection:
log.info("Output MD5: %s", hashes["md5"])
log.info("Output SHA-256: %s", hashes["sha256"])
return files


Expand Down
14 changes: 14 additions & 0 deletions acquire/hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,17 @@ def serialize_into_csv(rows: Iterator[list], compress: bool = True) -> tuple[int
)

return (counter, raw_buffer.getvalue())


def md5sum(path: Path) -> str:
with path.open(mode="rb") as f:
digest = hashlib.file_digest(f, "md5")

return digest.hexdigest()


def sha256sum(path: Path) -> str:
with path.open(mode="rb") as f:
digest = hashlib.file_digest(f, "sha256")

return digest.hexdigest()
5 changes: 5 additions & 0 deletions acquire/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ def create_argument_parser(profiles: dict, volatile: dict, modules: dict) -> arg
nargs="+",
help="upload specified files (all other acquire actions are ignored)",
)
parser.add_argument(
"--hash-collection",
action=argparse.BooleanOptionalAction,
help="Calculate hashes of the collection",
)
parser.add_argument("--no-proxy", action="store_true", help="don't autodetect proxies")

parser.add_argument("-K", "--keychain-file", type=Path, help="keychain file in CSV format")
Expand Down