tinyapps.org / docs / Cracking FileVault 2 (HFS+ or APFS)


1. HFS+

1.1 Download and compile fvde2john and hashcat on iMac

  1. git clone https://github.com/kholia/fvde2john.git && cd fvde2john/
  2. ./configure && make
  3. git clone https://github.com/hashcat/hashcat.git && cd hashcat/
  4. make

1.2 Start MacBook Air in Target Disk Mode and connect to iMac via Thunderbolt, FireWire, or USB

$ diskutil list
...
/dev/disk2 (external):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                         251.0 GB   disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:          Apple_CoreStorage Macintosh HD            250.1 GB   disk2s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk2s3

Offline
                                 Logical Volume Macintosh HD on disk2s2
                                 C59F0385-4F65-7EBA-36DB-3977388EB4AA
                                 Locked Encrypted

$ diskutil mount /dev/disk2s3
Volume Recovery HD on /dev/disk2s3 mounted

$ find /Volumes/Recovery\ HD -name Encry*
/Volumes/Recovery HD/com.apple.boot.S/System/Library/Caches/com.apple.corestorage/EncryptedRoot.plist.wipekey

$ sudo ./fvdetools/fvdeinfo -e /Volumes/Recovery\ HD/com.apple.boot.S/System/Library/Caches/com.apple.corestorage/EncryptedRoot.plist.wipekey -p dont-know /dev/disk2s2
...
$fvde$1$16$3fc886d887bef6f52b6d3f275c290e23$135098$5f852cd981bdad55bd8e60de04ab28742961b3c55e28a0f5
...

$ diskutil unmount /Volumes/Recovery\ HD/
Volume Recovery HD on disk2s3 unmounted

1.3 Save hash to hash.txt and begin cracking with hashcat, e.g.,

$ ./hashcat/hashcat -a 0 -m 16700 -o found.txt hash.txt wordlist.txt

2. APFS (Linux attacker)

2.1 Install apfs-fuse on PC

  1. sudo add-apt-repository universe && sudo apt update
  2. sudo apt install fuse3 libfuse3-dev libbz2-dev cmake git libattr1-dev zlib1g-dev
  3. git clone https://github.com/sgan81/apfs-fuse.git && cd apfs-fuse/
  4. git submodule update --init
  5. mkdir build && cd build
  6. cmake ..
  7. make

2.2 Start MacBook Pro in Target Disk Mode, connect to PC, and determine device name, e.g.,

$ cat /proc/partitions
major minor  #blocks  name

   8        0  125034840 sda
...
   8       16  118489088 sdb

2.3 Acquire hash

$ sudo ./apfs-dump-quick /dev/sdb log.txt

Device /dev/sdb opened. Size is 121332826112
Info: Found valid GPT partition table on main device. Dumping first APFS partition.
...
Volume Macintosh HD is encrypted.
...
Enter Password: JUST PRESS ENTER
...
[KEK]
Unk 80  : 0
UUID    : 48BCAEEB-4E7A-C5D2-B7EB-C21DCD1366F9
Unk 82  : 00000000 0002 15 174
KEK Wrpd: 2FDEAFAA0F6A971F674B487270A5AE59578B29FB377F76E35CF23985E045EBB8F70687086B6ED7F5
Iterat's: 100000
Salt    : 692B540738291E8B5248A74444E5B1EF
...

2.4 Arrange the hash and save to hash.txt

$fvde$2$16$692B540738291E8B5248A74444E5B1EF$100000$2FDEAFAA0F6A971F674B487270A5AE59578B29FB377F76E35CF23985E045EBB8F70687086B6ED7F5

2.5 Install hashcat (see §1.1) and start cracking

$ hashcat -a 0 -m 18300 -o found.txt hash.txt wordlist.txt

3. APFS (Apple silicon attacker)

3.1 Install apfs2hashcat on Mac mini

  1. Install Homebrew
  2. brew install cmake pkg-config git
  3. git clone "https://github.com/Banaanhangwagen/apfs2hashcat.git" && cd apfs2hashcat
  4. git submodule update --init --recursive
  5. mdkir build && cd build
  6. cmake .. -DCMAKE_POLICY_VERSION_MINIMUM=3.5
  7. make

3.2 Start MacBook Pro in Target Disk Mode, connect to Mac mini via Thunderbolt (ejecting target Macintosh HD if it mounts and dismissing password prompt), and determine disk identifier, e.g.,

% diskutil list
...
/dev/disk5 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk5
   1:                        EFI EFI                     209.7 MB   disk5s1
   2:                 Apple_APFS Container disk6         250.8 GB   disk5s2

/dev/disk6 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +250.8 GB   disk6
                                 Physical Store disk5s2
   1:                APFS Volume Macintosh HD - Data     122.3 GB   disk6s1
   2:                APFS Volume Preboot                 365.5 MB   disk6s2
   3:                APFS Volume Recovery                613.8 MB   disk6s3
   4:                APFS Volume VM                      1.1 GB     disk6s4
   5:                APFS Volume Macintosh HD            24.0 GB    disk6s5

3.3 Acquire hash

% sudo ./apfs-dump-quick /dev/disk5 log.txt
...
$fvde$1$16$XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX$93003$XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX00000000000000000000000000000000
...

3.4 Install hashcat and begin cracking

% brew install hashcat
% hashcat -a 0 -m 16700 -w 4 --force hash.txt combos.txt

4. Notes

5. Sources


created: 2019.05.27, updated: 2025.04.12