|
5 | 5 |
|
6 | 6 | ## Acquisition
|
7 | 7 |
|
| 8 | +> Always acquire **read-only** and **hash while you copy**. Keep the original device **write-blocked** and work only on verified copies. |
| 9 | +
|
8 | 10 | ### DD
|
9 | 11 |
|
10 | 12 | ```bash
|
11 |
| -#This will generate a raw copy of the disk |
12 |
| -dd if=/dev/sdb of=disk.img |
| 13 | +# Generate a raw, bit-by-bit image (no on-the-fly hashing) |
| 14 | +dd if=/dev/sdb of=disk.img bs=4M status=progress conv=noerror,sync |
| 15 | +# Verify integrity afterwards |
| 16 | +sha256sum disk.img > disk.img.sha256 |
| 17 | +``` |
| 18 | + |
| 19 | +### dc3dd / dcfldd |
| 20 | + |
| 21 | +`dc3dd` is the actively maintained fork of dcfldd (DoD Computer Forensics Lab dd). |
| 22 | + |
| 23 | +```bash |
| 24 | +# Create an image and calculate multiple hashes at acquisition time |
| 25 | +sudo dc3dd if=/dev/sdc of=/forensics/pc.img hash=sha256,sha1 hashlog=/forensics/pc.hashes log=/forensics/pc.log bs=1M |
| 26 | +``` |
| 27 | + |
| 28 | +### Guymager |
| 29 | +Graphical, multithreaded imager that supports **raw (dd)**, **EWF (E01/EWFX)** and **AFF4** output with parallel verification. Available in most Linux repos (`apt install guymager`). |
| 30 | + |
| 31 | +```bash |
| 32 | +# Start in GUI mode |
| 33 | +sudo guymager |
| 34 | +# Or acquire from CLI (since v0.9.5) |
| 35 | +sudo guymager --simulate --input /dev/sdb --format EWF --hash sha256 --output /evidence/drive.e01 |
13 | 36 | ```
|
14 | 37 |
|
15 |
| -### dcfldd |
| 38 | +### AFF4 (Advanced Forensics Format 4) |
| 39 | + |
| 40 | +AFF4 is Google’s modern imaging format designed for *very* large evidence (sparse, resumable, cloud-native). |
16 | 41 |
|
17 | 42 | ```bash
|
18 |
| -#Raw copy with hashes along the way (more secur as it checks hashes while it's copying the data) |
19 |
| -dcfldd if=<subject device> of=<image file> bs=512 hash=<algorithm> hashwindow=<chunk size> hashlog=<hash file> |
20 |
| -dcfldd if=/dev/sdc of=/media/usb/pc.image hash=sha256 hashwindow=1M hashlog=/media/usb/pc.hashes |
| 43 | +# Acquire to AFF4 using the reference tool |
| 44 | +pipx install aff4imager |
| 45 | +sudo aff4imager acquire /dev/nvme0n1 /evidence/nvme.aff4 --hash sha256 |
| 46 | + |
| 47 | +# Velociraptor can also acquire AFF4 images remotely |
| 48 | +velociraptor --config server.yaml frontend collect --artifact Windows.Disk.Acquire --args device="\\.\\PhysicalDrive0" format=AFF4 |
21 | 49 | ```
|
22 | 50 |
|
23 |
| -### FTK Imager |
| 51 | +### FTK Imager (Windows & Linux) |
| 52 | + |
| 53 | +You can [download FTK Imager](https://accessdata.com/product-download) and create **raw, E01 or AFF4** images: |
| 54 | + |
| 55 | +```bash |
| 56 | +ftkimager /dev/sdb evidence --e01 --case-number 1 --evidence-number 1 \ |
| 57 | + --description 'Laptop seizure 2025-07-22' --examiner 'AnalystName' --compress 6 |
| 58 | +``` |
24 | 59 |
|
25 |
| -You can [**download the FTK imager from here**](https://accessdata.com/product-download/debian-and-ubuntu-x64-3-1-1). |
| 60 | +### EWF tools (libewf) |
26 | 61 |
|
27 | 62 | ```bash
|
28 |
| -ftkimager /dev/sdb evidence --e01 --case-number 1 --evidence-number 1 --description 'A description' --examiner 'Your name' |
| 63 | +sudo ewfacquire /dev/sdb -u evidence -c 1 -d "Seizure 2025-07-22" -e 1 -X examiner --format encase6 --compression best |
29 | 64 | ```
|
30 | 65 |
|
31 |
| -### EWF |
| 66 | +### Imaging Cloud Disks |
32 | 67 |
|
33 |
| -You can generate a disk image using the[ **ewf tools**](https://github.com/libyal/libewf). |
| 68 | +*AWS* – create a **forensic snapshot** without shutting down the instance: |
34 | 69 |
|
35 | 70 | ```bash
|
36 |
| -ewfacquire /dev/sdb |
37 |
| -#Name: evidence |
38 |
| -#Case number: 1 |
39 |
| -#Description: A description for the case |
40 |
| -#Evidence number: 1 |
41 |
| -#Examiner Name: Your name |
42 |
| -#Media type: fixed |
43 |
| -#Media characteristics: physical |
44 |
| -#File format: encase6 |
45 |
| -#Compression method: deflate |
46 |
| -#Compression level: fast |
47 |
| - |
48 |
| -#Then use default values |
49 |
| -#It will generate the disk image in the current directory |
| 71 | +aws ec2 create-snapshot --volume-id vol-01234567 --description "IR-case-1234 web-server 2025-07-22" |
| 72 | +# Copy the snapshot to S3 and download with aws cli / aws snowball |
50 | 73 | ```
|
51 | 74 |
|
| 75 | +*Azure* – use `az snapshot create` and export to a SAS URL. See the HackTricks page {{#ref}} |
| 76 | +../../cloud/azure/azure-forensics.md |
| 77 | +{{#endref}} |
| 78 | + |
| 79 | + |
52 | 80 | ## Mount
|
53 | 81 |
|
54 |
| -### Several types |
| 82 | +### Choosing the right approach |
55 | 83 |
|
56 |
| -In **Windows** you can try to use the free version of Arsenal Image Mounter ([https://arsenalrecon.com/downloads/](https://arsenalrecon.com/downloads/)) to **mount the forensics image**. |
| 84 | +1. Mount the **whole disk** when you want the original partition table (MBR/GPT). |
| 85 | +2. Mount a **single partition file** when you only need one volume. |
| 86 | +3. Always mount **read-only** (`-o ro,norecovery`) and work on **copies**. |
57 | 87 |
|
58 |
| -### Raw |
| 88 | +### Raw images (dd, AFF4-extracted) |
59 | 89 |
|
60 | 90 | ```bash
|
61 |
| -#Get file type |
62 |
| -file evidence.img |
63 |
| -evidence.img: Linux rev 1.0 ext4 filesystem data, UUID=1031571c-f398-4bfb-a414-b82b280cf299 (extents) (64bit) (large files) (huge files) |
| 91 | +# Identify partitions |
| 92 | +fdisk -l disk.img |
| 93 | + |
| 94 | +# Attach the image to a network block device (does not modify the file) |
| 95 | +sudo modprobe nbd max_part=16 |
| 96 | +sudo qemu-nbd --connect=/dev/nbd0 --read-only disk.img |
64 | 97 |
|
65 |
| -#Mount it |
66 |
| -mount evidence.img /mnt |
| 98 | +# Inspect partitions |
| 99 | +lsblk /dev/nbd0 -o NAME,SIZE,TYPE,FSTYPE,LABEL,UUID |
| 100 | + |
| 101 | +# Mount a partition (e.g. /dev/nbd0p2) |
| 102 | +sudo mount -o ro,uid=$(id -u) /dev/nbd0p2 /mnt |
67 | 103 | ```
|
68 | 104 |
|
69 |
| -### EWF |
| 105 | +Detach when finished: |
| 106 | +```bash |
| 107 | +sudo umount /mnt && sudo qemu-nbd --disconnect /dev/nbd0 |
| 108 | +``` |
| 109 | + |
| 110 | +### EWF (E01/EWFX) |
70 | 111 |
|
71 | 112 | ```bash
|
72 |
| -#Get file type |
73 |
| -file evidence.E01 |
74 |
| -evidence.E01: EWF/Expert Witness/EnCase image file format |
75 |
| - |
76 |
| -#Transform to raw |
77 |
| -mkdir output |
78 |
| -ewfmount evidence.E01 output/ |
79 |
| -file output/ewf1 |
80 |
| -output/ewf1: Linux rev 1.0 ext4 filesystem data, UUID=05acca66-d042-4ab2-9e9c-be813be09b24 (needs journal recovery) (extents) (64bit) (large files) (huge files) |
81 |
| - |
82 |
| -#Mount |
83 |
| -mount output/ewf1 -o ro,norecovery /mnt |
| 113 | +# 1. Mount the EWF container |
| 114 | +mkdir /mnt/ewf |
| 115 | +ewfmount evidence.E01 /mnt/ewf |
| 116 | + |
| 117 | +# 2. Attach the exposed raw file via qemu-nbd (safer than loop) |
| 118 | +sudo qemu-nbd --connect=/dev/nbd1 --read-only /mnt/ewf/ewf1 |
| 119 | + |
| 120 | +# 3. Mount the desired partition |
| 121 | +sudo mount -o ro,norecovery /dev/nbd1p1 /mnt/evidence |
84 | 122 | ```
|
85 | 123 |
|
86 |
| -### ArsenalImageMounter |
| 124 | +Alternatively convert on the fly with **xmount**: |
87 | 125 |
|
88 |
| -It's a Windows Application to mount volumes. You can download it here [https://arsenalrecon.com/downloads/](https://arsenalrecon.com/downloads/) |
| 126 | +```bash |
| 127 | +xmount --in ewf evidence.E01 --out raw /tmp/raw_mount |
| 128 | +mount -o ro /tmp/raw_mount/image.dd /mnt |
| 129 | +``` |
89 | 130 |
|
90 |
| -### Errors |
| 131 | +### LVM / BitLocker / VeraCrypt volumes |
91 | 132 |
|
92 |
| -- **`cannot mount /dev/loop0 read-only`** in this case you need to use the flags **`-o ro,norecovery`** |
93 |
| -- **`wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.`** in this case the mount failed due as the offset of the filesystem is different than that of the disk image. You need to find the Sector size and the Start sector: |
| 133 | +After attaching the block device (loop or nbd): |
94 | 134 |
|
95 | 135 | ```bash
|
96 |
| -fdisk -l disk.img |
97 |
| -Disk disk.img: 102 MiB, 106954648 bytes, 208896 sectors |
98 |
| -Units: sectors of 1 * 512 = 512 bytes |
99 |
| -Sector size (logical/physical): 512 bytes / 512 bytes |
100 |
| -I/O size (minimum/optimal): 512 bytes / 512 bytes |
101 |
| -Disklabel type: dos |
102 |
| -Disk identifier: 0x00495395 |
103 |
| - |
104 |
| -Device Boot Start End Sectors Size Id Type |
105 |
| -disk.img1 2048 208895 206848 101M 1 FAT12 |
| 136 | +# LVM |
| 137 | +sudo vgchange -ay # activate logical volumes |
| 138 | +sudo lvscan | grep "/dev/nbd0" |
| 139 | + |
| 140 | +# BitLocker (dislocker) |
| 141 | +sudo dislocker -V /dev/nbd0p3 -u -- /mnt/bitlocker |
| 142 | +sudo mount -o ro /mnt/bitlocker/dislocker-file /mnt/evidence |
106 | 143 | ```
|
107 | 144 |
|
108 |
| -Note that sector size is **512** and start is **2048**. Then mount the image like this: |
| 145 | +### kpartx helpers |
| 146 | + |
| 147 | +`kpartx` maps partitions from an image to `/dev/mapper/` automatically: |
109 | 148 |
|
110 | 149 | ```bash
|
111 |
| -mount disk.img /mnt -o ro,offset=$((2048*512)) |
| 150 | +sudo kpartx -av disk.img # creates /dev/mapper/loop0p1, loop0p2 … |
| 151 | +mount -o ro /dev/mapper/loop0p2 /mnt |
112 | 152 | ```
|
113 | 153 |
|
| 154 | +### Common mount errors & fixes |
114 | 155 |
|
115 |
| -{{#include ../../banners/hacktricks-training.md}} |
| 156 | +| Error | Typical Cause | Fix | |
| 157 | +|-------|---------------|-----| |
| 158 | +| `cannot mount /dev/loop0 read-only` | Journaled FS (ext4) not cleanly unmounted | use `-o ro,norecovery` | |
| 159 | +| `bad superblock …` | Wrong offset or damaged FS | calculate offset (`sector*size`) or run `fsck -n` on a copy | |
| 160 | +| `mount: unknown filesystem type 'LVM2_member'` | LVM container | activate volume group with `vgchange -ay` | |
| 161 | + |
| 162 | +### Clean-up |
116 | 163 |
|
| 164 | +Remember to **umount** and **disconnect** loop/nbd devices to avoid leaving dangling mappings that can corrupt further work: |
117 | 165 |
|
| 166 | +```bash |
| 167 | +umount -Rl /mnt/evidence |
| 168 | +kpartx -dv /dev/loop0 # or qemu-nbd --disconnect /dev/nbd0 |
| 169 | +``` |
118 | 170 |
|
| 171 | + |
| 172 | +## References |
| 173 | + |
| 174 | +- AFF4 imaging tool announcement & specification: https://github.com/aff4/aff4 |
| 175 | +- qemu-nbd manual page (mounting disk images safely): https://manpages.debian.org/qemu-system-common/qemu-nbd.1.en.html |
| 176 | + |
| 177 | +{{#include ../../banners/hacktricks-training.md}} |
0 commit comments