From 98003046ca60c09fccbf8064841c25911854bc84 Mon Sep 17 00:00:00 2001 From: Didgeridoohan Date: Thu, 26 Apr 2018 00:17:32 +0200 Subject: [PATCH] Add files via upload --- README.md | 24 ++++-- common/post-fs-data.sh | 88 +++++++--------------- common/prints.sh | 3 +- common/propsconf_conf | 2 +- common/propsconf_late | 49 ++++++++---- common/util_functions.sh | 156 ++++++++++++++++++++++----------------- config.sh | 25 +++---- module.prop | 4 +- system/binpath/props | 24 +++--- 9 files changed, 194 insertions(+), 181 deletions(-) diff --git a/README.md b/README.md index 6c150f6..42b6ecf 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ To fix this, you can use a known working fingerprint (one that has been certifie There are a few pre-configured certified fingerprints available in the module, just in case you can't get a hold of one for your device. If you have a working fingerprint that could be added to the list, or an updated one for one already on there, please post that in the [module support thread](https://forum.xda-developers.com/apps/magisk/module-magiskhide-props-config-simple-t3765199) toghether with device details. ### Finding a certified fingerprint -The easies way to find a certified fingerprint for your device is to run the getprop command below on a stock ROM/firmware/factory image that fully passes SafetyNet. +If you don't want to use one of the provided fingerprints, the easies way to find a certified fingerprint for your device is to run the getprop command below on a stock ROM/firmware/factory image that fully passes SafetyNet. ``` getprop ro.build.fingerprint ``` @@ -43,13 +43,20 @@ Here's an example: Google Nexus 6=google/shamu/shamu:7.1.1/N8I11B/4171878:user/release-keys ``` +### I still can't pass the ctsProfile check +If you've picked a certified fingerprint from the provided list, or you're using a fingerprint that you know is certified but still can't pass the ctsProfile check, do the following. +- First, do you pass basicIntegrity? If you don't, there's something else going on that this module can't help you with. Take a look under "Miscellaneous MagiskHide issues" below. +- Try a different fingerprint from the provided list. +- Make sure you don't have any remnants from previous root methods that may interfere with the SafetyNet check. A clean install of your system may be required. +- If you can't get things working, make sure to provide logs. See "Logs, etc" below. + ## Current fingerprints list version The fingerprints list will update without the need to update the entire module. Keep an eye on the [module support thread](https://forum.xda-developers.com/apps/magisk/module-magiskhide-props-config-simple-t3765199) for info. Just run the `props` command and the list will be updated automatically. Use the -nw option to disable or disable it completely in the script settings (see below). If you've disabled the this setting you can update the list manually in the `Edit device fingerprint` menu. -**_Current fingerprints list version - v9_** +**_Current fingerprints list version - v10_** ## Improved root hiding - Editing build.prop and default.prop @@ -103,11 +110,11 @@ If you're having issues passing SafetyNet, getting your device certified, or oth But first: have you tried turning it off and on again? Toggling MagiskHide off and on usually works if MagiskHide has stopped working after an update of Magisk or your ROM. -## Support, etc +## Issues, support, etc If you have questions, suggestions or are experiencing some kind of issue, visit the [module support thread](https://forum.xda-developers.com/apps/magisk/module-magiskhide-props-config-simple-t3765199) @ XDA. ### Logs, etc -In case of issues, please provide the logs, saved in /cache, "magisk.log", "propsconf.log" and "propsconf_last.log", together with a detailed description of your problem. Providing the output from terminal might also be useful. +In case of issues, please provide the logs, saved in /cache, "magisk.log", "propsconf.log" and "propsconf_last.log", together with a detailed description of your problem. Providing the output from terminal might also be useful. If you have the latest beta release of Magisk installed, the "magisk_debug.log" is also useful. If there's no new beta released, there's always a beta version of the latest stable Magisk release, so that you can collect the debug log. ## Source @@ -120,6 +127,12 @@ In case of issues, please provide the logs, saved in /cache, "magisk.log", "prop ## Changelog +### v2.1.2 +- Detects and edits only existing device fingerprint props. +- Slightly optimised the boot scripts. +- New fingerprint (Motorola Moto E4), list v10. +- Minor updates and improvements. + ### v2.1.1 - Fixed transferring custom props between module updates. @@ -160,7 +173,7 @@ In case of issues, please provide the logs, saved in /cache, "magisk.log", "prop ## Current fingerprints list -### List v9   +### List v10   - Google Nexus 4 (5.1.1) - Google Nexus 5 (6.0.1) - Google Nexus 6 (7.1.1) @@ -175,6 +188,7 @@ In case of issues, please provide the logs, saved in /cache, "magisk.log", "prop - Google Pixel 2 XL (P DP1) - HTC 10 (6.0.1) - Huawei Mate 10 Pro (8.0.0) +- Motorola Moto E4 (7.1.1) - Motorola Moto G4 (7.0) - Motorola Moto G5 (7.0) - Motorola Moto G5 Plus (7.0) diff --git a/common/post-fs-data.sh b/common/post-fs-data.sh index 0247cac..27e41de 100644 --- a/common/post-fs-data.sh +++ b/common/post-fs-data.sh @@ -34,75 +34,37 @@ log_script_chk "Log start." if [ ! -f "$LATEFILE" ] || [ -f "$RESETFILE" ]; then cp -af $MODPATH/propsconf_late $LATEFILE chmod 755 $LATEFILE - log_handler "Boot script restored/reset (${LATEFILE})." -fi - -# Update placeholders -# Image path -placeholder_update $LATEFILE IMGPATH IMG_PLACEHOLDER $IMGPATH -placeholder_update $MODPATH/system/$BIN/props IMGPATH IMG_PLACEHOLDER $IMGPATH - -# Check the reboot variable -if [ "$(get_file_value $LATEFILE "REBOOTCHK=")" == 1 ]; then - sed -i 's/REBOOTCHK=1/REBOOTCHK=0/' $LATEFILE + if [ -f "$RESETFILE" ]; then + RSTTXT="reset" + else + RSTTXT="restored" + fi + log_handler "Boot script $RSTTXT (${LATEFILE})." fi # Get the current values saved in propsconf_late -orig_values latefile_values - -# Get default file values +# Get default values file_values # Save default file values in propsconf_late -sed -i "s/FILEDEBUGGABLE=\"$LATEFILEDEBUGGABLE\"/FILEDEBUGGABLE=\"$FILEDEBUGGABLE\"/" $LATEFILE -sed -i "s/FILESECURE=\"$LATEFILESECURE\"/FILESECURE=\"$FILESECURE\"/" $LATEFILE -sed -i "s/FILETYPE=\"$LATEFILETYPE\"/FILETYPE=\"$FILETYPE\"/" $LATEFILE -sed -i "s/FILETAGS=\"$LATEFILETAGS\"/FILETAGS=\"$FILETAGS\"/" $LATEFILE -sed -i "s/FILESELINUX=\"$LATEFILESELINUX\"/FILESELINUX=\"$FILESELINUX\"/" $LATEFILE -log_handler "Default file values saved to $LATEFILE." - -# Get the default prop values -curr_values +replace_fn FILEDEBUGGABLE "\"$LATEFILEDEBUGGABLE\"" "\"$FILEDEBUGGABLE\"" $LATEFILE +replace_fn FILESECURE "\"$LATEFILESECURE\"" "\"$FILESECURE\"" $LATEFILE +replace_fn FILETYPE "\"$LATEFILETYPE\"" "\"$FILETYPE\"" $LATEFILE +replace_fn FILETAGS "\"$LATEFILETAGS\"" "\"$FILETAGS\"" $LATEFILE +replace_fn FILESELINUX "\"$LATEFILESELINUX\"" "\"$FILESELINUX\"" $LATEFILE +replace_fn FILEFINGERPRINT "\"$LATEFILEFINGERPRINT\"" "\"$FILEFINGERPRINT\"" $LATEFILE +log_handler "Default values saved to $LATEFILE." -# Save default prop values in propsconf_late -sed -i "s/ORIGDEBUGGABLE=\"$ORIGDEBUGGABLE\"/ORIGDEBUGGABLE=\"$CURRDEBUGGABLE\"/" $LATEFILE -sed -i "s/ORIGSECURE=\"$ORIGSECURE\"/ORIGSECURE=\"$CURRSECURE\"/" $LATEFILE -sed -i "s/ORIGTYPE=\"$ORIGTYPE\"/ORIGTYPE=\"$CURRTYPE\"/" $LATEFILE -sed -i "s/ORIGTAGS=\"$ORIGTAGS\"/ORIGTAGS=\"$CURRTAGS\"/" $LATEFILE -sed -i "s/ORIGSELINUX=\"$ORIGSELINUX\"/ORIGSELINUX=\"$CURRSELINUX\"/" $LATEFILE -sed -i "s@ORIGFINGERPRINT=\"$ORIGFINGERPRINT\"@ORIGFINGERPRINT=\"$CURRFINGERPRINT\"@" $LATEFILE -log_handler "Current prop values saved to $LATEFILE." - -# Checks for the Universal SafetyNet Fix module and similar modules editing the device fingerprint -PRINTMODULE=false -for USNF in $USNFLIST; do - if [ -d "$IMGPATH/$USNF" ]; then - NAME=$(get_file_value $IMGPATH/$USNF/module.prop "name=") - log_handler "'$NAME' installed (modifies the device fingerprint)." - PRINTMODULE=true - fi -done -if [ "$PRINTMODULE" == "true" ]; then - sed -i 's/FINGERPRINTENB=1/FINGERPRINTENB=0/' $LATEFILE - log_handler "Fingerprint modification disabled." -else - sed -i 's/FINGERPRINTENB=0/FINGERPRINTENB=1/' $LATEFILE - if [ "$(get_file_value $LATEFILE "FINGERPRINTENB=")" == 1 ]; then - log_handler "Fingerprint modification enabled." - else - log_handler "Fingerprint modification disabled." - fi -fi +# Checks for configuration file +config_file # Check if original file values are safe orig_safe -# Checks for configuration file -config_file - # Edits build.prop if [ "$(get_file_value $LATEFILE "FILESAFE=")" == 0 ]; then + log_handler "Checking for conflicting build.prop modules." # Checks if any other modules are using a local copy of build.prop BUILDMODULE=false MODID=$(get_file_value $MODPATH/module.prop "id=") @@ -116,9 +78,9 @@ if [ "$(get_file_value $LATEFILE "FILESAFE=")" == 0 ]; then fi done if [ "$BUILDMODULE" == "true" ]; then - sed -i 's/BUILDPROPENB=1/BUILDPROPENB=0/' $LATEFILE + replace_fn BUILDPROPENB 1 0 $LATEFILE else - sed -i 's/BUILDPROPENB=0/BUILDPROPENB=1/' $LATEFILE + replace_fn BUILDPROPENB 0 1 $LATEFILE fi # Copies the stock build.prop to the module. Only if set in propsconf_late. @@ -136,7 +98,7 @@ if [ "$(get_file_value $LATEFILE "FILESAFE=")" == 0 ]; then SEDTYPE="user" fi if [ "$(get_file_value $LATEFILE "SETTYPE=")" == "true" ]; then - sed -i "s/ro.build.type=$FILETYPE/ro.build.type=$SEDTYPE/" $MODPATH/system/build.prop && log_handler "ro.build.type=$SEDTYPE" + replace_fn "ro.build.type" $FILETYPE $SEDTYPE $MODPATH/system/build.prop && log_handler "ro.build.type=$SEDTYPE" fi if [ "$MODULETAGS" ]; then SEDTAGS="$MODULETAGS" @@ -144,7 +106,7 @@ if [ "$(get_file_value $LATEFILE "FILESAFE=")" == 0 ]; then SEDTAGS="release-keys" fi if [ "$(get_file_value $LATEFILE "SETTAGS=")" == "true" ]; then - sed -i "s/ro.build.tags=$FILETAGS/ro.build.tags=$SEDTAGS/" $MODPATH/system/build.prop && log_handler "ro.build.tags=$SEDTAGS" + replace_fn "ro.build.tags" $FILETAGS $SEDTAGS $MODPATH/system/build.prop && log_handler "ro.build.tags=$SEDTAGS" fi if [ "$MODULESELINUX" ]; then SEDSELINUX="$MODULESELINUX" @@ -152,12 +114,12 @@ if [ "$(get_file_value $LATEFILE "FILESAFE=")" == 0 ]; then SEDSELINUX="0" fi if [ "$(get_file_value $LATEFILE "SETSELINUX=")" == "true" ]; then - sed -i "s/ro.build.selinux=$FILESELINUX/ro.build.selinux=$SEDSELINUX/" $MODPATH/system/build.prop && log_handler "ro.build.selinux=$SEDSELINUX" + replace_fn "ro.build.selinux" $FILESELINUX $SEDSELINUX $MODPATH/system/build.prop && log_handler "ro.build.selinux=$SEDSELINUX" fi - if [ "$(get_file_value $LATEFILE "SETFINGERPRINT=")" == "true" ] && [ "$MODULEFINGERPRINT" ]; then - PRINTSTMP="$(cat /system/build.prop | grep "$CURRFINGERPRINT")" + if [ "$MODULEFINGERPRINT" ] && [ "$(get_file_value $LATEFILE "SETFINGERPRINT=")" == "true" ]; then + PRINTSTMP="$(cat /system/build.prop | grep "$FILEFINGERPRINT")" for ITEM in $PRINTSTMP; do - sed -i "s@${ITEM}@$(get_eq_left $ITEM)=${MODULEFINGERPRINT}@" $MODPATH/system/build.prop && log_handler "$(get_eq_left $ITEM)=$MODULEFINGERPRINT" + replace_fn $(get_eq_left $ITEM) $(get_eq_right $ITEM) $MODULEFINGERPRINT $MODPATH/system/build.prop && log_handler "$(get_eq_left $ITEM)=$MODULEFINGERPRINT" done fi else diff --git a/common/prints.sh b/common/prints.sh index cbc9762..6a5a685 100644 --- a/common/prints.sh +++ b/common/prints.sh @@ -3,7 +3,7 @@ # MagiskHide Props Config # By Didgeridoohan @ XDA Developers -PRINTSV=9 +PRINTSV=10 PRINTSTRANSF=1 PRINTSFILE=/sdcard/printslist @@ -24,6 +24,7 @@ Google Pixel 2 XL (8.1.0)=google/taimen/taimen:8.1.0/OPM1.171019.013/4474084:use Google Pixel 2 XL (P DP1)=google/taimen/taimen:P/PPP1.180208.014/4633861:user/release-keys HTC 10 (6.0.1)=htc/HTCOneM10vzw/htc_pmewl:6.0.1/MMB29M/774095.8:user/release-keys Huawei Mate 10 Pro (8.0.0)=HUAWEI/BLA-L29/HWBLA:8.0.0/HUAWEIBLA-L29S/137(C432):user/release-keys +Motorola Moto E4 (7.1.1)=motorola/sperry_sprint/sperry:7.1.1/NCQ26.69-64/68:user/release-keys Motorola Moto G4 (7.0)=motorola/athene/athene:7.0/NPJS25.93-14-13/3:user/release-keys Motorola Moto G5 (7.0)=motorola/cedric/cedric:7.0/NPPS25.137-15-11/11:user/release-keys Motorola Moto G5 Plus (7.0)=motorola/potter_n/potter_n:7.0/NPNS25.137-33-11/11:user/release-keys diff --git a/common/propsconf_conf b/common/propsconf_conf index 4a176a9..9a0ff9b 100644 --- a/common/propsconf_conf +++ b/common/propsconf_conf @@ -40,7 +40,7 @@ CONFWEB=enabled # # CONFPROPS should contain any custom props and the value you want the module to set. # Any props you've previously edited in build.prop, and more, can be set like this. -# Add them to the PROPS variable according to the following example: +# Add them to the CONFPROPS variable according to the following example: # CONFPROPS=" # ro.sf.lcd_density=320 # ro.config.media_vol_steps=30 diff --git a/common/propsconf_late b/common/propsconf_late index 7315191..b68eb93 100644 --- a/common/propsconf_late +++ b/common/propsconf_late @@ -9,7 +9,7 @@ # In that case, feel free to delete it. # Script version -SCRIPTV=3 +SCRIPTV=4 SETTRANSF=1 # Variables @@ -55,6 +55,28 @@ if [ -d "$MODPATH" ]; then if [ -f "$MODPATH/disable" ]; then log_handler "Module disabled." else + # Checks for the Universal SafetyNet Fix module and similar modules editing the device fingerprint + PRINTMODULE=false + for USNF in $USNFLIST; do + if [ -d "$IMGPATH/$USNF" ]; then + NAME=$(get_file_value $IMGPATH/$USNF/module.prop "name=") + log_handler "'$NAME' installed (modifies the device fingerprint)." + PRINTMODULE=true + fi + done + if [ "$PRINTMODULE" == "true" ]; then + replace_fn FINGERPRINTENB 1 0 $LATEFILE + log_handler "Fingerprint modification disabled." + else + replace_fn FINGERPRINTENB 0 1 $LATEFILE + log_handler "Fingerprint modification enabled." + fi + + # Check the reboot variable + if [ "$(get_file_value $LATEFILE "REBOOTCHK\=")" == 1 ]; then + replace_fn REBOOTCHK 1 0 $LATEFILE + fi + # ---Original values--- # default.prop FILEDEBUGGABLE="" @@ -63,13 +85,7 @@ if [ -d "$MODPATH" ]; then FILETYPE="" FILETAGS="" FILESELINUX="" - # Prop values - ORIGDEBUGGABLE="" - ORIGSECURE="" - ORIGTYPE="" - ORIGTAGS="" - ORIGSELINUX="" - ORIGFINGERPRINT="" + FILEFINGERPRINT="" # ---Module values--- MODULEDEBUGGABLE="" @@ -120,10 +136,13 @@ if [ -d "$MODPATH" ]; then fi fi # Set new fingerprint - if [ "$FINGERPRINTENB" == 1 ] && [ "$PRINTEDIT" == 1 ]; then + if [ "$FINGERPRINTENB" == 1 -o "$PRINTMODULE" == "false" ] && [ "$PRINTEDIT" == 1 ]; then log_handler "Changing fingerprint." - resetprop -v ro.build.fingerprint $MODULEFINGERPRINT 2>> $LOGFILE - resetprop -v ro.bootimage.build.fingerprint $MODULEFINGERPRINT 2>> $LOGFILE + PRINTSTMP="$(resetprop | grep "build.fingerprint" | sed 's/\]\:\ /\]/')" + for ITEM in $PRINTSTMP; do + TMPPROP=$(echo $ITEM | sed 's/\]\[.*//' | sed 's/\[//') + resetprop -v $TMPPROP $MODULEFINGERPRINT 2>> $LOGFILE + done fi # ---Setting custom props--- @@ -146,7 +165,7 @@ if [ -d "$MODPATH" ]; then SEDDEBUGGABLE="0" fi if [ "$SETDEBUGGABLE" == "true" ]; then - sed -i "s/ro.debuggable=$FILEDEBUGGABLE/ro.debuggable=$SEDDEBUGGABLE/" /default.prop && log_handler "ro.debuggable=$SEDDEBUGGABLE" + replace_fn "ro.debuggable" $FILEDEBUGGABLE $SEDDEBUGGABLE /default.prop && log_handler "ro.debuggable=$SEDDEBUGGABLE" fi if [ "$MODULESECURE" ]; then SEDSECURE="$MODULESECURE" @@ -154,13 +173,13 @@ if [ -d "$MODPATH" ]; then SEDSECURE="1" fi if [ "$SETSECURE" == "true" ]; then - sed -i "s/ro.secure=$FILESECURE/ro.secure=$SEDSECURE/" /default.prop && log_handler "ro.secure=$SEDSECURE" + replace_fn "ro.secure" $FILESECURE $SEDSECURE /default.prop && log_handler "ro.secure=$SEDSECURE" fi mount -ro remount rootfs / else log_handler "Default.prop editing disabled." - fi - fi + fi + fi log_script_chk "Boot script finished.\n\n==================" fi else diff --git a/common/util_functions.sh b/common/util_functions.sh index a448221..6a88f18 100644 --- a/common/util_functions.sh +++ b/common/util_functions.sh @@ -47,6 +47,11 @@ ro.build.tags=release-keys ro.build.selinux=0 " +# Finding file values +get_file_value() { + cat $1 | grep $2 | sed "s/.*${2}//" | sed 's/\"//g' +} + # Logs log_handler() { echo "" >> $LOGFILE @@ -83,11 +88,6 @@ menu_header() { echo $DIVIDER } -# Finding file values -get_file_value() { - cat $1 | grep $2 | sed "s/.*$2//" | sed 's/\"//g' -} - # Find prop type get_prop_type() { echo $1 | sed 's/.*\.//' @@ -105,7 +105,17 @@ get_eq_right() { # Get first word in string get_first() { - echo $1 | sed 's/\ .*//' + case $1 in + *\ *) echo $1 | sed 's/\ .*//' + ;; + *=*) get_eq_left $1 + ;; + esac +} + +# Replace file values +replace_fn() { + sed -i "s@${1}=${2}@${1}=${3}@" $4 } # Updates placeholders @@ -113,7 +123,7 @@ placeholder_update() { FILEVALUE=$(get_file_value $1 "$2=") log_handler "Checking for '$3' in '$1'. Current value is '$FILEVALUE'." case $FILEVALUE in - *PLACEHOLDER*) sed -i "s@${2}=${3}@${2}=${4}@g" $1 + *PLACEHOLDER*) replace_fn $2 $3 $4 $1 log_handler "Placeholder '$3' updated to '$4' in '$1'." ;; esac @@ -126,7 +136,7 @@ orig_check() { ORIGLOAD=0 for PROPTYPE in $PROPSTMPLIST; do PROP=$(get_prop_type $PROPTYPE) - ORIGPROP=$(echo "ORIG${PROP}" | tr '[:lower:]' '[:upper:]') + ORIGPROP=$(echo "FILE${PROP}" | tr '[:lower:]' '[:upper:]') ORIGVALUE=$(get_file_value $LATEFILE "${ORIGPROP}=") if [ "$ORIGVALUE" ]; then ORIGLOAD=1 @@ -165,6 +175,16 @@ file_values() { FILETYPE=$(get_file_value /system/build.prop "ro.build.type=") FILETAGS=$(get_file_value /system/build.prop "ro.build.tags=") FILESELINUX=$(get_file_value /system/build.prop "ro.build.selinux=") + FILEFINGERPRINT=$(get_file_value /system/build.prop "ro.build.fingerprint=") + if [ -z "$FILEFINGERPRINT" ]; then + FILEFINGERPRINT=$(get_file_value /system/build.prop "ro.bootimage.build.fingerprint=") + if [ -z "$FILEFINGERPRINT" ]; then + FILEFINGERPRINT=$(resetprop ro.build.fingerprint) + if [ -z "$FILEFINGERPRINT" ]; then + FILEFINGERPRINT=$(resetprop ro.bootimage.build.fingerprint) + fi + fi + fi } # Latefile values @@ -174,16 +194,7 @@ latefile_values() { LATEFILETYPE=$(get_file_value $LATEFILE "FILETYPE=") LATEFILETAGS=$(get_file_value $LATEFILE "FILETAGS=") LATEFILESELINUX=$(get_file_value $LATEFILE "FILESELINUX=") -} - -# Original prop values -orig_values() { - ORIGDEBUGGABLE=$(get_file_value $LATEFILE "ORIGDEBUGGABLE=") - ORIGSECURE=$(get_file_value $LATEFILE "ORIGSECURE=") - ORIGTYPE=$(get_file_value $LATEFILE "ORIGTYPE=") - ORIGTAGS=$(get_file_value $LATEFILE "ORIGTAGS=") - ORIGSELINUX=$(get_file_value $LATEFILE "ORIGSELINUX=") - ORIGFINGERPRINT=$(get_file_value $LATEFILE "ORIGFINGERPRINT=") + LATEFILEFINGERPRINT=$(get_file_value $LATEFILE "FILEFINGERPRINT=") } # Module values @@ -205,8 +216,6 @@ all_values() { file_values # Latefile values latefile_values - # Original prop values - orig_values # Module values module_values } @@ -231,7 +240,7 @@ after_change_file() { } reboot_chk() { - sed -i 's/REBOOTCHK=0/REBOOTCHK=1/' $LATEFILE + replace_fn REBOOTCHK 0 1 $LATEFILE } reset_fn() { @@ -239,10 +248,10 @@ reset_fn() { FINGERPRINTENB=$(get_file_value $LATEFILE "FINGERPRINTENB=") cp -af $MODPATH/propsconf_late $LATEFILE if [ "$BUILDPROPENB" ] && [ -z "$BUILDPROPENB" == 1 ]; then - sed -i "s@BUILDPROPENB=1@BUILDPROPENB=$BUILDPROPENB@g" $LATEFILE + replace_fn BUILDPROPENB 1 $BUILDPROPENB $LATEFILE fi if [ "$FINGERPRINTENB" ] && [ -z "$FINGERPRINTENB" == 1 ]; then - sed -i "s@FINGERPRINTENB=1@FINGERPRINTENB=$FINGERPRINTENB@g" $LATEFILE + replace_fn FINGERPRINTENB 1 $FINGERPRINTENB $LATEFILE fi chmod 755 $LATEFILE placeholder_update $LATEFILE IMGPATH IMG_PLACEHOLDER $IMGPATH @@ -256,7 +265,7 @@ reset_fn() { # Check if original file values are safe orig_safe() { - sed -i 's/FILESAFE=0/FILESAFE=1/' $LATEFILE + replace_fn FILESAFE 0 1 $LATEFILE for V in $PROPSLIST; do PROP=$(get_prop_type $V) FILEPROP=$(echo "FILE${PROP}" | tr '[:lower:]' '[:upper:]') @@ -265,7 +274,7 @@ orig_safe() { safe_props $V $FILEVALUE if [ "$SAFE" == 0 ]; then log_handler "Prop $V set to triggering value in prop file." - sed -i 's/FILESAFE=1/FILESAFE=0/' $LATEFILE + replace_fn FILESAFE 1 0 $LATEFILE else log_handler "Prop $V set to \"safe\" value in prop file." fi @@ -274,6 +283,7 @@ orig_safe() { # Checks for configuration file config_file() { + log_handler "Checking for configuration file." if [ -f "$CONFFILE" ]; then log_handler "Configuration file detected." # Loads custom variables @@ -336,22 +346,25 @@ config_file() { OPTCCURR=$(get_file_value $LATEFILE "OPTIONCOLOUR=") OPTWCURR=$(get_file_value $LATEFILE "OPTIONWEB=") if [ "$CONFCOLOUR" == "enabled" ]; then - - sed -i "s@OPTIONCOLOUR=$OPTCCURR@OPTIONCOLOUR=1@" $LATEFILE + OPTCCHNG=1 else - sed -i "s@OPTIONCOLOUR=$OPTCCURR@OPTIONCOLOUR=0" $LATEFILE + OPTCCHNG=0 fi + replace_fn OPTIONCOLOUR $OPTCCURR $OPTCCHNG $LATEFILE log_handler "Colour $CONFCOLOUR." if [ "$CONFWEB" == "enabled" ]; then - sed -i "s@OPTIONWEB=$OPTWCURR@OPTIONWEB=1@" $LATEFILE + OPTWCHNG=1 else - sed -i "s@OPTIONWEB=$OPTWCURR@OPTIONWEB=0@" $LATEFILE + OPTWCHNG=0 fi + replace_fn OPTIONWEB $OPTWCURR $OPTWCHNG $LATEFILE log_handler "Automatic fingerprints list update $CONFWEB." # Deletes the configuration file log_handler "Deleting configuration file." rm -f $CONFFILE + else + log_handler "No configuration file." fi } @@ -372,7 +385,7 @@ download_prints() { mv -f $PRINTSTMP $PRINTSLOC # Updates list version in module.prop VERSIONTMP=$(get_file_value $MODPATH/module.prop "version=") - sed -i "s/version=$VERSIONTMP/version=$MODVERSION-v$LISTVERSION/g" $MODPATH/module.prop + replace_fn version $VERSIONTMP "${MODVERSION}-v${LISTVERSION}" $MODPATH/module.prop log_print "Updated list to v${LISTVERSION}." else rm -f $PRINTSTMP @@ -399,9 +412,13 @@ reset_print() { SUBA=$(get_file_value $LATEFILE "MODULEFINGERPRINT=") # Saves new module value - sed -i "s@MODULEFINGERPRINT=\"$SUBA\"@MODULEFINGERPRINT=\"\"@" $LATEFILE + replace_fn MODULEFINGERPRINT "\"$SUBA\"" "\"\"" $LATEFILE # Updates prop change variables in propsconf_late - sed -i 's/PRINTEDIT=1/PRINTEDIT=0/g' $LATEFILE + replace_fn PRINTEDIT 1 0 $LATEFILE + # Updates improved hiding setting + if [ "$(get_file_value $LATEFILE "BUILDEDIT=")" ]; then + replace_fn SETFINGERPRINT "true" "false" $LATEFILE + fi if [ "$2" != "file" ]; then after_change "$1" @@ -415,9 +432,13 @@ change_print() { SUBA=$(get_file_value $LATEFILE "MODULEFINGERPRINT=") # Saves new module value - sed -i "s@MODULEFINGERPRINT=\"$SUBA\"@MODULEFINGERPRINT=\"$2\"@" $LATEFILE + replace_fn MODULEFINGERPRINT "\"$SUBA\"" "\"$2\"" $LATEFILE # Updates prop change variables in propsconf_late - sed -i 's/PRINTEDIT=0/PRINTEDIT=1/' $LATEFILE + replace_fn PRINTEDIT 0 1 $LATEFILE + # Updates improved hiding setting + if [ "$(get_file_value $LATEFILE "BUILDEDIT=")" ]; then + replace_fn SETFINGERPRINT "false" "true" $LATEFILE + fi NEWFINGERPRINT="" @@ -435,15 +456,14 @@ reset_prop_files() { for PROPTYPE in $PROPSLIST; do log_handler "Disabling prop file editing for '$PROPTYPTE'." PROP=$(get_prop_type $PROPTYPE) - FILEPROP=$(echo "FILE$PROP" | tr '[:lower:]' '[:upper:]') SETPROP=$(echo "SET$PROP" | tr '[:lower:]' '[:upper:]') - sed -i "s/$SETPROP=true/$SETPROP=false/" $LATEFILE + replace_fn $SETPROP "true" "false" $LATEFILE done # Change fingerprint - sed -i "s/SETFINGERPRINT=true/SETFINGERPRINT=false/" $LATEFILE + replace_fn SETFINGERPRINT "true" "false" $LATEFILE # Edit settings variables - sed -i 's/BUILDEDIT=1/BUILDEDIT=0/' $LATEFILE - sed -i 's/DEFAULTEDIT=1/DEFAULTEDIT=0/' $LATEFILE + replace_fn BUILDEDIT 1 0 $LATEFILE + replace_fn DEFAULTEDIT 1 0 $LATEFILE if [ "$1" != "file" ]; then after_change_file "$1" "$2" @@ -464,8 +484,8 @@ edit_prop_files() { else # Checking if the device fingerprint is set by the module if [ "$(get_file_value $LATEFILE "FINGERPRINTENB=")" == 1 ] && [ "$(get_file_value $LATEFILE "PRINTEDIT=")" == 1 ]; then - if [ "$(cat /system/build.prop | grep "$ORIGFINGERPRINT")" ]; then - sed -i "s/SETFINGERPRINT=false/SETFINGERPRINT=true/" $LATEFILE + if [ "$(cat /system/build.prop | grep "$FILEFINGERPRINT")" ]; then + replace_fn SETFINGERPRINT "false" "true" $LATEFILE fi fi fi @@ -492,16 +512,16 @@ edit_prop_files() { # Changes file only if necessary if [ "$SAFE" == 0 ]; then log_handler "Enabling prop file editing for '$PROPTYPE'." - sed -i "s/$SETPROP=false/$SETPROP=true/" $LATEFILE + replace_fn $SETPROP "false" "true" $LATEFILE elif [ "$SAFE" == 1 ]; then log_handler "Prop file editing unnecessary for '$PROPTYPE'." - sed -i "s/$SETPROP=true/$SETPROP=false/" $LATEFILE + replace_fn $SETPROP "true" "false" $LATEFILE else log_handler "Couldn't check safe value for '$PROPTYPE'." fi done - sed -i 's/DEFAULTEDIT=0/DEFAULTEDIT=1/' $LATEFILE - sed -i 's/BUILDEDIT=0/BUILDEDIT=1/' $LATEFILE + replace_fn BUILDEDIT 0 1 $LATEFILE + replace_fn DEFAULTEDIT 0 1 $LATEFILE if [ "$1" != "file" ]; then after_change_file "$1" "$2" @@ -554,19 +574,19 @@ reset_prop() { log_handler "Resetting $1 to default value." # Saves new module value - sed -i "s/$MODULEPROP=\"$SUBA\"/$MODULEPROP=\"\"/" $LATEFILE + replace_fn $MODULEPROP "\"$SUBA\"" "\"\"" $LATEFILE # Changes prop - sed -i "s/$REPROP=true/$REPROP=false/" $LATEFILE + replace_fn $REPROP "true" "false" $LATEFILE # Updates prop change variable in propsconf_late PROPCOUNT=$(get_file_value $LATEFILE "PROPCOUNT=") if [ "$SUBA" ]; then if [ "$PROPCOUNT" -gt 0 ]; then PROPCOUNTP=$(($PROPCOUNT-1)) - sed -i "s/PROPCOUNT=$PROPCOUNT/PROPCOUNT=$PROPCOUNTP/" $LATEFILE + replace_fn PROPCOUNT $PROPCOUNT $PROPCOUNTP $LATEFILE fi if [ "$PROPCOUNT" == 0 ]; then - sed -i 's/PROPEDIT=1/PROPEDIT=0/' $LATEFILE + replace_fn PROPEDIT 1 0 $LATEFILE fi fi @@ -586,17 +606,17 @@ change_prop() { log_handler "Changing $1 to $2." # Saves new module value - sed -i "s/$MODULEPROP=\"$SUBA\"/$MODULEPROP=\"$2\"/" $LATEFILE + replace_fn $MODULEPROP "\"$SUBA\"" "\"$2\"" $LATEFILE # Changes prop - sed -i "s/$REPROP=false/$REPROP=true/" $LATEFILE + replace_fn $REPROP "false" "true" $LATEFILE # Updates prop change variables in propsconf_late if [ -z "$SUBA" ]; then PROPCOUNT=$(get_file_value $LATEFILE "PROPCOUNT=") PROPCOUNTP=$(($PROPCOUNT+1)) - sed -i "s/PROPCOUNT=$PROPCOUNT/PROPCOUNT=$PROPCOUNTP/" $LATEFILE + replace_fn PROPCOUNT $PROPCOUNT $PROPCOUNTP $LATEFILE fi - sed -i 's/PROPEDIT=0/PROPEDIT=1/' $LATEFILE + replace_fn PROPEDIT 0 1 $LATEFILE if [ "$3" != "file" ]; then after_change "$1" @@ -614,16 +634,16 @@ reset_prop_all() { SUBA=$(get_file_value $LATEFILE "${MODULEPROP}=") # Saves new module value - sed -i "s/$MODULEPROP=\"$SUBA\"/$MODULEPROP=\"\"/" $LATEFILE + replace_fn $MODULEPROP "\"$SUBA\"" "\"\"" $LATEFILE # Changes prop - sed -i "s/$REPROP=true/$REPROP=false/" $LATEFILE - - # Updates prop change variables in propsconf_late - PROPCOUNT=$(get_file_value $LATEFILE "PROPCOUNT=") - sed -i "s/PROPCOUNT=$PROPCOUNT/PROPCOUNT=0/" $LATEFILE - sed -i 's/PROPEDIT=1/PROPEDIT=0/' $LATEFILE + replace_fn $REPROP "true" "false" $LATEFILE done + # Updates prop change variables in propsconf_late + PROPCOUNT=$(get_file_value $LATEFILE "PROPCOUNT=") + replace_fn PROPCOUNT $PROPCOUNT 0 $LATEFILE + replace_fn PROPEDIT 1 0 $LATEFILE + after_change "$1" } @@ -636,8 +656,8 @@ set_custprop() { SORTCUSTPROPS=$(echo $(printf '%s\n' $TMPCUSTPROPS | sort -u)) log_handler "Setting custom prop $1." - sed -i "s/CUSTOMPROPS=\"$CURRCUSTPROPS\"/CUSTOMPROPS=\"$SORTCUSTPROPS\"/" $LATEFILE - sed -i 's/CUSTOMEDIT=0/CUSTOMEDIT=1/' $LATEFILE + replace_fn CUSTOMPROPS "\"$CURRCUSTPROPS\"" "\"$SORTCUSTPROPS\"" $LATEFILE + replace_fn CUSTOMEDIT 0 1 $LATEFILE if [ "$3" != "file" ]; then after_change "$1" @@ -651,8 +671,8 @@ reset_all_custprop() { log_handler "Resetting all custom props." # Removing all custom props - sed -i "s/CUSTOMPROPS=\"$CURRCUSTPROPS\"/CUSTOMPROPS=\"\"/" $LATEFILE - sed -i 's/CUSTOMEDIT=1/CUSTOMEDIT=0/' $LATEFILE + replace_fn CUSTOMPROPS "\"$CURRCUSTPROPS\"" "\"\"" $LATEFILE + replace_fn CUSTOMEDIT 1 0 $LATEFILE if [ "$1" != "file" ]; then after_change "$1" @@ -664,13 +684,13 @@ reset_custprop() { CURRCUSTPROPS=$(get_file_value $LATEFILE "CUSTOMPROPS=") log_handler "Resetting custom props $1." - TMPCUSTPROPS=$(echo $CURRCUSTPROPS | sed "s/$1=$2//" | tr -s " " | sed 's/^[ \t]*//') + TMPCUSTPROPS=$(echo $CURRCUSTPROPS | sed "s/${1}=${2}//" | tr -s " " | sed 's/^[ \t]*//') # Removing all custom props - sed -i "s/CUSTOMPROPS=\"$CURRCUSTPROPS\"/CUSTOMPROPS=\"$TMPCUSTPROPS\"/" $LATEFILE + replace_fn CUSTOMPROPS "\"$CURRCUSTPROPS\"" "\"$TMPCUSTPROPS\"" $LATEFILE CURRCUSTPROPS=$(get_file_value $LATEFILE "CUSTOMPROPS=") if [ -z "$CURRCUSTPROPS" ]; then - sed -i 's/CUSTOMEDIT=1/CUSTOMEDIT=0/' $LATEFILE + replace_fn CUSTOMEDIT 1 0 $LATEFILE fi after_change "$1" diff --git a/config.sh b/config.sh index ada6c8c..361c455 100644 --- a/config.sh +++ b/config.sh @@ -106,7 +106,8 @@ get_file_value() { } # Variables -$BOOTMODE && IMGPATH=/sbin/.core/img || IMGPATH=$MOUNTPATH +BIMGPATH=/sbin/.core/img +$BOOTMODE && IMGPATH=$BIMGPATH || IMGPATH=$MOUNTPATH UPDATELATEFILE=$INSTALLER/common/propsconf_late LATEFILE=$IMGPATH/.core/service.d/propsconf_late UPDATEV=$(get_file_value $UPDATELATEFILE "SCRIPTV=") @@ -130,23 +131,13 @@ BUILDEDIT DEFAULTEDIT PROPCOUNT PROPEDIT +CUSTOMEDIT CUSTOMCHK REBOOTCHK OPTIONCOLOUR OPTIONWEB " PROPSETTINGSLIST=" -FILEDEBUGGABLE -FILESECURE -FILETYPE -FILETAGS -FILESELINUX -ORIGDEBUGGABLE -ORIGSECURE -ORIGTYPE -ORIGTAGS -ORIGSELINUX -ORIGFINGERPRINT MODULEDEBUGGABLE MODULESECURE MODULETYPE @@ -200,16 +191,20 @@ script_placement() { SETPROP=$(echo "SET${ITEM}" | tr '[:lower:]' '[:upper:]') REOLD=$(get_file_value $LATEFILE "${REPROP}=") SETOLD=$(get_file_value $LATEFILE "${SETPROP}=") - if [ "$REOLD" ]; then + if [ "$REOLD" != "false" ]; then sed -i "s/${REPROP}=false/${REPROP}=${REOLD}/" $UPDATELATEFILE fi - if [ "$SETOLD" ]; then + if [ "$SETOLD" != "false" ]; then sed -i "s/${SETPROP}=false/${SETPROP}=${SETOLD}/" $UPDATELATEFILE fi done fi cp -af $UPDATELATEFILE $LATEFILE chmod 755 $LATEFILE + elif [ "$UPDATEV" -lt "$FILEV" ]; then + ui_print "- Settings cleared (script downgraded)" + cp -af $UPDATELATEFILE $LATEFILE + chmod 755 $LATEFILE else ui_print "- Module settings preserved" fi @@ -293,6 +288,8 @@ script_install() { placeholder_update $MODPATH/util_functions.sh CACHELOC CACHE_PLACEHOLDER "$CACHELOC" MODVERSION=$(echo $(get_file_value $MODPATH/module.prop "version=") | sed 's/-.*//') placeholder_update $MODPATH/util_functions.sh MODVERSION VER_PLACEHOLDER $MODVERSION + placeholder_update $LATEFILE IMGPATH IMG_PLACEHOLDER $BIMGPATH + placeholder_update $MODPATH/system/$BIN/props IMGPATH IMG_PLACEHOLDER $BIMGPATH # Load module functions . $MODPATH/util_functions.sh # Checks original file values diff --git a/module.prop b/module.prop index 134adac..0ff60b5 100644 --- a/module.prop +++ b/module.prop @@ -1,7 +1,7 @@ id=MagiskHidePropsConf name=MagiskHide Props Config -version=v2.1.1-v9 -versionCode=7 +version=v2.1.2-v10 +versionCode=8 author=Didgeridoohan description=Change your device's fingerprint, to pass SafetyNet's CTS Profile check. Edit prop files for better root hiding. Set/reset prop values set by MagiskHide. Change any prop values easily. minMagisk=1500 diff --git a/system/binpath/props b/system/binpath/props index c112767..3996fbb 100644 --- a/system/binpath/props +++ b/system/binpath/props @@ -590,15 +590,15 @@ menu_magiskhide_props() { read -r INPUT2 fi case "$INPUT2" in - 1) menu_change_prop "ro.debuggable" $CURRDEBUGGABLE $ORIGDEBUGGABLE $MODULEDEBUGGABLE + 1) menu_change_prop "ro.debuggable" $CURRDEBUGGABLE $FILEDEBUGGABLE $MODULEDEBUGGABLE ;; - 2) menu_change_prop "ro.secure" $CURRSECURE $ORIGSECURE $MODULESECURE + 2) menu_change_prop "ro.secure" $CURRSECURE $FILESECURE $MODULESECURE ;; - 3) menu_change_prop "ro.build.type" $CURRTYPE $ORIGTYPE $MODULETYPE + 3) menu_change_prop "ro.build.type" $CURRTYPE $FILETYPE $MODULETYPE ;; - 4) menu_change_prop "ro.build.tags" $CURRTAGS $ORIGTAGS $MODULETAGS + 4) menu_change_prop "ro.build.tags" $CURRTAGS $FILETAGS $MODULETAGS ;; - 5) menu_change_prop "ro.build.selinux" $CURRSELINUX $ORIGSELINUX $MODULESELINUX + 5) menu_change_prop "ro.build.selinux" $CURRSELINUX $FILESELINUX $MODULESELINUX ;; r) if [ "$(get_file_value $LATEFILE "PROPCOUNT=")" -gt 1 ]; then @@ -1164,7 +1164,7 @@ menu_options_colour() { case "$INPUT3" in y) log_handler "The script colour option was ${TMPTXT}d." - sed -i "s@OPTIONCOLOUR=$OPTCURR@OPTIONCOLOUR=$OPTNEW@" $LATEFILE + replace_fn OPTIONCOLOUR $OPTCURR $OPTNEW $LATEFILE INPUT2="" break ;; @@ -1208,7 +1208,7 @@ menu_options_printschk() { case "$INPUT3" in y) log_handler "The script prints list check option was ${TMPTXT}d." - sed -i "s@OPTIONWEB=$OPTCURR@OPTIONWEB=$OPTNEW@" $LATEFILE + replace_fn OPTIONWEB $OPTCURR $OPTNEW $LATEFILE INPUT2="" break ;; @@ -1245,8 +1245,8 @@ menu_options_reset() { log_handler "Resetting all script settings." OPTCCURR=$(get_file_value $LATEFILE "OPTIONCOLOUR=") OPTWCURR=$(get_file_value $LATEFILE "OPTIONWEB=") - sed -i "s@OPTIONCOLOUR=$OPTCCURR@OPTIONCOLOUR=1@" $LATEFILE - sed -i "s@OPTIONWEB=$OPTWCURR@OPTIONWEB=1@" $LATEFILE + replace_fn OPTIONCOLOUR $OPTCCURR 1 $LATEFILE + replace_fn OPTIONWEB $OPTWCURR 1 $LATEFILE INPUT2="" break ;; @@ -1345,11 +1345,11 @@ fi script_ran_check if [ "$POSTCHECK" == 0 ]; then log_handler "The post-fs-data script did not run during boot." - reboot_fn "The post-fs-data boot script does not appear to have run during boot.\n\n That means the module won't work.\n\n Please reboot your device and see if\n it does run. If it doesn't, please\n report the issue, ${R}with logs${N}." "reset-script" + reboot_fn "The post-fs-data boot script does not appear to have run during boot.\n\n That means the module won't work.\n\n Please reboot your device and see if\n it does run. If it doesn't, please\n report the issue, ${R}with logs!${N}" "reset-script" fi if [ "$LATECHECK" == 0 ]; then log_handler "The settings boot script did not run during boot." - reboot_fn "The settings boot script does not\n appear to have run during boot.\n\n That means the module won't work.\n\n Please reboot your device and see if\n it does run. If it doesn't, please\n report the issue, ${R}with logs${N}." "reset-script" + reboot_fn "The settings boot script does not\n appear to have run during boot.\n\n That means the module won't work.\n\n Please reboot your device and see if\n it does run. If it doesn't, please\n report the issue, ${R}with logs!${N}" "reset-script" fi # ================================================== @@ -1481,7 +1481,7 @@ do read -r INPUT fi case "$INPUT" in - 1) menu_change_fingerprint "ro.build.fingerprint${PRINTTXT}" $CURRFINGERPRINT $ORIGFINGERPRINT $MODULEFINGERPRINT + 1) menu_change_fingerprint "ro.build.fingerprint${PRINTTXT}" $CURRFINGERPRINT $FILEFINGERPRINT $MODULEFINGERPRINT ;; 2) menu_edit_prop_files "Improved hiding${FILETXT}" ;;