yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] osm0sis:
NEW! 999-customkernel.sh addon.d script has been added to the 2nd OP!

The blurb in the OP pretty much covers it all, but basically it'll work on any device with a normally named EMMC boot partition (just like my Flashify script zip), then back up your custom kernel and restore it after your ROM flash so you don't have to. :)

#!/sbin/sh
#
# /system/addon.d/999-customkernel.sh
# During an upgrade, this script backs up the emmc boot (kernel) partition,
# ROM kernel is allowed to flash then the previous custom kernel is restored.
#
# osm0sis @ xda-developers

. /tmp/backuptool.functions

# determine the location of the emmc boot partition
if [ -e /dev/block/platform/*/by-name/boot ]; then
block=/dev/block/platform/*/by-name/boot;
elif [ -e /dev/block/platform/*/*/by-name/boot ]; then
block=/dev/block/platform/*/*/by-name/boot;
fi;

# force expansion of the path so we can use it
block=`echo -n $block`;

case "$1" in
backup)
# backup custom kernel
if [ -e "$block" ]; then
dd if=$block of=/tmp/boot.img;
fi;
;;
restore)
# Stub
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
# wait out ROM kernel flash then restore custom kernel
while sleep 5; do
[ -e /tmp/boot.img -a -e "$block" ] && dd if=/tmp/boot.img of=$block;
exit;
done&
;;
esac;

Here's an example of me integrating the script as a toggle into the DirtyV ramdisk's Synapse support as well:

https://github.com/bsmitty83/DirtyV_tuna/commit/064eaabdc79a18ad84e34e488e1872c3eea21e69

Also, check out my WIP Knowledge Base (3rd OP) for a link to an example of my personal addon.d script I use to automatically backup and restore (and delete) other things during the ROM flashing process. Happy flashing! :D
[Android Software/Hacking General [Developers Only]] PiggyFlooper:
The zip won't open, ES says Central Directory Entry Signature not found

And the individual script links are all the same remount script

Sent from above using xparent tapatalk blue
[Android Software/Hacking General [Developers Only]] osm0sis:
Thanks. Yeah, it's just been brought to my attention that literally everything I've uploaded to BasketBuild via ftp has been somehow corrupted. I'll try to fix it up on Monday when I have time.

Edit: Should be good now! :)
[Android Software/Hacking General [Developers Only]] osm0sis:
Anybody in here getting a Nexus 6 or Nexus 9 and want to help me see if we can add support to the BootUnlocker Script zip and app?
[Android Software/Hacking General [Developers Only]] efrant:
I'll probably get an N6. That is if it ever shows up on the Canadian Google Play Store ... :D If so, I'd be happy to help out.
[Android Software/Hacking General [Developers Only]] osm0sis:
Awesome! I'm a little worried that the new Developer Options requirement might interfere, or mean there's a new/different method to unlock than before, but damnit we'll try! :D
[Android Software/Hacking General [Developers Only]] Tommy-Geenexus:
Hi [MENTION=4544860]osm0sis[/MENTION],

i wanna thank you for AnyKernel2.

It works perfect on my Z Ultra and with some mods on my Z too, many thanks for your work.
[Android Software/Hacking General [Developers Only]] osm0sis:
After a lotttt of work from Chainfire, myself, Modding.MyMind and [MENTION=2777334]TKruzze[/MENTION] to name just a few!

Complete Shell Script Flashable Zip EDIFY/update-binary Replacement + Zip Signing Documentation:

http://xdaforums.com/android/software-hacking/dev-complete-shell-script-flashable-zip-t2934449

Now.. I can finally get around to cleaning up the Knowledge Base post here. :)

[MENTION=4179234]trevd[/MENTION] any ideas on how to get applypatch working? Am I right that it wouldn't be possible without bspatch binaries?
[Android Software/Hacking General [Developers Only]] GizmoTheGreen:
bootunlocker script safe to use with NExus 5 on the fresh out of the oven lollipop factory images??
[Android Software/Hacking General [Developers Only]] osm0sis:
Good question. I'm not sure if/how the new Developer Options checkbox affects the partition that needs to have the bit flipped in it. I'm waiting on the OTA for my N7, then I should have a somewhat better idea.

If you're feeling intrepid, you could try it as well. It just flips the bit, so the worst that could happen is you run it again to change it back, or if they changed the layout entirely it'll detect it doesn't match at all and bail leaving things untouched.
[Android Software/Hacking General [Developers Only]] GizmoTheGreen:
it worked just fine!

tampering returns false now and so does unlocked :)

I have noticed anything being broken by it
[Android Software/Hacking General [Developers Only]] trevd:
Who me? Dam it should really check in more often!! :o

[MENTION=4544860]osm0sis[/MENTION] Did you sort this dude? not read the post or anything, figured I'd ask before getting my brain into it :p
[Android Software/Hacking General [Developers Only]] osm0sis:
Nah I haven't, but I remembered you saying you got actual bsdiff OTAs working so I thought you might know if there was a way to manually do that sort of stuff from the recovery command line. ;) :)
[Android Software/Hacking General [Developers Only]] Spaceminer:
@osm0sis

I just wanted to let you know that the most recent magisk adb-ndk works perfectly with the fastbootd that's used in Orange Fox and TWRP. I've been able to unlock the bootloader, and flash custom roms on 3 different devices without any issues via OTG. Stock firmware can also be flashed. I haven't had a PC in 8 months and this has been a blessing to me.

Edit: It also works with stock fastboot and fastbootd! I just tested it.
[Android Software/Hacking General [Developers Only]] segfault_bilibili:
Thank you very much! However so far I have just seen that SIGSEGV was triggered here https://git.busybox.net/busybox/tree/networking/netstat.c?h=1_31_1#n468 (call stack was something like strlen/printf/print_inet_line/...)

Maybe I still have to build selinux-enabled binary on my own, otherwise I won't be sure whether this issue is fixed.
[Android Software/Hacking General [Developers Only]] osm0sis:
Well! Lots done and lots to do. Hope everyone's doing well out there!

An updated Payload-Dumper-Go Magisk Module resolving out-of-memory issues has been added to its previous post and linked in the OP. The instructions I worked out for retaining passing SafetyNet on Incremental Google OTA Virtual A/B devices has been linked in the Knowledge Base post as well.

For more on the "Diffusion Installer Backend updates" see any of my module GitHub commit histories, e.g. https://github.com/Magisk-Modules-Repo/busybox-ndk/commits/master (y)

I work on these projects in my limited time off, so if you like the progress I'm making, or enjoy anything else I've done on xda, please consider sponsoring my ongoing work using my GitHub Sponsors profile. For a one-time donation you can hit the donate link from my profile. Thanks for your support!

98-twrp_ab.sh:

- add support for latest Magisk AVBv1 BootSigner changes

UPDATE-adb.Installer.v1.0.41-signed.zip;

UPDATE-Adreno.Systemless.Installer-signed.zip;

UPDATE-mtd-utils.Installer.v2.1.2-signed.zip;

UPDATE-Nexus.Media.Installer-signed.zip;

UPDATE-ZipSigner.Installer.v3.0-signed.zip:

- Diffusion Installer Backend updates

UPDATE-Busybox.Installer.v1.32.1-ALL-signed.zip:

- update to latest busybox stable official source

- Diffusion Installer Backend updates

UPDATE-Fla****.Installer.v3.8-signed.zip:

- update busybox binary (1.32.1) with the latest patches and fixes from my repo

- Diffusion Installer Backend updates

UPDATE-nano.Terminal.Editor.v5.7-signed.zip:

- update to latest nano official source

- Diffusion Installer Backend updates

TWRP_A_B_Retention_Script-Magisk(1).zip and AnyKernel3 have also seen some more improvements for the latest Magisk, and an Android Image Kitchen v3.8 release with boot_img_hdr_v3 and vendor_boot support will be incoming soon once I finish regression testing. Download TWRP A/B Retention Script again from the repo in the Magisk app to obtain the new version. 👌
[Android Software/Hacking General [Developers Only]] osm0sis:
Updated the above since nano 5.7 just came out today. Also reuploaded Payload-Dumper-Go with an improved wrapper to show the correct new partition list/choice options with --help. (y)
[Android Software/Hacking General [Developers Only]] tkalfaoglu:
thank you.. all that is needed is where to download and how to install :)
[Android Software/Hacking General [Developers Only]] Lughnasadh:
All the information is provided in the OP (1st 3 posts)
[Android Software/Hacking General [Developers Only]] rodken:
Can you provide a short list of what Nexus/Pixel/Android One features and apps this module provides?
[Android Software/Hacking General [Developers Only]] lebigmac:
Hi @osm0sis thanks for sharing your great tools with the open source community.

Could you please tell me what could be causing unknown error 255 in this screenshot? It doesn't seem to be caused by my update-binary itself. I know that error 255 in bash is equivalent to -1 in c++

Do you think it could have anything to do with the missing digest file? This error doesn't seem to occur in recoveries that have the ability to skip the digest file check.

Could you please share a default digest file template with me? I've got no clue what a TWRP digest file is supposed to look like and more information about it is scarce online.

Thank you for your assistance. Keep up the great work!
[Android Software/Hacking General [Developers Only]] osm0sis:
The ones I know/care about are kinda already mentioned: you get access to the Recorder app, and Photos app extra "Pixel exclusive" features. Dialer back when it wasn't widely rolled out. I'm sure there are more apps and features which I haven't noticed. Report back if you find any. 😉

A Digest file is just a .md5 or .sha2 file with the checksum of the zip in question.

The only TWRP that "enforced" the Digest check was 3.5.1 I believe, and that was a bug, and why we got 3.5.2 so quickly.

You could still work around it by going into settings and disabling Digest Verification of backups (since the options were also erroneously tied together).

No promises that's what your actual issue is, however, since what you really need to post is the /tmp/recovery.log, not a screenshot, to maybe have more of an idea what's going on with a zip error.
[Android Software/Hacking General [Developers Only]] HippoMan:
I want to find the mapping of my /dev/block partitions into the standard names of /data, /system, /boot, and /vendor.

On my device, there are system_{a,b}, boot_{a,b}, and vendor_{a,b} in /dev/block/by-name, and I think it's clear that these are mapped to /system, /boot, and /vendor. However, I don't know what items in /dev/block/by-name would end up being mapped to /data.

Is there some way to determine, on any given device, what exact items that are listed in /dev/block/by-name (or the particular device's equivalent directory) would be mapped to /data, /system, /boot, and /vendor?

The reason i want to know this is because I want to write my own dd-based backup and restore scripts that can take the place of TWRP's nandroid backup and restore. I want this because TWRP isn't working under Android 11 in many cases, and I'd like to be able to do the equivalent of nandroid backup/restore under A11.

Thank you for any tips and pointers.
[Android Software/Hacking General [Developers Only]] DiamondJohn:
TeMeFI has a heap of partition info under Device Details>Partition Info and Device Details>Block Details
[Android Software/Hacking General [Developers Only]] HippoMan:
Thank you!

Maybe I'm missing something, but I haven't found any info in TeMeFI's Partition Info or Block Details that will tell me which item(s) in /dev/block/by-name or /dev/block/mapper point to /data.

I can do an ls -l in /dev/block/mapper from a root session in a terminal which says that dm-2 points to userdata. Is userdata what gets mapped to /data?

And anyway, that is only specific to my device and the OS I'm running. Is there some programmatic method that will work on any Android device to figure out how the /dev/block stuff gets mapped to the standard partitions such as /data, /system, /boot, /vendor, etc. on that device? Or does this have to be done manually, by inspection, on every device? Maybe inspection is the only way, and if so, that would explain, in part, why there is not a generic TWRP that runs on all devices.
[Android Software/Hacking General [Developers Only]] BillGoss:
The mount command will show you what's mounted and where.

Backing up /data is problematic because:

1. It's encrypted, and

2. It also includes the user data (/data/media/0 aka /sdcard)
[Android Software/Hacking General [Developers Only]] HippoMan:
Thank you again. I have already looked at mount, both from the command line and also in TeMeFI. And now I see that I had overlooked the /dev/block/dm-2 => /data mount from both of those sources.

And now I understand better why /data can be problematic. I am perfectly happy to back up and restore /sdcard, but the encryption/decryption will indeed be a challenge. But maybe I can figure it out.
[Android Software/Hacking General [Developers Only]] HippoMan:
Hmm ... maybe /data isn't so problematic, after all. If I do the following (given that dm-2 maps to /data) ...

dd if=/dev/block/dm-2 of=./foobar

... will the following work later on to restore /data?

dd if=./foobar of=/dev/block/dm-2

I don't care that the foobar file would contain encrypted data, as long as I can successfully write it back to /dev/block/dm-2 at a later date.
[Android Software/Hacking General [Developers Only]] BillGoss:
I personally wouldn't try that. I've always thought that the dm* partitions weren't actual, physical partitions. It seemed to me that they were dynamic partitions created on the fly.

But, I may be wrong.
[Android Software/Hacking General [Developers Only]] DiamondJohn:
And I understand that you already know this, but for others, TeMeFI's mounts command is a simple toybox mounts command.

If you are trying to backup your data partition (off your phone) using a script, could you not use pull commands to get each individual files (unencrypted) and a ls -l -R to get the permissions, ownership and group info.

I would also investigate if you tar the files into a single tar file (part of toybox), that tar file would be un-encrypted, when pulled off the device. I think the tar file would also have the permissions etc stored in the file. Kinda like a live TWRP process. Looking at the GuitHub of TWRP may give you an in-road; even may help with determining the partitions you are interested in.
[Android Software/Hacking General [Developers Only]] osm0sis:
The problem with trying to use the basic tar command for Android backups is it loses capabilities, I think SELinux contexts, and possibly other things. TWRP uses a special updated libtar for backups which keeps all of that important extra info.
[Android Software/Hacking General [Developers Only]] HippoMan:
Thank you very much. I'd love to get my hands on that libtar! I'm going to the TWRP github to see if I can find it.
[Android Software/Hacking General [Developers Only]] HippoMan:
Thank you. And I will see if that special libtar which TWRP uses can help me.

Another thought: Android offers some sort of cloud-based backup. I always quickly disable this when installing a ROM, so I don't know what it actually backs up. If it does the equivalent of a nandroid /data backup, then perhaps I can find the software which performs that backup and modify it for my non-cloud purposes.

Of course, I want to back up /boot, /system, and probably /vendor, as well, and I doubt that this Android cloud backup does that.
[Android Software/Hacking General [Developers Only]] lebigmac:
@HippoMan

If you want to backup /system, /vendor and /product just dump the super partition ;) (Android 10+)

And for backing up /data can't you just pull /dev/block/by-name/userdata and restore it back later on?
[Android Software/Hacking General [Developers Only]] HippoMan:
Thank you. My understanding (which at this point is still sketchy and may be incorrect) is that the dynamic aspect of the dm* and other similar partitions is managed via the symlinks in /dev/block/mapper and /dev/block/by-name (or in other similar locations, depending on the device and the OS). I'm guessing that as long as I follow those symlinks, I will get to the actual physical partitions.
[Android Software/Hacking General [Developers Only]] HippoMan:
Thank you very much. Isn't the super partition just a construct that's utilized during boot and maybe recovery, but not when booted into system? I don't see such a partition now when I'm running in system.

As for userdata, that's what the dm-2 symlink points to on my device. Would every 10+ device have a partition called "userdata", or is that device-or-OS-specific?
[Android Software/Hacking General [Developers Only]] osm0sis:
It's been called userdata since at least Ice Cream Sandwich, if not before. 👍
[Android Software/Hacking General [Developers Only]] 3mel:
a little help needed for virgin newbie. I have a cheap Chinese TV box that I have rooted with magisk 21.4 and I've installed the...

ADB Fastboot for Android NDK module.

am I right in thinking I should be able to use this with Termux terminal to run ADB commands on device ?

the daemon does run but I'm hitting a wall. ADB devices always brings back an IP address with a port number and then another port number.

List of devices attached
127.0.0.1:5555 device
192.168.0.41:5555 device
emulator-5554 device

I'm trying to install an apk I deleted stupidly from system/priv it's actually play store because this garbage device wouldn't update it no what I tried thru normal means.

when trying to reinstall a backed up copy of the apk I get.

error more than one device/emulator
error more than one device/emulator
Performing Push Install
adb: error: failed to get feature set: more than one device/emulator
255|:/data/data/com.termux/files/home #

am I missing something, doing something wrong or is that my cheap TV boxes thrown together kanged pixel firmware is just garbage ?

also of note (maybe) is if I turn off the Wi-Fi on the box 192.168.0.41:5555 shows as offline but there are still more than one device/emulator as far Termux is considered.

any and all help greatly appreciated thanks
[Android Software/Hacking General [Developers Only]] HippoMan:
Thank you!
[Android Software/Hacking General [Developers Only]] ipdev:
Hi.

The ADB & Fastboot for Android NDK module installs the binary files so you can run the adb or fastboot command from a terminal on the device.

No different than if you download and install platform-tools on your computer.

If you install it on your TV Box, you can use the adb and fastboot commands like you do from a computer.

You could use your TV Box to fastboot flash a boot image to your phone for example.​

This post got way too long and a bit OT, so I hid most of it.

If you use adb to install PlayStore, it would be installed to userdata not system.

To get it back in system/priv-app/ you will need to manually put it there and correct the permissions.

Take a look at similar files in system/priv-app to see what the permissions should be.

ls -lZ will show the file permission, user, group and selinux.

Example.

bonito:/product/priv-app/PrebuiltGmsCore # ls -lZ PrebuiltGmsCore.apk
-rw-r--r-- 1 root root u:object_r:system_file:s0 90763369 2008-12-31 18:00 PrebuiltGmsCore.apk

Running adb devices on my Pixel 3aXL without another device attached, returns

Does not matter what terminal app I use or even if I run the command adb on device from an adb shell.

adb devices
List of devices attached

Running adb devices on my Pixel 3aXL with my 4a connected, it returns

adb devices
List of devices attached
TheDeviceID device

I do not know were emulator-5554 device is coming from, besides the fact that it is on port 5554.

127.0.01 is localhost

There is no place like home ;)

192.168.0.41 is the TV Box

I am guessing you run your local network on 192.168.0.x (I start my DHCP server at 192.168.0.10)

Not sure why both are showing but they are coming from the same port, 5555 so that might be causing an issue.

To be able to connect to your TV Box with adb, you need to enable adb on the TV Box.

Normally somewhere in the settings menu(s).

If no option is available, you can try setting the props manually using Magisk's resetprop and/or setprop command.

This may change depending on device/system. If the prop does not exist, you will need to use setprop instead of resetprop.

resetprop ro.adb.secure 0
resetprop ro.secure 0
resetprop ro.debuggable 1

On miui, without being logged into my mi account, I had to add two persist props.

setprop persist.security.adbinput 1
setprop persist.security.adbinstall 1

Unless I misunderstood your post and you are trying to connect to your TV Box using adb from another device with the adb-fastboot module installed. ?

Hope it helps more than confuse.

Cheers. :cowboy:
[Android Software/Hacking General [Developers Only]] 3mel:
@ipdev thanks for your reply. reading thru this it seems yes I was doing something very wrong i.e. thinking it was all on one device, no server and client.

I think I'll have to try using the controversial app I paid for that uses this code otherwise I'll have to order a USB A male to USB A male lead (no PC).

is playstore OK as a user app ? I have no problem with that if it works. I tried copying the apk back to system/priv but it shows as 0Bs
[Android Software/Hacking General [Developers Only]] osm0sis:
Sounds like your TV box already has adb over WiFi enabled. That's why both IPs show, since localhost and your network IP are both the same device.

You should be able to just adb connect <ip> on the device from a command prompt without using any sketchy apps that stole my and Surge's sh*t.

Basically you just needed to type adb and read the help printed to know how to send commands to the specific device since you'll always have at least 2 listed.
[Android Software/Hacking General [Developers Only]] rezapatel:
All sounds good here, but can you share how to do #4 (dump the updated boot image without rebooting after update or going to fastboot mode)? Thanks!
[Android Software/Hacking General [Developers Only]] osm0sis:
You can use my Fla**** package and FX File Explorer, for one. 👍
[Android Software/Hacking General [Developers Only]] rezapatel:
Thanks. Will check it out.

Also hypothetically, I am wondering if this process should also work?

- Uninstall magisk via the app

- Restart to ensure, I'm unrooted and then do an OTA incremental update to the latest one

- After the OS has been upgraded, follow the steps to root the boot dump file using fastboot and the broken twrp for Oneplus 8T

2 things I'm worried about are -

1) if I uninstall Magisk via the app, does it fully unroot and allows incremental OTA?

2) will the broken twrp for Oneplus 8T be compatible with the latest OOS 11.0.8.13?

Thanks!
[Android Software/Hacking General [Developers Only]] AndDiSa:
@rezapatel I was doing so for quite some time with my pixel 3a ... there is only one disadvantage with unrooting / taking the OTA and rooting again:

for the time you are unrooted SafetyNet will fail / apps (especially bank apps) may detect that and cache that imformation. This may lead to failing apps even if you root again later ...
[Android Software/Hacking General [Developers Only]] rezapatel:
It requires flashing it via recovery, unfortunately, no working twrp for the 8T..
[Android Software/Hacking General [Developers Only]] rezapatel:
Uh, yes, makes sense .. but I'm ok with that, even if I have to wipe the dalvik/cache once after rooting. Thanks for giving me the confidence to attempt it :)
[Android Software/Hacking General [Developers Only]] rezapatel:
Yep, worked like a charm! :)
[Android Software/Hacking General [Developers Only]] osm0sis:
That's why my method then uses airplane mode to avoid SafetyNet ever "seeing" you were briefly unrooted.👌

My instructions post already says all this. 😛

You can flash it in the Magisk app as well using the manual install button on the Modules page. 😉