android-props

POSIX shell script to change "dangerous props" of LineageOS
git clone git://xn--q9jzb1c.xn--q9jyb4c/android-props
Log | Files | Refs | README | LICENSE

android-props.sh (2702B)


      1 #!/usr/bin/env sh
      2 # android-props.sh - Change build.props to bypass app errors (e.g. 'rooted')
      3 # Copyleft, 2023 - nanmi <nanmi@xn--q9jzb1c.xn--q9jyb4c>
      4 # SPDX-License-Identifier: AGPL-3.0-or-later
      5 # This script is currently working on LOS20
      6 
      7 # https://www.reddit.com/r/LineageOS/comments/o2lswm/banking_apps_working_in_lineageos_181/
      8 # Maybe interesting checking for LOS18: /system/etc/prop.default
      9 
     10 DEFAULT_PROP='/system/build.prop' # In LOS18 default.prop is located at /default.prop
     11 BUILD_PROP='/system/build.prop' # In LOS18 build.prop is located at /system/build.prop
     12 GREEN='\033[32;01m'
     13 RED='\033[31;01m'
     14 NORMAL='\033[0m'
     15 
     16 text()
     17 {
     18     case ${?} in
     19         0)
     20             printf "${GREEN}*${NORMAL} %s\n" "${*}"
     21             ;;
     22         *)
     23             printf "${RED}*${NORMAL} %s\n" "${*}" >&2
     24             exit 1
     25     esac
     26 }
     27 
     28 main()
     29 {
     30     # Root is necessary to start adb server
     31     [ "$(id -u)" -eq 0 ] || text "Please, run as root"
     32 
     33     # 0. Start adb server
     34     text "Starting adb server"
     35     { adb start-server; } || text "adb server failed."
     36 
     37     # 1. Root shell needed to edit /system/build.prop
     38     text "Enabling root shell..."
     39     { adb root; } || text "Enable rooted debbuging on developer options."
     40 
     41     # 2. Need to remount / as rw to edit /system/build.prop
     42     text "Remounting..."
     43     { adb remount; } || text "Remount failed."
     44     { adb shell mount -o rw,remount /; } || text "Remount failed."
     45 
     46     # 3. Change ro.secure=0 to ro.secure=1 from /system/build.prop
     47     text "Changing ro.secure to 1..."
     48     { adb shell sed -e '/ro\.secure/s/0/1/' -i "${DEFAULT_PROP}"; } || text "sed failed."
     49 
     50     # 4. Change ro.debuggable=1 to ro.debuggable=0 from /system/build.prop
     51     text "Changing ro.debuggable to 0..."
     52     { adb shell sed -e '/ro\.debuggable/s/1/0/' -i "${DEFAULT_PROP}"; } || text "sed failed."
     53 
     54     # 5. Change ro.build.type=userdebug to ro.build.type=user from /system/build.prop
     55     text "Changing ro.build.type to user..."
     56     { adb shell sed -e '/ro\.build.type/s/debug//' -i "${BUILD_PROP}"; } || text "sed failed."
     57 
     58     # 6. Unroot shell
     59     text "Unrooting shell..."
     60     { adb unroot; } || text "Unroot failed."
     61 
     62     # 7. Kill adb server
     63     text "Killing adb server..."
     64     adb kill-server || text "killing adb server failed."
     65 
     66     printf '\n* %s *\n' 'A reboot is needed to apply the changes.'
     67     printf '%s\n' 'Disable rooted debbuging on developer options.'
     68     printf '%s\n' 'This process needs to be redone after every system update.'
     69     printf '%s\n' 'You can check if everything went right with the app RootBeer Sample.'
     70     printf '%s\n' 'This script makes it pass "Dangerous Props".'
     71     printf '%s\n' 'https://github.com/scottyab/rootbeer'
     72 }
     73 
     74 main "${@}"