mirror of
https://github.com/kdrag0n/safetynet-fix.git
synced 2024-07-01 02:28:54 +00:00
Remove Riru implementation
Zygisk is now the primary implementation of this module. NB: The Zygisk module template is in the public domain, so attribution is no longer needed in the license.
This commit is contained in:
parent
b6508f642d
commit
8015d36786
2
LICENSE
2
LICENSE
|
@ -2,8 +2,6 @@ The MIT License (MIT)
|
|||
|
||||
Copyright (c) 2021 Danny Lin <danny@kdrag0n.dev>
|
||||
|
||||
Riru Module Template: Copyright (c) 2020 Rikka
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
|
|
4
riru/.gitattributes
vendored
4
riru/.gitattributes
vendored
|
@ -1,4 +0,0 @@
|
|||
* text=auto eol=lf
|
||||
|
||||
*.bat text eol=crlf
|
||||
*.jar binary
|
14
riru/.gitignore
vendored
14
riru/.gitignore
vendored
|
@ -1,14 +0,0 @@
|
|||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
.idea
|
||||
/.idea/caches/build_file_checksums.ser
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
/out
|
||||
.externalNativeBuild
|
||||
.cxx
|
|
@ -1,35 +0,0 @@
|
|||
apply plugin: 'idea'
|
||||
|
||||
idea.module {
|
||||
excludeDirs += file('out')
|
||||
resourceDirs += file('template')
|
||||
resourceDirs += file('scripts')
|
||||
}
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.2.2'
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
minSdkVersion = 23
|
||||
targetSdkVersion = 30
|
||||
|
||||
outDir = file("$rootDir/out")
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir, outDir
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Automatically convert third-party libraries to use AndroidX
|
||||
android.enableJetifier=true
|
||||
# https://github.com/google/prefab/issues/122
|
||||
# Remove this until AGP update prefab version
|
||||
android.prefabVersion=1.1.3
|
BIN
riru/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
riru/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
|
@ -1,6 +0,0 @@
|
|||
#Mon Jul 12 21:05:17 CST 2021
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
172
riru/gradlew
vendored
172
riru/gradlew
vendored
|
@ -1,172 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
84
riru/gradlew.bat
vendored
84
riru/gradlew.bat
vendored
|
@ -1,84 +0,0 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
|
@ -1,30 +0,0 @@
|
|||
ext {
|
||||
/*
|
||||
This name will be used in the name of the so file ("lib${moduleLibraryName}.so").
|
||||
*/
|
||||
moduleLibraryName = "safetynetfix"
|
||||
|
||||
/* Minimal supported Riru API version, used in the version check of riru.sh */
|
||||
moduleMinRiruApiVersion = 24
|
||||
|
||||
/* The version name of minimal supported Riru, used in the version check of riru.sh */
|
||||
moduleMinRiruVersionName = "v24.0.0"
|
||||
|
||||
/* Maximum supported Riru API version, used in the version check of riru.sh */
|
||||
moduleRiruApiVersion = 26
|
||||
|
||||
/*
|
||||
Magisk module ID
|
||||
Since Magisk use it to distinguish different modules, you should never change it.
|
||||
|
||||
Note, the older version of the template uses '-' instead of '_', if your are upgrading from
|
||||
the older version, please pay attention.
|
||||
*/
|
||||
magiskModuleId = "safetynet-fix"
|
||||
|
||||
moduleName = "Universal SafetyNet Fix"
|
||||
moduleAuthor = "kdrag0n"
|
||||
moduleDescription = "A universal fix for SafetyNet on Android 7–12 devices with hardware attestation and unlocked bootloaders. Requires MagiskHide and Riru $moduleMinRiruVersionName or newer."
|
||||
moduleVersion = "v2.1.1"
|
||||
moduleVersionCode = 20101
|
||||
}
|
3
riru/module/.gitignore
vendored
3
riru/module/.gitignore
vendored
|
@ -1,3 +0,0 @@
|
|||
/.externalNativeBuild
|
||||
/build
|
||||
/release
|
|
@ -1,136 +0,0 @@
|
|||
import org.apache.tools.ant.filters.FixCrLfFilter
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
|
||||
import java.security.MessageDigest
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply from: file(rootProject.file('module.gradle'))
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.targetSdkVersion
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments "-DMODULE_NAME:STRING=$moduleLibraryName",
|
||||
"-DRIRU_MODULE_API_VERSION=$moduleRiruApiVersion",
|
||||
"-DRIRU_MODULE_VERSION=$moduleVersionCode",
|
||||
"-DRIRU_MODULE_VERSION_NAME:STRING=$moduleVersion",
|
||||
"-DRIRU_MODULE_MIN_API_VERSION=$moduleMinRiruApiVersion"
|
||||
}
|
||||
}
|
||||
}
|
||||
buildFeatures {
|
||||
prefab true
|
||||
}
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "src/main/cpp/CMakeLists.txt"
|
||||
version "3.10.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// This is prefab aar which contains "riru.h"
|
||||
// If you want to use older versions of AGP,
|
||||
// you can copy this file from https://github.com/RikkaApps/Riru/blob/master/riru/src/main/cpp/include_riru/riru.h
|
||||
|
||||
// The default version of prefab in AGP has problem to process header only package,
|
||||
// you may have to add "android.prefabVersion" in your gradle.properties.
|
||||
// See https://github.com/google/prefab/issues/122
|
||||
|
||||
implementation 'dev.rikka.ndk:riru:26.0.0'
|
||||
}
|
||||
|
||||
|
||||
afterEvaluate {
|
||||
android.libraryVariants.forEach { variant ->
|
||||
def variantCapped = variant.name.capitalize()
|
||||
def variantLowered = variant.name.toLowerCase()
|
||||
|
||||
def zipName = "${magiskModuleId.replace('_', '-')}-${moduleVersion}-${variantLowered}.zip"
|
||||
def magiskDir = file("$outDir/magisk_module_$variantLowered")
|
||||
|
||||
task("prepareMagiskFiles${variantCapped}", type: Sync) {
|
||||
dependsOn("assemble$variantCapped")
|
||||
|
||||
def templatePath = "$rootDir/template/magisk_module"
|
||||
|
||||
into magiskDir
|
||||
from(templatePath) {
|
||||
exclude 'riru.sh', 'module.prop'
|
||||
}
|
||||
from(templatePath) {
|
||||
include 'riru.sh'
|
||||
filter(ReplaceTokens.class, tokens: [
|
||||
"RIRU_MODULE_LIB_NAME" : moduleLibraryName,
|
||||
"RIRU_MODULE_API_VERSION" : moduleRiruApiVersion.toString(),
|
||||
"RIRU_MODULE_MIN_API_VERSION" : moduleMinRiruApiVersion.toString(),
|
||||
"RIRU_MODULE_MIN_RIRU_VERSION_NAME": moduleMinRiruVersionName,
|
||||
])
|
||||
filter(FixCrLfFilter.class,
|
||||
eol: FixCrLfFilter.CrLf.newInstance("lf"))
|
||||
}
|
||||
from(templatePath) {
|
||||
include 'module.prop'
|
||||
expand([
|
||||
id : magiskModuleId,
|
||||
name : moduleName,
|
||||
version : moduleVersion,
|
||||
versionCode: moduleVersionCode.toString(),
|
||||
author : moduleAuthor,
|
||||
description: moduleDescription,
|
||||
])
|
||||
filter(FixCrLfFilter.class,
|
||||
eol: FixCrLfFilter.CrLf.newInstance("lf"))
|
||||
}
|
||||
from("$buildDir/intermediates/stripped_native_libs/$variantLowered/out/lib") {
|
||||
into 'lib'
|
||||
}
|
||||
doLast {
|
||||
fileTree("$magiskDir").visit { f ->
|
||||
if (f.directory) return
|
||||
if (f.file.name == '.gitattributes') return
|
||||
|
||||
def md = MessageDigest.getInstance("SHA-256")
|
||||
f.file.eachByte 4096, { bytes, size ->
|
||||
md.update(bytes, 0, size)
|
||||
}
|
||||
file(f.file.path + ".sha256sum").text = md.digest().encodeHex()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task("zip${variantCapped}", type: Zip) {
|
||||
dependsOn("prepareMagiskFiles${variantCapped}")
|
||||
from magiskDir
|
||||
archiveName zipName
|
||||
destinationDir outDir
|
||||
}
|
||||
|
||||
task("push${variantCapped}", type: Exec) {
|
||||
dependsOn("zip${variantCapped}")
|
||||
workingDir outDir
|
||||
commandLine android.adbExecutable, "push", zipName, "/data/local/tmp/"
|
||||
}
|
||||
|
||||
task("flash${variantCapped}", type: Exec) {
|
||||
dependsOn("push${variantCapped}")
|
||||
commandLine android.adbExecutable, "shell", "su", "-c",
|
||||
"magisk --install-module /data/local/tmp/${zipName}"
|
||||
}
|
||||
|
||||
task("flashAndReboot${variantCapped}", type: Exec) {
|
||||
dependsOn("flash${variantCapped}")
|
||||
commandLine android.adbExecutable, "shell", "reboot"
|
||||
}
|
||||
|
||||
variant.assembleProvider.get().finalizedBy("zip${variantCapped}")
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
<manifest package="riru.template" />
|
|
@ -1,44 +0,0 @@
|
|||
cmake_minimum_required(VERSION 3.4.1)
|
||||
|
||||
if (NOT DEFINED MODULE_NAME)
|
||||
message(FATAL_ERROR "MODULE_NAME is not set")
|
||||
else ()
|
||||
project(${MODULE_NAME})
|
||||
endif ()
|
||||
|
||||
add_definitions(-DRIRU_MODULE)
|
||||
|
||||
configure_file(template/config.cpp config.cpp)
|
||||
|
||||
message("Build type: ${CMAKE_BUILD_TYPE}")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
set(LINKER_FLAGS "-ffixed-x18 -Wl,--hash-style=both")
|
||||
set(C_FLAGS "-Werror=format -fdata-sections -ffunction-sections")
|
||||
set(CXX_FLAGS "${CXX_FLAGS} -fno-exceptions -fno-rtti")
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(C_FLAGS "${C_FLAGS} -O2 -fvisibility=hidden -fvisibility-inlines-hidden")
|
||||
set(LINKER_FLAGS "${LINKER_FLAGS} -Wl,-exclude-libs,ALL -Wl,--gc-sections -Wl,--strip-all")
|
||||
else ()
|
||||
set(C_FLAGS "${C_FLAGS} -O0")
|
||||
endif ()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${C_FLAGS} ${CXX_FLAGS}")
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINKER_FLAGS}")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${LINKER_FLAGS}")
|
||||
|
||||
find_package(riru REQUIRED CONFIG)
|
||||
|
||||
include_directories(include)
|
||||
|
||||
add_library(${MODULE_NAME} SHARED main.cpp ${CMAKE_CURRENT_BINARY_DIR}/config.cpp)
|
||||
target_link_libraries(${MODULE_NAME} log riru::riru)
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
add_custom_command(TARGET ${MODULE_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_STRIP} --strip-all --remove-section=.comment "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${MODULE_NAME}.so")
|
||||
endif ()
|
|
@ -1,8 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
namespace riru {
|
||||
extern const int moduleVersionCode;
|
||||
extern const char* const moduleVersionName;
|
||||
extern const int moduleApiVersion;
|
||||
extern const int moduleMinApiVersion;
|
||||
}
|
|
@ -1,198 +0,0 @@
|
|||
#include <jni.h>
|
||||
#include <sys/types.h>
|
||||
#include <riru.h>
|
||||
#include <malloc.h>
|
||||
#include <cstring>
|
||||
#include <config.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <android/log.h>
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define DEBUG(...) __android_log_write(ANDROID_LOG_DEBUG, "SafetyNetRiru/JNI", __VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG(...)
|
||||
#endif
|
||||
|
||||
static void *moduleDex;
|
||||
static size_t moduleDexSize;
|
||||
|
||||
static constexpr size_t APP_DATA_DIR_SIZE = 128;
|
||||
static char lastAppDataDir[APP_DATA_DIR_SIZE];
|
||||
|
||||
static void updateAppDataDir(JNIEnv *env, jstring appDataDir) {
|
||||
DEBUG("updateAppDataDir");
|
||||
if (!appDataDir) {
|
||||
DEBUG("dir is null");
|
||||
memset(lastAppDataDir, 0, APP_DATA_DIR_SIZE);
|
||||
} else {
|
||||
DEBUG("copy dir");
|
||||
// For simplicity, copy it into the buffer and release the JNI copy instead
|
||||
// of keeping the JNI string reference.
|
||||
const char *copy = env->GetStringUTFChars(appDataDir, NULL);
|
||||
strncpy(lastAppDataDir, copy, APP_DATA_DIR_SIZE);
|
||||
env->ReleaseStringUTFChars(appDataDir, copy);
|
||||
DEBUG(lastAppDataDir);
|
||||
}
|
||||
}
|
||||
|
||||
static void specializeCommon(JNIEnv *env) {
|
||||
DEBUG("specializeCommon");
|
||||
DEBUG(lastAppDataDir);
|
||||
if (!moduleDex || !strstr(lastAppDataDir, "com.google.android.gms")) {
|
||||
DEBUG("dex null or pkg doesn't match");
|
||||
riru_set_unload_allowed(true);
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG("get system classloader");
|
||||
// First, get the system classloader
|
||||
jclass clClass = env->FindClass("java/lang/ClassLoader");
|
||||
jmethodID getSystemClassLoader = env->GetStaticMethodID(clClass, "getSystemClassLoader", "()Ljava/lang/ClassLoader;");
|
||||
jobject systemClassLoader = env->CallStaticObjectMethod(clClass, getSystemClassLoader);
|
||||
|
||||
DEBUG("create buf");
|
||||
// Assuming we have a valid mapped module, load it. This is similar to the approach used for
|
||||
// Dynamite modules in GmsCompat, except we can use InMemoryDexClassLoader directly instead of
|
||||
// tampering with DelegateLastClassLoader's DexPathList.
|
||||
jobject buf = env->NewDirectByteBuffer(moduleDex, moduleDexSize);
|
||||
DEBUG("construct dex cl");
|
||||
jclass dexClClass = env->FindClass("dalvik/system/InMemoryDexClassLoader");
|
||||
jmethodID dexClInit = env->GetMethodID(dexClClass, "<init>", "(Ljava/nio/ByteBuffer;Ljava/lang/ClassLoader;)V");
|
||||
jobject dexCl = env->NewObject(dexClClass, dexClInit, buf, systemClassLoader);
|
||||
|
||||
// Load the class
|
||||
DEBUG("load class method lookup");
|
||||
jmethodID loadClass = env->GetMethodID(clClass, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;");
|
||||
DEBUG("call load class");
|
||||
jstring entryClassName = env->NewStringUTF("dev.kdrag0n.safetynetriru.EntryPoint");
|
||||
jobject entryClassObj = env->CallObjectMethod(dexCl, loadClass, entryClassName);
|
||||
|
||||
// Call init. Static initializers don't run when merely calling loadClass from JNI.
|
||||
DEBUG("call init");
|
||||
auto entryClass = (jclass) entryClassObj;
|
||||
jmethodID entryInit = env->GetStaticMethodID(entryClass, "init", "()V");
|
||||
env->CallStaticVoidMethod(entryClass, entryInit);
|
||||
DEBUG("specializeCommon end");
|
||||
}
|
||||
|
||||
static void *readFile(char *path, size_t *fileSize) {
|
||||
int fd = open(path, O_RDONLY, 0);
|
||||
if (fd < 0) {
|
||||
DEBUG("open fail");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Get size
|
||||
DEBUG("get size");
|
||||
*fileSize = lseek(fd, 0, SEEK_END);
|
||||
if (*fileSize < 0) {
|
||||
DEBUG("seek fail");
|
||||
return nullptr;
|
||||
}
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
|
||||
// Map
|
||||
/*
|
||||
DEBUG("mmap");
|
||||
moduleDex = mmap(nullptr, *fileSize, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (moduleDex == MAP_FAILED) {
|
||||
DEBUG("mmap fail");
|
||||
}*/
|
||||
|
||||
// Read the entire file into a buffer
|
||||
// TODO: see if mmap path is visible in /proc/pid/maps after closing and forking
|
||||
char *data = (char *) malloc(*fileSize);
|
||||
int bytes = 0;
|
||||
while (bytes < *fileSize) {
|
||||
bytes += read(fd, data + bytes, *fileSize - bytes);
|
||||
}
|
||||
|
||||
// Close the fd. This doesn't destroy the mapping.
|
||||
DEBUG("close");
|
||||
close(fd);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static void forkAndSpecializePre(
|
||||
JNIEnv *env, jclass clazz, jint *uid, jint *gid, jintArray *gids, jint *runtimeFlags,
|
||||
jobjectArray *rlimits, jint *mountExternal, jstring *seInfo, jstring *niceName,
|
||||
jintArray *fdsToClose, jintArray *fdsToIgnore, jboolean *is_child_zygote,
|
||||
jstring *instructionSet, jstring *appDataDir, jboolean *isTopApp, jobjectArray *pkgDataInfoList,
|
||||
jobjectArray *whitelistedDataInfoList, jboolean *bindMountAppDataDirs, jboolean *bindMountAppStorageDirs) {
|
||||
updateAppDataDir(env, *appDataDir);
|
||||
}
|
||||
|
||||
static void specializeAppProcessPre(
|
||||
JNIEnv *env, jclass clazz, jint *uid, jint *gid, jintArray *gids, jint *runtimeFlags,
|
||||
jobjectArray *rlimits, jint *mountExternal, jstring *seInfo, jstring *niceName,
|
||||
jboolean *startChildZygote, jstring *instructionSet, jstring *appDataDir,
|
||||
jboolean *isTopApp, jobjectArray *pkgDataInfoList, jobjectArray *whitelistedDataInfoList,
|
||||
jboolean *bindMountAppDataDirs, jboolean *bindMountAppStorageDirs) {
|
||||
updateAppDataDir(env, *appDataDir);
|
||||
}
|
||||
|
||||
static void forkAndSpecializePost(JNIEnv *env, jclass clazz, jint res) {
|
||||
if (res == 0) {
|
||||
// Child process
|
||||
specializeCommon(env);
|
||||
}
|
||||
}
|
||||
|
||||
static void specializeAppProcessPost(JNIEnv *env, jclass clazz) {
|
||||
specializeCommon(env);
|
||||
}
|
||||
|
||||
static void onModuleLoaded() {
|
||||
// Load
|
||||
DEBUG("onModuleLoaded, loading file");
|
||||
char pathBuf[128];
|
||||
snprintf(pathBuf, 128, "%s/%s", riru_magisk_module_path, "classes.dex");
|
||||
DEBUG((char*)riru_magisk_module_path);
|
||||
DEBUG(pathBuf);
|
||||
|
||||
moduleDex = readFile(pathBuf, &moduleDexSize);
|
||||
if (!moduleDex) {
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG("module loaded");
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
int riru_api_version;
|
||||
const char *riru_magisk_module_path = nullptr;
|
||||
int *riru_allow_unload = nullptr;
|
||||
|
||||
static auto module = RiruVersionedModuleInfo{
|
||||
.moduleApiVersion = riru::moduleApiVersion,
|
||||
.moduleInfo = RiruModuleInfo{
|
||||
.supportHide = true,
|
||||
.version = riru::moduleVersionCode,
|
||||
.versionName = riru::moduleVersionName,
|
||||
.onModuleLoaded = onModuleLoaded,
|
||||
.forkAndSpecializePre = forkAndSpecializePre,
|
||||
.forkAndSpecializePost = forkAndSpecializePost,
|
||||
.forkSystemServerPre = NULL,
|
||||
.forkSystemServerPost = NULL,
|
||||
.specializeAppProcessPre = specializeAppProcessPre,
|
||||
.specializeAppProcessPost = specializeAppProcessPost,
|
||||
},
|
||||
};
|
||||
|
||||
RiruVersionedModuleInfo *init(Riru *riru) {
|
||||
auto core_max_api_version = riru->riruApiVersion;
|
||||
riru_api_version = core_max_api_version <= riru::moduleApiVersion ? core_max_api_version : riru::moduleApiVersion;
|
||||
module.moduleApiVersion = riru_api_version;
|
||||
|
||||
riru_magisk_module_path = strdup(riru->magiskModulePath);
|
||||
if (riru_api_version >= 25) {
|
||||
riru_allow_unload = riru->allowUnload;
|
||||
}
|
||||
return &module;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
#include "config.h"
|
||||
|
||||
namespace riru {
|
||||
const int moduleVersionCode = ${RIRU_MODULE_VERSION};
|
||||
const char* const moduleVersionName = "${RIRU_MODULE_VERSION_NAME}";
|
||||
const int moduleApiVersion = ${RIRU_MODULE_API_VERSION};
|
||||
const int moduleMinApiVersion = ${RIRU_MODULE_MIN_API_VERSION};
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
include ':module'
|
||||
|
||||
import org.apache.tools.ant.DirectoryScanner
|
||||
|
||||
DirectoryScanner.removeDefaultExclude('**/.gitattributes')
|
10
riru/template/magisk_module/.gitattributes
vendored
10
riru/template/magisk_module/.gitattributes
vendored
|
@ -1,10 +0,0 @@
|
|||
# Declare files that will always have LF line endings on checkout.
|
||||
META-INF/** text eol=lf
|
||||
*.prop text eol=lf
|
||||
*.sh text eol=lf
|
||||
*.md text eol=lf
|
||||
sepolicy.rule text eol=lf
|
||||
|
||||
# Denote all files that are truly binary and should not be modified.
|
||||
system/** binary
|
||||
system_x86/** binary
|
|
@ -1,23 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2021 Danny Lin <danny@kdrag0n.dev>
|
||||
|
||||
Riru Module Template: Copyright (c) 2020 Rikka
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -1,33 +0,0 @@
|
|||
#!/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
|
|
@ -1 +0,0 @@
|
|||
#MAGISK
|
|
@ -1,72 +0,0 @@
|
|||
SKIPUNZIP=1
|
||||
|
||||
# Extract 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 riru.sh
|
||||
|
||||
# Variables provided by riru.sh:
|
||||
#
|
||||
# RIRU_API: API version of installed Riru, 0 if not installed
|
||||
# RIRU_MIN_COMPATIBLE_API: minimal supported API version by installed Riru, 0 if not installed or version < v23.2
|
||||
# RIRU_VERSION_CODE: version code of installed Riru, 0 if not installed or version < v23.2
|
||||
# RIRU_VERSION_NAME: version name of installed Riru, "" if not installed or version < v23.2
|
||||
|
||||
extract "$ZIPFILE" 'riru.sh' "$TMPDIR"
|
||||
. $TMPDIR/riru.sh
|
||||
|
||||
# Functions from util_functions.sh (it will be loaded by riru.sh)
|
||||
check_riru_version
|
||||
enforce_install_from_magisk_app
|
||||
|
||||
# Check architecture
|
||||
if [ "$ARCH" != "arm" ] && [ "$ARCH" != "arm64" ] && [ "$ARCH" != "x86" ] && [ "$ARCH" != "x64" ]; then
|
||||
abort "! Unsupported platform: $ARCH"
|
||||
else
|
||||
ui_print "- Device platform: $ARCH"
|
||||
fi
|
||||
|
||||
# Extract libs
|
||||
ui_print "- Extracting module files"
|
||||
|
||||
extract "$ZIPFILE" 'module.prop' "$MODPATH"
|
||||
extract "$ZIPFILE" 'system.prop' "$MODPATH"
|
||||
extract "$ZIPFILE" 'classes.dex' "$MODPATH"
|
||||
extract "$ZIPFILE" 'service.sh' "$MODPATH"
|
||||
chmod 755 "$MODPATH/service.sh"
|
||||
|
||||
# Riru v24+ load files from the "riru" folder in the Magisk module folder
|
||||
# This "riru" folder is also used to determine if a Magisk module is a Riru module
|
||||
|
||||
mkdir "$MODPATH/riru"
|
||||
mkdir "$MODPATH/riru/lib"
|
||||
mkdir "$MODPATH/riru/lib64"
|
||||
|
||||
if [ "$ARCH" = "arm" ] || [ "$ARCH" = "arm64" ]; then
|
||||
ui_print "- Extracting arm libraries"
|
||||
extract "$ZIPFILE" "lib/armeabi-v7a/lib$RIRU_MODULE_LIB_NAME.so" "$MODPATH/riru/lib" true
|
||||
|
||||
if [ "$IS64BIT" = true ]; then
|
||||
ui_print "- Extracting arm64 libraries"
|
||||
extract "$ZIPFILE" "lib/arm64-v8a/lib$RIRU_MODULE_LIB_NAME.so" "$MODPATH/riru/lib64" true
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$ARCH" = "x86" ] || [ "$ARCH" = "x64" ]; then
|
||||
ui_print "- Extracting x86 libraries"
|
||||
extract "$ZIPFILE" "lib/x86/lib$RIRU_MODULE_LIB_NAME.so" "$MODPATH/riru/lib" true
|
||||
|
||||
if [ "$IS64BIT" = true ]; then
|
||||
ui_print "- Extracting x64 libraries"
|
||||
extract "$ZIPFILE" "lib/x86_64/lib$RIRU_MODULE_LIB_NAME.so" "$MODPATH/riru/lib64" true
|
||||
fi
|
||||
fi
|
||||
|
||||
set_perm_recursive "$MODPATH" 0 0 0755 0644
|
|
@ -1,6 +0,0 @@
|
|||
id=${id}
|
||||
name=${name}
|
||||
version=${version}
|
||||
versionCode=${versionCode}
|
||||
author=${author}
|
||||
description=${description}
|
|
@ -1,44 +0,0 @@
|
|||
#!/sbin/sh
|
||||
RIRU_MODULE_LIB_NAME="@RIRU_MODULE_LIB_NAME@"
|
||||
|
||||
# Variables for customize.sh
|
||||
RIRU_API=0
|
||||
RIRU_MIN_COMPATIBLE_API=0
|
||||
RIRU_VERSION_CODE=0
|
||||
RIRU_VERSION_NAME=""
|
||||
|
||||
# Used by util_functions.sh
|
||||
RIRU_MODULE_API_VERSION=@RIRU_MODULE_API_VERSION@
|
||||
RIRU_MODULE_MIN_API_VERSION=@RIRU_MODULE_MIN_API_VERSION@
|
||||
RIRU_MODULE_MIN_RIRU_VERSION_NAME="@RIRU_MODULE_MIN_RIRU_VERSION_NAME@"
|
||||
|
||||
if [ "$MAGISK_VER_CODE" -ge 21000 ]; then
|
||||
MAGISK_CURRENT_RIRU_MODULE_PATH=$(magisk --path)/.magisk/modules/riru-core
|
||||
else
|
||||
MAGISK_CURRENT_RIRU_MODULE_PATH=/sbin/.magisk/modules/riru-core
|
||||
fi
|
||||
|
||||
if [ ! -d $MAGISK_CURRENT_RIRU_MODULE_PATH ]; then
|
||||
ui_print "*********************************************************"
|
||||
ui_print "! Riru is not installed"
|
||||
ui_print "! Please install Riru from Magisk Manager or https://github.com/RikkaApps/Riru/releases"
|
||||
abort "*********************************************************"
|
||||
fi
|
||||
|
||||
if [ -f "$MAGISK_CURRENT_RIRU_MODULE_PATH/disable" ] || [ -f "$MAGISK_CURRENT_RIRU_MODULE_PATH/remove" ]; then
|
||||
ui_print "*********************************************************"
|
||||
ui_print "! Riru is not enabled or will be removed"
|
||||
ui_print "! Please enable Riru in Magisk first"
|
||||
abort "*********************************************************"
|
||||
fi
|
||||
|
||||
if [ -f $MAGISK_CURRENT_RIRU_MODULE_PATH/util_functions.sh ]; then
|
||||
ui_print "- Load $MAGISK_CURRENT_RIRU_MODULE_PATH/util_functions.sh"
|
||||
# shellcheck disable=SC1090
|
||||
. $MAGISK_CURRENT_RIRU_MODULE_PATH/util_functions.sh
|
||||
else
|
||||
ui_print "*********************************************************"
|
||||
ui_print "! Riru $RIRU_MODULE_MIN_RIRU_VERSION_NAME or above is required"
|
||||
ui_print "! Please upgrade Riru from Magisk Manager or https://github.com/RikkaApps/Riru/releases"
|
||||
abort "*********************************************************"
|
||||
fi
|
|
@ -1,39 +0,0 @@
|
|||
#!/system/bin/sh
|
||||
# Conditional MagiskHide properties
|
||||
|
||||
maybe_set_prop() {
|
||||
local prop="$1"
|
||||
local contains="$2"
|
||||
local value="$3"
|
||||
|
||||
if [[ "$(getprop "$prop")" == *"$contains"* ]]; then
|
||||
resetprop "$prop" "$value"
|
||||
fi
|
||||
}
|
||||
|
||||
# Magisk recovery mode
|
||||
maybe_set_prop ro.bootmode recovery unknown
|
||||
maybe_set_prop ro.boot.mode recovery unknown
|
||||
maybe_set_prop vendor.boot.mode recovery unknown
|
||||
|
||||
# MIUI cross-region flash
|
||||
maybe_set_prop ro.boot.hwc CN GLOBAL
|
||||
maybe_set_prop ro.boot.hwcountry China GLOBAL
|
||||
|
||||
resetprop --delete ro.build.selinux
|
||||
|
||||
# SELinux permissive
|
||||
if [[ "$(cat /sys/fs/selinux/enforce)" == "0" ]]; then
|
||||
chmod 640 /sys/fs/selinux/enforce
|
||||
chmod 440 /sys/fs/selinux/policy
|
||||
fi
|
||||
|
||||
# Late props which must be set after boot_completed
|
||||
{
|
||||
until [[ "$(getprop sys.boot_completed)" == "1" ]]; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# avoid breaking OnePlus display modes/fingerprint scanners
|
||||
resetprop vendor.boot.verifiedbootstate green
|
||||
}&
|
|
@ -1,22 +0,0 @@
|
|||
# Basic MagiskHide properties
|
||||
|
||||
# RootBeer, Microsoft
|
||||
ro.build.tags=release-keys
|
||||
|
||||
# Samsung
|
||||
ro.boot.warranty_bit=0
|
||||
ro.vendor.boot.warranty_bit=0
|
||||
ro.vendor.warranty_bit=0
|
||||
ro.warranty_bit=0
|
||||
|
||||
# SafetyNet
|
||||
ro.boot.flash.locked=1
|
||||
ro.boot.verifiedbootstate=green
|
||||
ro.boot.veritymode=enforcing
|
||||
ro.boot.vbmeta.device_state=locked
|
||||
vendor.boot.vbmeta.device_state=locked
|
||||
|
||||
# Other
|
||||
ro.build.type=user
|
||||
ro.debuggable=0
|
||||
ro.secure=1
|
|
@ -1,38 +0,0 @@
|
|||
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").sha256sum"
|
||||
else
|
||||
file_path="$dir/$file"
|
||||
hash_path="$TMPDIR_FOR_VERIFY/$file.sha256sum"
|
||||
fi
|
||||
|
||||
unzip $opts "$zip" "$file" -d "$dir" >&2
|
||||
[ -f "$file_path" ] || abort_verify "$file not exists"
|
||||
|
||||
unzip $opts "$zip" "$file.sha256sum" -d "$TMPDIR_FOR_VERIFY" >&2
|
||||
[ -f "$hash_path" ] || abort_verify "$file.sha256sum not exists"
|
||||
|
||||
(echo "$(cat "$hash_path") $file_path" | sha256sum -c -s -) || abort_verify "Failed to verify $file"
|
||||
}
|
Loading…
Reference in New Issue
Block a user