mirror of
https://github.com/topjohnwu/Magisk
synced 2025-10-28 05:40:52 +01:00
Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30c048723c | ||
|
|
85dc669ddf | ||
|
|
397c1a1c2b | ||
|
|
f1d3e35aac | ||
|
|
0e69201f05 | ||
|
|
f8fdaf5c1f | ||
|
|
1f3b81338c | ||
|
|
5921d3a42a | ||
|
|
dbbc85719e | ||
|
|
0ddb6c3f10 | ||
|
|
e13281726c | ||
|
|
0ddf4355a1 | ||
|
|
7c8a3ca1a8 | ||
|
|
3068738a70 | ||
|
|
cfa0d8b7c0 | ||
|
|
7ac41652f7 | ||
|
|
24a510bc2e | ||
|
|
0498540439 | ||
|
|
da94c2e1e5 | ||
|
|
bcdd74514f | ||
|
|
1d0c36a0ab | ||
|
|
a34ea8f131 | ||
|
|
7fbfa6a52b | ||
|
|
799ef3380d | ||
|
|
d5087858ca | ||
|
|
d9fc5650b8 | ||
|
|
9ea028f5ab | ||
|
|
aa309087fd | ||
|
|
57bdd9d3bf | ||
|
|
dc9871fe5b | ||
|
|
3255ca3ea4 | ||
|
|
a06ef6fe25 | ||
|
|
696d256fa0 | ||
|
|
70e8ad7104 | ||
|
|
f785dcac3d | ||
|
|
aa54ef10ae | ||
|
|
14946da163 | ||
|
|
5f9bcfbefe | ||
|
|
aa2eed2c38 | ||
|
|
6bff6e9cff | ||
|
|
023d369b74 | ||
|
|
c9d4241afe | ||
|
|
e1279c29c2 | ||
|
|
2d6fb1c45e |
23
.gitignore
vendored
23
.gitignore
vendored
@@ -1,2 +1,21 @@
|
||||
obj
|
||||
libs
|
||||
obj/
|
||||
libs/
|
||||
*.zip
|
||||
|
||||
# Generated binaries
|
||||
zip_static/arm/*
|
||||
zip_static/arm64/*
|
||||
zip_static/x86/*
|
||||
zip_static/x64/*
|
||||
uninstaller/arm/*
|
||||
uninstaller/arm64/*
|
||||
uninstaller/x86/*
|
||||
uninstaller/x64/*
|
||||
zipsigntools/zipadjust
|
||||
|
||||
# Generated scripts
|
||||
zip_static/common/magic_mask.sh
|
||||
zip_static/META-INF/com/google/android/update-binary
|
||||
|
||||
# Leave all busybox!
|
||||
!busybox
|
||||
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -4,3 +4,6 @@
|
||||
[submodule "jni/sepolicy-inject"]
|
||||
path = jni/sepolicy-inject
|
||||
url = https://github.com/topjohnwu/sepolicy-inject
|
||||
[submodule "jni/resetprop"]
|
||||
path = jni/resetprop
|
||||
url = https://github.com/topjohnwu/resetprop.git
|
||||
|
||||
10
README.MD
10
README.MD
@@ -1,4 +1,10 @@
|
||||
# Magisk
|
||||
Static binaries included:
|
||||
###Static binaries included:
|
||||
* Busybox: http://forum.xda-developers.com/android/software-hacking/tool-busybox-flashable-archs-t3348543
|
||||
* Open source su binary: https://github.com/seSuperuser/Superuser
|
||||
|
||||
###How to build Magisk
|
||||
1. Only support MacOS and Linux
|
||||
2. Download and install NDK
|
||||
3. Add the NDK directory into PATH.
|
||||
To check if success, please try calling `which ndk-build` and see if it returns the NDK directory
|
||||
4. Execute `./build.sh`, it will give you further information
|
||||
|
||||
170
build.sh
Executable file
170
build.sh
Executable file
@@ -0,0 +1,170 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo "$0 all <version name>"
|
||||
echo -e "\tBuild binaries, zip, and sign Magisk"
|
||||
echo -e "\tThis is equlivant to first --build, then --zip"
|
||||
echo "$0 clean"
|
||||
echo -e "\tCleanup compiled / generated files"
|
||||
echo "$0 build"
|
||||
echo -e "\tBuild the binaries with ndk"
|
||||
echo "$0 zip <version name>"
|
||||
echo -e "\tZip and sign Magisk"
|
||||
echo "$0 uninstaller"
|
||||
echo -e "\tZip and sign the uninstaller"
|
||||
exit 1
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
echo "************************"
|
||||
echo "* Cleaning up"
|
||||
echo "************************"
|
||||
ndk-build clean 2>/dev/null
|
||||
ls zip_static/arm/* | grep -v "busybox" | xargs rm -rfv
|
||||
ls zip_static/arm64/* | grep -v "busybox" | xargs rm -rfv
|
||||
ls zip_static/x86/* | grep -v "busybox" | xargs rm -rfv
|
||||
ls zip_static/x64/* | grep -v "busybox" | xargs rm -rfv
|
||||
rm -rfv zip_static/META-INF/com/google/android/update-binary
|
||||
rm -rfv zip_static/common/magic_mask.sh
|
||||
rm -rfv uninstaller/arm
|
||||
rm -rfv uninstaller/arm64
|
||||
rm -rfv uninstaller/x86
|
||||
rm -rfv uninstaller/x64
|
||||
}
|
||||
|
||||
mkcp() {
|
||||
[ ! -d "$2" ] && mkdir -p "$2"
|
||||
cp -afv $1 $2
|
||||
}
|
||||
|
||||
build_bin() {
|
||||
echo "************************"
|
||||
echo "* Building binaries"
|
||||
echo "************************"
|
||||
if [ -z `which ndk-build` ]; then
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "! Please add ndk-build to PATH!"
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
exit 1
|
||||
fi
|
||||
ndk-build -j4
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "! Magisk binary tools build failed...."
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
exit 1
|
||||
fi
|
||||
echo "************************"
|
||||
echo "* Copying binaries"
|
||||
echo "************************"
|
||||
mkcp "libs/armeabi/*" zip_static/arm
|
||||
mkcp libs/armeabi/bootimgtools uninstaller/arm
|
||||
mkcp "libs/arm64-v8a/*" zip_static/arm64
|
||||
mkcp libs/arm64-v8a/bootimgtools uninstaller/arm64
|
||||
mkcp "libs/x86/*" zip_static/x86
|
||||
mkcp libs/x86/bootimgtools uninstaller/x86
|
||||
mkcp "libs/x86_64/*" zip_static/x64
|
||||
mkcp libs/x86_64/bootimgtools uninstaller/x64
|
||||
}
|
||||
|
||||
zip_package() {
|
||||
if [ ! -f "zip_static/arm/bootimgtools" ]; then
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "! Missing binaries!!"
|
||||
echo "! Please run \"$0 build\" before zipping"
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
exit 1
|
||||
fi
|
||||
echo "************************"
|
||||
echo "* Adding version info"
|
||||
echo "************************"
|
||||
sed "s/MAGISK_VERSION_STUB/Magisk v$1 Boot Image Patcher/g" scripts/flash_script.sh > zip_static/META-INF/com/google/android/update-binary
|
||||
sed "s/MAGISK_VERSION_STUB/setprop magisk.version \"$1\"/g" scripts/magic_mask.sh > zip_static/common/magic_mask.sh
|
||||
echo "************************"
|
||||
echo "* Zipping Magisk v$1"
|
||||
echo "************************"
|
||||
cd zip_static
|
||||
find . -type f -exec chmod 644 {} \;
|
||||
find . -type d -exec chmod 755 {} \;
|
||||
rm -rf "../Magisk-v$1.zip"
|
||||
zip "../Magisk-v$1.zip" -r .
|
||||
cd ../
|
||||
sign_zip "Magisk-v$1.zip"
|
||||
}
|
||||
|
||||
zip_uninstaller() {
|
||||
if [ ! -f "uninstaller/arm/bootimgtools" ]; then
|
||||
echo "! Missing binaries!!"
|
||||
echo "! Please run \"$0 build\" before zipping"
|
||||
exit 1
|
||||
fi
|
||||
echo "************************"
|
||||
echo "* Zipping uninstaller"
|
||||
echo "************************"
|
||||
cd uninstaller
|
||||
find . -type f -exec chmod 644 {} \;
|
||||
find . -type d -exec chmod 755 {} \;
|
||||
TIMESTAMP=$(date "+%Y%m%d")
|
||||
rm -rf "../Magisk-uninstaller-$TIMESTAMP.zip"
|
||||
zip "../Magisk-uninstaller-$TIMESTAMP.zip" -r .
|
||||
cd ../
|
||||
sign_zip "Magisk-uninstaller-$TIMESTAMP.zip"
|
||||
}
|
||||
|
||||
sign_zip() {
|
||||
if [ ! -f "zipsigntools/zipadjust" ]; then
|
||||
echo "************************"
|
||||
echo "* Compiling ZipAdjust"
|
||||
echo "************************"
|
||||
gcc -o zipsigntools/zipadjust zipsigntools/src/*.c -lz
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "! ZipAdjust Build failed...."
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
exit 1
|
||||
fi
|
||||
chmod 755 zipsigntools/zipadjust
|
||||
fi
|
||||
echo "************************"
|
||||
echo "* First sign $1"
|
||||
echo "************************"
|
||||
java -jar "zipsigntools/signapk.jar" "zipsigntools/test.certificate.x509.pem" "zipsigntools/test.key.pk8" "$1" "${1%.*}-firstsign.zip"
|
||||
echo "************************"
|
||||
echo "* Adjusting $1"
|
||||
echo "************************"
|
||||
zipsigntools/zipadjust "${1%.*}-firstsign.zip" "${1%.*}-adjusted.zip"
|
||||
echo "************************"
|
||||
echo "* Final sign $1"
|
||||
echo "************************"
|
||||
java -jar "zipsigntools/signapk.jar" "zipsigntools/test.certificate.x509.pem" "zipsigntools/test.key.pk8" "${1%.*}-adjusted.zip" "${1%.*}-signed.zip"
|
||||
|
||||
mv "${1%.*}-signed.zip" "$1"
|
||||
rm "${1%.*}-adjusted.zip" "${1%.*}-firstsign.zip"
|
||||
}
|
||||
|
||||
DIR="$(cd "$(dirname "$0")"; pwd)"
|
||||
cd "$DIR"
|
||||
|
||||
case $1 in
|
||||
"all" )
|
||||
[ -z "$2" ] && echo -e "! Missing version number\n" && usage
|
||||
build_bin
|
||||
zip_package $2
|
||||
;;
|
||||
"clean" )
|
||||
cleanup
|
||||
;;
|
||||
"build" )
|
||||
build_bin
|
||||
;;
|
||||
"zip" )
|
||||
[ -z "$2" ] && echo -e "! Missing version number\n" && usage
|
||||
zip_package $2
|
||||
;;
|
||||
"uninstaller" )
|
||||
zip_uninstaller
|
||||
;;
|
||||
* )
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
@@ -2,12 +2,16 @@ my_path := $(call my-dir)
|
||||
|
||||
LOCAL_PATH := $(my_path)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := magiskhide
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_SRC_FILES := magiskhide.c
|
||||
LOCAL_CFLAGS += -std=gnu11
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := bootimgtools
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_FORCE_STATIC_EXECUTABLE := true
|
||||
LOCAL_LDFLAGS := -static
|
||||
LOCAL_STATIC_LIBRARIES := libc libcutils
|
||||
LOCAL_SRC_FILES := bootimgtools.c extract.c repack.c hexpatch.c
|
||||
LOCAL_CFLAGS += -std=gnu11
|
||||
include $(BUILD_EXECUTABLE)
|
||||
@@ -15,12 +19,17 @@ include $(BUILD_EXECUTABLE)
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := sepolicy-inject
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_FORCE_STATIC_EXECUTABLE := true
|
||||
LOCAL_LDFLAGS := -static
|
||||
LOCAL_STATIC_LIBRARIES := libc libcutils libsepol
|
||||
LOCAL_STATIC_LIBRARIES := libsepol
|
||||
LOCAL_SRC_FILES := sepolicy-inject/sepolicy-inject.c sepolicy-inject/builtin_rules.c
|
||||
LOCAL_C_INCLUDES := selinux/libsepol/include/
|
||||
LOCAL_CFLAGS += -std=gnu11
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := resetprop
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_SRC_FILES := resetprop/resetprop.cpp resetprop/system_properties.cpp resetprop/libc_logging.cpp
|
||||
LOCAL_LDLIBS += -latomic
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
include selinux/libsepol/Android.mk
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
APP_ABI := x86 armeabi
|
||||
APP_ABI := x86 x86_64 armeabi arm64-v8a
|
||||
APP_PIE = true
|
||||
APP_PLATFORM := android-21
|
||||
APP_CPPFLAGS += -std=c++11
|
||||
# APP_STL := c++_static
|
||||
|
||||
@@ -27,9 +27,9 @@ void dump_ramdisk(uint8_t *ptr, size_t size) {
|
||||
dump(ptr, size, "ramdisk.gz");
|
||||
//MTK header
|
||||
} else if(memcmp(ptr, "\x88\x16\x88\x58", 4) == 0) {
|
||||
if(memcmp(ptr+4, "RECOVERY", 8)==0) {
|
||||
if(memcmp(ptr+8, "RECOVERY", 8)==0) {
|
||||
dump(ptr, 0, "ramdisk-mtk-recovery");
|
||||
} else if(memcmp(ptr+4, "ROOTFS\0\0", 8)==0) {
|
||||
} else if(memcmp(ptr+8, "ROOTFS\0\0", 8)==0) {
|
||||
dump(ptr, 0, "ramdisk-mtk-boot");
|
||||
} else {
|
||||
exit(1);
|
||||
@@ -128,7 +128,8 @@ int extract(char *image) {
|
||||
|
||||
if(memcmp(base+pos, "QCDT", 4) == 0 ||
|
||||
memcmp(base+pos, "SPRD", 4) == 0 ||
|
||||
memcmp(base+pos, "DTBH", 4) == 0
|
||||
memcmp(base+pos, "DTBH", 4) == 0 ||
|
||||
memcmp(base+pos, "\xD0\x0D\xFE\xED", 4) == 0
|
||||
) {
|
||||
dump(base+pos, hdr->unused[0], "dt");
|
||||
pos += hdr->unused[0] + hdr->page_size-1;
|
||||
|
||||
256
jni/magiskhide.c
Normal file
256
jni/magiskhide.c
Normal file
File diff suppressed because it is too large
Load Diff
1
jni/resetprop
Submodule
1
jni/resetprop
Submodule
Submodule jni/resetprop added at 96949566fb
Submodule jni/sepolicy-inject updated: 3a0df56605...f760a9d0c2
File diff suppressed because it is too large
Load Diff
487
scripts/magic_mask.sh
Normal file
487
scripts/magic_mask.sh
Normal file
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,9 @@
|
||||
|
||||
INSTALLER=/tmp/uninstall
|
||||
|
||||
# Default permissions
|
||||
umask 022
|
||||
|
||||
##########################################################################################
|
||||
# Flashable update-binary preparation
|
||||
##########################################################################################
|
||||
@@ -63,14 +66,14 @@ getvar() {
|
||||
find_boot_image() {
|
||||
if [ -z "$BOOTIMAGE" ]; then
|
||||
for PARTITION in kern-a KERN-A android_boot ANDROID_BOOT kernel KERNEL boot BOOT lnx LNX; do
|
||||
BOOTIMAGE=$(readlink /dev/block/by-name/$PARTITION || readlink /dev/block/platform/*/by-name/$PARTITION || readlink /dev/block/platform/*/*/by-name/$PARTITION)
|
||||
BOOTIMAGE=`readlink /dev/block/by-name/$PARTITION || readlink /dev/block/platform/*/by-name/$PARTITION || readlink /dev/block/platform/*/*/by-name/$PARTITION`
|
||||
if [ ! -z "$BOOTIMAGE" ]; then break; fi
|
||||
done
|
||||
fi
|
||||
if [ -z "$BOOTIMAGE" ]; then
|
||||
FSTAB="/etc/recovery.fstab"
|
||||
[ ! -f "$FSTAB" ] && FSTAB="/etc/recovery.fstab.bak"
|
||||
BOOTIMAGE=$(grep -E '\b/boot\b' "$FSTAB" | grep -oE '/dev/[a-zA-Z0-9_./-]*')
|
||||
[ -f "$FSTAB" ] BOOTIMAGE=`grep -E '\b/boot\b' "$FSTAB" | grep -oE '/dev/[a-zA-Z0-9_./-]*'`
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -100,11 +103,6 @@ unpack_boot() {
|
||||
cd $UNPACKDIR
|
||||
$BINDIR/bootimgtools --extract $1
|
||||
|
||||
find $TMPDIR/boottmp -type d -exec chmod 755 {} \;
|
||||
find $TMPDIR/boottmp -type f -exec chmod 644 {} \;
|
||||
chmod 755 $(find $TMPDIR/boottmp -type d)
|
||||
chmod 644 $(find $TMPDIR/boottmp -type f)
|
||||
|
||||
cd $RAMDISK
|
||||
gunzip -c < $UNPACKDIR/ramdisk.gz | cpio -i
|
||||
}
|
||||
@@ -135,22 +133,18 @@ revert_boot() {
|
||||
mkdir -p $TMPDIR/boottmp
|
||||
|
||||
CHROMEDIR=$INSTALLER/chromeos
|
||||
ORIGBOOT=$TMPDIR/boottmp/boot.img
|
||||
NEWBOOT=$TMPDIR/boottmp/new-boot.img
|
||||
UNPACKDIR=$TMPDIR/boottmp/bootunpack
|
||||
RAMDISK=$TMPDIR/boottmp/ramdisk
|
||||
|
||||
chmod 777 $CHROMEDIR/futility $BINDIR/*
|
||||
|
||||
ui_print "- Dumping boot image"
|
||||
dd if=$BOOTIMAGE of=$ORIGBOOT
|
||||
ORIGBOOT=$BOOTIMAGE
|
||||
|
||||
ui_print "- Unpacking boot image"
|
||||
unpack_boot $ORIGBOOT
|
||||
|
||||
if [ -d ".backup" ]; then
|
||||
ui_print "- Restoring ramdisk with backup"
|
||||
cp -af .backup/* .
|
||||
cp -af .backup/. .
|
||||
rm -rf magisk init.magisk.rc sbin/magic_mask.sh 2>/dev/null
|
||||
rm -rf .backup
|
||||
else
|
||||
@@ -188,24 +182,28 @@ if [ ! -f '/system/build.prop' ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SAMSUNG=false
|
||||
SAMSUNG_CHECK=$(cat /system/build.prop | grep "ro.build.fingerprint=" | grep -i "samsung")
|
||||
if [ $? -eq 0 ]; then
|
||||
SAMSUNG=true
|
||||
fi
|
||||
|
||||
API=$(grep_prop ro.build.version.sdk)
|
||||
ABI=$(grep_prop ro.product.cpu.abi | cut -c-3)
|
||||
ABI2=$(grep_prop ro.product.cpu.abi2 | cut -c-3)
|
||||
ABILONG=$(grep_prop ro.product.cpu.abi)
|
||||
|
||||
ARCH=arm
|
||||
IS64BIT=
|
||||
IS64BIT=false
|
||||
if [ "$ABI" = "x86" ]; then ARCH=x86; fi;
|
||||
if [ "$ABI2" = "x86" ]; then ARCH=x86; fi;
|
||||
if [ "$ABILONG" = "arm64-v8a" ]; then ARCH=arm64; IS64BIT=1; fi;
|
||||
if [ "$ABILONG" = "x86_64" ]; then ARCH=x64; IS64BIT=1; fi;
|
||||
if [ "$ABILONG" = "arm64-v8a" ]; then ARCH=arm64; IS64BIT=true; fi;
|
||||
if [ "$ABILONG" = "x86_64" ]; then ARCH=x64; IS64BIT=true; fi;
|
||||
|
||||
ui_print "- Device platform: $ARCH"
|
||||
|
||||
BINDIR=$INSTALLER/arm
|
||||
if [ "$ARCH" = "x86" -o "$ARCH" = "x64" ]; then
|
||||
BINDIR=$INSTALLER/x86
|
||||
fi
|
||||
BINDIR=$INSTALLER/$ARCH
|
||||
chmod -R 755 $CHROMEDIR/futility $BINDIR
|
||||
|
||||
find_boot_image
|
||||
if [ -z "$BOOTIMAGE" ]; then
|
||||
@@ -213,18 +211,10 @@ if [ -z "$BOOTIMAGE" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SAMSUNG=false
|
||||
SAMSUNG_CHECK=$(cat /system/build.prop | grep "ro.build.fingerprint=" | grep -i "samsung")
|
||||
if [ $? -eq 0 ]; then
|
||||
SAMSUNG=true
|
||||
fi
|
||||
|
||||
##########################################################################################
|
||||
# Detection all done, start installing
|
||||
##########################################################################################
|
||||
|
||||
umount /magisk 2>/dev/null
|
||||
|
||||
if (is_mounted /data); then
|
||||
cp -af /data/stock_boot_*.gz /data/stock_boot.img.gz 2>/dev/null
|
||||
gzip -d /data/stock_boot.img.gz 2>/dev/null
|
||||
@@ -237,26 +227,28 @@ if (is_mounted /data); then
|
||||
revert_boot
|
||||
fi
|
||||
ui_print "- Removing Magisk files"
|
||||
rm -rf /cache/magisk /cache/magisk_merge /cache/magisk.log /cache/last_magisk.log /cache/unblock /data/Magisk.apk /data/magisk.img /data/magisk_merge.img /data/busybox /data/magisk 2>/dev/null
|
||||
rm -rf /cache/magisk.log /cache/last_magisk.log /cache/magiskhide.log \
|
||||
/cache/magisk /cache/magisk_merge /cache/magisk_mount /cache/unblock \
|
||||
/data/Magisk.apk /data/magisk.img /data/magisk_merge.img \
|
||||
/data/busybox /data/magisk /data/custom_ramdisk_patch.sh 2>/dev/null
|
||||
else
|
||||
ui_print "! Data unavalible"
|
||||
ui_print "! Impossible to restore original boot image"
|
||||
ui_print "! Try using ramdisk backup"
|
||||
revert_boot
|
||||
ui_print "- Removing Magisk files"
|
||||
rm -rf /cache/magisk* /cache/last_magisk.log /cache/unblock 2>/dev/null
|
||||
rm -rf /cache/magisk.log /cache/last_magisk.log /cache/magiskhide.log \
|
||||
/cache/magisk /cache/magisk_merge /cache/magisk_mount /cache/unblock 2>/dev/null
|
||||
ui_print "*****************************************"
|
||||
ui_print " Magisk is not fully removed yet "
|
||||
ui_print " Please manually remove /data/magisk.img "
|
||||
ui_print "*****************************************"
|
||||
fi
|
||||
|
||||
if [ -L "$BOOTIMAGE" ]; then
|
||||
ui_print "- Block symlink detected!"
|
||||
else
|
||||
dd if=/dev/zero of=$BOOTIMAGE bs=4096 2>/dev/null
|
||||
fi
|
||||
chmod 644 $NEWBOOT
|
||||
|
||||
ui_print "- Flashing reverted image"
|
||||
[ ! -L "$BOOTIMAGE" ] && dd if=/dev/zero of=$BOOTIMAGE bs=4096 2>/dev/null
|
||||
dd if=$NEWBOOT of=$BOOTIMAGE bs=4096
|
||||
|
||||
umount /system
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
zip_static/arm64/busybox
Normal file
BIN
zip_static/arm64/busybox
Normal file
Binary file not shown.
53
zip_static/common/custom_ramdisk_patch.sh
Normal file
53
zip_static/common/custom_ramdisk_patch.sh
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
RAMDISK=$1
|
||||
BINDIR=/data/magisk
|
||||
|
||||
cpio_add() {
|
||||
/su/bin/sukernel --cpio-add $RAMDISK $RAMDISK $2 $1 $1
|
||||
}
|
||||
|
||||
cpio_extract() {
|
||||
/su/bin/sukernel --cpio-extract $RAMDISK $1 $1
|
||||
}
|
||||
|
||||
cpio_mkdir() {
|
||||
/su/bin/sukernel --cpio-mkdir $RAMDISK $RAMDISK $2 $1
|
||||
}
|
||||
|
||||
rm -rf /tmp/magisk/ramdisk 2>/dev/null
|
||||
mkdir -p /tmp/magisk/ramdisk
|
||||
cd /tmp/magisk/ramdisk
|
||||
|
||||
cat $RAMDISK | cpio -i
|
||||
|
||||
# Patch ramdisk
|
||||
echo "- Patching ramdisk"
|
||||
|
||||
# Add magisk entrypoint
|
||||
for INIT in init*.rc; do
|
||||
if [ $(grep -c "import /init.environ.rc" $INIT) -ne "0" ] && [ $(grep -c "import /init.magisk.rc" $INIT) -eq "0" ]; then
|
||||
sed -i "/import \/init\.environ\.rc/iimport /init.magisk.rc" $INIT
|
||||
cpio_add $INIT 750
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Add magisk PATH
|
||||
if [ $(grep -c "/magisk/.core/busybox" init.environ.rc) -eq "0" ]; then
|
||||
sed -i "/export PATH/ s/\/system\/xbin/\/system\/xbin:\/magisk\/.core\/busybox/g" init.environ.rc
|
||||
cpio_add init.environ.rc 750
|
||||
fi
|
||||
|
||||
# sepolicy patches
|
||||
$BINDIR/sepolicy-inject --magisk -P sepolicy
|
||||
cpio_add sepolicy 644
|
||||
|
||||
# Add new items
|
||||
mkdir -p magisk 2>/dev/null
|
||||
cp -af $BINDIR/init.magisk.rc init.magisk.rc
|
||||
cp -af $BINDIR/magic_mask.sh sbin/magic_mask.sh
|
||||
|
||||
cpio_mkdir magisk 755
|
||||
cpio_add init.magisk.rc 750
|
||||
cpio_add sbin/magic_mask.sh 750
|
||||
@@ -1,21 +1,17 @@
|
||||
# Triggers
|
||||
|
||||
on post-fs
|
||||
# Paths
|
||||
export PATH /magisk/.core/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/magisk/.core/busybox:/system/xbin
|
||||
|
||||
start magisk_pfs
|
||||
wait /dev/.magisk.unblock 20
|
||||
rm /dev/.magisk.unblock
|
||||
|
||||
on post-fs-data
|
||||
|
||||
start magisk_pfsd
|
||||
wait /dev/.magisk.unblock 40
|
||||
rm /dev/.magisk.unblock
|
||||
|
||||
on property:magisk.root=*
|
||||
start magisk_root
|
||||
on property:magisk.restart_pfsd=1
|
||||
trigger post-fs-data
|
||||
|
||||
# Services
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
11
zip_static/common/magiskhide/add
Normal file
11
zip_static/common/magiskhide/add
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
HIDELIST=/magisk/.core/magiskhide/hidelist
|
||||
|
||||
if [ ! -z "$1" ]; then
|
||||
if [ $(grep -c "^$1$" $HIDELIST) -eq "0" ]; then
|
||||
echo "$1" >> $HIDELIST
|
||||
set `/data/busybox/ps -o pid,args | grep "$1" | grep -v "grep"`
|
||||
kill "$1"
|
||||
fi
|
||||
fi
|
||||
5
zip_static/common/magiskhide/list
Normal file
5
zip_static/common/magiskhide/list
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
HIDELIST=/magisk/.core/magiskhide/hidelist
|
||||
|
||||
cat $HIDELIST
|
||||
11
zip_static/common/magiskhide/rm
Normal file
11
zip_static/common/magiskhide/rm
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
HIDELIST=/magisk/.core/magiskhide/hidelist
|
||||
|
||||
if [ ! -z "$1" ]; then
|
||||
cp -af $HIDELIST $HIDELIST.tmp
|
||||
cat $HIDELIST.tmp | grep -v "^$1$" > $HIDELIST
|
||||
rm -f $HIDELIST.tmp
|
||||
set `/data/busybox/ps -o pid,args | grep "$1" | grep -v "grep"`
|
||||
kill "$1"
|
||||
fi
|
||||
@@ -1,9 +0,0 @@
|
||||
id=phh
|
||||
name=phh's SuperUser
|
||||
version=Root Helper
|
||||
versionCode=1
|
||||
author=phhusson, topjohnwu
|
||||
description=This is a helper, please upgrade from downloads section :)
|
||||
support=http://forum.xda-developers.com/showthread.php?t=3216394
|
||||
donate=http://forum.xda-developers.com/donatetome.php?u=1915408
|
||||
cacheModule=false
|
||||
@@ -1,40 +0,0 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
LOGFILE=/cache/magisk.log
|
||||
|
||||
log_print() {
|
||||
echo $1
|
||||
echo "phh: $1" >> $LOGFILE
|
||||
log -p i -t phh "$1"
|
||||
}
|
||||
|
||||
launch_daemonsu() {
|
||||
export PATH=$OLDPATH
|
||||
# Switch contexts
|
||||
echo "u:r:su_daemon:s0" > /proc/self/attr/current
|
||||
# Start daemon
|
||||
exec /magisk/phh/bin/su --daemon
|
||||
}
|
||||
|
||||
# Disable the other root
|
||||
[ -d "/magisk/zzsupersu" ] && touch /magisk/zzsupersu/disable
|
||||
|
||||
log_print "Live patching sepolicy"
|
||||
/magisk/phh/bin/sepolicy-inject --live
|
||||
|
||||
# Expose the root path
|
||||
log_print "Linking supath"
|
||||
rm -rf /magisk/.core/bin
|
||||
ln -s /magisk/phh/bin /magisk/.core/bin
|
||||
|
||||
# Run su.d
|
||||
for script in /magisk/phh/su.d/* ; do
|
||||
if [ -f "$script" ]; then
|
||||
chmod 755 $script
|
||||
log_print "su.d: $script"
|
||||
$script
|
||||
fi
|
||||
done
|
||||
|
||||
log_print "Starting su daemon"
|
||||
(launch_daemonsu &)
|
||||
@@ -1,29 +0,0 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
cd /magisk/00roothelper
|
||||
|
||||
if [ -f "launch_daemonsu.sh" ]; then
|
||||
# SuperSU mode
|
||||
rm -rf /magisk/supersu /magisk/zzsupersu
|
||||
mkdir -p /magisk/zzsupersu
|
||||
cp supersu.sh /magisk/zzsupersu/post-fs-data.sh
|
||||
cp supersu.prop /magisk/zzsupersu/module.prop
|
||||
cp launch_daemonsu.sh /magisk/zzsupersu/launch_daemonsu.sh
|
||||
chmod 755 /magisk/zzsupersu /magisk/zzsupersu/*
|
||||
else
|
||||
# phh mode
|
||||
if [ -f "/magisk/phh/su" ]; then
|
||||
# Old version detected
|
||||
cp /magisk/phh/su su
|
||||
rm -rf /magisk/phh
|
||||
mkdir -p /magisk/phh/bin
|
||||
mkdir -p /magisk/phh/su.d
|
||||
cp su /magisk/phh/bin/su
|
||||
cp /data/magisk/sepolicy-inject /magisk/phh/bin/sepolicy-inject
|
||||
cp phh.sh /magisk/phh/post-fs-data.sh
|
||||
cp phh.prop /magisk/phh/module.prop
|
||||
chmod 755 /magisk/phh /magisk/phh/* /magisk/phh/bin/*
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -rf /magisk/00roothelper
|
||||
@@ -1,7 +0,0 @@
|
||||
id=supersu
|
||||
name=SuperSU Helper
|
||||
version=v1
|
||||
versionCode=1
|
||||
author=topjohnwu
|
||||
description=This is a helper module for Chainfire's SuperSU to work with Magisk
|
||||
cacheModule=false
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
mount -o rw,remount rootfs /
|
||||
mkdir /su 2>/dev/null
|
||||
mount -o ro,remount rootfs /
|
||||
|
||||
chmod 755 /magisk/zzsupersu/launch_daemonsu.sh
|
||||
/magisk/zzsupersu/launch_daemonsu.sh post-fs-data
|
||||
|
||||
rm -rf /magisk/.core/bin
|
||||
ln -s /su/bin /magisk/.core/bin
|
||||
BIN
zip_static/x64/busybox
Normal file
BIN
zip_static/x64/busybox
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user