Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
sa-jdi disable
Browse files Browse the repository at this point in the history
  • Loading branch information
4ra1n committed Sep 14, 2023
1 parent a8e22c9 commit 0734389
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions native/start.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void internal(unsigned char *_data, int start, unsigned char *key) {
}
uint32_t v[2] = {convert(first), convert(second)};

printf("DECRYPT KEY: %s\n",key);
printf("DECRYPT KEY: %s\n", key);
unsigned char *key_part1 = key;
unsigned char *key_part2 = key + 4;
unsigned char *key_part3 = key + 8;
Expand Down Expand Up @@ -117,11 +117,11 @@ void JNICALL ClassDecryptHook(
return;
}
// 1. {[10:14],[14:18]}
internal(_data,10,KEY);
internal(_data, 10, KEY);
// 2. {[18:22],[22:26]}
internal(_data,18,KEY);
internal(_data, 18, KEY);
// 3. {[26:30],[30:34]}
internal(_data,26,KEY);
internal(_data, 26, KEY);
// 4. asm encrypt
decrypt((unsigned char *) _data, class_data_len);
} else {
Expand Down Expand Up @@ -164,7 +164,7 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) {
v1 = tokens[1];
printf("PACKAGE_NAME: %s\n", v1);
printf("LENGTH: %llu\n", strlen((char *) v1));
}else{
} else {
printf("ERROR");
return 0;
}
Expand All @@ -174,7 +174,7 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) {
v2 = tokens[1];
printf("KEY: %s\n", v2);
printf("LENGTH: %llu\n", strlen((char *) v2));
} else{
} else {
printf("ERROR");
return 0;
}
Expand All @@ -191,14 +191,14 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) {
}

// SET PACKAGE_NAME
PACKAGE_NAME = (char *) malloc(strlen((char *)v1));
strcpy(PACKAGE_NAME, (char *)v1);
printf("SET GLOBAL PACKAGE: %s\n",PACKAGE_NAME);
PACKAGE_NAME = (char *) malloc(strlen((char *) v1));
strcpy(PACKAGE_NAME, (char *) v1);
printf("SET GLOBAL PACKAGE: %s\n", PACKAGE_NAME);

// SET KEY
KEY = (unsigned char *) malloc(16);
strcpy((char *)KEY, (char *)v2);
printf("SET GLOBAL KEY: %s\n",KEY);
strcpy((char *) KEY, (char *) v2);
printf("SET GLOBAL KEY: %s\n", KEY);

jvmtiEnv *jvmti;
DE_LOG("INIT JVMTI ENVIRONMENT");
Expand Down Expand Up @@ -241,7 +241,7 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) {

DE_LOG("INIT JVMTI SUCCESS");

error = (*vm)->GetEnv(vm, (void**)&jvmti, JVMTI_VERSION_1_0);
error = (*vm)->GetEnv(vm, (void **) &jvmti, JVMTI_VERSION_1_0);
if (error != JVMTI_ERROR_NONE) {
return JNI_ERR;
}
Expand All @@ -256,14 +256,13 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) {
return 1;
}

uintptr_t baseAddress = (uintptr_t)moduleHandle;
uintptr_t functionRVA = (uintptr_t)functionAddress - baseAddress;
uintptr_t baseAddress = (uintptr_t) moduleHandle;
uintptr_t functionRVA = (uintptr_t) functionAddress - baseAddress;

printf("gHotSpotVMStructs RVA: 0x%08X\n", (unsigned int)functionRVA);
printf("Function Addr: 0x%08X\n",(unsigned int)(uintptr_t)functionAddress);
printf("gHotSpotVMStructs RVA: 0x%08X\n", (unsigned int) functionRVA);
printf("Function Addr: 0x%08X\n", (unsigned int) (uintptr_t) functionAddress);

FARPROC* functionAddressPtr = &functionAddress;
*functionAddressPtr = 0;
*(size_t *) functionAddress = 0;

FreeLibrary(moduleHandle);

Expand Down

0 comments on commit 0734389

Please sign in to comment.