Development [RECOVERY][3.7.0_12-8][UNOFFICIAL][UNIFIED] TWRP with A12/A13 encryption support

Search This thread

shadabkiani

Senior Member
Mar 2, 2018
486
190
Pakistan
HTC 10
OnePlus 9
i saw that. so u wanna to say boot.img its Recovery.img? boot and recovery imgs it's a different things ))
i need exactly recovery.img not boot.img to run TWRP )
I understand your confusion. We all shared the same confusion when coming to OnePlus 9 with dynamic A/B partitioning. All modern phones are now like this. :ROFLMAO:
There is no dedicated recovery partition anymore. Recovery now resides inside boot partition sharing the same kernel. So yes, boot.img contains recovery. That is why you don't flash it. You just boot it with command fastboot boot <your_recovery_boot.img> and then from TWRP you install/patch it permanently if you want (although permanent is not needed and I won't recommend). Just temporarily boot it and use it for whatever reason.
 

Mikefy

New member
Jan 17, 2017
4
1
I understand your confusion. We all shared the same confusion when coming to OnePlus 9 with dynamic A/B partitioning. All modern phones are now like this. :ROFLMAO:
There is no dedicated recovery partition anymore. Recovery now resides inside boot partition sharing the same kernel. So yes, boot.img contains recovery. That is why you don't flash it. You just boot it with command fastboot boot <your_recovery_boot.img> and then from TWRP you install/patch it permanently if you want (although permanent is not needed and I won't recommend). Just temporarily boot it and use it for whatever reason.
OH SHOOT :ROFLMAO::ROFLMAO: now i get it....right new system with A\b....OMAGOD. iam so exuse for my stupid
u right. boot.img from link work like TWRP .thx for explane! I appreciate it
 
  • Haha
Reactions: shadabkiani

shadabkiani

Senior Member
Mar 2, 2018
486
190
Pakistan
HTC 10
OnePlus 9
OH SHOOT :ROFLMAO::ROFLMAO: now i get it....right new system with A\b....OMAGOD. iam so exuse for my stupid
u right. boot.img from link work like TWRP .thx for explane! I appreciate it
Yeah. Just another bit of information that if you flash a custom ROM like LineageOS, you would notice it might ask you to download recovery.img, but keep it mind that it is essentially boot.img, even though it is named recovery.img. (That was the case in early builds, I don't know if they still have one of the required files named as recovery).
 
  • Like
Reactions: der_akinator

PartyZone

Member
Oct 7, 2009
15
0
I need your help guys so much! I am desparate.
OP9 pro, unlocked, rooted.
I was so stupide to set the pattern, never used it before in my life. So I forgot it.
Now the device doesn't wants any of fingerprint or the pincode, or gmail, or 2FA, nothing but the f.. pattern.
Fastboot is recognized. adb "no devices"
When loading from TWRP the data can't be mounted, it's 0kb.

When tried to restore the backup on another device, it's still asking for a pattern.
Please help, if it's even possible not to loose everything.
Thanks guys!
 

der_akinator

Senior Member
Mar 27, 2015
231
395
Berlin
OnePlus 3T
OnePlus 9 Pro
I need your help guys so much! I am desparate.
OP9 pro, unlocked, rooted.
I was so stupide to set the pattern, never used it before in my life. So I forgot it.
Now the device doesn't wants any of fingerprint or the pincode, or gmail, or 2FA, nothing but the f.. pattern.
Fastboot is recognized. adb "no devices"
When loading from TWRP the data can't be mounted, it's 0kb.

When tried to restore the backup on another device, it's still asking for a pattern.
Please help, if it's even possible not to loose everything.
Thanks guys!
There can't be done much, if you forgot you pattern. For the adb issue you have to use Mount-> disable MTP. If you have your backup stored on PC or a flash drive, you can factory reset data and restore the backup. Keep in mind the backup only includes apps and settings ando so on, but NOT pictures, downloads and everything that is stored under /sdacrd.
 
Last edited:

PartyZone

Member
Oct 7, 2009
15
0
OMG. So I did managed how to push files to device and install it with twrp. So you are saying despite this, nothing can't be done? Even not google backup restore after reset?
2nd questiom
Does it count's the pattern tryes when trying to decrypt inside the twrp?
I also can see the data size now instead of 0.
Thanks
 

der_akinator

Senior Member
Mar 27, 2015
231
395
Berlin
OnePlus 3T
OnePlus 9 Pro
OMG. So I did managed how to push files to device and install it with twrp. So you are saying despite this, nothing can't be done? Even not google backup restore after reset?
2nd questiom
Does it count's the pattern tryes when trying to decrypt inside the twrp?
I also can see the data size now instead of 0.
Thanks
Google (cloud) backup and so should work, if you have enabled it and it's synced. I never used restricted login attempts, so I'm not sure if twrp has any effect on that counter.
I would suggest to pull the contents of /sdcard, if you can access it. The other stuff in /data is already in the backup, that is hopefully on you PC or any other storage media.
 
  • Like
Reactions: Smedslund

PartyZone

Member
Oct 7, 2009
15
0
Google (cloud) backup and so should work, if you have enabled it and it's synced. I never used restricted login attempts, so I'm not sure if twrp has any effect on that counter.
I would suggest to pull the contents of /sdcard, if you can access it. The other stuff in /data is already in the backup, that is hopefully on you PC or any other storage media.
No, I don't have any twrp backup. Also as I said for the google full backup to restore the device it still demands the pattern. So it's lost i guess.
 

der_akinator

Senior Member
Mar 27, 2015
231
395
Berlin
OnePlus 3T
OnePlus 9 Pro
No, I don't have any twrp backup. Also as I said for the google full backup to restore the device it still demands the pattern. So it's lost i guess.
You can try to use you normal google password for the backup, but it's not really clear what exactly is used to encrypt those backups.

 

PartyZone

Member
Oct 7, 2009
15
0
You can try to use you normal google password for the backup, but it's not really clear what exactly is used to encrypt those backups.

Sorry, I don't really understand what do you mean. Beacause google asks for the pattern in order to restore backup. Not the pin, not the google password or 2fa, Nothing.Only the pattern is all it knows in this world. I am frustrated.
 

PartyZone

Member
Oct 7, 2009
15
0
My logic is simple. If TWRP knows what is the right pattern, then it's at some file inside the system, not a cloud or something.
So if we determine what the file this is, then we can decrypt the numeric to 3x3 pattern.
I have an access to the files beacause of an unlocked and rooted device. So why not to find the file which storing the pattern?
 
My logic is simple. If TWRP knows what is the right pattern, then it's at some file inside the system, not a cloud or something.
So if we determine what the file this is, then we can decrypt the numeric to 3x3 pattern.
I have an access to the files beacause of an unlocked and rooted device. So why not to find the file which storing the pattern?
Good luck in finding it.
 
  • Like
Reactions: der_akinator

der_akinator

Senior Member
Mar 27, 2015
231
395
Berlin
OnePlus 3T
OnePlus 9 Pro
Sorry, I don't really understand what do you mean. Beacause google asks for the pattern in order to restore backup. Not the pin, not the google password or 2fa, Nothing.Only the pattern is all it knows in this world. I am frustrated.
The link states that google either uses google password or phone pin for backups. So it seems you don't have luck.

My logic is simple. If TWRP knows what is the right pattern, then it's at some file inside the system, not a cloud or something.
So if we determine what the file this is, then we can decrypt the numeric to 3x3 pattern.
I have an access to the files beacause of an unlocked and rooted device. So why not to find the file which storing the pattern?
TWRP essential does the same as default android, and there is no password stored. That would defeat the whole purpose of encryption. I'm not sure about the internals, but broadly speaking the system tries to decrypt with your provided pattern and if the result doesn't make sense, you get an error.
 

TheGhost1951

Senior Member
Feb 11, 2009
2,043
533
Garfield
OnePlus 9 Pro
When I use to enable Google backup....it was done based on my Gmail account. If I re-did my phone and needed to restore everything from Google, during phone setup I would log into my Gmail account after connecting to wifi and everything was restored (usually) as part of phone setup. However, since Google is not totally reliable, I have gone to SwiftBackup (rooted) and currently testing oandbackup (not rooted).
 

TheGhost1951

Senior Member
Feb 11, 2009
2,043
533
Garfield
OnePlus 9 Pro
When I use to enable Google backup....it was done based on my Gmail account. If I re-did my phone and needed to restore everything from Google, during phone setup I would log into my Gmail account after connecting to wifi and everything was restored (usually) as part of phone setup. However, since Google is not totally reliable, I have gone to SwiftBackup (rooted) and currently testing oandbackup (not rooted).
Oandbackup requires root, last but not least there is Helium for non-root backup of apps and data. But I would still rather have a rooted phone just for the possibilities!
 
  • Like
Reactions: Nimueh

shadabkiani

Senior Member
Mar 2, 2018
486
190
Pakistan
HTC 10
OnePlus 9
My logic is simple. If TWRP knows what is the right pattern, then it's at some file inside the system, not a cloud or something.
So if we determine what the file this is, then we can decrypt the numeric to 3x3 pattern.
I have an access to the files beacause of an unlocked and rooted device. So why not to find the file which storing the pattern?
Lock settings are stored in /data/system/locksetting.db and other files with filenames locksettings. Now since /data/ is encrypted, you cannot access it without decrypting. And, even if you decrypt phone by entering correct pattern, and then you delete those files, that would make the entire /data useless and forever encrypted because there would be no way to decrypt it anymore.

On my HTC 10, I have custom ROM installed and /data isn't encrypted by default, unlike OnePlus 9. You have to manually encrypt from Settings > Security if you want. So, if I don't have encryption, I can go to TWRP and simply delete /data/system/locksettings.db and phone lock would just go away. However, if encryption is enabled, and I go to TWRP, decrypt with correct lock code, then delete the same files, it would not work. The phone will boot up and would be stuck after bootanimation. I would have to format data and only then it would work again.

Ain't no way you can bypass encryption. You either enter the correct lock code, or just get super lucky and try again again through brute forcing.
 

[GR]Frostbyte

Senior Member
Jan 9, 2012
192
75
33
Q3DM6
TWRP essential does the same as default android, and there is no password stored. That would defeat the whole purpose of encryption. I'm not sure about the internals, but broadly speaking the system tries to decrypt with your provided pattern and if the result doesn't make sense, you get an error.

Lock settings are stored in /data/system/locksetting.db and other files with filenames locksettings. Now since /data/ is encrypted, you cannot access it without decrypting. And, even if you decrypt phone by entering correct pattern, and then you delete those files, that would make the entire /data useless and forever encrypted because there would be no way to decrypt it anymore.

On my HTC 10, I have custom ROM installed and /data isn't encrypted by default, unlike OnePlus 9. You have to manually encrypt from Settings > Security if you want. So, if I don't have encryption, I can go to TWRP and simply delete /data/system/locksettings.db and phone lock would just go away. However, if encryption is enabled, and I go to TWRP, decrypt with correct lock code, then delete the same files, it would not work. The phone will boot up and would be stuck after bootanimation. I would have to format data and only then it would work again.

Ain't no way you can bypass encryption. You either enter the correct lock code, or just get super lucky and try again again through brute forcing.

I would also like to add my own two cents, as a senior UNIX/Linux system administrator, to these already helpful excerpts of information.

@PartyZone

Even if the stars could align and a decrypted version of the file that the pattern/pin is stored in could be found, one could never get the actual pattern/pin out of it; the reason being that the actual pattern/pin is being hashed (with blowfish/bcrypt being the latest trend) and usually salted too.

This means that when one enters a password/pattern/pin, the input is being hashed once more and compared against the stored hash. Hashing is typically considered to be a one-way process, which cannot be reversed (while in theory it technically could, it would require immeasurable processing power to do so).
As you also might've guessed, an added salt makes the possibility of a successful decryption even more unfathomable. (Further details and explanation can be found here)

As @der_akinator most eloquently and accurately put; an encryption process which could be reversed (at least not without an insurmountable cost), would defeat it's whole purpose and existence in the first place.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 9
    still no official twrp version for android 13 ?
    A couple of other devs and I are working on a TWRP build based on A13 sources. But progress is slow, mainly due to the fact that it will not bring much benefit compared to A12.

    Some updates about the state of official OP9 (A12) builds:
    The latest device-specific changes have been uploaded and are mostly reviewed. A new point release is planned for the near future, so official builds will be available soon. I don't see much benefit in having official nightly builds, because this is what you can get here, or builds from 3.7.0 sources that are missing some bug fixes.
    5
    Hello! Please help! What TWRP should be put on android13? Phone OnePlus 9 Pro LE 2127
    OOS users should make a backup of boot before installation. Otherwise incremental updates can't be applied.
    Installation overwrites all boot partition changes done previously (e.g. by Magisk or custom kernel). So you have to reflash all zips that change the boot partition after TWRP is installed.
    For permanent installation, you have three options depending on your current system.
    1. Option for rooted devices:
    1. Download the twrp-installer zip
    2. Flash it with Magisk manager or some other kernel flash utility
    3. Reflash your custom kernel and Magisk.apk if previously installed (see example of how to install with Magisk manager below). Or alternatively flash zips in TWRP.
      1. Don't reboot
      2. Rename downloaded Magisk.apk to Magisk.zip
      3. Open Magisk app
      4. Select Modules tab
      5. Click "Install from storage"
      6. Select Magisk.zip
    2. Option for users with other custom recoveries but without root:
    1. Download the twrp-installer zip
    2. Reboot to recovery
    3. Flash it with "adb sideload twrp-installer*.zip"
    4. Reboot to recovery
    5. Reflash your custom kernel and Magisk.apk if previously installed
    3. Option is universal:
    1. Download boot.img
    2. Reboot to bootloader
    3. Run "fastboot boot boot.img" with the TWRP boot image on your PC
    4. Go to Advanced > Flash Current TWRP
    5. Reflash your custom kernel and Magisk.apk if previously installed
    4
    Thank you! But which version of TWRP needs to be installed? On android 12 I installed 3.7.0_11-0-emonadep.zip. Is this version suitable for android 13 or not?
    3.7.0_12 is fine for A12 and A13.The old 3.7.0_11version has issues with encryption
    For LE 2127, you have to make a backup of your boot partition. Otherwise you can get problems when you try to update.
    3
    still no official twrp version for android 13 ?
    The 12 branch decrypts 13 just fine.
    3
    If it is not difficult. Tell me how to create on OnePlus 9 Pro backup boot partition ?
    the backup is only important, if you are using OOS (stock ROM). For that you can also follow "Try without installation" and use the backup feature. You can either make a full backup or just select "boot" an make a backup.
  • 55
    This is an unofficial build of TWRP, based on the Android 12.1 branch, that supports encryption used by Android 12 and 13 ROMs. This build is tested on OP9 pro, but it was confirmed to work on regular OP9 too.

    As always I'm not responsible for any bricked device or data loss resulting from the use of this TWRP builds. You use this at your own risk.

    For ROMs using FBEv1 encryption aka A11 encryption, please use the official builds by
    @Nebrassy from:

    Download:


    Installation:

    Permanent installation is not possible with TMO 12 stock ROM installed. With TMO 13 stock it's possible, but it was reported that uninstalling causes issues.

    OOS users should make a backup of boot before installation. Otherwise incremental updates can't be applied.

    Installation overwrites all boot partition changes done previously (e.g. by Magisk or custom kernel). So you have to reflash all zips that change the boot partition after TWRP is installed.

    For permanent installation, you have three options depending on your current system.

    1. Option for rooted devices:
    1. Download the twrp-installer zip
    2. Flash it with Magisk manager or some other kernel flash utility
    3. Reflash your custom kernel and Magisk.apk if previously installed (see example of how to install with Magisk manager below). Or alternatively flash zips in TWRP.
      1. Don't reboot
      2. Rename downloaded Magisk.apk to Magisk.zip
      3. Open Magisk app
      4. Select Modules tab
      5. Click "Install from storage"
      6. Select Magisk.zip
    2. Option for users with other custom recoveries but without root:
    1. Download the twrp-installer zip
    2. Reboot to recovery
    3. Flash it with "adb sideload twrp-installer*.zip"
    4. Reboot to recovery
    5. Reflash your custom kernel and Magisk.apk if previously installed
    3. Option is universal:
    1. Download boot.img
    2. Reboot to bootloader
    3. Run "fastboot boot boot.img" with the TWRP boot image on your PC
    4. Go to Advanced > Flash Current TWRP
    5. Reflash your custom kernel and Magisk.apk if previously installed

    Try without installation:
    1. Download boot.img
    2. Reboot to bootloader
    3. Run "fastboot boot boot.img" with the TWRP boot image on your PC

    Uninstall:

    Just flash the boot partition with your current ROMs boot image with the following steps.
    Replace "YOUR ROM BOOTIMAGE" with the filename of the extracted boot image of your current ROM.
    1. Reboot to bootloader
    2. Run "fastboot flash boot_a YOUR ROM BOOTIMAGE"
    3. Run "fastboot flash boot_b YOUR ROM BOOTIMAGE"
    Alternatively you can flash your currently installed OTA zip, which overwrites boot on the unused slot, but not on the currently used one.

    Collection of OOS boot images:

    TWRP Updates:
    1. Download and flash the twrp-installer zip
    2. After that reflash your custom kernel and Magisk if previously installed

    ROM Updates:

    Please follow the official update instructions for your ROM!

    If they give an option to update via recovery you have to substitute adb sideload commands with zip installations. Also use the "Automatically reflash TWRP after flashing a ROM" option, if you are going to install a ROM zip to preserve TWRP installation.

    In case your ROM does not provide a recovery update instruction you can try to update via recovery but you are on the safe side if you follow the official instructions. They always have a reason for their particular update instructions!

    Instructions that work for me (on LOS based ROMs):
    1. Flash ROM zip with "Automatically reflash TWRP after flashing a ROM" checked
    2. Flash your previously installed zips (custom kernel, Gapps, Magisk, etc)
    3. Reboot to system
    4. If Gapps packages keep crashing:
      1. Reboot to TWRP
      2. Flash Gapps again
      3. Reboot to system
    OOS full OTA updates should work out of the box.
    For incremental OOS updates, you have to flash the original boot image. Your can follow this short guide and use the boot image from link in the uninstall section.

    About backups/restore:

    Restore data only WITHOUT pin/pattern set.

    If you restore a backup made from another ROM, then the currently installed, you may have to format data. So please manually copy all contents from /sdcard to a PC or flash drive.

    Backups can be made with or without pin/pattern set. It is always good practice to copy your backups to your PC or an USB drive. Also after you restored your data partition you have to reboot to system and do a second reboot to get a working system.
    To make first boot faster and eliminate the need to reboot again, additionally use the step mandatory for OOS users.

    If you want to copy your backup to PC, but it doesn't show up, flash change_backup_selinux_context.zip, which is available in download folder.

    For OOS users:
    When data is restored, you have to delete "/data/system/users/0/package-restrictions.xml" before rebooting to system.

    In case you restore a backup with pin/pattern set or have some other issues I have a guide that works for me:

    How to use MTP, adb and fastbootD:

    Windows:
    Install official Google USB drivers and select the right USB drivers. For MTP and adb, the WinUSB driver is sufficient on Windows 11. For fastbootD, Google drivers (Android Bootloader interface) has to be chosen.
    You may have to select WinMTP for MTP and Google USB drivers for adb, if you run Windows 10.

    To use adb on Windows, MTP has to be disabled with "Mount->Disable MTP" in TWRP.

    Steps for choosing a specific driver (no the exact wording):
    1. Connect phone in specific mode
    2. Open device manager
    3. Right click on phone either under "Android device" or "USB device", depending on mode
    4. Select "update driver"
    5. Select 2. option "browse my computer"
    6. Select "pick from available drivers"
    7. Pick driver according to above description
    Linux:
    1. Intall the fastboot and adb packages for your distribution
    2. Set udev rules. There might be a package for your distro or use this gh repo: https://github.com/M0Rf30/android-udev-rules
    3. Add user to the group used in udev rules. Most common are "plugdev" and "adbusers"

    Source Code:

    Bugs:
    • Permanent installation alongside TMO stock isn't possible
    • Error message regarding vendor_dlkm in fastbootD for OOS users (just cosmetic and not problematic)
    • In case you notice anything else please let me know.
    If you encounter any bug, please give me description with logcat.txt and recovery.log output attached. You can copy those to your data folder in TWRP, if you go to Advanced->Copy Logs.

    Thanks to:
    • @Nebrassy for the original device tree
    • @osm0sis for the zip installer
    • TWRP team
    • LineageOS
    13
    Update
    • /data/fonts/* is excluded from backups (has to be verified by someone with backup errors)
    • screen turns completely off now
    • updated firmware files from LE2125_11.C.63 (maybe this helps with OOS13 problems)
    • initial installation is now possible without flashing vendor_boot (I tested a few combinations of installation methods and initial system configurations. So hopefully nothing is broken this time.)
    Have a happy New Year tomorrow!

    11
    Update
    • add vendor_boot and dtbo to backup targets
    • add CPU temperature output
    • fix vibration (still doesn't work in fastbootd mode)
    I tested this build on LOS 19.1 (OOS 12 firmware) and crdroid 13 (OOS 13 firmware). Also keep in mind that you have to use the boot image according to your installed firmware, if you want to install/test via fastboot.

    10
    Update
    • improve vibration support
    • fix kernel modules loading in fastbootd mode for custom roms (might result in an error message regarding vendor_dlkm for OOS users, but it's just cosmetic)
    Tested on LOS 19.1 (OOS 12 firmware) and crdroid 13 (OOS 13 firmware).

    10
    Good new for OOS users. One of the TWRP devs found a workaround for data restore on OOS. Just delete "/data/system/users/0/package-restrictions.xml", after data is restored. I will exclude this file by default in a future build, but for existing backups, the file must always be removed manually.

    Edit:
    This is also useful for custom ROMs, because it makes first boot faster and eliminates the need to reboot again.