How to infuse/push/modify/install busybox SU in twrprecovery.img for getting root privilages commands?


Question

Question :How to infuse/push/modify/install busybox SU in twrprecovery.img for getting root privilages commands


I want to take backup restore flash change some PM Package management and SM storage Management settings of my android 5.1.1 /6.0 mobile phone through adb shell commands or through twrp terminal without installing twrp or SU or rooting mobile device



  1. Firstly I want to take backup of mobile system.img userdata.img through adb pull command and then recover write back adb push


My concerns related to first :


a. As adb pull reads and copy data but adb push writes on the device
b. Will adb push work without rooting mobile phone without root privilages.

c. If phone bricked or something gets wrong while rooting and phone is not rooted then will adb push work or not.


Steps of commands using for backup of device
Adb devices
adb reboot bootloader
adb pull /dev/block/mmcblk0 mmcblk0.img
Adb push mmcblk0.img /dev/block/mmcblk0 mmcblk0.img


  1. Using PM package manager on unrooted mobile android 5.1.1 with following commands but error


    Adb devices
    adb reboot bootloader
    adb shell pm set-install-location 2
    adb shell pm get-install-location




Error of command



/sbin/sh: pm: not found



what I understood from above error means that PM binary command file is not available in /sbin/sh/ folder as phone is not rooted so what I think if I put these binary files or install busybox within twrprecovery.img before loading and run temporary pm command so that I don't have to root the device and temporary set the changes in device.


If it's possible then kindly share the link for step by step procedure
for modifying twrprecovery.img before booting in pc computer windows as I am new novice to adb shell Linux commands



  1. Thirdly As whenever I run SM storage manager command adb shell following command on unrooted android 6.0 mobile from it gives following errors


    Adb devices
    adb reboot bootloader
    adb shell sm has-adoptable
    adb shell sm set -force- adoptable true




It gives following errors



/sbin/sh: sm: not found



what I understood from above error means that SM binary command file is not available in /sbin/sh/ folder as phone is not rooted so what I think if I put these binary files or install busybox within twrprecovery.img before loading and run temporary pm command so that I don't have to root the device and temporary set the changes in device.


If it's possible then kindly share the link for step by step procedure for modifying Twrprecovery.img before booting in pc windows as I am new novice to adb shell Linux commands



  1. Now if boot in fastboot mode and run twrprexovery.img or cwgmod recovery.img with these commands and then in twrp or cgmod terminal windows can I run busybox or Super user or PM SM command


    Adb devices
    Adb boot bootloader
    Fastboot boot twrprecovery.img



  2. Secondly the whole ideas is that I want to virtually temporary use twrp terminal with busybox or Super user binary to execute services packages like PM (package manager) SM (storage manager) within from twrp recovery menu terminal (loaded in fastboot boot twrprecovery.img mode). Or adb sideload If it's possible technically feasable. If yes then can we modify twrprexovery.img and infuse insert busybox in it before loading or after loading.




twrp adb sideload or teminal



  1. Thirdly I don't want to install twrp or busybox or any super user binary file inside mobile device and don't want to install anything inside mobile except the changes alteration of settings done after execution of SM PM commands. That is I want to execute PM SM from within twrprecovery.img


Answer


  1. a) adb pull requires root access. This can be achieved by running custom recovery like TWRP.

    b) adb push works the same way like adb pull and requires root access (without rooting android).

    c) adb daemon only works on booted kernel (android or recovery) therefore not on bricked devices.


    Warning: Never write whole mmcblk0 because this contains bootloader and little kernel, therefore fastboot will not work in case you bricked!


    Backup every partition on it's own instead. you will get a full list of symlinks to all partitions from adb


    adb shell ls -l /dev/block/bootdevice/by-name

    commands for raw backup of device (encrypted)


    adb reboot bootloader
    fastboot boot twrp*.img
    adb pull /dev/block/bootdevice/by-name/boot
    adb pull /dev/block/bootdevice/by-name/system
    adb pull /dev/block/bootdevice/by-name/modem
    adb pull /dev/block/bootdevice/by-name/persist
    adb pull /dev/block/bootdevice/by-name/userdata
    ...






  1. Android service Package Manager pm requires java which is not available in recovery mode.

    It might be possible to start java when /system is mounted and even possible to execute pm but still Package Manager will badly crash because of missing framework dependencies.

    Someone could figure out all required services and may be able to start them in right order, but that ends up similar to fully booted android and is not worth the effort.





  1. Android service Storage Manager sm is not available in recovery mode for the same reason.

    Furthermore adoptable-storage isn't available on Android 5.1.1 regardless it is rooted or not.

    It is pointless to copy files like sm.jar from other android version and there is no way to run it from recovery, not even temporary. Integrating adoptable-storage on android 5 will result in compiling custom ROM which requires lot of patience. Anyone who manages this most likely would become a skilled developer during this long troubleshooting period.





  1. su sm pm and busybox are unrelated to each other. None of that tools will help to edit some storage settings in a way to overcome problem 2. + 3.

    Furthermore /data is encrypted and storage settings can not edited -offline- until you decrypt userdata or disable encryption (which requires factory reset and modification of boot).





  1. It is possible to temporary push desired binaries like busybox into RAM while in recovery mode, or permanently integrate it in recovery ramdisk by modification of twrp.img


    Steps for adding busybox into recovery ramdisk



    • download twrp.img

    • download Android.Image.Kitchen.Win32.zip

    • download Busybox.Installer.zip

    • disable antivir heuristic and extract the zip files. make sure Android_Image_Kitchen \ android_win_tools \ sudo.exe is not in quarantine

    • place twrp.img in Android_Image_Kitchen directory

    • open cmd.exe, navigate to directory and execute unpackimg.bat

    • copy busybox-arm-selinux binary into Android_Image_Kitchen \ ramdisk \ sbin directory and rename it busybox

    • execute repackimg.bat







  1. There is no need to root android for doing modifications in boot.img

    you can even install custom init.rc script or init.d shell script without installing su or busybox


    You can write custom mount script for MicroSD Card sdext2 partition. You can even do all the symlinks offline from twrp recovery adb shell commands.

    But this is unusual and over-complicated when one could just install Link2SD as system app and automatized the whole symlink handling.


    However, for more information about creating custom init.rc or init.d script refer to

    How to run an executable on boot and keep it running?




Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes