You've already forked TrickyStore
mirror of
https://github.com/5ec1cff/TrickyStore.git
synced 2025-09-06 06:37:07 +00:00
feature: Add customize spoof build vars support
Signed-off-by: GarfieldHan <2652609017@qq.com>
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -4,3 +4,6 @@
|
||||
[submodule "module/src/main/cpp/external/LSPlt"]
|
||||
path = module/src/main/cpp/external/LSPlt
|
||||
url = https://github.com/LSPosed/LSPlt
|
||||
[submodule "module/src/main/cpp/external/glaze"]
|
||||
path = module/src/main/cpp/external/glaze
|
||||
url = https://github.com/stephenberry/glaze
|
||||
|
||||
@@ -40,5 +40,5 @@ target_link_libraries(${MODULE_NAME} log binder utils elf_util my_logging)
|
||||
target_compile_options(${MODULE_NAME} PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
|
||||
|
||||
add_library(tszygisk SHARED zygisk/main.cpp)
|
||||
target_link_libraries(tszygisk log my_logging)
|
||||
target_link_libraries(tszygisk log my_logging glaze::glaze)
|
||||
target_compile_options(tszygisk PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
|
||||
|
||||
17
module/src/main/cpp/external/CMakeLists.txt
vendored
17
module/src/main/cpp/external/CMakeLists.txt
vendored
@@ -10,6 +10,8 @@ target_include_directories(lsplt PRIVATE LSPlt/lsplt/src/main/jni)
|
||||
target_link_libraries(lsplt PUBLIC my_logging cxx)
|
||||
# end lsplt
|
||||
|
||||
add_subdirectory(glaze)
|
||||
|
||||
# cxx
|
||||
set(LIBCXX_SOURCES
|
||||
algorithm.cpp
|
||||
@@ -23,16 +25,16 @@ set(LIBCXX_SOURCES
|
||||
condition_variable_destructor.cpp
|
||||
# debug.cpp
|
||||
exception.cpp
|
||||
# filesystem/directory_iterator.cpp
|
||||
# filesystem/int128_builtins.cpp
|
||||
# filesystem/operations.cpp
|
||||
filesystem/directory_iterator.cpp
|
||||
filesystem/int128_builtins.cpp
|
||||
filesystem/operations.cpp
|
||||
functional.cpp
|
||||
future.cpp
|
||||
hash.cpp
|
||||
# ios.cpp
|
||||
# ios.instantiations.cpp
|
||||
# iostream.cpp
|
||||
# locale.cpp
|
||||
ios.cpp
|
||||
ios.instantiations.cpp
|
||||
iostream.cpp
|
||||
locale.cpp
|
||||
memory.cpp
|
||||
mutex.cpp
|
||||
mutex_destructor.cpp
|
||||
@@ -65,7 +67,6 @@ set(LIBCXX_EXPORT_FLAGS
|
||||
-D_LIBCPP_BUILDING_LIBRARY
|
||||
-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
|
||||
-D_LIBCXXABI_NO_EXCEPTIONS
|
||||
-D_LIBCPP_HAS_NO_LOCALIZATION
|
||||
)
|
||||
set(LIBCXX_FLAGS
|
||||
-fvisibility-global-new-delete-hidden
|
||||
|
||||
1
module/src/main/cpp/external/glaze
vendored
Submodule
1
module/src/main/cpp/external/glaze
vendored
Submodule
Submodule module/src/main/cpp/external/glaze added at 53b69c447f
@@ -3,7 +3,9 @@
|
||||
#include <fcntl.h>
|
||||
#include <android/log.h>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "glaze/glaze.hpp"
|
||||
#include "logging.hpp"
|
||||
#include "zygisk.hpp"
|
||||
|
||||
@@ -12,6 +14,21 @@ using zygisk::AppSpecializeArgs;
|
||||
using zygisk::ServerSpecializeArgs;
|
||||
using namespace std::string_view_literals;
|
||||
|
||||
struct spoof_config {
|
||||
std::string manufacturer{"Google"};
|
||||
std::string model{"Pixel"};
|
||||
std::string fingerprint{"google/sailfish/sailfish:8.1.0/OPM1.171019.011/4448085:user/release-keys"};
|
||||
std::string brand{"google"};
|
||||
std::string product{"sailfish"};
|
||||
std::string device{"sailfish"};
|
||||
std::string release{"8.1.0"};
|
||||
std::string id{"OPM1.171019.011"};
|
||||
std::string incremental{"4448085"};
|
||||
std::string security_patch{"2017-12-05"};
|
||||
std::string type{"user"};
|
||||
std::string tags{"release-keys"};
|
||||
};
|
||||
|
||||
class TrickyStore : public zygisk::ModuleBase {
|
||||
public:
|
||||
void onLoad(Api *api, JNIEnv *env) override {
|
||||
@@ -21,15 +38,30 @@ public:
|
||||
|
||||
void preAppSpecialize(AppSpecializeArgs *args) override {
|
||||
api_->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
|
||||
|
||||
int enabled = 0;
|
||||
spoof_config spoofConfig{};
|
||||
{
|
||||
auto fd = api_->connectCompanion();
|
||||
if (fd >= 0) {
|
||||
if (fd >= 0) [[likely]] {
|
||||
// read enabled
|
||||
read(fd, &enabled, sizeof(enabled));
|
||||
if (enabled) {
|
||||
size_t bufferSize = 0;
|
||||
std::string buffer;
|
||||
// read size first
|
||||
read(fd, &bufferSize, sizeof(bufferSize));
|
||||
// resize and receive
|
||||
buffer.resize(bufferSize);
|
||||
read(fd, buffer.data(), bufferSize);
|
||||
// parse
|
||||
if (glz::read_json(spoofConfig, buffer)) [[unlikely]] {
|
||||
LOGE("[preAppSpecialize] spoofConfig parse error");
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
if (!enabled) return;
|
||||
if (args->app_data_dir == nullptr) {
|
||||
return;
|
||||
@@ -47,23 +79,18 @@ public:
|
||||
auto buildClass = env_->FindClass("android/os/Build");
|
||||
auto buildVersionClass = env_->FindClass("android/os/Build$VERSION");
|
||||
|
||||
#define SET_FIELD(CLAZZ, FIELD, VALUE) ({ \
|
||||
auto id = env_->GetStaticFieldID(CLAZZ, FIELD, "Ljava/lang/String;"); \
|
||||
env_->SetStaticObjectField(buildClass, id, env_->NewStringUTF(VALUE)); })
|
||||
|
||||
SET_FIELD(buildClass, "MANUFACTURER", "Google");
|
||||
SET_FIELD(buildClass, "MODEL", "Pixel");
|
||||
SET_FIELD(buildClass, "FINGERPRINT",
|
||||
"google/sailfish/sailfish:8.1.0/OPM1.171019.011/4448085:user/release-keys");
|
||||
SET_FIELD(buildClass, "BRAND", "google");
|
||||
SET_FIELD(buildClass, "PRODUCT", "sailfish");
|
||||
SET_FIELD(buildClass, "DEVICE", "sailfish");
|
||||
SET_FIELD(buildVersionClass, "RELEASE", "8.1.0");
|
||||
SET_FIELD(buildClass, "ID", "OPM1.171019.011");
|
||||
SET_FIELD(buildVersionClass, "INCREMENTAL", "4448085");
|
||||
SET_FIELD(buildVersionClass, "SECURITY_PATCH", "2017-12-05");
|
||||
SET_FIELD(buildClass, "TYPE", "user");
|
||||
SET_FIELD(buildClass, "TAGS", "release-keys");
|
||||
setField(buildClass, "MANUFACTURER", std::move(spoofConfig.manufacturer));
|
||||
setField(buildClass, "MODEL", std::move(spoofConfig.model));
|
||||
setField(buildClass, "FINGERPRINT", std::move(spoofConfig.fingerprint));
|
||||
setField(buildClass, "BRAND", std::move(spoofConfig.brand));
|
||||
setField(buildClass, "PRODUCT", std::move(spoofConfig.product));
|
||||
setField(buildClass, "DEVICE", std::move(spoofConfig.device));
|
||||
setField(buildVersionClass, "RELEASE", std::move(spoofConfig.release));
|
||||
setField(buildClass, "ID", std::move(spoofConfig.id));
|
||||
setField(buildVersionClass, "INCREMENTAL", std::move(spoofConfig.incremental));
|
||||
setField(buildVersionClass, "SECURITY_PATCH", std::move(spoofConfig.security_patch));
|
||||
setField(buildClass, "TYPE", std::move(spoofConfig.type));
|
||||
setField(buildClass, "TAGS", std::move(spoofConfig.tags));
|
||||
}
|
||||
|
||||
env_->ReleaseStringUTFChars(args->nice_name, nice_name);
|
||||
@@ -77,11 +104,38 @@ public:
|
||||
private:
|
||||
Api *api_;
|
||||
JNIEnv *env_;
|
||||
|
||||
inline void setField(jclass clazz, const char* field, std::string&& value) {
|
||||
auto id = env_->GetStaticFieldID(clazz, field, "Ljava/lang/String;");
|
||||
env_->SetStaticObjectField(clazz, id, env_->NewStringUTF(value.c_str()));
|
||||
}
|
||||
};
|
||||
|
||||
static void companion_handler(int fd) {
|
||||
int enabled = access("/data/adb/tricky_store/spoof_build_vars", F_OK) == 0;
|
||||
write(fd, &enabled, sizeof(enabled));
|
||||
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
spoof_config spoofConfig{};
|
||||
auto ec = glz::read_file_json(spoofConfig, "/data/adb/tricky_store/spoof_build_vars"sv, std::string{});
|
||||
if (ec) [[unlikely]] {
|
||||
LOGW("[companion_handler] Failed to parse spoof_build_vars, writing and using default spoof config...");
|
||||
ec = glz::write_file_json<glz::opts{.prettify = true}>(spoofConfig, "/data/adb/tricky_store/spoof_build_vars"sv, std::string{});
|
||||
if (ec) [[unlikely]] {
|
||||
LOGW("[companion_handler] Failed to write spoof_build_vars");
|
||||
}
|
||||
LOGI("[write_spoof_configs@companion_handler] write done!");
|
||||
}
|
||||
|
||||
std::string buffer = glz::write_json(spoofConfig).value_or("");
|
||||
size_t bufferSize = buffer.size();
|
||||
// Send buffer size first
|
||||
write(fd, &bufferSize, sizeof(bufferSize));
|
||||
// client resize string stl and receive buffer
|
||||
write(fd, buffer.data(), bufferSize);
|
||||
}
|
||||
|
||||
// Register our module class and the companion handler function
|
||||
|
||||
Reference in New Issue
Block a user