Decrypt ANDROID card

From Essential
Jump to navigation Jump to search

To read an encrypted microSD card from an Android device on Linux, you'll need to decrypt the card first. This process can be a bit challenging since Android uses an encryption method called Adoptable Storage, which is specific to Android devices. However, you can try the following steps:

  1. Prepare your Linux system:

Before proceeding, make sure you have installed the required software:

  • dmsetup: a utility for managing the device mapper, which is used for creating and managing encrypted devices on Linux.
  • android-tools-adb: a utility for interfacing with Android devices.

You can install them using your distribution's package manager. For Ubuntu, you can run:

bash
sudo apt-get update
sudo apt-get install dmsetup android-tools-adb
  1. Connect your Android device to your Linux system:

Connect your Android device to your Linux system using a USB cable. Enable USB debugging on your Android device. To do so:

  • Go to Settings > About phone
  • Tap on 'Build number' 7 times to enable Developer options
  • Go back to the main Settings menu, and find Developer options
  • Enable 'USB debugging'
  1. Obtain the encryption key:

On your Linux system, open a terminal and run the following command to access the shell on your Android device:

bash
adb shell

Now, run the following command to get the encryption key:

bash
su -c "cat /data/misc/vold/user_keys/expand_XXXX.key"

Replace "XXXX" with the appropriate key ID. If you don't know the key ID, you can find it by running:

bash
su -c "ls /data/misc/vold/user_keys/"

Copy the encryption key (32-byte hex string) and exit the shell.

  1. Decrypt the microSD card:

Insert the encrypted microSD card into a card reader connected to your Linux system. Identify the device node (e.g., /dev/sdb) corresponding to the microSD card. You can use the lsblk command to list all the block devices.

Use the dmsetup command to create a decrypted device mapper on Linux. Replace "XXXX" with the device node (e.g., sdb) and "YYYY" with the encryption key you obtained in step 3:

bash
echo "0 `blockdev --getsize /dev/XXXX` crypt aes-cbc-essiv:sha256 YYYY 0 /dev/XXXX 0" | sudo dmsetup create decrypted_sdcard
  1. Mount the decrypted device:

Create a mount point and mount the decrypted device:

bash
sudo mkdir /mnt/decrypted_sdcard
sudo mount /dev/mapper/decrypted_sdcard /mnt/decrypted_sdcard

Now, you should be able to access the decrypted contents of the microSD card at /mnt/decrypted_sdcard.

Please note that this process may not work for all Android devices or encryption configurations. Additionally, manipulating encrypted storage can lead to data loss, so make sure to back up your data before attempting these steps.