cswl / tsu

Gain root shell on Termux.
ISC License
646 stars 155 forks source link

tsu fails on latest magisk canary #76

Open kevin01523 opened 3 years ago

kevin01523 commented 3 years ago
tsu --dbg
+ shift
+ _TSU_CALL=tsu
+ [[ tsu == \s\u\d\o ]]
+ TERMUX_FS=/data/data/com.termux/files
+ TERMUX_PREFIX=/data/data/com.termux/files/usr
+ TERMUX_PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets
+ ROOT_HOME=/data/data/com.termux/files/home/.suroot
+ ANDROID_SYSPATHS=/system/bin:/system/xbin
+ EXTRA_SYSPATHS=/sbin:/sbin/bin
+ BB_MAGISK=/sbin/.magisk/busybox
+ log_DEBUG TSU_AS_SUDO
+ [[ '' == true ]]
+ log_DEBUG _TSU_AS_SUDO
+ [[ -z '' ]]
+ SWITCH_USER=
+ declare -A EXP_ENV
+ log_DEBUG _TSU_AS_SUDO
+ [[ '' == true ]]
+ root_shell_helper
+ log_DEBUG root_shell_helper
+ [[ -n '' ]]
+ log_DEBUG ALT_SHELL
+ [[ '' == \s\y\s\t\e\m ]]
+ [[ -n '' ]]
+ [[ -x /data/data/com.termux/files/home/.termux/shell ]]
+ [[ -x /data/data/com.termux/files/usr/bin/bash ]]
+ ROOT_SHELL=/data/data/com.termux/files/usr/bin/bash
+ env_path_helper
+ log_DEBUG env_path_helper
+ log_DEBUG SWITCH_USER
+ [[ -z '' ]]
+ NEW_HOME=/data/data/com.termux/files/home/.suroot
+ EXP_ENV[PREFIX]=/data/data/com.termux/files/usr
+ EXP_ENV[TMPDIR]=/data/data/com.termux/files/home/.suroot/.tmp
+ EXP_ENV[LD_PRELOAD]=/data/data/com.termux/files/usr/lib/libtermux-exec.so
+ [[ -d /data/data/com.termux/files/home/.suroot/.tmp ]]
+ log_DEBUG _TSU_AS_SUDO
+ [[ '' == true ]]
+ NEW_PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets
+ log_DEBUG LD_LIBRARY_PATH
+ [[ -n '' ]]
+ ASP=/system/bin:/system/xbin:/sbin:/sbin/bin
+ log_DEBUG PREPEND_SYSTEM_PATH
+ [[ -n '' ]]
+ NEW_PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin
+ EXP_ENV[PATH]=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin
+ EXP_ENV[HOME]=/data/data/com.termux/files/home/.suroot
+ EXP_ENV[TERM]=xterm-256color
+ [[ -z true ]]
+ set +x
+ STARTUP_SCRIPT=/data/data/com.termux/files/usr/bin/bash
+ SU_BINARY_SEARCH=("/system/xbin/su" "/system/bin/su")
+ [[ -x /sbin ]]
+ SU_BINARY_SEARCH+=("/sbin/su" "/sbin/bin/su")
+ unset LD_LIBRARY_PATH
+ unset LD_PRELOAD
+ [[ -z '' ]]
++ /sbin/su -v
+ [[ 04c53c35:MAGISKSU == *\M\A\G\I\S\K\S\U ]]
+ su_args=("/sbin/su")
+ [[ -z '' ]]
+ su_cmdline='PATH=/sbin/.magisk/busybox '
+ [[ -n '' ]]
+ su_cmdline+='env -i  PREFIX=/data/data/com.termux/files/usr  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so  HOME=/data/data/com.termux/files/home/.suroot  TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp  ANDROID_DATA=/data  TERM=xterm-256color  ANDROID_ROOT=/system  PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin  /data/data/com.termux/files/usr/bin/bash'
+ su_args+=("-c")
+ exec /sbin/su -c 'PATH=/sbin/.magisk/busybox env -i  PREFIX=/data/data/com.termux/files/usr  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so  HOME=/data/data/com.termux/files/home/.suroot  TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp  ANDROID_DATA=/data  TERM=xterm-256color  ANDROID_ROOT=/system  PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin  /data/data/com.termux/files/usr/bin/bash'
/system/bin/sh: PATH=/sbin/.magisk/busybox env -i  PREFIX=/data/data/com.termux/files/usr  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so  HOME=/data/data/com.termux/files/home/.suroot  TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp  ANDROID_DATA=/data  TERM=xterm-256color  ANDROID_ROOT=/system  PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin  /data/data/com.termux/files/usr/bin/bash: inaccessible or not found

Screenshot_20210116-014433

kevin01523 commented 3 years ago

also it seems that its not limited to termux tried out ktweak same error i think its related to bash

~ $ bash -x $PREFIX/bin/tsu
+ _TSU_VERSION=8.5.1
+ [[ '' == \-\-\d\b\g ]]
+ _TSU_CALL=tsu
+ [[ tsu == \s\u\d\o ]]
+ TERMUX_FS=/data/data/com.termux/files
+ TERMUX_PREFIX=/data/data/com.termux/files/usr
+ TERMUX_PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets
+ ROOT_HOME=/data/data/com.termux/files/home/.suroot
+ ANDROID_SYSPATHS=/system/bin:/system/xbin
+ EXTRA_SYSPATHS=/sbin:/sbin/bin
+ BB_MAGISK=/sbin/.magisk/busybox
+ log_DEBUG TSU_AS_SUDO
+ [[ '' == true ]]
+ log_DEBUG _TSU_AS_SUDO
+ [[ -z '' ]]
+ SWITCH_USER=
+ declare -A EXP_ENV
+ log_DEBUG _TSU_AS_SUDO
+ [[ '' == true ]]
+ root_shell_helper
+ log_DEBUG root_shell_helper
+ [[ -n '' ]]
+ log_DEBUG ALT_SHELL
+ [[ '' == \s\y\s\t\e\m ]]
+ [[ -n '' ]]
+ [[ -x /data/data/com.termux/files/home/.termux/shell ]]
+ [[ -x /data/data/com.termux/files/usr/bin/bash ]]
+ ROOT_SHELL=/data/data/com.termux/files/usr/bin/bash
+ env_path_helper
+ log_DEBUG env_path_helper
+ log_DEBUG SWITCH_USER
+ [[ -z '' ]]
+ NEW_HOME=/data/data/com.termux/files/home/.suroot
+ EXP_ENV[PREFIX]=/data/data/com.termux/files/usr
+ EXP_ENV[TMPDIR]=/data/data/com.termux/files/home/.suroot/.tmp
+ EXP_ENV[LD_PRELOAD]=/data/data/com.termux/files/usr/lib/libtermux-exec.so
+ [[ -d /data/data/com.termux/files/home/.suroot/.tmp ]]
+ log_DEBUG _TSU_AS_SUDO
+ [[ '' == true ]]
+ NEW_PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets
+ log_DEBUG LD_LIBRARY_PATH
+ [[ -n '' ]]
+ ASP=/system/bin:/system/xbin:/sbin:/sbin/bin
+ log_DEBUG PREPEND_SYSTEM_PATH
+ [[ -n '' ]]
+ NEW_PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin
+ EXP_ENV[PATH]=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin
+ EXP_ENV[HOME]=/data/data/com.termux/files/home/.suroot
+ EXP_ENV[TERM]=xterm-256color
+ [[ -z '' ]]
+ EXP_ENV[ANDROID_ROOT]=/system
+ EXP_ENV[ANDROID_DATA]=/data
+ ENV_BUILT=
+ for key in "${!EXP_ENV[@]}"
+ ENV_BUILT=' PREFIX=/data/data/com.termux/files/usr '
+ for key in "${!EXP_ENV[@]}"
+ ENV_BUILT=' PREFIX=/data/data/com.termux/files/usr  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so '
+ for key in "${!EXP_ENV[@]}"
+ ENV_BUILT=' PREFIX=/data/data/com.termux/files/usr  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so  HOME=/data/data/com.termux/files/home/.suroot '
+ for key in "${!EXP_ENV[@]}"
+ ENV_BUILT=' PREFIX=/data/data/com.termux/files/usr  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so  HOME=/data/data/com.termux/files/home/.suroot  TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp '
+ for key in "${!EXP_ENV[@]}"
+ ENV_BUILT=' PREFIX=/data/data/com.termux/files/usr  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so  HOME=/data/data/com.termux/files/home/.suroot  TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp  ANDROID_DATA=/data '
+ for key in "${!EXP_ENV[@]}"
+ ENV_BUILT=' PREFIX=/data/data/com.termux/files/usr  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so  HOME=/data/data/com.termux/files/home/.suroot  TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp  ANDROID_DATA=/data  TERM=xterm-256color '
+ for key in "${!EXP_ENV[@]}"
+ ENV_BUILT=' PREFIX=/data/data/com.termux/files/usr  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so  HOME=/data/data/com.termux/files/home/.suroot  TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp  ANDROID_DATA=/data  TERM=xterm-256color  ANDROID_ROOT=/system '
+ for key in "${!EXP_ENV[@]}"
+ ENV_BUILT=' PREFIX=/data/data/com.termux/files/usr  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so  HOME=/data/data/com.termux/files/home/.suroot  TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp  ANDROID_DATA=/data  TERM=xterm-256color  ANDROID_ROOT=/system  PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin '
+ [[ -z '' ]]
+ STARTUP_SCRIPT=/data/data/com.termux/files/usr/bin/bash
+ SU_BINARY_SEARCH=("/system/xbin/su" "/system/bin/su")
+ [[ -x /sbin ]]
+ SU_BINARY_SEARCH+=("/sbin/su" "/sbin/bin/su")
+ unset LD_LIBRARY_PATH
+ unset LD_PRELOAD
+ [[ -z '' ]]
++ /sbin/su -v
+ [[ 04c53c35:MAGISKSU == *\M\A\G\I\S\K\S\U ]]
+ su_args=("/sbin/su")
+ [[ -z '' ]]
+ su_cmdline='PATH=/sbin/.magisk/busybox '
+ [[ -n '' ]]
+ su_cmdline+='env -i  PREFIX=/data/data/com.termux/files/usr  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so  HOME=/data/data/com.termux/files/home/.suroot  TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp  ANDROID_DATA=/data  TERM=xterm-256color  ANDROID_ROOT=/system  PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin  /data/data/com.termux/files/usr/bin/bash'
+ su_args+=("-c")
+ exec /sbin/su -c 'PATH=/sbin/.magisk/busybox env -i  PREFIX=/data/data/com.termux/files/usr  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so  HOME=/data/data/com.termux/files/home/.suroot  TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp  ANDROID_DATA=/data  TERM=xterm-256color  ANDROID_ROOT=/system  PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin  /data/data/com.termux/files/usr/bin/bash'
/system/bin/sh: PATH=/sbin/.magisk/busybox env -i  PREFIX=/data/data/com.termux/files/usr  LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so  HOME=/data/data/com.termux/files/home/.suroot  TMPDIR=/data/data/com.termux/files/home/.suroot/.tmp  ANDROID_DATA=/data  TERM=xterm-256color  ANDROID_ROOT=/system  PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin  /data/data/com.termux/files/usr/bin/bash: inaccessible or not found

@cswl

DaleBCooper commented 3 years ago

This bug is fixed in latest Magisk release 21.4.