In Linux, you can read data a device encrypted e.g. with LUKS by doing cryptsetup luksOpen and mounting the volume. What is the equivalent for this in Android, i.e. what specification for encryption is used and what is the syntax to decrypt a device, e.g. my /data partition? I suppose that Android uses my lock screen PIN as the encryption key, correct?

Reason I ask: While attempting to debloat my Samsung A40FN with stock Android 9.0 Pie, I seem to have accidentally uninstalled some app required for Android to boot properly, resulting in a boot loop/soft brick (I can still enter recovery and download mode). As I've learned, uninstalling apps by pm uninstall does not actually delete the apps from the device, but just removes them from my (unrooted) user space by modifying entries in /data/system/packages.xml - which is by default encrypted by Android one a lock screen PIN is set up.

In order to rescue my data, it was suggested to flash the device (i.e. reinstall all packages) using the HOME_CSC firmware file instead of CSC, which supposedly keeps the data partition from getting wiped. However, this seems futile as the apps responsible for this mess will remain disabled as long as I don't reset /data/system/packages.xml. And to do that, I need to decrypt the data partition first.

Rooting the device does not seem to be an option as this supposedly wipes the data partition by design (is this true?). But isn't there a much simpler way to do something analogous to cryptsetup luksOpen and just copy my data?

Some information:

FRP lock: Off
OEM lock: On (L)
Bootloader level: U3
  • Your bootloader is locked, so the only way to edit the file would be an exploit that allows you to gain temporary root permissions. As your phone is running an older Android version but that will requires a lot of luck that a matching exploit exists and you find a way to execute it. But as you can't boot I don't think this is realistic to find an exploit that can be executed against a not fully booted phone. That would require a really low level exploit such as on USB level or something like that.
    – Robert
    Jun 18 at 22:54
  • And yes, bootloader unlocking erases user data, so rooting is not an option.
    – Robert
    Jun 18 at 23:00
  • this is for educational purposes only e4crypt/f2fscrypt for FBE file-based encryption (dmcrypt for FDE full-disk encryption)
    – alecxs
    Jun 19 at 7:26


You must log in to answer this question.

Browse other questions tagged .