From 854021c7d8d716cbca0fb413aedf39afacf0e1eb Mon Sep 17 00:00:00 2001 From: LoveSy Date: Mon, 23 Nov 2020 23:50:42 +0800 Subject: [PATCH] Remove useless hooks --- edxp-core/src/main/cpp/main/include/config.h | 7 ---- .../cpp/main/include/framework/fd_utils.h | 38 ------------------- .../src/main/cpp/main/src/native_hook.cpp | 15 -------- 3 files changed, 60 deletions(-) delete mode 100644 edxp-core/src/main/cpp/main/include/framework/fd_utils.h diff --git a/edxp-core/src/main/cpp/main/include/config.h b/edxp-core/src/main/cpp/main/include/config.h index 11f36900..def24080 100644 --- a/edxp-core/src/main/cpp/main/include/config.h +++ b/edxp-core/src/main/cpp/main/include/config.h @@ -29,7 +29,6 @@ namespace edxp { static const auto kSandHookNeverCallClassName = "com.swift.sandhook.ClassNeverCall"_str; static const auto kLibArtName = "libart.so"_str; - static const auto kLibFwkName = "libandroid_runtime.so"_str; static const auto kLibFwName = "libandroidfw.so"_str; static const auto kLibWhaleName = "libwhale.edxp.so"_str; static const auto kLibSandHookName = "libsandhook.edxp.so"_str; @@ -39,16 +38,10 @@ namespace edxp { static const auto kLibBasePath = std::string( LP_SELECT("/system/lib/", "/system/lib64/")); - static const auto kLinkerPath = std::string( - LP_SELECT("/apex/com.android.runtime/bin/linker", - "/apex/com.android.runtime/bin/linker64")); - - static const auto kLibDlPath = kLibBasePath + kLibDlName; static const auto kLibArtLegacyPath = kLibBasePath + kLibArtName; static const auto kLibSandHookPath = kLibBasePath + kLibSandHookName; static const auto kLibSandHookNativePath = kLibBasePath + kLibSandHookNativeName; static const auto kLibFwPath = kLibBasePath + kLibFwName; - static const auto kLibFwkPath = kLibBasePath + kLibFwkName; inline constexpr const char *const BoolToString(bool b) { return b ? "true" : "false"; diff --git a/edxp-core/src/main/cpp/main/include/framework/fd_utils.h b/edxp-core/src/main/cpp/main/include/framework/fd_utils.h deleted file mode 100644 index 8fe4190c..00000000 --- a/edxp-core/src/main/cpp/main/include/framework/fd_utils.h +++ /dev/null @@ -1,38 +0,0 @@ - -#pragma once - -#include -#include "base/object.h" - -namespace android { - - // Static whitelist of open paths that the zygote is allowed to keep open. - static const char *kPathWhitelist[] = { - "/data/app/", - "/data/app-private/" - }; - - class FileDescriptorWhitelist : public edxp::HookedObject { - - public: - FileDescriptorWhitelist(void *thiz) : HookedObject(thiz) {} - - static void Setup(void *handle, HookFunType hook_func) { - HOOK_FUNC(IsAllowed, - "_ZNK23FileDescriptorWhitelist9IsAllowedERKNSt3__112" - "basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE"); - } - - private: - - CREATE_HOOK_STUB_ENTRIES(bool, IsAllowed, void *thiz, const std::string &path) { - for (const auto &whitelist_path : kPathWhitelist) { - if (android::base::StartsWith(path, whitelist_path)) - return true; - } - return IsAllowedBackup(thiz, path); - } - - }; - -} \ No newline at end of file diff --git a/edxp-core/src/main/cpp/main/src/native_hook.cpp b/edxp-core/src/main/cpp/main/src/native_hook.cpp index 77866b91..bb67be17 100644 --- a/edxp-core/src/main/cpp/main/src/native_hook.cpp +++ b/edxp-core/src/main/cpp/main/src/native_hook.cpp @@ -18,7 +18,6 @@ #include "art/runtime/gc/heap.h" #include "art/runtime/hidden_api.h" #include "art/runtime/oat_file_manager.h" -#include "framework/fd_utils.h" std::vector linker_get_solist(); // Dobby but not in .h @@ -26,13 +25,10 @@ namespace edxp { static volatile bool installed = false; static volatile bool art_hooks_installed = false; - static volatile bool fwk_hooks_installed = false; static HookFunType hook_func = nullptr; void InstallArtHooks(void *art_handle); - void InstallFwkHooks(void *fwk_handle); - void InstallInlineHooks() { if (installed) { LOGI("Inline hooks have been installed, skip"); @@ -72,9 +68,6 @@ namespace edxp { ScopedDlHandle art_handle(kLibArtLegacyPath.c_str()); InstallArtHooks(art_handle.Get()); } - - ScopedDlHandle fwk_handle(kLibFwkPath.c_str()); - InstallFwkHooks(fwk_handle.Get()); } void InstallArtHooks(void *art_handle) { @@ -94,13 +87,5 @@ namespace edxp { art_hooks_installed = true; LOGI("ART hooks installed"); } - - void InstallFwkHooks(void *fwk_handle) { - if (fwk_hooks_installed) { - return; - } - android::FileDescriptorWhitelist::Setup(fwk_handle, hook_func); - } - }