Can DRM Keys be restored on the XZ1 after rooting? - Sony Xperia XZ1 Questions & Answers

I want to unlock the bootloader and root my XZ1 and use Magisk. Can the DRM keys be restored after rooting? Edit: Nevermind it seems the bounty for XZ1 DRM restore/fix is still going.

You answered it yourself.
No, it cannot. The DRM-Keys can't even be backed up, since the place where and how they are stored is unknown as of yet.
As a sidenote, for the XZ Premium, which uses the same chipset and similar software, there exists a DRM Fix which emulates the existence of the DRM keys, enabling you to use all protected features even after the keys are lost. It's currently in the works of being ported over to the XZ1 series of phones.

The answer has changed; thanks to j4nn's glorious work, it is now possible to do exactly this. You can find instructions over on the XZ1 Compact forum: https://forum.xda-developers.com/xperia-xz1-compact/development/devonly-exploits-temp-root-to-backup-t3795510

"saving" the DRM-Keys means: backup of the device specific Trim Area
"restoring" means: copying the Trim Area back
THIS WILL result in a soft brick on a modified (rooted ...) ROM
What you can do: create a boot partition with the keys "baked in" -> ta_poc (search for it)

Related

[Q] Walkman Live - Unlock Bootloader (Second thoughts)

Recently got my hands on this lovely phone..I want to play/tweak with the device but I have certain doubts regarding unlocking the bootloader. I seek answers to some questions below
Following lines are quoted from http://unlockbootloader.sonyericsson.com/
Certain functions in your phone might cease to work, and performance might not be ideal.​What functions get impaired?
Certain content on your phone may also be inaccessible due to the removal of DRM security keys and the secure user data partition while unlocking the boot loader​What content is being talked about?
We advise you to create backups, since user data, settings and accounts will be removed.​How do I create a full backup so that I can restore my current firmware at any time later?
Also, I noticed some unresponsivness at the lowermost part of the touchscreen quite a few times.. anybody else having the same problem??
Hmmm.....
I recently unlocked my live with walkman bootloader and re locked it (just needed to go back to stock as it is )
How did u relock it? I've read that it isn't possible fr now....
Sent from my WT19i using XDA App
By unlocking, DRM function are deleted. Which means you can't use trackid.apk and 'FB like' in music player as its a part of the trackid application.
Well, you can always use Soundhound if you wish to.
Nothing is impossible
Just need to know how to do a search
Here you go
http://forum.xda-developers.com/showthread.php?t=1451919
u can use mybackup pro or TB(root needed) for backing up but they will only backup user data not the frimware.
Wat u have to do is to flash the original rom to move it to stock

adding DRM keys in future possible?

Unlocking the bootloader the official way (and only way for now) Will result in a permanent loss of your DRM "keys".
But does that also mean that the DRM keys can never be added in te future in a unofficial way??
(thinking how long it will take to root without unlocking bootloader..)
DRM lost forever once its unlocked.
No way to add it again.
Sent from my LT26i using XDA
I've read a couple of times now that it's bad if the DRM keys get erased.
What I would like to know is: what do I need DRM keys for on my phone, where exactly are they stored that they can't be backed up, and how did they get there in the first place?
They are used for DRM protected media. You can't listen to music that is protected with DRM or watch movies if I got it right.
They are deleted because of copyright reasons.
Pezo said:
I've read a couple of times now that it's bad if the DRM keys get erased.
What I would like to know is: what do I need DRM keys for on my phone, where exactly are they stored that they can't be backed up, and how did they get there in the first place?
Click to expand...
Click to collapse
They are stored in the bootloader partition, which is not accessible from system and/or fastboot. The keys are also likely device specific. However, it seems they are not used for anything now. The only known problem was TrackID, but the latest update works for me on two unlocked devices.

Possible to recover deleted files after unlocking bootloader / rooting?

I stupidly trusted the "transfer to SD card" function and now my Z5 Compact has moved a big chunk of my photos from internal storage to… nowhere. They've been deleted and I'm not sure if I can get them back. I've managed to recover the thumbnails using FonePaw so I'm assuming the original full resolution files are still hanging around somewhere in the internal storage.
All the "recovery" tools I've found require your phone to be rooted in order to recover the deleted files from the internal storage. I'm aware that, in order to root the phone, the bootloader needs to be unlocked but that there are issues with losing DRM keys and the impact of that on some of the phone’s functions (specifically a number of the camera features). Given the camera was the primary reason I purchased this phone, I am reluctant to do something that messes with that, especially since this is the second handset as the first one was replaced under warranty after only three months (and this one still has 4 months of warranty left and has been having intermittent issues). There is also the issue that unlocking the bootloader factory resets the phone and therefore wipes all the data.
I know there is a bit of a workaround in that I can downgrade the firmware from Marshmallow to Lollipop and temporarily root the phone in order to backup the TA partition so I can restore the DRM keys et al after unlocking the bootloader and rooting the phone. Again, as I understand it the firmware downgrade will wipe my phone.
Normally wiping my phone wouldn’t bother me beyond being a pain to reinstall apps etc. What concerns me is that, given my missing files are likely floating somewhere in the internal storage ether, would a factory reset completely wipe those files from the phone permanently? Or would I likely still be able to recover them using appropriate software even after the reset, downgrade, unlocking of bootloader, and rooting?
I don't know much about it (and I’m willing to find out more for myself) but Is it possible to use something like adb backup to back up the whole phone and restore that to the phone after rooting in order to recover the missing files? Or will that also only work on a rooted phone?
If it's unlikely that my missing files would survive the repeated resets during the rooting process then I will probably just take this as a lesson learned the hard way and not bother trying to recover the files. Given the way my luck has been going, this handset will also fail before 12 months and I’ll have no warranty – and still no files!
Thank you in advance for any light you can help shed on this dilemma

Dealing with an encrypted android phone

I have a OnePlus 3 and I was thinking of encrypting it for additional security & privacy reasons. But since I flash various ROM level mods / use xposed modules on my phone, I was wondering about the negative consequences I have to face after encrypting an android phone.
I have a few doubts which need to be cleared.
1) Since my android phone would be encrypted, would I absolutely not be able to flash any new files/make nandroid backup from the recovery?
2) If 1) is true, which means, let's say I install an xposed module which causes a bootloop. Now I would have no way to disable all the active xposed modules from recovery since the files are encrypted, which means I would have to restore everything from scratch?
3) Is there absolutely no known way of decrypting android/access files unencrypted from recovery if we know the master PIN/password?
Can somebody who has dealt/dealing with an encrypted android phone please answer these questions? Thanks.
Deleted
Hi, thanks for your reply.
Just Passing By said:
1. When you access recovery on an encrypted phone, you have to decrypt your phone. After that, your recovery can do anything it normally could do. This would of course include flashing ROMs, zip files, and making nandroid backups.
.
Click to expand...
Click to collapse
2 things to say about that.
1)Decrypting just to flash files is a huge problem. TWRP/CWM should have a feature when it asks for the master PIN/password on the recovery, then after I enter it, it should decrypt the data on the fly and then mount the system and data partitions unencrypted so that I can flash files without going though all the decryption process.
2)Correct me if I'm wrong, but all android decryption processes I read online require wiping all data/doing a factory reset. That's again a huge problem. Why? In case I flash a mod/install a xposed module which causes a bootloop, I would have no way to decrypt my data, even if I have my master password. Which would mean I would lose all my files which I haven't backed up.
Problems like these could be avoided if TWRP provided permanent decryption/on the fly decryption using the master PIN. Comparing this with veracrypt on windows for e.g. , let's say my windows is encrypted with veracrypt and a hardware failure occurs at some point in the future & windows refuses to boot, but I'm able to load a live ISO. In this case, veracrypt offers a rescue ISO which I could use to decrypt the data without losing all my files after I enter the master PIN. So in this case, I can have security of encryption & also the convenience of decrypting it without losing all my files with the master password in case my main OS refuses to boot.
If I can't decrypt android from the recovery using the master PIN, that would mean in any case my android refuses to boot, I have lost all my files.
3. I'm assume you meant to say "... If we don't know the master PIN/Password?" And the answer to that is yes. If you can't decrypt your phone, you'll lose everything in it, so making periodic backups is a must. Otherwise, there'd be no point if you could just decrypt things right?
Click to expand...
Click to collapse
No, I did not say that wrong, sorry if I wasn't clear enough on my first post. I just wanted to know if there was a way to permanently decrypt android from recovery using the master PIN so that i would be able to recover my files to a USB in case my android refuses to boot.
Deleted

A proper way to create complete backup?

Hello, maybe someone could point me in the right direction, just trying to make a complete backup of my phone ( samsung galaxy S22), so I could back everything up when needed, I have tried the 'titanium backup' and 'swift backup' tools so far, but they only back up the .apks, and my google login credentials are lost..
Really kind of lost browsing through some 11 year old topics about 'nandroid' and 'ClockWorkMod', do people use these tools today?
Thank you
no way. use samsung smart switch and cross fingers
I don't know Samsung from a hole in the ground.
If your device has Qualcomm EDL (and open Firehose loader) you could make a full raw backup of the entire flash.
That's not really helpful if you want to grab a single file but it means that you can restore your device to a snapshot.
@Renate restoring snapshot is not possible after factory reset, as the encryption key is not in userspace and therefore not in backup.
afaik there is no samsung signed firehose programmer leaked for SM8450 (and probably never will) and that device is also shipped with Exynos 2200.
aIecxs said:
Restoring snapshot is not possible after factory reset, as the encryption key is not in userspace and therefore not in backup.
Click to expand...
Click to collapse
Well, that's a good reason not to factory reset!
So, where is the encryption key stored?
get some coffee and read about tee...
encrypted file encryption keys are stored in files metadata, but DEK required for decrypting keys is random generated and securely deleted from TEE keystore on factory reset. I don't know exactly what triggers that deleteKey (it's another OS) but it can survive simple formatting userdata.
aIecxs said:
get some coffee and read about tee...
Click to expand...
Click to collapse
Well, I did have my second coffee already and I know about as much about TEE as I want (which is little).
My point being, if you make a full flash backup, then do whatever, then restore the complete flash, how is that not going to get you back wherever you were?
There are tons of ELF and data partitions used by TEE, TZ.
But are you telling me there is some state built into a device that is neither OTP or flash?
right, it's not in flash storage emmc/ufs.
Appreciate te replies!
Is there any other popular android device which would support the earlier mentioned flashing method?
Thanks!!
aIecxs said:
right, it's not in flash storage emmc/ufs.
Click to expand...
Click to collapse
I'd still like to know exactly where that is.
There are enough partitions called keymaster and other stuff.
Well, ok, but if you don't use factory reset a full flash backup is the best way to get you back to where you were.
actually, it IS in flash storage, but you won't see it
https://www.wikipedia.org/wiki/Replay_Protected_Memory_Block
Note: for all devices running old (FDE) full disk encryption, the static hardware master key is used directly, and the encrypted DEK is stored in crypto-footer (userspace) therefore restoring full raw backup was always possible.
Google and Samsung devices in general used to lack raw access. However, things have changed with Samsung started shipping MediaTek SoCs on their low-/mid-range lines.
But if you're looking for full backup solution, don't use any DRM related or banking apps and don't care about losing warranty and Samsung Knox, rooting and removing encryption is possible so you could just use TWRP or Swift Backup.
aIecxs said:
actually, it IS in flash storage, but you won't see it
https://www.wikipedia.org/wiki/Replay_Protected_Memory_Block
Note: for all devices running old (FDE) full disk encryption, the static hardware master key is used directly, and the encrypted DEK is stored in crypto-footer (userspace) therefore restoring full raw backup was always possible.
Google and Samsung devices in general used to lack raw access. However, things have changed with Samsung started shipping MediaTek SoCs on their low-/mid-range lines.
But if you're looking for full backup solution, don't use any DRM related or banking apps and don't care about losing warranty and Samsung Knox, rooting and removing encryption is possible so you could just use TWRP or Swift Backup.
Click to expand...
Click to collapse
Thank you, that's the thing, as a matter of fact I already have tried using swift backup tool, but all google accounts are lost when backing up, and the apps that have used google to log in ( like play store, google maps etc ) are also losing the connected account.
Any suggestions on how to transfer the google accounts as well?
Thanks again!
actually Swift Backup should work. it looks like some extended Google One fork with optional root features. google account is required for it to work, not sure what problems you are facing?
aIecxs said:
actually Swift Backup should work. it looks like some extended Google One fork with optional root features. google account is required for it to work, not sure what problems you are facing?
Click to expand...
Click to collapse
The main issue for me was that it doesn't back up my google signed in accounts.
After reading for one more day I stumbled upon one of your very interesting posts on this thread - https://forum.xda-developers.com/t/android-12-and-nandroid-backup.4420185/
Here you explain how it's possible to pull out the 'nandroid' image from the phone to the computer which is exactly what I was looking for, but couldn't express clearly.
That's 100% the functionality I am looking for
- Ability to pull out the exact state of the phone to a file on the computer
- Put it back in if things go south, and all my files are exactly as they were at that point.
1) From your experience, do you think it would be possible to achieve this on a Samsung phone?
2) As far as I understood, after doing a 'factory reset' I would no longer be able to put the old 'nandroid' image back, because of the encryption?
Thank you for your time!
P.s I would be happy to pay for a consultation on this topic from you or someone who has managed to do this.
I also would like to see a full nandroid backup solution tool similar to how Windows System image backup works - a full 1:1 flash image with all files and settings intact of an android device.
Renate said:
I don't know Samsung from a hole in the ground.
If your device has Qualcomm EDL (and open Firehose loader) you could make a full raw backup of the entire flash.
That's not really helpful if you want to grab a single file but it means that you can restore your device to a snapshot.
Click to expand...
Click to collapse
How do I do this @Renate with my one plus pro 9 phone? I have the MSM tool, how do I dump a full system image?
immortalwon said:
How do I do this with my one plus pro 9 phone? I have the MSM tool, how do I dump a full system image?
Click to expand...
Click to collapse
I don't know.
I've been trying to get down to brass tacks what's the difference between this MSM Tool and a generic EDL client.
I don't know about its authorization and phone-home-ness.
I'm not even sure if with VIP you can transfer complete device images.
OTOH, VIP is built into many loaders but not used.
I don't have a OnePlus. I'd need a USB capture to say anything intelligent.
I know on my Android 10 ereader I can simply (with my EDL client):
Code:
C:\>edl /r /s0 /c0 mybackup.img
That's for eMMC. For UFS you'd probably need six files.
Renate said:
I don't know.
I've been trying to get down to brass tacks what's the difference between this MSM Tool and a generic EDL client.
I don't know about its authorization and phone-home-ness.
I'm not even sure if with VIP you can transfer complete device images.
OTOH, VIP is built into many loaders but not used.
I don't have a OnePlus. I'd need a USB capture to say anything intelligent.
I know on my Android 10 ereader I can simply (with my EDL client):
Code:
C:\>edl /r /s0 /c0 mybackup.img
That's for eMMC. For UFS you'd probably need six files.
Click to expand...
Click to collapse
I found a way to do a full image readback using the msm tool, which downloads everything firmware related to my pc on the main C:/ drive. The question is, if I ever need to in the future, how do we use the restore function of the msm tool to restore these backups?
EDIT: I don't think it was a full image backup after all because the backups in total are 13gb, while my device is using a lot more storage then that.
@myndeswx what you have linked in post #14 is exactly what Migrate does. It creates tarball archives of apps of decrypted /data partition during runtime. Restoring will work after factory reset because it's a backup of plain files. However, it's far from complete, it is not atomic, still security critical apps using android keystore cannot restored, and it requires rooted device (with all its disadvantages)
For Samsung phones there is currently a hack to gain temporary access to /data with system privileges (uid 1000) floating around (haven't tried)
***LOCKED UNTIL FURTHER NOTICE*** System Shell Exploit - ALL Samsung Mobile Devices NO BL UNLOCK REQUIRED.
***MODERATOR ANNOUNCEMENT: THREAD CLOSED*** @K0mraid3 you are hereby required to provide proper credit in your OP as follows: Link the assigned CVE for this exploit as it mentions the author's blog and GitHub, OR Link the original research repo...
forum.xda-developers.com
hallo i have S22 exynos S908B
- Magisk 26.1
- Encrypted
- S-health working
- Health connect working
- Bank apps working
- Galaxy Watch 4 working
i extracted Titanium Baclups and see there is only installation apk because data in Android/data is encrypted so Titanium backup can't see it and not advise about not backupped data.
Android/data is accessible only by mtp/usb by pc.
So what option i have for backup?
by twrp can i baclup partitions with dd command? After can i restore it without factory reset? (can't factory reset because cause encryption keys lost)
Any working way for bakup?

Categories

Resources