zhkl0228 / unidbg

Allows you to emulate an Android native library, and an experimental iOS emulation
Apache License 2.0
3.88k stars 966 forks source link

jni调用java类属性的问题 #192

Open panchoGG opened 4 years ago

panchoGG commented 4 years ago

如题, JNIEnv->FindClass(com/umetrip/android/umehttp/security/UmeJni) was called from RX@0x400022b1[libumejni.so]0x22b1 JNIEnv->RegisterNatives(com/umetrip/android/umehttp/security/UmeJni, RW@0x40018008[libumejni.so]0x18008, 3) was called from RX@0x4000241d[libumejni.so]0x241d [18:20:34 167] WARN [com.github.unidbg.linux.ARM32SyscallHandler] (ARM32SyscallHandler:446) - handleInterrupt intno=2, NR=-1073744024, svcNumber=0x157, PC=unicorn@0xfffe0604, syscall=null unicorn.UnicornException: Invalid memory read (UC_ERR_READ_UNMAPPED) at unicorn.Unicorn.mem_read(Native Method) at com.github.unidbg.arm.backend.UnicornBackend.mem_read(UnicornBackend.java:32) at com.github.unidbg.pointer.UnidbgPointer.getString(UnidbgPointer.java:299) at com.github.unidbg.pointer.UnidbgPointer.getString(UnidbgPointer.java:290) at com.github.unidbg.linux.android.dvm.DalvikVM$88.handle(DalvikVM.java:1788) at com.github.unidbg.linux.ARM32SyscallHandler.hook(ARM32SyscallHandler.java:103) at com.github.unidbg.arm.backend.UnicornBackend$5.hook(UnicornBackend.java:129) at unicorn.Unicorn$NewHook.onInterrupt(Unicorn.java:128) at unicorn.Unicorn.emu_start(Native Method) at com.github.unidbg.arm.backend.UnicornBackend.emu_start(UnicornBackend.java:136) at com.github.unidbg.AbstractEmulator.emulate(AbstractEmulator.java:388) at com.github.unidbg.AbstractEmulator.eFunc(AbstractEmulator.java:477) at com.github.unidbg.arm.AbstractARMEmulator.eFunc(AbstractARMEmulator.java:209) at com.github.unidbg.Module.emulateFunction(Module.java:154) at com.github.unidbg.linux.LinuxModule.callFunction(LinuxModule.java:211) at com.github.unidbg.linux.LinuxSymbol.call(LinuxSymbol.java:27) at com.github.unidbg.linux.android.dvm.DalvikModule.callJNI_OnLoad(DalvikModule.java:30) at pancho.Demo2.(Demo2.java:52) at pancho.Demo2.main(Demo2.java:94) [18:20:34 169] WARN [com.github.unidbg.AbstractEmulator] (AbstractEmulator:407) - emulate RX@0x40003e55[libumejni.so]0x3e55 exception sp=unicorn@0xbffff6b0, msg=Invalid memory read (UC_ERR_READ_UNMAPPED), offset=6ms Find native function Java_com_umetrip_android_umehttp_security_UmeJni_sub_0515(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String; => RX@0x4000c889[libumejni.so]0xc889 JNIEnv->CallObjectMethod(android/content/Context, getPackageManager()Landroid/content/pm/PackageManager; => android.content.pm.PackageManager@7006c658) was called from RX@0x4000c91d[libumejni.so]0xc91d JNIEnv->CallObjectMethod(android/content/Context, getPackageName()Ljava/lang/String; => "com.umetrip.android.msky.app") was called from RX@0x4000c987[libumejni.so]0xc987 JNIEnv->GetStringUtfChars("com.umetrip.android.msky.app") was called from RX@0x4000c9b1[libumejni.so]0xc9b1 JNIEnv->FindClass(com/umetrip/android/msky/app/BuildConfig) was called from RX@0x40010409[libumejni.so]0x10409 [18:20:34 308] WARN [com.github.unidbg.linux.ARM32SyscallHandler] (ARM32SyscallHandler:446) - handleInterrupt intno=2, NR=-1073743992, svcNumber=0x139, PC=unicorn@0xfffe0424, syscall=null java.lang.UnsupportedOperationException: com/umetrip/android/msky/app/BuildConfig->tc2a2wqv:Ljava/lang/String; at com.github.unidbg.linux.android.dvm.AbstractJni.getStaticObjectField(AbstractJni.java:66) at com.github.unidbg.linux.android.dvm.DvmField.getStaticObjectField(DvmField.java:27) at com.github.unidbg.linux.android.dvm.DalvikVM$58.handle(DalvikVM.java:1263) at com.github.unidbg.linux.ARM32SyscallHandler.hook(ARM32SyscallHandler.java:103) at com.github.unidbg.arm.backend.UnicornBackend$5.hook(UnicornBackend.java:129) at unicorn.Unicorn$NewHook.onInterrupt(Unicorn.java:128) at unicorn.Unicorn.emu_start(Native Method) at com.github.unidbg.arm.backend.UnicornBackend.emu_start(UnicornBackend.java:136) at com.github.unidbg.AbstractEmulator.emulate(AbstractEmulator.java:388) at com.github.unidbg.AbstractEmulator.eFunc(AbstractEmulator.java:477) at com.github.unidbg.arm.AbstractARMEmulator.eFunc(AbstractARMEmulator.java:209) at com.github.unidbg.Module.emulateFunction(Module.java:154) at com.github.unidbg.linux.android.dvm.DvmObject.callJniMethod(DvmObject.java:115) at com.github.unidbg.linux.android.dvm.DvmClass.callStaticJniMethod(DvmClass.java:244) at pancho.Demo2.myJni(Demo2.java:68) at pancho.Demo2.main(Demo2.java:105) [18:20:34 309] WARN [com.github.unidbg.AbstractEmulator] (AbstractEmulator:407) - emulate RX@0x4000c889[libumejni.so]0xc889 exception sp=unicorn@0xbfffec30, msg=com/umetrip/android/msky/app/BuildConfig->tc2a2wqv:Ljava/lang/String;, offset=139ms error emulator destroy...

代码如下: package pancho;

import com.github.unidbg.Module; import com.github.unidbg.linux.android.AndroidARMEmulator; import com.github.unidbg.linux.android.AndroidResolver; import com.github.unidbg.linux.android.dvm.*; import com.github.unidbg.linux.android.dvm.array.ByteArray; import com.github.unidbg.memory.Memory;

import java.io.File; import java.io.IOException;

/**

}

拜托大佬,我应该怎样才能把java类的属性放到jni中呢

zhkl0228 commented 4 years ago

java及so或者apk打包发出来看下

panchoGG commented 4 years ago

上述是脱壳后的APK以及核心加密算法的so.现在要模拟调用的是com.umetrip.android.umehttp.security.UmeJni类中的sub_0515方法。 问题:jni调用过程中用到了java一个类的属性, 就是不知道怎么模拟

------------------ 原始邮件 ------------------ 发件人: "zhkl0228/unidbg" <notifications@github.com>; 发送时间: 2020年10月10日(星期六) 晚上11:36 收件人: "zhkl0228/unidbg"<unidbg@noreply.github.com>; 抄送: "328366802@qq.com"<328366802@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [zhkl0228/unidbg] jni调用java类属性的问题 (#192)

java及so或者apk打包发出来看下

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

从QQ邮箱发来的超大附件

航旅纵横v2020_09_19.apk (99.38M, 2020年11月09日 23:38 到期)进入下载页面:http://mail.qq.com/cgi-bin/ftnExs_download?t=exs_ftn_download&k=75323535c688f19aeb48a72640640a4c0b57570056075e5a14540d575e490c535a0b185456560a4e5f02040756575e540951560c667338d984f0f6e2bbded9150b0207053954013c080b1b54160f385e&code=9255fd8c

ghost commented 3 years ago

ava.lang.ClassCastException: com.github.unidbg.linux.android.dvm.DvmObject cannot be cast to com.github.unidbg.linux.android.dvm.Array