Compare commits

...

13 Commits
v7 ... v8

Author SHA1 Message Date
topjohnwu
a06ef6fe25 Magisk v8 2016-10-19 06:22:00 +08:00
topjohnwu
696d256fa0 Move root helper location 2016-10-15 05:38:30 +08:00
topjohnwu
70e8ad7104 Add scripts / support for Magisk Hide to Magisk 2016-10-15 05:38:12 +08:00
topjohnwu
f785dcac3d Magisk Hide: Auto unmount necessary files 2016-10-15 05:18:16 +08:00
topjohnwu
aa54ef10ae Magisk Hide: Unmount everything 2016-10-06 17:53:52 +08:00
topjohnwu
14946da163 Magisk Hide done 2016-10-06 04:33:33 +08:00
topjohnwu
5f9bcfbefe Change the name to magiskhide 2016-10-06 02:21:12 +08:00
topjohnwu
aa2eed2c38 Make hidesu hide Magisk and read config file 2016-10-06 02:17:21 +08:00
Pierre-Hugues Husson
6bff6e9cff [hidesu] Don't suicide 2016-10-05 04:11:07 +08:00
Pierre-Hugues Husson
023d369b74 Move to android-21 NDK 2016-10-05 04:10:24 +08:00
Pierre-Hugues Husson
c9d4241afe PoC++ of hidesu
This uses logcat -b events to search for new process
2016-10-05 04:10:05 +08:00
Pierre-Hugues Husson
e1279c29c2 Add hidesu program.
This is a test program, this will probably be integrated into su daemon.
This hides su by bind-mounting something (/system) over /sbin, so that
there is no /sbin/su binary.
Usage:
hidesu /proc/<one pid of the namespace>/ns/mnt

This uses the fact that when a program wants access to /sdcard, zygote
does this using mount namespaces, so every program accessing /sdcard
will be in a custom mount namespace, that can be modified.
2016-10-05 04:07:48 +08:00
Tom Briden
2d6fb1c45e Only delete verity_key if ! $KEEPVERITY
otherwise the device can't boot
2016-10-04 14:56:02 -05:00
19 changed files with 383 additions and 216 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
obj
libs
*.zip

View File

@@ -1,4 +1,3 @@
# Magisk
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

View File

@@ -2,6 +2,15 @@ my_path := $(call my-dir)
LOCAL_PATH := $(my_path)
include $(CLEAR_VARS)
LOCAL_MODULE := magiskhide
LOCAL_MODULE_TAGS := optional
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_LDFLAGS := -static
LOCAL_STATIC_LIBRARIES := libc libcutils
LOCAL_SRC_FILES := magiskhide.c
include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_MODULE := bootimgtools
LOCAL_MODULE_TAGS := optional

View File

@@ -1,2 +1,3 @@
APP_ABI := x86 armeabi
APP_PIE = true
APP_PLATFORM := android-21

165
jni/magiskhide.c Normal file
View File

@@ -0,0 +1,165 @@
typedef unsigned short int sa_family_t;
//Linux includes
#define _LINUX_TIME_H
#define _GNU_SOURCE
#include <sys/types.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/connector.h>
#include <linux/cn_proc.h>
#include <linux/netlink.h>
#include <linux/fs.h>
#include <sys/socket.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <asm/unistd.h>
#include <sys/mount.h>
char **file_to_str_arr(FILE *fp, int *size) {
int allocated = 16;
char *line = NULL, **array;
size_t len = 0;
ssize_t read;
array = (char **) malloc(sizeof(char*) * allocated);
*size = 0;
while ((read = getline(&line, &len, fp)) != -1) {
if (*size >= allocated) {
// Double our allocation and re-allocate
allocated *= 2;
array = (char **) realloc(array, sizeof(char*) * allocated);
}
// Remove end newline
if (line[read - 1] == '\n') {
line[read - 1] = '\0';
}
array[*size] = line;
line = NULL;
++(*size);
}
return array;
}
//WARNING: Calling this will change our current namespace
//We don't care because we don't want to run from here anyway
int hideMagisk(int pid) {
char *path = NULL;
asprintf(&path, "/proc/%d/ns/mnt", pid);
int fd = open(path, O_RDONLY);
if(fd == -1) return 2;
int res = syscall(SYS_setns, fd, 0);
if(res == -1) return 3;
free(path);
path = NULL;
asprintf(&path, "/proc/%d/mounts", pid);
FILE *mount_fp = fopen(path, "r");
if (mount_fp == NULL) {
fprintf(stderr, "Error opening mount list!\n");
return 1;
}
free(path);
int mount_size;
char **mount_list = file_to_str_arr(mount_fp, &mount_size), mountpoint[256], *sbstr;
fclose(mount_fp);
int i, unmount = 0;
for(i = mount_size - 1; i >= 0; --i) {
if((strstr(mount_list[i], "/dev/block/loop") != NULL)) {
sscanf(mount_list[i], "%256s %256s", mountpoint, mountpoint);
if (strstr(mountpoint, "/.core/dummy") != NULL)
unmount = 0;
else
unmount = 1;
} else if ((sbstr = strstr(mount_list[i], "/.core/dummy")) != NULL) {
sscanf(sbstr, "/.core/dummy%256s", mountpoint);
unmount = 1;
}
if(unmount) {
unmount = 0;
res = umount2(mountpoint, MNT_DETACH);
if (res != -1) printf("Unmounted: %s\n", mountpoint);
else printf("Failed: %s\n", mountpoint);
}
free(mount_list[i]);
}
// Free memory
free(mount_list);
return 0;
}
int main(int argc, char **argv, char **envp) {
if (argc != 2) {
fprintf(stderr, "%s <process/package name list>\n", argv[0]);
return 1;
}
int i, hide_size;
char **hide_list;
FILE *hide_fp = fopen(argv[1], "r");
if (hide_fp == NULL) {
fprintf(stderr, "Error opening hide list\n");
return 1;
}
hide_list = file_to_str_arr(hide_fp, &hide_size);
fclose(hide_fp);
printf("Get process / package name from config:\n");
for(i = 0; i < hide_size; i++)
printf("%s\n", hide_list[i]);
printf("\n");
char buffer[512];
FILE *p = popen("while true;do logcat -b events -v raw -s am_proc_start;sleep 1;done", "r");
while(!feof(p)) {
//Format of am_proc_start is (as of Android 5.1 and 6.0)
//UserID, pid, unix uid, processName, hostingType, hostingName
fgets(buffer, sizeof(buffer), p);
{
char *pos = buffer;
while(1) {
pos = strchr(pos, ',');
if(pos == NULL)
break;
pos[0] = ' ';
}
}
int user, pid, uid;
char processName[256], hostingType[16], hostingName[256];
int ret = sscanf(buffer, "[%d %d %d %256s %16s %256s]",
&user, &pid, &uid,
processName, hostingType, hostingName);
if(ret != 6) {
continue;
}
for (i = 0; i < hide_size; ++i) {
if(strstr(processName, hide_list[i]) != NULL) {
printf("Disabling for process = %s, PID = %d, UID = %d\n", processName, pid, uid);
hideMagisk(pid);
break;
}
}
}
pclose(p);
// Free memory
for(i = 0; i < hide_size; ++i)
free(hide_list[i]);
free(hide_list);
return 0;
}

View File

@@ -185,7 +185,7 @@ repack_boot() {
##########################################################################################
ui_print "****************************"
ui_print "Magisk v7 Boot Image Patcher"
ui_print "Magisk v8 Boot Image Patcher"
ui_print "****************************"
if [ ! -d "$INSTALLER/common" ]; then
@@ -270,6 +270,7 @@ if (is_mounted /data); then
rm -rf /data/busybox /data/magisk 2>/dev/null
mkdir -p /data/busybox
cp -af $BINDIR /data/magisk
cp -af $INSTALLER/common/init.magisk.rc $INSTALLER/common/magic_mask.sh /data/magisk
chmod 755 /data/busybox /data/magisk /data/magisk/*
chcon 'u:object_r:system_file:s0' /data/busybox /data/magisk /data/magisk/*
/data/magisk/busybox --install -s /data/busybox
@@ -279,6 +280,7 @@ else
rm -rf /cache/data_bin 2>/dev/null
mkdir -p /cache/data_bin
cp -af $BINDIR /cache/data_bin
cp -af $INSTALLER/common/init.magisk.rc $INSTALLER/common/magic_mask.sh /cache/data_bin
fi
##########################################################################################
@@ -309,6 +311,13 @@ if (! is_mounted /magisk); then
fi
MAGISKLOOP=$LOOPDEVICE
mkdir -p /magisk/.core/magiskhide 2>/dev/null
cp -af $INSTALLER/common/magiskhide/. /magisk/.core/magiskhide
# Remove legacy SuperSU module
mkdir -p /magisk/zzsupersu
touch /magisk/zzsupersu/remove
##########################################################################################
# Boot image patch
##########################################################################################
@@ -332,92 +341,45 @@ dd if=$BOOTIMAGE of=$ORIGBOOT
ui_print "- Unpacking boot image"
unpack_boot $ORIGBOOT
# Restore ramdisk
SUPERSU=false
if (! $NORESTORE); then
# Backups
if [ -d ".backup" ]; then
ui_print "- Restoring ramdisk with backup"
cp -af .backup/* .
ui_print "- Restoring ramdisk with ramdisk backup"
cp -af .backup/. .
rm -rf magisk init.magisk.rc sbin/magic_mask.sh 2>/dev/null
else
if [ -f "sbin/launch_daemonsu.sh" ]; then
SUPERSU=true
# Save it for helper module
mkdir -p /magisk/zzsupersu
touch /magisk/zzsupersu/stub
cp -af sbin/launch_daemonsu.sh $INSTALLER/roothelper/launch_daemonsu.sh
fi
# Non-standard boot image restores
[ -f "sbin/launch_daemonsu.sh" ] && SUPERSU=true
if ($SUPERSU); then
ui_print "- SuperSU patched boot detected"
# Restore with SuperSU's backup
MOUNTSU=false
(! is_mounted /su) && (is_mounted /data) && mount_image /data/su.img /su && MOUNTSU=true
if (is_mounted /su); then
# Use sukernel's built-in functions
ui_print "- Using sukernel to restore boot image"
cd $UNPACKDIR
gunzip -c < $UNPACKDIR/ramdisk.gz > suramdisk
/su/bin/sukernel --restore suramdisk /data/stock_boot.img
if [ "$?" -ne "0" ]; then
# No boot backup found, use ramdisk backup
ui_print "- Restoring ramdisk with backup"
/su/bin/sukernel --cpio-restore suramdisk suramdisk
rm -rf $RAMDISK
mkdir -p $RAMDISK
cd $RAMDISK
cpio -i < $UNPACKDIR/suramdisk
rm -f $UNPACKDIR/suramdisk
else
ui_print "- Restoring boot image with backup"
cp -af /data/stock_boot.img $ORIGBOOT
unpack_boot $ORIGBOOT
fi
if ($MOUNTSU); then
ui_print "- Unmounting su.img"
umount /su
losetup -d $LOOPDEVICE
fi
else
# Find the boot backup ourselves
ui_print "! su.img mount failed... find the backup ourselves"
cp -af /data/stock_boot_*.gz /data/stock_boot.img.gz 2>/dev/null
gzip -d /data/stock_boot.img.gz 2>/dev/null
rm -rf /data/stock_boot.img.gz 2>/dev/null
if [ -f "/data/stock_boot.img" ]; then
ui_print "- Restoring boot image with backup"
cp -af /data/stock_boot.img $ORIGBOOT
unpack_boot $ORIGBOOT
else
ui_print "! No backups found"
ui_print "! Installer will still proceed, but might cause issues"
ui_print "! If possible, please restore to stock boot then flash Magisk again"
# Force removing SuperSU parts
rm -rf su init.supersu.rc sbin/launch_daemonsu.sh 2>/dev/null
fi
fi
else
# Magisk's own situation
if [ -d "magisk" ]; 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
if [ -f "/data/stock_boot.img" ]; then
ui_print "- Restoring boot image with backup"
cp -af /data/stock_boot.img $ORIGBOOT
unpack_boot $ORIGBOOT
else
ui_print "! No backups found"
ui_print "! Installer will still proceed, but might cause issues"
ui_print "! If possible, please restore to stock boot then flash Magisk again"
# Removing other boot image modifications
rm -rf sbin/su init.xposed.rc sbin/mount_xposed.sh 2>/dev/null
fi
fi
ui_print "- SuperSU patched boot detected!"
ui_print "- Adding auto patch script for SuperSU"
cp -af $INSTALLER/common/custom_ramdisk_patch.sh /data/custom_ramdisk_patch.sh
fi
ui_print "- Creating backups"
mkdir .backup
cp -af init.rc *fstab* verity_key sepolicy .backup 2>/dev/null
if [ -d "magisk" ]; then
# If Magisk is installed and no SuperSU and no ramdisk backups
# Restore previous stock boot image
if (! $SUPERSU); 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
if [ -f "/data/stock_boot.img" ]; then
ui_print "- Restoring boot image with backup"
cp -af /data/stock_boot.img $ORIGBOOT
unpack_boot $ORIGBOOT
fi
fi
# Removing possible modifications
rm -rf magisk init.magisk.rc sbin/magic_mask.sh 2>/dev/null
rm -rf init.xposed.rc sbin/mount_xposed.sh 2>/dev/null
fi
fi
fi
if (! $SUPERSU); then
ui_print "- Creating backups"
mkdir .backup 2>/dev/null
cp -af init.environ.rc *fstab* verity_key sepolicy .backup 2>/dev/null
if (! $SUPERSU); then
# SuperSU already backup stock boot, no need to do again
if (is_mounted /data); then
cp -af $ORIGBOOT /data/stock_boot.img
else
@@ -426,29 +388,46 @@ if (! $NORESTORE); then
fi
fi
ui_print "- Installing root helper module"
cp -af $INSTALLER/roothelper /magisk/00roothelper
chmod 755 /magisk/00roothelper /magisk/00roothelper/*
# Patch ramdisk
ui_print "- Patching ramdisk"
if [ $(grep -c "import /init.magisk.rc" init.rc) -eq "0" ]; then
sed -i "/import \/init\.environ\.rc/iimport /init.magisk.rc" init.rc
fi
sed -i "/selinux.reload_policy/d" init.rc
find . -type f -name "*fstab*" 2>/dev/null | while read FSTAB ; do
if (! $KEEPVERITY); then
sed -i "s/,support_scfs//g" $FSTAB
sed -i 's;,\{0,1\}verify\(=[^,]*\)\{0,1\};;g' $FSTAB
fi
if (! $KEEPFORCEENCRYPT); then
sed -i "s/forceencrypt/encryptable/g" $FSTAB
sed -i "s/forcefdeorfbe/encryptable/g" $FSTAB
# 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
cp $INIT .backup
sed -i "/import \/init\.environ\.rc/iimport /init.magisk.rc" $INIT
break
fi
done
rm verity_key 2>/dev/null
# Add magisk PATH
if [ $(grep -c "export PATH" init.environ.rc) -eq "0" ]; then
sed -i "/on init/a\ \ \ \ export PATH /magisk/.core/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:/magisk/.core/busybox" init.environ.rc
else
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
fi
if [ $(grep -c "/magisk/.core/bin" init.environ.rc) -eq "0" ] && (! $SUPERSU); then
sed -i "/export PATH/ s/\/sbin/\/magisk\/.core\/bin:\/sbin/g" init.environ.rc
fi
fi
if (! $SUPERSU); then
sed -i "/selinux.reload_policy/d" init.rc
find . -type f -name "*fstab*" 2>/dev/null | while read FSTAB ; do
if (! $KEEPVERITY); then
sed -i "s/,support_scfs//g" $FSTAB
sed -i 's;,\{0,1\}verify\(=[^,]*\)\{0,1\};;g' $FSTAB
fi
if (! $KEEPFORCEENCRYPT); then
sed -i "s/forceencrypt/encryptable/g" $FSTAB
sed -i "s/forcefdeorfbe/encryptable/g" $FSTAB
fi
done
if (! $KEEPVERITY); then
rm verity_key 2>/dev/null
fi
fi
# sepolicy patches
$BINDIR/sepolicy-inject --magisk -P sepolicy

BIN
zip_static/arm/magiskhide Normal file

Binary file not shown.

View 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

View File

@@ -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.hide=1
restart magisk_hide
# Services
@@ -37,3 +33,9 @@ service magisk_service /sbin/magic_mask.sh service
user root
seclabel u:r:su:s0
oneshot
# launch magisk hide script
service magisk_hide /sbin/magic_mask.sh hide
user root
seclabel u:r:su:s0
oneshot

View File

@@ -1,9 +1,12 @@
#!/system/bin/sh
LOGFILE=/cache/magisk.log
HIDELOG=/cache/magiskhide.log
IMG=/data/magisk.img
COREDIR=/magisk/.core
export MOUNTPOINT=/magisk
COREDIR=$MOUNTPOINT/.core
DUMMDIR=$COREDIR/dummy
MIRRDIR=$COREDIR/mirror
@@ -38,7 +41,7 @@ unblock() {
}
run_scripts() {
BASE=/magisk
BASE=$MOUNTPOINT
if [ "$1" = "post-fs" ]; then
BASE=/cache/magisk
fi
@@ -137,8 +140,11 @@ travel() {
bind_mount() {
if [ -e "$1" -a -e "$2" ]; then
mount -o bind $1 $2
if [ "$?" -eq "0" ]; then log_print "Mount: $1";
else log_print "Mount Fail: $1"; fi
if [ "$?" -eq "0" ]; then
log_print "Mount: $1"
else
log_print "Mount Fail: $1"
fi
fi
}
@@ -188,6 +194,7 @@ merge_image() {
# Merge (will reserve selinux contexts)
cd /cache/merge_img
for MOD in *; do
log_print "Merging: $MOD"
rm -rf /cache/data_img/$MOD
cp -afc $MOD /cache/data_img/
done
@@ -222,8 +229,9 @@ case $1 in
if [ -d "/cache/magisk_merge" ]; then
cd /cache/magisk_merge
for MOD in *; do
log_print "Merging: $MOD"
rm -rf /cache/magisk/$MOD
cp -afc $MOD /cache/magisk/
mv $MOD /cache/magisk/$MOD
done
rm -rf /cache/magisk_merge
fi
@@ -260,6 +268,8 @@ case $1 in
# Live patch sepolicy
/data/magisk/sepolicy-inject --live -s su
[ ! -d "$MOUNTPOINT" ] && mkdir -p $MOUNTPOINT
# Cache support
if [ -d "/cache/data_bin" ]; then
rm -rf /data/busybox /data/magisk
@@ -280,14 +290,14 @@ case $1 in
merge_image /data/magisk_merge.img
# Mount magisk.img
if [ `cat /proc/mounts | grep /magisk >/dev/null 2>&1; echo $?` -ne 0 ]; then
if [ `cat /proc/mounts | grep $MOUNTPOINT >/dev/null 2>&1; echo $?` -ne 0 ]; then
loopsetup $IMG
if [ ! -z "$LOOPDEVICE" ]; then
mount -t ext4 -o rw,noatime $LOOPDEVICE /magisk
mount -t ext4 -o rw,noatime $LOOPDEVICE $MOUNTPOINT
fi
fi
if [ `cat /proc/mounts | grep /magisk >/dev/null 2>&1; echo $?` -ne 0 ]; then
if [ `cat /proc/mounts | grep $MOUNTPOINT >/dev/null 2>&1; echo $?` -ne 0 ]; then
log_print "magisk.img mount failed, nothing to do :("
unblock
fi
@@ -295,14 +305,14 @@ case $1 in
log_print "Preparing modules"
# First do cleanups
rm -rf $DUMMDIR
rmdir $(find /magisk -type d -depth ! -path "*core*" ) 2>/dev/null
rmdir $(find $MOUNTPOINT -type d -depth ! -path "*core*" ) 2>/dev/null
rm -rf $COREDIR/bin
mkdir -p $DUMMDIR
mkdir -p $MIRRDIR/system
# Travel through all mods
for MOD in /magisk/* ; do
for MOD in $MOUNTPOINT/* ; do
if [ -f "$MOD/remove" ]; then
log_print "Remove module: $MOD"
rm -rf $MOD
@@ -325,7 +335,7 @@ case $1 in
fi
# Unmount, shrink, remount
if [ `umount /magisk >/dev/null 2>&1; echo $?` -eq 0 ]; then
if [ `umount $MOUNTPOINT >/dev/null 2>&1; echo $?` -eq 0 ]; then
losetup -d $LOOPDEVICE
target_size_check $IMG
NEWDATASIZE=$(((curUsedM / 32 + 2) * 32))
@@ -335,17 +345,17 @@ case $1 in
fi
loopsetup $IMG
if [ ! -z "$LOOPDEVICE" ]; then
mount -t ext4 -o rw,noatime $LOOPDEVICE /magisk
mount -t ext4 -o rw,noatime $LOOPDEVICE $MOUNTPOINT
fi
fi
if [ `cat /proc/mounts | grep /magisk >/dev/null 2>&1; echo $?` -ne 0 ]; then
if [ `cat /proc/mounts | grep $MOUNTPOINT >/dev/null 2>&1; echo $?` -ne 0 ]; then
log_print "magisk.img mount failed, nothing to do :("
unblock
fi
# Remove crap folder
rm -rf /magisk/lost+found
rm -rf $MOUNTPOINT/lost+found
# Start doing tasks
@@ -395,9 +405,25 @@ case $1 in
service )
# Version info
setprop magisk.version 7
setprop magisk.version 8
log_print "Magisk late_start service mode running..."
run_scripts service
[ -f "$COREDIR/magiskhide/enable" ] && setprop magisk.hide 1
;;
hide )
# Enable magiskhide
[ ! -f "$COREDIR/magiskhide/hidelist" ] && mktouch $COREDIR/magiskhide/hidelist
# Add preset for Safety Net
if [ $(grep -c "com.google.android.gms.unstable" $COREDIR/magiskhide/hidelist) -eq "0" ]; then
mv $COREDIR/magiskhide/hidelist $COREDIR/magiskhide/hidelist.tmp
echo "com.google.android.gms.unstable" > $COREDIR/magiskhide/hidelist
cat $COREDIR/magiskhide/hidelist.tmp >> $COREDIR/magiskhide/hidelist
rm -f $COREDIR/magiskhide/hidelist.tmp
fi
chmod 755 $COREDIR/magiskhide $COREDIR/magiskhide/*
log_print "Starting Magisk Hide"
exec /data/magisk/magiskhide $COREDIR/magiskhide/hidelist > $HIDELOG
;;
esac

View File

@@ -0,0 +1,12 @@
#!/system/bin/sh
HIDELIST=$MOUNTPOINT/.core/magiskhide/hidelist
if [ ! -z "$1" ]; then
if [ $(grep -c "^$1$" $HIDELIST) -eq "0" ]; then
echo "$1" >> $HIDELIST
fi
fi
# Reload the list
setprop magisk.hide 1

View File

@@ -0,0 +1,4 @@
#!/system/bin/sh
HIDELIST=$MOUNTPOINT/.core/magiskhide/hidelist
cat $HIDELIST

View File

@@ -0,0 +1,12 @@
#!/system/bin/sh
HIDELIST=$MOUNTPOINT/.core/magiskhide/hidelist
if [ ! -z "$1" ]; then
mv $HIDELIST $HIDELIST.tmp
cat $HIDELIST.tmp | grep -v "^$1$" > $HIDELIST
rm -f $HIDELIST.tmp
fi
# Reload the list
setprop magisk.hide 1

View File

@@ -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

View File

@@ -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 &)

View File

@@ -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

View File

@@ -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

View File

@@ -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/x86/magiskhide Normal file

Binary file not shown.