Skip to the content ForoHackers
Log inJoin

Acquiring a disk image the careful way: hash, copy, hash again

Digital forensicsIncident responseSecurity education
#1134 · c0ld_b00t · · Report

Practice setup: you have a USB stick or a VM disk of your own that you want to analyse as if it were evidence. The goal is a copy that is bit-for-bit identical, with proof. This is the boring, essential part of forensics.

1. Do not touch the original. Attach it read-only. A hardware write blocker is the proper tool; in a lab, a read-only mount or a VM snapshot works. Even mounting a file system read-write can change metadata (timestamps, journal replay).

2. Hash the source before you copy.

sha256sum /dev/sdX > source.sha256

3. Copy the whole device, not the files. A device image includes deleted data, slack space and the partition table.

dd if=/dev/sdX of=evidence.img bs=4M conv=noerror,sync status=progress

If the media is flaky, ddrescue is the better tool: it keeps a map of the bad areas and retries later.

4. Hash the copy and compare.

sha256sum evidence.img

The two hashes must be identical. If they are not, something changed and you start over.

5. Write it down. Who, when, which device (serial number), which tools and versions, the hashes. Store the image read-only. Work on a second copy.

Why bother? Because an analysis is only as credible as your ability to show that the data you analysed is the data that existed. A single hash is the simplest proof you will ever make.

#1864 · PacoElDelCronjob · · Report

Un hilo serio y de los de verdad. Lo de /dev/sdX hay que escribirlo con cuidado, que ya hemos visto lo que pasa cuando se confunde el disco de origen con el de destino. Usa los nombres by-id, por favor.

#1865 · c0ld_b00t · · Report

Paco is right and it is the main reason I put the source hash first: if you read the wrong device, the hash will not match the one you wrote down for the evidence, and the mistake is caught at step 4 instead of in the report.

#1866 · ElChamoDelFirmware · · Report

Esto también aplica a los chips de memoria de los aparatos: cuando volqué la flash de mi propio router con un programador, saqué el volcado dos veces y comparé los hashes. Con los contactos mal puestos, las dos lecturas daban distinto y así me enteré.

Log in or join to reply.