You've already forked Zygisk-Assistant
mirror of
https://github.com/snake-4/Zygisk-Assistant.git
synced 2025-09-06 06:37:02 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#!/sbin/sh
|
||||
|
||||
#################
|
||||
# Initialization
|
||||
#################
|
||||
|
||||
umask 022
|
||||
|
||||
# echo before loading util_functions
|
||||
ui_print() { echo "$1"; }
|
||||
|
||||
require_new_magisk() {
|
||||
ui_print "*******************************"
|
||||
ui_print " Please install Magisk v20.4+! "
|
||||
ui_print "*******************************"
|
||||
exit 1
|
||||
}
|
||||
|
||||
#########################
|
||||
# Load util_functions.sh
|
||||
#########################
|
||||
|
||||
OUTFD=$2
|
||||
ZIPFILE=$3
|
||||
|
||||
mount /data 2>/dev/null
|
||||
|
||||
[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
|
||||
. /data/adb/magisk/util_functions.sh
|
||||
[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk
|
||||
|
||||
install_module
|
||||
exit 0
|
||||
@@ -0,0 +1 @@
|
||||
#MAGISK
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
resetprop sys.oem_unlock_allowed 0
|
||||
resetprop init.svc.adbd stopped
|
||||
@@ -0,0 +1 @@
|
||||
riru-momohider huskydgfor some codes, playintegrity fork osm0sis for resetprop and samurai for boot-completed
|
||||
@@ -0,0 +1,37 @@
|
||||
SKIPUNZIP=1
|
||||
|
||||
if [ "$BOOTMODE" ] && [ "$APATCH" ]; then
|
||||
ui_print "- Installing from APatch app"
|
||||
else
|
||||
ui_print "*********************************************************"
|
||||
ui_print "! Install from recovery is not supported"
|
||||
ui_print "! Please install from APatch app"
|
||||
abort "*********************************************************"
|
||||
fi
|
||||
|
||||
VERSION=$(grep_prop version "${TMPDIR}/module.prop")
|
||||
ui_print "- Installing $SONAME $VERSION"
|
||||
|
||||
ui_print "- Extracting verify.sh"
|
||||
unzip -o "$ZIPFILE" 'verify.sh' -d "$TMPDIR" >&2
|
||||
if [ ! -f "$TMPDIR/verify.sh" ]; then
|
||||
ui_print "*********************************************************"
|
||||
ui_print "! Unable to extract verify.sh!"
|
||||
ui_print "! This zip may be corrupted, please try downloading again"
|
||||
abort "*********************************************************"
|
||||
fi
|
||||
. "$TMPDIR/verify.sh"
|
||||
extract "$ZIPFILE" 'customize.sh' "$TMPDIR/.vunzip"
|
||||
extract "$ZIPFILE" 'verify.sh' "$TMPDIR/.vunzip"
|
||||
|
||||
ui_print "- Extracting module files"
|
||||
extract "$ZIPFILE" 'module.prop' "$MODPATH"
|
||||
extract "$ZIPFILE" "credits" "$MODPATH"
|
||||
extract "$ZIPFILE" "service.sh" "$MODPATH"
|
||||
extract "$ZIPFILE" "boot-completed.sh" "$MODPATH"
|
||||
extract "$ZIPFILE" "hide.prop" "$MODPATH"
|
||||
|
||||
chmod -R 755 "$MODPATH/*"
|
||||
|
||||
ui_print "- Extracting arm64 libraries"
|
||||
extract "$ZIPFILE" "libs/arm64-v8a.so" "$MODPATH" true
|
||||
@@ -0,0 +1,16 @@
|
||||
ro.boot.vbmeta.device_state=locked
|
||||
ro.boot.verifiedbootstate=green
|
||||
ro.boot.flash.locked=1
|
||||
ro.boot.veritymode=enforcing
|
||||
ro.boot.warranty_bit=0
|
||||
ro.warranty_bit=0
|
||||
ro.debuggable=0
|
||||
ro.secure=1
|
||||
ro.adb.secure=1
|
||||
ro.build.type=user
|
||||
ro.build.tags=release-keys
|
||||
ro.vendor.boot.warranty_bit=0
|
||||
ro.vendor.warranty_bit=0
|
||||
vendor.boot.vbmeta.device_state=locked
|
||||
vendor.boot.verifiedbootstate=green
|
||||
ro.secureboot.lockstate=locked
|
||||
@@ -0,0 +1,6 @@
|
||||
id=${moduleId}
|
||||
name=${moduleName}
|
||||
version=${versionName}
|
||||
versionCode=${versionCode}
|
||||
author=yervant7
|
||||
description=Improve Hide in APatch
|
||||
@@ -0,0 +1,82 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
MODDIR="${0%/*}"
|
||||
|
||||
alias resetprop="/data/adb/ap/bin/resetprop"
|
||||
|
||||
# resetprop_hexpatch [-f|--force] <prop name> <new value>
|
||||
resetprop_hexpatch() {
|
||||
case "$1" in
|
||||
-f|--force) local FORCE=1; shift;;
|
||||
esac
|
||||
|
||||
local NAME="$1"
|
||||
local NEWVALUE="$2"
|
||||
local CURVALUE="$(resetprop "$NAME")"
|
||||
|
||||
[ ! "$NEWVALUE" -o ! "$CURVALUE" ] && return 1
|
||||
[ "$NEWVALUE" = "$CURVALUE" -a ! "$FORCE" ] && return 1
|
||||
|
||||
local NEWLEN=${#NEWVALUE}
|
||||
if [ -f /dev/__properties__ ]; then
|
||||
local PROPFILE=/dev/__properties__
|
||||
else
|
||||
local PROPFILE="/dev/__properties__/$(resetprop -Z "$NAME")"
|
||||
fi
|
||||
local NAMEOFFSET=$(echo $(strings -t d "$PROPFILE" | grep "$NAME") | cut -d ' ' -f 1)
|
||||
|
||||
#<hex 2-byte change counter><flags byte><hex length of prop value><prop value + nul padding to 92 bytes><prop name>
|
||||
local NEWHEX="$(printf '%02x' "$NEWLEN")$(printf "$NEWVALUE" | od -A n -t x1 -v | tr -d ' \n')$(printf "%$((92-NEWLEN))s" | sed 's/ /00/g')"
|
||||
|
||||
printf "Patch '$NAME' to '$NEWVALUE' in '$PROPFILE' @ 0x%08x -> \n[0000??$NEWHEX]\n" $((NAMEOFFSET-96))
|
||||
|
||||
echo -ne "\x00\x00" \
|
||||
| dd obs=1 count=2 seek=$((NAMEOFFSET-96)) conv=notrunc of="$PROPFILE"
|
||||
echo -ne "$(printf "$NEWHEX" | sed -e 's/.\{2\}/&\\x/g' -e 's/^/\\x/' -e 's/\\x$//')" \
|
||||
| dd obs=1 count=93 seek=$((NAMEOFFSET-93)) conv=notrunc of="$PROPFILE"
|
||||
}
|
||||
|
||||
# resetprop_if_diff <prop name> <expected value>
|
||||
resetprop_if_diff() {
|
||||
local NAME="$1"
|
||||
local EXPECTED="$2"
|
||||
local CURRENT="$(resetprop "$NAME")"
|
||||
|
||||
[ -z "$CURRENT" ] || [ "$CURRENT" == "$EXPECTED" ] || resetprop_hexpatch "$NAME" "$EXPECTED"
|
||||
}
|
||||
|
||||
# resetprop_if_match <prop name> <value match string> <new value>
|
||||
resetprop_if_match() {
|
||||
local NAME="$1"
|
||||
local CONTAINS="$2"
|
||||
local VALUE="$3"
|
||||
|
||||
[[ "$(resetprop "$NAME")" == *"$CONTAINS"* ]] && resetprop_hexpatch "$NAME" "$VALUE"
|
||||
}
|
||||
|
||||
{
|
||||
# Reset props after boot completed to avoid breaking some weird devices/ROMs...
|
||||
while [ "$(getprop sys.boot_completed)" != "1" ]
|
||||
do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Xiaomi cross region flash...
|
||||
# See https://github.com/topjohnwu/Magisk/pull/2470
|
||||
resetprop_if_match ro.boot.hwc CN GLOBAL
|
||||
resetprop_if_match ro.boot.hwcountry China GLOBAL
|
||||
|
||||
# some stupid banking apps check this prop
|
||||
resetprop_if_diff sys.oem_unlock_allowed 0
|
||||
|
||||
# Load MagiskHide props
|
||||
resetprop -n --file "$MODDIR/hide.prop"
|
||||
|
||||
# Hide that we booted from recovery when magisk is in recovery mode
|
||||
resetprop_if_match "ro.bootmode" "recovery" "unknown"
|
||||
resetprop_if_match "ro.boot.bootmode" "recovery" "unknown"
|
||||
resetprop_if_match "vendor.boot.bootmode" "recovery" "unknown"
|
||||
|
||||
resetprop --delete ro.build.selinux
|
||||
|
||||
}&
|
||||
@@ -0,0 +1,51 @@
|
||||
TMPDIR_FOR_VERIFY="$TMPDIR/.vunzip"
|
||||
mkdir "$TMPDIR_FOR_VERIFY"
|
||||
|
||||
abort_verify() {
|
||||
ui_print "*********************************************************"
|
||||
ui_print "! $1"
|
||||
ui_print "! This zip may be corrupted, please try downloading again"
|
||||
abort "*********************************************************"
|
||||
}
|
||||
|
||||
# extract <zip> <file> <target dir> <junk paths>
|
||||
extract() {
|
||||
zip=$1
|
||||
file=$2
|
||||
dir=$3
|
||||
junk_paths=$4
|
||||
[ -z "$junk_paths" ] && junk_paths=false
|
||||
opts="-o"
|
||||
[ $junk_paths = true ] && opts="-oj"
|
||||
|
||||
file_path=""
|
||||
hash_path=""
|
||||
if [ $junk_paths = true ]; then
|
||||
file_path="$dir/$(basename "$file")"
|
||||
hash_path="$TMPDIR_FOR_VERIFY/$(basename "$file").sha256"
|
||||
else
|
||||
file_path="$dir/$file"
|
||||
hash_path="$TMPDIR_FOR_VERIFY/$file.sha256"
|
||||
fi
|
||||
|
||||
unzip $opts "$zip" "$file" -d "$dir" >&2
|
||||
[ -f "$file_path" ] || abort_verify "$file not exists"
|
||||
|
||||
unzip $opts "$zip" "$file.sha256" -d "$TMPDIR_FOR_VERIFY" >&2
|
||||
[ -f "$hash_path" ] || abort_verify "$file.sha256 not exists"
|
||||
|
||||
(echo "$(cat "$hash_path") $file_path" | sha256sum -c -s -) || abort_verify "Failed to verify $file"
|
||||
ui_print "- Verified $file" >&1
|
||||
}
|
||||
|
||||
file="META-INF/com/google/android/update-binary"
|
||||
file_path="$TMPDIR_FOR_VERIFY/$file"
|
||||
hash_path="$file_path.sha256"
|
||||
unzip -o "$ZIPFILE" "META-INF/com/google/android/*" -d "$TMPDIR_FOR_VERIFY" >&2
|
||||
[ -f "$file_path" ] || abort_verify "$file not exists"
|
||||
if [ -f "$hash_path" ]; then
|
||||
(echo "$(cat "$hash_path") $file_path" | sha256sum -c -s -) || abort_verify "Failed to verify $file"
|
||||
ui_print "- Verified $file" >&1
|
||||
else
|
||||
ui_print "- Download from Magisk app"
|
||||
fi
|
||||
Reference in New Issue
Block a user