Skip to content

Commit

Permalink
Merge pull request #23 from Thehepta/developer
Browse files Browse the repository at this point in the history
Developer
  • Loading branch information
Thehepta committed Aug 24, 2024
2 parents e8ef792 + 55180c6 commit cbbe3cb
Show file tree
Hide file tree
Showing 74 changed files with 4,091 additions and 991 deletions.
6 changes: 4 additions & 2 deletions Manager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ android {

//android.mk 配置
ndk {
//noinspection ChromeOsAbiSupport
abiFilters 'armeabi-v7a','arm64-v8a' //写在这里
}
}
Expand Down Expand Up @@ -67,7 +68,7 @@ android {
dataBinding {
enabled = true
}
ndkVersion '23.1.7779620' //这个需要高一点的版本,因为编译中使用了自定的linker,有部分elf的宏,只有在新版本中才会存在
// ndkVersion '23.1.7779620' //这个需要高一点的版本,因为编译中使用了自定的linker,有部分elf的宏,只有在新版本中才会存在
namespace 'hepta.rxposed.manager'


Expand All @@ -86,7 +87,8 @@ android {
}
}
mergeAssetsTask.get().doLast {
copy_file_to_assets(variant.name,"Tool","InjectTool")
copy_file_to_assets(variant.name,"Tool","generalInjectTool")
copy_file_to_assets(variant.name,"Tool","mntSh")
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion Manager/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
<application
android:allowBackup="true"
android:icon="@mipmap/ic_rxmlauncher_round"
android:enableOnBackInvokedCallback="true"
android:label="@string/app_name"
android:name=".RxposedApp"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
tools:targetApi="tiramisu">

<activity android:name="hepta.rxposed.manager.MainActivity"
android:exported="true">
Expand Down
21 changes: 21 additions & 0 deletions Manager/src/main/assets/Inject.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/system/bin/sh

echo `id`
#zygote_pid=$1
mount_dir=$1
src=$2
dst=$3
echo "mount_dir: ${mount_dir}"
echo "src: ${src}"
echo "dst: ${dst}"
mkdir -p $mount_dir
mount -t tmpfs tmpfs $mount_dir
libdir=$(echo "$dst" | sed 's|/[^/]*$||')
echo "libdir: ${libdir}"
mkdir -p $libdir
cp $src $dst
chown system:system $dst
chcon u:object_r:system_lib_file:s0 $dst
chmod 0644 $dst
exit

17 changes: 0 additions & 17 deletions Manager/src/main/cpp/check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,7 @@ Java_hepta_rxposed_manager_util_CheckTool_chekc_1GetArtmethodNative_1init(JNIEnv
return false;
}
}
extern "C"
JNIEXPORT jboolean JNICALL
Java_hepta_rxposed_manager_util_CheckTool_chekc_1android_1os_1Process_1getUidForName(JNIEnv *env,
jobject thiz) {
//如果rxposed已经激活了,那么这个检测应该是失败的
jclass Process_cls = env->FindClass("android/os/Process");
jmethodID javamethod = env->GetStaticMethodID(Process_cls,"getUidForName", "(Ljava/lang/String;)I");

uintptr_t getUidForName = reinterpret_cast<uintptr_t>(linkerResolveElfInternalSymbol("libandroid_runtime.so","_Z32android_os_Process_getUidForNameP7_JNIEnvP8_jobjectP8_jstring"));
// LOGE("getUidForName = %lx",getUidForName);

uintptr_t native_get_addr = getJmethod_JniFunction(env,Process_cls,javamethod);

if(getUidForName == native_get_addr){
return true;
}
return false;
}
extern "C"
JNIEXPORT jboolean JNICALL
Java_hepta_rxposed_manager_util_CheckTool_ELFresolveSymbol(JNIEnv *env, jobject thiz) {
Expand Down
1 change: 1 addition & 0 deletions Manager/src/main/cpp/rxposed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ add_library( # Sets the name of the library.
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
android14_hook.cpp
android12_hook.cpp
android11_hook.cpp
android_util_api.cpp
Expand Down
35 changes: 2 additions & 33 deletions Manager/src/main/cpp/rxposed/android11_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,37 +57,6 @@ namespace android11 {




// hook getUidForName 函数是为了进行rxposed进程激活状态
jint (*android_os_Process_getUidForName_org)(JNIEnv *env, jclass clazz, jstring name);
jint android_os_Process_getUidForName_hook(JNIEnv *env, jclass clazz, jstring name) {
DEBUG()
const char *Authority_arg = const_cast<char *>(env->GetStringUTFChars(name, nullptr));
const char *Authority = rprocess::GetInstance()->getStatusAuthority();
int ret = 0;
if (strncmp(Authority_arg, Authority, strlen(Authority_arg)) == 0) {
ret = rprocess::GetInstance()->getHostUid();
} else {
ret = android_os_Process_getUidForName_org(env, clazz, name);
}
DEBUG()
return ret;
}

void HOOK_Process_getUidForName(JNIEnv *env) {
jclass Process_cls = env->FindClass("android/os/Process");
jmethodID getUidForName_Jmethod = env->GetStaticMethodID(Process_cls, "getUidForName",
"(Ljava/lang/String;)I");

android_os_Process_getUidForName_org = reinterpret_cast<jint (*)(JNIEnv *, jclass,
jstring)>(HookJmethod_JniFunction(
env, Process_cls, getUidForName_Jmethod,
(uintptr_t) android_os_Process_getUidForName_hook));
}




jint (*nativeForkAndSpecialize_org)(JNIEnv* env, jclass, jint uid, jint gid, jintArray gids,
jint runtime_flags, jobjectArray rlimits,
jint mount_external, jstring se_info, jstring nice_name,
Expand Down Expand Up @@ -124,7 +93,7 @@ namespace android11 {
if(pid == 0){
LOGE("child nativeForkAndSpecialize_afore start uid = %d currentuid = %d pid = %d",uid,getuid(),getpid());
if(is_HostProcess){
HOOK_Process_getUidForName(env);
rprocess::GetInstance()->add_Rxposed_Status();
} else if (is_Init) {
HOOK_Process_setArgv0(env);
}
Expand Down Expand Up @@ -188,7 +157,7 @@ namespace android11 {
rprocess::GetInstance()->setProcessInfo(pkgName, uid, gid);

if (rprocess::GetInstance()->is_HostProcess()) {
HOOK_Process_getUidForName(env);
rprocess::GetInstance()->add_Rxposed_Status();
} else if (rprocess::GetInstance()->InitEnable(env)) {
HOOK_Process_setArgv0(env);
}
Expand Down
34 changes: 2 additions & 32 deletions Manager/src/main/cpp/rxposed/android12_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,32 +60,6 @@ namespace android12 {



// hook getUidForName 函数是为了进行rxposed进程激活状态
jint (*android_os_Process_getUidForName_org)(JNIEnv *env, jclass clazz, jstring name);
jint android_os_Process_getUidForName_hook(JNIEnv *env, jclass clazz, jstring name) {
DEBUG()
const char *Authority_arg = const_cast<char *>(env->GetStringUTFChars(name, nullptr));
const char *Authority = rprocess::GetInstance()->getStatusAuthority();
int ret = 0;
if (strncmp(Authority_arg, Authority, strlen(Authority_arg)) == 0) {
ret = rprocess::GetInstance()->getHostUid();
} else {
ret = android_os_Process_getUidForName_org(env, clazz, name);
}
DEBUG()
return ret;
}

void HOOK_Process_getUidForName(JNIEnv *env) {
jclass Process_cls = env->FindClass("android/os/Process");
jmethodID getUidForName_Jmethod = env->GetStaticMethodID(Process_cls, "getUidForName",
"(Ljava/lang/String;)I");

android_os_Process_getUidForName_org = reinterpret_cast<jint (*)(JNIEnv *, jclass,
jstring)>(HookJmethod_JniFunction(
env, Process_cls, getUidForName_Jmethod,
(uintptr_t) android_os_Process_getUidForName_hook));
}



Expand Down Expand Up @@ -126,7 +100,7 @@ namespace android12 {
if(pid == 0){
LOGE(" child nativeForkAndSpecialize_afore start uid = %d currentuid = %d pid = %d",uid,getuid(),getpid());
if(is_HostProcess){
HOOK_Process_getUidForName(env);
rprocess::GetInstance()->add_Rxposed_Status();
} else if (is_Init) {
HOOK_Process_setArgv0(env);
}
Expand Down Expand Up @@ -189,7 +163,7 @@ namespace android12 {
rprocess::GetInstance()->setProcessInfo(pkgName, uid, gid);

if (rprocess::GetInstance()->is_HostProcess()) {
HOOK_Process_getUidForName(env);
rprocess::GetInstance()->add_Rxposed_Status();
} else if (rprocess::GetInstance()->InitEnable(env)) {
HOOK_Process_setArgv0(env);
}
Expand Down Expand Up @@ -313,8 +287,4 @@ namespace android12 {
DEBUG()
return ret_bundle;
}




}
Loading

0 comments on commit cbbe3cb

Please sign in to comment.