diff --git a/anticheat/libtersafe.idb b/anticheat/libtersafe.idb index 204db8d8f..4ba9c1972 100644 Binary files a/anticheat/libtersafe.idb and b/anticheat/libtersafe.idb differ diff --git a/ligma-cheat/ligma-cheat/SDK/il2cpp/il2cpp.h b/ligma-cheat/ligma-cheat/SDK/il2cpp/il2cpp.h index b09831268..347111dac 100644 --- a/ligma-cheat/ligma-cheat/SDK/il2cpp/il2cpp.h +++ b/ligma-cheat/ligma-cheat/SDK/il2cpp/il2cpp.h @@ -11,6 +11,6 @@ #include namespace il2cpp { -bool attach(const char *libname = "libil2cpp.so"); -std::uintptr_t il2cpp_base(); + bool attach(const char *libname = "libil2cpp.so"); + std::uintptr_t il2cpp_base(); }; // namespace il2cpp \ No newline at end of file diff --git a/ligma-cheat/ligma-cheat/SDK/il2cpp/il2cpp_type.h b/ligma-cheat/ligma-cheat/SDK/il2cpp/il2cpp_type.h index dcb38c113..c0e65c3e0 100644 --- a/ligma-cheat/ligma-cheat/SDK/il2cpp/il2cpp_type.h +++ b/ligma-cheat/ligma-cheat/SDK/il2cpp/il2cpp_type.h @@ -1,5 +1,10 @@ #pragma once #include +#include +#include +#include +#include +#include struct virt_invoke_data { std::uintptr_t method_ptr; @@ -97,17 +102,17 @@ struct il2cpp_string { int32_t length; wchar_t start_char; - static il2cpp_string *newString(const wchar_t *string) { + static il2cpp_string *new_string(const wchar_t *string) { const auto result = reinterpret_cast(malloc( - sizeof(il2cpp_string) + (std::wcslen(string) * sizeof(wchar_t)))); - memcpy(&result->start_char, string, std::wcslen(string) * sizeof(wchar_t)); + sizeof(il2cpp_string) + (wcslen(string) * sizeof(wchar_t)))); + memcpy(&result->start_char, string, wcslen(string) * sizeof(wchar_t)); return result; } - static il2cpp_string *newString(const char *string) { + static il2cpp_string *new_string(const char *string) { const auto result = reinterpret_cast( - malloc(sizeof(il2cpp_string) + (std::strlen(string)))); - memcpy(&result->start_char, string, std::strlen(string)); + malloc(sizeof(il2cpp_string) + (strlen(string)))); + memcpy(&result->start_char, string, strlen(string)); return result; } diff --git a/ligma-cheat/ligma-cheat/bypass/bypass.cpp b/ligma-cheat/ligma-cheat/bypass/bypass.cpp index 514aa442a..e62ca0867 100644 --- a/ligma-cheat/ligma-cheat/bypass/bypass.cpp +++ b/ligma-cheat/ligma-cheat/bypass/bypass.cpp @@ -21,25 +21,37 @@ namespace ligma [&](std::uintptr_t module_base, void* module_handle) -> bool { 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; } ); - fopen_ptr = dlsym(dlopen("libc.so", RTLD_NOLOAD), "fopen"); 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(&fopen_hook)); - ligma::hook::make_hook(system_prop_get, reinterpret_cast(&system_property_hook)); + ligma::hook::make_hook(strcat_ptr, &strcat_hook); + ligma::hook::make_hook(fopen_ptr, &fopen_hook); + ligma::hook::make_hook(system_prop_get, &system_property_hook); } - __attribute__((noinline)) - int null_sub() + char* strcat_hook(char* destination, const char* source) { - LOGI("null_sub called, return -> null...."); - return NULL; + if (!destination || !source) + 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; } // diff --git a/ligma-cheat/ligma-cheat/bypass/bypass.h b/ligma-cheat/ligma-cheat/bypass/bypass.h index 24045621e..527a1a090 100644 --- a/ligma-cheat/ligma-cheat/bypass/bypass.h +++ b/ligma-cheat/ligma-cheat/bypass/bypass.h @@ -14,12 +14,14 @@ namespace ligma { inline void* fopen_ptr = nullptr; inline void* system_prop_get = nullptr; + inline void* strcat_ptr = nullptr; inline std::mutex fopen_mutex; inline std::mutex system_prop_mutex; + inline std::mutex strcat_mutex; void init(const std::function& callback); - int null_sub(); + char* strcat_hook(char* destination, const char* source); FILE* fopen_hook(const char* path, const char* mode); int system_property_hook(const char* name, char* value); int load_bufferx_hook(void* L, const char* buff, size_t sz, const char* name, const char* mode); diff --git a/ligma-cheat/ligma-cheat/hooks/dlsym_hook.cpp b/ligma-cheat/ligma-cheat/hooks/dlsym_hook.cpp index 84ad1d3c1..9b9b5fe91 100644 --- a/ligma-cheat/ligma-cheat/hooks/dlsym_hook.cpp +++ b/ligma-cheat/ligma-cheat/hooks/dlsym_hook.cpp @@ -15,8 +15,7 @@ namespace ligma { dlsym_mutex.lock(); ligma::hook::disable(dlsym_ptr); - const auto result = - reinterpret_cast(dlsym_ptr)(handle, symbol); + const auto result = reinterpret_cast(dlsym_ptr)(handle, symbol); ligma::hook::enable(dlsym_ptr); dlsym_mutex.unlock(); return result; @@ -25,8 +24,9 @@ namespace ligma __attribute__((noinline)) void* dlsym_handler(void* handle, const char* symbol) { + LOGI("dlsym called... handle -> %p, symbol -> %s", handle, symbol); for (const auto& [map_handle, function_ptr] : *get_dlsym_hooks()) - if (map_handle.first == handle) + if (!map_handle.first || map_handle.first == handle) if(std::regex_match(symbol, std::regex(map_handle.second.data()))) return function_ptr; diff --git a/ligma-cheat/ligma-cheat/hooks/dlsym_hook.h b/ligma-cheat/ligma-cheat/hooks/dlsym_hook.h index b3996a14a..780f8ce59 100644 --- a/ligma-cheat/ligma-cheat/hooks/dlsym_hook.h +++ b/ligma-cheat/ligma-cheat/hooks/dlsym_hook.h @@ -27,7 +27,7 @@ namespace ligma static std::once_flag once; std::call_once(once, [&]() { - make_hook((dlsym_ptr = dlsym(dlopen("libdl.so", RTLD_NOLOAD), "dlsym")), &dlsym_handler); + make_hook((dlsym_ptr = dlsym(dlopen("libdl.so", RTLD_NOW), "dlsym")), &dlsym_handler); make_hook(&dlsym, &dlsym_bypass); }); diff --git a/ligma-cheat/ligma-cheat/hooks/shithook.h b/ligma-cheat/ligma-cheat/hooks/shithook.h index 2b72049c3..25345e68d 100644 --- a/ligma-cheat/ligma-cheat/hooks/shithook.h +++ b/ligma-cheat/ligma-cheat/hooks/shithook.h @@ -56,7 +56,7 @@ namespace ligma std::map>* get_hooks(); template - void make_hook(T* addr_to_hook, U* jmp_to_addr, bool enable = true) + void make_hook(T addr_to_hook, U* jmp_to_addr, bool enable = true) { if (!addr_to_hook || !jmp_to_addr) return; diff --git a/ligma-cheat/ligma-cheat/ligma-cheat.vcxproj b/ligma-cheat/ligma-cheat/ligma-cheat.vcxproj index 555faceb1..c28e8b4b6 100644 --- a/ligma-cheat/ligma-cheat/ligma-cheat.vcxproj +++ b/ligma-cheat/ligma-cheat/ligma-cheat.vcxproj @@ -39,6 +39,7 @@ + @@ -46,6 +47,8 @@ + + diff --git a/ligma-cheat/ligma-cheat/ligma-cheat.vcxproj.filters b/ligma-cheat/ligma-cheat/ligma-cheat.vcxproj.filters index a5df519b9..6a665db4e 100644 --- a/ligma-cheat/ligma-cheat/ligma-cheat.vcxproj.filters +++ b/ligma-cheat/ligma-cheat/ligma-cheat.vcxproj.filters @@ -25,6 +25,9 @@ {f084f5b1-c94a-4e1b-ac6d-6fdeecb34ba4} + + {41f37979-a1df-4b59-bf4d-23f51411f4c1} + @@ -42,6 +45,9 @@ source\hooks + + headers\SDK + @@ -59,5 +65,11 @@ headers\hooks + + headers\SDK + + + headers\SDK + \ No newline at end of file diff --git a/ligma-cheat/ligma-cheat/main.cpp b/ligma-cheat/ligma-cheat/main.cpp index 50e8a3aa3..4b46258bf 100644 --- a/ligma-cheat/ligma-cheat/main.cpp +++ b/ligma-cheat/ligma-cheat/main.cpp @@ -1,4 +1,27 @@ #include "bypass/bypass.h" +#include "SDK/assembly-csharp.dll/gameshop.h" + +__attribute__((noinline)) +bool is_free(gameshop::codmshopitem* item) +{ + LOGI("=============== is item free called! ============="); + LOGI("item -> %p", item); + return true; +} + +__attribute__((noinline)) +int get_price() +{ + LOGI("get price called!"); + return NULL; +} + +__attribute__((noinline)) +bool unlock_all() +{ + LOGI("unlock all called!"); + return true; +} __attribute__((constructor)) void init() @@ -6,6 +29,10 @@ void init() ligma::bypass::init([&](std::uintptr_t il2cpp_base, void* module_handle) -> bool { LOGI("il2cpp base address = %p, module_handle = %p", il2cpp_base, module_handle); + ligma::hook::make_hook(il2cpp_base + 0x294D198, &is_free); + ligma::hook::make_hook(il2cpp_base + 0x294C77C, &get_price); + ligma::hook::make_hook(il2cpp_base + 0x294D7D8, &unlock_all); + ligma::hook::make_hook(il2cpp_base + 0x294D574, &unlock_all); return false; }); } \ No newline at end of file diff --git a/ligma-cheat/ligma-cheat/utils/utils.cpp b/ligma-cheat/ligma-cheat/utils/utils.cpp index c465c3869..5d2f62d92 100644 --- a/ligma-cheat/ligma-cheat/utils/utils.cpp +++ b/ligma-cheat/ligma-cheat/utils/utils.cpp @@ -29,7 +29,8 @@ namespace ligma dlopen_mutex.lock(); ligma::hook::disable(dlopen_ptr); const auto result = dlopen(filename, flags); - ligma::hook::enable(dlopen_ptr); + if(ligma::utils::get_callbacks()->size()) + ligma::hook::enable(dlopen_ptr); dlopen_mutex.unlock(); for (const auto& [file_key, callback] : *ligma::utils::get_callbacks())