Skip to content

Commit 514c1b6

Browse files
authored
Add files via upload
1 parent 227eb26 commit 514c1b6

File tree

7 files changed

+197
-0
lines changed

7 files changed

+197
-0
lines changed

compile.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
D:\android-ndk-r16b\ndk-build
2+
NDK_PROJECT_PATH=\
3+
NDK_APPLICATION_MK=\jni\Application.mk

jni/Android.mk

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
LOCAL_PATH := $(call my-dir)
2+
MAIN_LOCAL_PATH := $(call my-dir)
3+
include $(CLEAR_VARS)
4+
LOCAL_MODULE := wolve
5+
6+
LOCAL_CFLAGS := -Wno-error=format-security -fpermissive
7+
LOCAL_CFLAGS += -fno-rtti -fno-exceptions
8+
9+
LOCAL_C_INCLUDES += $(MAIN_LOCAL_PATH)
10+
11+
LOCAL_SRC_FILES := main.cpp
12+
13+
LOCAL_LDLIBS := -llog
14+
15+
include $(BUILD_SHARED_LIBRARY)

jni/Application.mk

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
APP_ABI := armeabi-v7a x86
2+
APP_OPTIM := release
3+
APP_PLATFORM := android-27
4+
APP_STL := system
5+
APP_STL := gnustl_static
6+
APP_THIN_ARCHIVE := true
7+
APP_PIE:= true
8+
9+
10+
ifneq ($(APP_OPTIM), debug)
11+
$(info APP_OPTIM is $(APP_OPTIM) ...)
12+
APP_LDFLAGS += -Wl,--strip-all
13+
APP_CFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
14+
APP_CFLAGS += -g0 -O3 -fomit-frame-pointer -ffunction-sections -fdata-sections
15+
endif

jni/includes/il2cpp.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifndef IL2CPP_H
2+
#define IL2CPP_H
3+
4+
typedef void Il2CppDomain;
5+
typedef void Il2CppImage;
6+
#define PUBLIC_KEY_BYTE_LENGTH 8
7+
struct Il2CppAssemblyName
8+
{
9+
const char* name;
10+
const char* culture;
11+
const char* hash_value;
12+
const char* public_key;
13+
uint32_t hash_alg;
14+
int32_t hash_len;
15+
uint32_t flags;
16+
int32_t major;
17+
int32_t minor;
18+
int32_t build;
19+
int32_t revision;
20+
uint8_t public_key_token[PUBLIC_KEY_BYTE_LENGTH];
21+
};
22+
struct Il2CppAssembly
23+
{
24+
Il2CppImage* image;
25+
uint32_t token;
26+
int32_t referencedAssemblyStart;
27+
int32_t referencedAssemblyCount;
28+
Il2CppAssemblyName aname;
29+
};
30+
typedef void Il2CppDomain;
31+
typedef void Il2CppClass;
32+
33+
struct MethodInfo {
34+
void* methodPointer;
35+
};
36+
37+
typedef Il2CppDomain* (*il2cpp_domain_get_)();
38+
typedef const Il2CppAssembly** (*il2cpp_domain_get_assemblies_) (const Il2CppDomain * domain, unsigned long * size);
39+
typedef const Il2CppImage* (*il2cpp_assembly_get_image_) (const Il2CppAssembly * assembly);
40+
typedef Il2CppClass* (*il2cpp_class_from_name_) (const Il2CppImage * image, const char* namespaze, const char *name);
41+
typedef const MethodInfo* (*il2cpp_class_get_method_from_name_) (Il2CppClass * klass, const char* name, int argsCount);
42+
43+
#endif

jni/includes/logger.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#ifndef LOGGER_H
2+
#define LOGGER_H
3+
#include <android/log.h>
4+
5+
enum daLogType {
6+
daDEBUG = 3,
7+
daERROR = 6,
8+
daINFO = 4,
9+
daWARN = 5
10+
};
11+
12+
//Change this to another Log Tag if ya want. IN the batch script I provide you change the log tag then too
13+
#define TAG "il2cppHacking"
14+
15+
#define LOGD(...) ((void)__android_log_print(daDEBUG, TAG, __VA_ARGS__))
16+
#define LOGE(...) ((void)__android_log_print(daERROR, TAG, __VA_ARGS__))
17+
#define LOGI(...) ((void)__android_log_print(daINFO, TAG, __VA_ARGS__))
18+
#define LOGW(...) ((void)__android_log_print(daWARN, TAG, __VA_ARGS__))
19+
20+
#endif //LOGGER_H

jni/includes/utils.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#ifndef UTILS_H
2+
#define UTILS_H
3+
#include <jni.h>
4+
#include <unistd.h>
5+
6+
typedef unsigned long DWORD;
7+
static DWORD libBase;
8+
static void* il2cpp_handle = NULL;
9+
10+
DWORD findLibrary(const char *library) {
11+
FILE *fp;
12+
unsigned long addr = 0;
13+
char *pch;
14+
char filename[32];
15+
char buffer[1024];
16+
17+
snprintf(filename, sizeof(filename), "/proc/self/maps");
18+
19+
fp = fopen(filename, "r");
20+
21+
if (fp != NULL) {
22+
while( fgets( buffer, sizeof(buffer), fp ) ) {
23+
if( strstr( buffer, library ) ){
24+
addr = (DWORD)strtoul( buffer, NULL, 16 );
25+
if (addr == 0x8000)
26+
addr = 0;
27+
break;
28+
}
29+
}
30+
fclose(fp);
31+
}
32+
return addr;
33+
}
34+
35+
DWORD getAbsoluteAddress(const char* libraryName, DWORD relativeAddr) {
36+
if(libBase == 0)
37+
libBase = findLibrary(libraryName);
38+
if (libBase != 0)
39+
return (reinterpret_cast<DWORD>(libBase + relativeAddr));
40+
else
41+
return 0;
42+
}
43+
44+
bool isLibraryLoaded(const char *libraryName) {
45+
char line[512] = {0};
46+
FILE *fp = fopen("/proc/self/maps", "rt");
47+
if (fp != NULL) {
48+
while (fgets(line, sizeof(line), fp)) {
49+
if (strstr(line, libraryName))
50+
return true;
51+
}
52+
fclose(fp);
53+
}
54+
return false;
55+
}
56+
#endif

jni/main.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <pthread.h>
2+
#include <jni.h>
3+
#include <memory.h>
4+
#include <dlfcn.h>
5+
#include <cstdio>
6+
#include <cstdlib>
7+
8+
#include "includes/utils.h"
9+
#include "includes/il2cpp.h"
10+
#include "includes/logger.h"
11+
12+
13+
void* main_thread(void*){
14+
il2cpp_handle = dlopen("libil2cpp.so", RTLD_LAZY);
15+
if(!il2cpp_handle){
16+
LOGE("Cannot open library: %s", dlerror());
17+
}
18+
else{
19+
il2cpp_domain_get_ il2cpp_domain_get = (il2cpp_domain_get_)dlsym(il2cpp_handle, "il2cpp_domain_get");
20+
il2cpp_domain_get_assemblies_ il2cpp_domain_get_assemblies = (il2cpp_domain_get_assemblies_)dlsym(il2cpp_handle, "il2cpp_domain_get_assemblies");
21+
il2cpp_assembly_get_image_ il2cpp_assembly_get_image = (il2cpp_assembly_get_image_)dlsym(il2cpp_handle, "il2cpp_assembly_get_image");
22+
il2cpp_class_from_name_ il2cpp_class_from_name = (il2cpp_class_from_name_)dlsym(il2cpp_handle, "il2cpp_class_from_name");
23+
il2cpp_class_get_method_from_name_ il2cpp_class_get_method_from_name = (il2cpp_class_get_method_from_name_)dlsym(il2cpp_handle, "il2cpp_class_get_method_from_name");
24+
sleep(2);
25+
LOGD("hack game begin");
26+
Il2CppDomain* domain = il2cpp_domain_get();
27+
unsigned long ass_len = 0;
28+
const Il2CppAssembly** assembly_list = il2cpp_domain_get_assemblies(domain, &ass_len);
29+
while(strcmp((*assembly_list)->aname.name, "Assembly-CSharp") != 0){
30+
LOGD("Assembly name: %s", (*assembly_list)->aname.name);
31+
assembly_list++;
32+
}
33+
const Il2CppImage* image = il2cpp_assembly_get_image(*assembly_list);
34+
Il2CppClass* clazz = il2cpp_class_from_name(image, "<Namespace> ", "<Classname> Player");
35+
36+
//octo_hook((unsigned long)il2cpp_class_get_method_from_name(clazz, "<Your Method> PlayerUpdate", 1)->methodPointer, (void*)Player_Update, (void**)&old_Player_Update)
37+
}
38+
39+
}
40+
41+
__attribute__((constructor))
42+
void libil2cpp_main() {
43+
pthread_t ptid;
44+
pthread_create(&ptid, NULL, main_thread, NULL);
45+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy