|
|
@ -21,25 +21,37 @@ namespace ligma
|
|
|
|
[&](std::uintptr_t module_base, void* module_handle) -> bool
|
|
|
|
[&](std::uintptr_t module_base, void* module_handle) -> bool
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOGI("libtersafe.so -> %p, module_handle -> %p", module_base, module_handle);
|
|
|
|
LOGI("libtersafe.so -> %p, module_handle -> %p", module_base, module_handle);
|
|
|
|
|
|
|
|
|
|
|
|
// all imports just return null now....
|
|
|
|
|
|
|
|
ligma::hook::dlsym_hook({ module_handle, "^.*" }, &null_sub);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
fopen_ptr = dlsym(dlopen("libc.so", RTLD_NOLOAD), "fopen");
|
|
|
|
fopen_ptr = dlsym(dlopen("libc.so", RTLD_NOLOAD), "fopen");
|
|
|
|
system_prop_get = dlsym(dlopen("libc.so", RTLD_NOLOAD), "__system_property_get");
|
|
|
|
system_prop_get = dlsym(dlopen("libc.so", RTLD_NOLOAD), "__system_property_get");
|
|
|
|
|
|
|
|
strcat_ptr = dlsym(dlopen("libc.so", RTLD_NOLOAD), "strcat");
|
|
|
|
|
|
|
|
|
|
|
|
ligma::hook::make_hook(fopen_ptr, reinterpret_cast<void*>(&fopen_hook));
|
|
|
|
ligma::hook::make_hook(strcat_ptr, &strcat_hook);
|
|
|
|
ligma::hook::make_hook(system_prop_get, reinterpret_cast<void*>(&system_property_hook));
|
|
|
|
ligma::hook::make_hook(fopen_ptr, &fopen_hook);
|
|
|
|
|
|
|
|
ligma::hook::make_hook(system_prop_get, &system_property_hook);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
__attribute__((noinline))
|
|
|
|
char* strcat_hook(char* destination, const char* source)
|
|
|
|
int null_sub()
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOGI("null_sub called, return -> null....");
|
|
|
|
if (!destination || !source)
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!strncmp(destination, "retval=1", strlen("retval=1")))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
destination[strlen("retval=1") - 1] = '0';
|
|
|
|
|
|
|
|
memset(destination + strlen("retval=1"), NULL, strlen("|emulator_name="));
|
|
|
|
|
|
|
|
LOGI("destination string after -> %s", destination);
|
|
|
|
|
|
|
|
return destination;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strcat_mutex.lock();
|
|
|
|
|
|
|
|
ligma::hook::disable(strcat_ptr);
|
|
|
|
|
|
|
|
const auto result = std::strcat(destination, source);
|
|
|
|
|
|
|
|
ligma::hook::enable(strcat_ptr);
|
|
|
|
|
|
|
|
strcat_mutex.unlock();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|