65,206
社区成员
发帖
与我相关
我的任务
分享
void JNICALL
cbClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv* env,
jclass class_being_redefined, jobject loader,
const char* name, jobject protection_domain,
jint class_data_len, const unsigned char* class_data,
jint* new_class_data_len, unsigned char** new_class_data)
{
char *r="com/yy/hunter";
char *p;
p=strstr(name,r);
if(p){
printf("需要解密的class name=%s\n", name);
//此处解密;
enter_critical_section(jvmti_env);
{
printf("开始解密a%s\n",name);
printf("%s\n",class_data);
unsigned char key[] = "hsylgwk-20120101";
AES aes(key);
//int o_len = aes.getUCharLen(class_data);
//printf("class_data len=%s\n",o_len);
printf("class_data len=%s\n","aaaaaaaaaaaaaaaaaaaaaaaaaaa");
char* old_data;
old_data = (char *)allocate(jvmti_env, class_data_len);
(void)memcpy((void*)old_data, (void*)(class_data), (int)class_data_len);
//memcpy(old_data,class_data,class_data_len);
printf("%s\n",old_data);
printf("%s\n","bbbbbbbbbbbbbbbbbbbbbbbbb");
char hex_data[1024];
//memset(hex_data, 0, 20);
aes.Bm53InvCipher(old_data, hex_data);
printf("%s\n",hex_data);
printf("%s\n","cccccccccccccccccccccccccccccc");
unsigned char *de_hex_data = (unsigned char *)malloc(strlen(hex_data));
//strcpy(de_hex_data,hex_data);
memcpy(de_hex_data,hex_data,strlen(hex_data));
aes.InvCipher(de_hex_data);
printf("%s\n",de_hex_data);
printf("%s\n","ddddddddddddddddddddddddddddddd");
//int nLen = strlen(old_data);
unsigned int len = strlen((char*)old_data);
m_pJvmTI->Allocate(len, (unsigned char **)&old_data);
free(old_data);
printf("%s\n","eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
}
exit_critical_section(jvmti_env);
}
}
char hex_data[1024];
//memset(hex_data, 0, 20); 为啥要注释这行呢?加上吧,同时把最后的20改为1024
memset(hex_data, 0, 1024);