newbit1 / rootCROS

24 stars 1 forks source link

Can not launch android apps after reboot #2

Closed deadpixel134 closed 2 years ago

deadpixel134 commented 2 years ago

Hello! I'm looking for the way to root android subsystem in brunch framework about 3~4 days and I found this repo.

I've tried this repo's rootCROS.sh, and It didn't work.

After I execute rootCROS.sh and reboot, Android subsystem is kinda broken I think.

I'll post my shell text , and thank you in advance!

(Rammus ChromeOS 93)

crosh> shell

chronos@localhost / $ adb devices

List of devices attached

* daemon not running; starting now at tcp:5037

* daemon started successfully

emulator-5554   device

chronos@localhost / $ cd $PORTAGE_CONFIGROOT && sudo su

We trust you have received the usual lecture from the local System

Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.

    #2) Think before you type.

    #3) With great power comes great responsibility.

localhost /usr/local # curl -LO https://raw.githubusercontent.com/newbit1/rootCROS/master/rootCROS.sh

localhost /usr/local # cd crosswork

bash: cd: crosswork: No such file or directory

localhost /usr/local # bash ./rootCROS.sh

[-] Moving to the location /usr/local/crosswork

[*] Re-Execute the script proper

bash: /usr/local/crosswork/./rootCROS.sh: Permission denied

bash: line 0: exec: /usr/local/crosswork/./rootCROS.sh: cannot execute: Permission denied

localhost /usr/local # cd /usr/local/crosswork

localhost /usr/local/crosswork # ls -l

total 16

-rw-r--r--. 1 root root 14693 Oct 27 17:29 rootCROS.sh

localhost /usr/local/crosswork # chmod +x rootCROS.sh

localhost /usr/local/crosswork # ls -l

total 16

-rwxr-xr-x. 1 root root 14693 Oct 27 17:29 rootCROS.sh

localhost /usr/local/crosswork # bash ./rootCROS.sh

PWD=/usr/local/crosswork

[-] Downloading rootAVD.sh

################################################################################################################################################################# 100.0%################################################################################################################################################################# 100.0%

[*] Downloading Magisk.zip

################################################################################################################################################################# 100.0%################################################################################################################################################################# 100.0%

[-] Downloading busybox

################################################################################################################################################################# 100.0%################################################################################################################################################################# 100.0%

rm: cannot remove '/usr/local/crosswork/ramdisk.img': No such file or directory

[*] Init ADB

[*] Creating fake ramdisk.img

[*] Cleaning up the ADB working space

[*] Creating the ADB working space

rootAVD.sh: 1 file pushed. 68.5 MB/s (7825022 bytes in 0.109s)

ramdisk.img: 1 file pushed. 20.4 MB/s (1026136 bytes in 0.048s)

Magisk.zip: 1 file pushed. 66.9 MB/s (6874374 bytes in 0.098s)

[!] We are in a ChromeOS shell

[-] Api Level Arch Detect

[-] Device Platform: x64

[-] ARCH32 x86

[-] Device SDK API: 28

[-] First API Level: 28

[-] Switch to the location of the script file

[*] Extracting busybox from script ...

[!] Found a working busybox Binary: 

[!] BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.

[*] Extracting Magisk.zip ...

[-] Checking AVDs Internet connection...

[!] AVD is online

[!] Checking available Magisk Versions

[?] Choose a Magisk Version to install and make it local

[1] Local '23.0' (ENTER)

[2] Canary d7e7df3b(23010)

[3] Stable 23.0

[4] Alpha b6298f86-alpha(23001)

[1] You choose Magisk Local Version '23.0'

[*] Re-Run rootAVD in Magisk Busybox STANDALONE (D)ASH

[!] We are in a ChromeOS shell

[-] We are now in Magisk Busybox STANDALONE (D)ASH

[*] rootAVD with Magisk '23.0' Installer

[-] Get Flags

[*] System-as-root, keep dm/avb-verity

[-] Encrypted data, keep forceencrypt

[*] RECOVERYMODE=false

[-] KEEPVERITY=true

[*] KEEPFORCEENCRYPT=true

[*] No 64-Bit Binarys found, please consider Magisk Alpha

[-] copy all x86 files from /data/data/com.android.shell/Magisk/lib/x86 to /data/data/com.android.shell/Magisk

[*] Detecting ramdisk.img compression

[!] Ramdisk.img uses gzip compression

[-] taken from shakalaca's MagiskOnEmulator/process.sh

[*] executing ramdisk splitting / extraction / repacking

[*] After decompressing ramdisk.img, magiskboot will work

Detected format: [gzip]

[-] Test patch status and do restore

[-] Checking ramdisk status

[-] STATUS=0

[-] Stock boot image detected

[-] Patching ramdisk

[*] adding overlay.d/sbin folders to ramdisk

Loading cpio: [ramdisk.cpio]

Create directory [overlay.d] (0750)

Create directory [overlay.d/sbin] (0750)

Dump cpio: [ramdisk.cpio]

[!] PATCHFSTAB=false

[!] Skipping fstab.ranchu patch with /dev/block/sda

[?] If you want fstab.ranchu patched, Call rootAVD with PATCHFSTAB

[!] AddRCscripts=false

[!] Skip adding *.rc scripts into ramdisk.img/sbin/*.rc

[?] If you want *.rc scripts added into ramdisk.img/sbin/*.rc, Call rootAVD with AddRCscripts

[!] patching the ramdisk with Magisk Init

Loading cpio: [ramdisk.cpio]

Add entry [init] (0750)

Add entry [overlay.d/sbin/magisk32.xz] (0644)

Add entry [overlay.d/sbin/magisk64.xz] (0644)

Patch with flag KEEPVERITY=[true] KEEPFORCEENCRYPT=[true]

Loading cpio: [ramdisk.cpio.orig]

Backup mismatch entry: [init] -> [.backup/init]

Record new entry: [overlay.d] -> [.backup/.rmlist]

Record new entry: [overlay.d/sbin] -> [.backup/.rmlist]

Record new entry: [overlay.d/sbin/magisk32.xz] -> [.backup/.rmlist]

Record new entry: [overlay.d/sbin/magisk64.xz] -> [.backup/.rmlist]

Create directory [.backup] (0000)

Add entry [.backup/.magisk] (0000)

Dump cpio: [ramdisk.cpio]

[*] repacking back to ramdisk.img format

[!] Rename Magisk.zip to Magisk.apk

/data/data/com.android.shell/Magisk/ramdiskpatched4AVD.img: 1 file pulled. 27.4 MB/s (1391882 bytes in 0.048s)

/data/data/com.android.shell/Magisk/Magisk.apk: 1 file pulled. 25.0 MB/s (6874374 bytes in 0.262s)

/data/data/com.android.shell/Magisk/busybox: 1 file pulled. 21.3 MB/s (2214088 bytes in 0.099s)

[*] Trying to install Magisk.apk

Success

[*] cleaning up /usr/local/crosswork/fin

./rootCROS.sh: line 294: unsquashfs: command not found

Make your changes and Enter when finshed to continue

and after this,

Make your changes and Enter when finshed to continue

[*] Patching Overlay with fake ramdisk.img

stat: cannot statx '/usr/local/crosswork/fin/system': No such file or directory

[-] Extracting ramdisk.cpio

BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.

Usage: chmod [-Rcvf] MODE[,MODE]... FILE...

Each MODE is one or more of the letters ugoa, one of the

symbols +-= and one or more of the letters rwxst

        -R      Recurse

        -c      List changed files

        -v      List all files

        -f      Hide errors

BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.

Usage: chmod [-Rcvf] MODE[,MODE]... FILE...

Each MODE is one or more of the letters ugoa, one of the

symbols +-= and one or more of the letters rwxst

        -R      Recurse

        -c      List changed files

        -v      List all files

        -f      Hide errors

BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.

Usage: chmod [-Rcvf] MODE[,MODE]... FILE...

Each MODE is one or more of the letters ugoa, one of the

symbols +-= and one or more of the letters rwxst

        -R      Recurse

        -c      List changed files

        -v      List all files

        -f      Hide errors

BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.

Usage: chmod [-Rcvf] MODE[,MODE]... FILE...

Each MODE is one or more of the letters ugoa, one of the

symbols +-= and one or more of the letters rwxst

        -R      Recurse

        -c      List changed files

        -v      List all files

        -f      Hide errors

BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.

Usage: chmod [-Rcvf] MODE[,MODE]... FILE...

Each MODE is one or more of the letters ugoa, one of the

symbols +-= and one or more of the letters rwxst

        -R      Recurse

        -c      List changed files

        -v      List all files

        -f      Hide errors

BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.

Usage: chmod [-Rcvf] MODE[,MODE]... FILE...

Each MODE is one or more of the letters ugoa, one of the

symbols +-= and one or more of the letters rwxst

        -R      Recurse

        -c      List changed files

        -v      List all files

        -f      Hide errors

BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.

Usage: chmod [-Rcvf] MODE[,MODE]... FILE...

Each MODE is one or more of the letters ugoa, one of the

symbols +-= and one or more of the letters rwxst

        -R      Recurse

        -c      List changed files

        -v      List all files

        -f      Hide errors

BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.

Usage: chmod [-Rcvf] MODE[,MODE]... FILE...

Each MODE is one or more of the letters ugoa, one of the

symbols +-= and one or more of the letters rwxst

        -R      Recurse

        -c      List changed files

        -v      List all files

        -f      Hide errors

BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.

Usage: chmod [-Rcvf] MODE[,MODE]... FILE...

Each MODE is one or more of the letters ugoa, one of the

symbols +-= and one or more of the letters rwxst

        -R      Recurse

        -c      List changed files

        -v      List all files

        -f      Hide errors

BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.

Usage: chmod [-Rcvf] MODE[,MODE]... FILE...

Each MODE is one or more of the letters ugoa, one of the

symbols +-= and one or more of the letters rwxst

        -R      Recurse

        -c      List changed files

        -v      List all files

        -f      Hide errors

BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.

Usage: chmod [-Rcvf] MODE[,MODE]... FILE...

Each MODE is one or more of the letters ugoa, one of the

symbols +-= and one or more of the letters rwxst

        -R      Recurse

        -c      List changed files

        -v      List all files

        -f      Hide errors

BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.

Usage: chmod [-Rcvf] MODE[,MODE]... FILE...

Each MODE is one or more of the letters ugoa, one of the

symbols +-= and one or more of the letters rwxst

        -R      Recurse

        -c      List changed files

        -v      List all files

        -f      Hide errors

BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.

Usage: chmod [-Rcvf] MODE[,MODE]... FILE...

Each MODE is one or more of the letters ugoa, one of the

symbols +-= and one or more of the letters rwxst

        -R      Recurse

        -c      List changed files

        -v      List all files

        -f      Hide errors

BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.

Usage: chmod [-Rcvf] MODE[,MODE]... FILE...

Each MODE is one or more of the letters ugoa, one of the

symbols +-= and one or more of the letters rwxst

        -R      Recurse

        -c      List changed files

        -v      List all files

        -f      Hide errors

BusyBox v1.33.1-Magisk (2021-05-08 15:20:41 PDT) multi-call binary.

Usage: chmod [-Rcvf] MODE[,MODE]... FILE...

Each MODE is one or more of the letters ugoa, one of the

symbols +-= and one or more of the letters rwxst

        -R      Recurse

        -c      List changed files

        -v      List all files

        -f      Hide errors

chown: unknown user/group 0755:u:object_r:magisk_exec:s0

chown: unknown user/group 0755:u:object_r:magisk_exec:s0

chown: unknown user/group 0755:u:object_r:system_file:s0

chown: unknown user/group 0755:u:object_r:system_file:s0

chown: unknown user/group 0755:u:object_r:system_file:s0

chown: unknown user/group 0755:u:object_r:system_file:s0

chown: unknown user/group 0755:u:object_r:system_file:s0

chown: unknown user/group 0755:u:object_r:system_file:s0

chown: unknown user/group 0755:u:object_r:magisk_file:s0

[*] Injecting Magisk into init.rc

[*] create Backup File of /etc/selinux/arc/policy/policy.30

[*] Inject SELinux with Magisk built-in rules via ADB

/data/data/com.android.shell/Magisk/policy.30.magisk: 1 file pulled. 236.9 MB/s (910448 bytes in 0.004s)

/data/data/com.android.shell/Magisk/sepolicy.magisk: 1 file pulled. 175.4 MB/s (579742 bytes in 0.003s)

[!] Set Permissions and Context from

[-] /etc/selinux/arc/contexts/files/file_contexts to /etc/selinux/arc/policy/policy.30

[*] Change Owner:Group to 0:0

[-] Change Mod to 0644

[*] Change Context to u:object_r:cros_selinux_config_file:s0

[!] Set Permissions and Context from

[-] /usr/local/crosswork/fin/sepolicy to /usr/local/crosswork/fin/sepolicy.magisk

stat: cannot statx '/usr/local/crosswork/fin/sepolicy': No such file or directory

stat: cannot statx '/usr/local/crosswork/fin/sepolicy': No such file or directory

[*] Change Owner:Group to :

stat: cannot statx '/usr/local/crosswork/fin/sepolicy': No such file or directory

stat: cannot statx '/usr/local/crosswork/fin/sepolicy': No such file or directory

stat: cannot statx '/usr/local/crosswork/fin/sepolicy': No such file or directory

[-] Change Mod to 

stat: cannot statx '/usr/local/crosswork/fin/sepolicy': No such file or directory

chmod: missing operand after '/usr/local/crosswork/fin/sepolicy.magisk'

Try 'chmod --help' for more information.

stat: cannot statx '/usr/local/crosswork/fin/sepolicy': No such file or directory

[*] Change Context to 

chcon: failed to get security context of '/usr/local/crosswork/fin/sepolicy': No such file or directory

[*] create Backup File of /opt/google/containers/android/system.raw.img

[-] Generating SquashFS with Magisk

rm: cannot remove '/opt/google/containers/android/system.raw.img': No such file or directory

./rootCROS.sh: line 470: mksquashfs: command not found

[*] Set Magisk SquashFS System

[*] Change Context to u:object_r:cros_system_file:s0

chcon: cannot access '/opt/google/containers/android/system.raw.img': No such file or directory

[*] cleaning up /usr/local/crosswork/fin

localhost /usr/local/crosswork # 

When I reboot after this, It can't open up android apps.

crosh> shell

chronos@localhost / $ adb devices

List of devices attached

chronos@localhost / $ cd ~/Downloads

chronos@localhost ~/Downloads $ sudo su

localhost /home/chronos/user/Downloads # bash root.sh

root.sh: warning: root.sh: warning: script from noexec mount; see https://chromium.googlesource.com/chromiumos/docs/+/master/security/noexec_shell_scripts.md

Beta Rooting script for Android on Chrome OS v80+ installed with Brunch

Version 0.10

Beta script to inject SuperSU files in an Android Container on Chrome OS v80+

Part 1 of 2

only INTEL CPU and Chrome OS v80+ stable tested

This script expects the x86 and common folders from the SuperSU zip to be extracted to separate folders in Downloads.

Be aware that modifying the system partition could cause automatic updates to fail, may result in having to powerwash or restore from USB potentially causing loss of data! Please make sure important files are backed up.

Error!

System.raw.img not found

localhost /home/chronos/user/Downloads # cd /usr/local

localhost /usr/local # cd crosswork

localhost /usr/local/crosswork # ls -l

total 26196

-rw-r--r--. 1 root root 6874374 Oct 27 16:58 Magisk.apk

-rw-r--r--. 1 root root 6874374 Oct 27 16:55 Magisk.zip

-rwxr-xr-x. 1 root root 2214088 Oct 27 16:58 busybox

-rw-r--r--. 1 root root 3007092 Oct 27 16:59 ramdisk.cpio

-rwxr-xr-x. 1 root root 7825022 Oct 27 16:55 rootAVD.sh

-rwxr-xr-x. 1 root root   14693 Oct 27 17:08 rootCROS.sh

localhost /usr/local/crosswork # 

1

newbit1 commented 2 years ago

Sorry for my late response. Thank you for using this script. Did you meet all the Preconditions? Especially mount -o remount,rw / ?

The scirpt was written for ChromeOS R90 Stable Rammus. So I can't promise it will work with other Versions too.

deadpixel134 commented 2 years ago

I don't know much about linux, so I didn't know mount -o remount,rw / works or not. but I thought there's no error message so It worked.

If you tell me how to check mount -o remount,rw / worked or what I should do make this command works, I'll do that with pleasure.

Sorry for noob's basic question.

newbit1 commented 2 years ago

In ChromeOS you have 2 overlayed Anroid/Linux Systems. The outer Linux that mounts/starts the inner Android system. In order to get root installed on Android, you must be already root on the outer Linux in order to mount Linux in a writable state. To check this, you run this command mount -o remount,rw / If this works for you, which I guess is default in Brunch, you should be good to go. You can try to bring you System.raw.img back. ctrl+alt+t -> crosh> shell

cd $PORTAGE_CONFIGROOT && sudo su
curl -LO https://raw.githubusercontent.com/newbit1/rootCROS/master/rootCROS.sh
export restore=true
bash ./rootCROS.sh
reboot

If this works for you, you can try again.

cd $PORTAGE_CONFIGROOT && sudo su
curl -LO https://raw.githubusercontent.com/newbit1/rootCROS/master/rootCROS.sh
bash ./rootCROS.sh
reboot
deadpixel134 commented 2 years ago

Well, restore didn't work, so I'm trying to install rammus 90, so I'll write comment after that

localhost ~ # bash ./rootCROS.sh [-] Moving to the location /usr/local/crosswork [] Re-Execute the script proper bash: /usr/local/crosswork/./rootCROS.sh: Permission denied bash: line 0: exec: /usr/local/crosswork/./rootCROS.sh: cannot execute: Permission denied localhost ~ # bash ./rootCROS.sh [-] Moving to the location /usr/local/crosswork [] Re-Execute the script proper bash: /usr/local/crosswork/./rootCROS.sh: Permission denied bash: line 0: exec: /usr/local/crosswork/./rootCROS.sh: cannot execute: Permission denied localhost ~ # cd /usr/local/crosswork localhost /usr/local/crosswork # bash ./rootCROS.sh [] Restore Backup File of /opt/google/containers/android/system.raw.img rm: cannot remove '/opt/google/containers/android/system.raw.img': No such file or directory [] Backup remains [] Restore Backup File of /etc/selinux/arc/policy/policy.30 [] Backup remains localhost /usr/local/crosswork #

newbit1 commented 2 years ago

Ok, my apologies for this inconvenience. I will have a look at Rammus 93 and see If I can update the script.

deadpixel134 commented 2 years ago

I just check out with Rammus 90 and It worked. Thank you for awesome script. I can close this issue at this moment, but I'll leave this by your decision

newbit1 commented 2 years ago

Thanks for your feedback. So this points to a difference between Rammus 90 and 93.

Edit: Is fixed now. It seems the SquashFS Tools are removed from the Brunch R93. So I took them from the R90 and added them to the repo. I've tested it with both Versions Rammus R90 and R93, both are working fine now.