maoabc / nmmp

dex-vm used to protect the android classes.dex file
736 stars 259 forks source link

个别设备so会崩溃,是否编译需要提供DEBUG的so文件? #67

Open frankgogoland opened 1 year ago

frankgogoland commented 1 year ago

_ZN3art22IndirectReferenceTable3AddENS_15IRTSegmentStateENS_6ObjPtrINS_6mirror6ObjectEEEPNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEE+1240)

01 pc 0000000000057724 /apex/com.android.runtime/lib64/libart.so (_ZN3art9JNIEnvExt17AddLocalReferenceIP8_jobjectEET_NS_6ObjPtrINS_6mirror6ObjectEEE+60)

#02 pc 0000000000252f90  /apex/com.android.runtime/lib64/libart.so (_ZN3art3JNI11NewLocalRefEP7_JNIEnvP8_jobject+620)
#03 pc 000000000000fba8  /data/app/xxxx-nNaaodSWfKkgesDVybwLbg==/lib/arm64/libnmmvm.so (vmInterpret+2200)
#04 pc 0000000000072534  /data/app/xxxx-nNaaodSWfKkgesDVybwLbg==/lib/arm64/libnmmp.so
#05 pc 00000000000002ec  /data/app/xxxx-nNaaodSWfKkgesDVybwLbg==/oat/arm64/base.odex
maoabc commented 1 year ago

是不是安卓5或者6上面?需要缩小下范围,定位到java方法,然后再编译debug版

frankgogoland commented 1 year ago

android 10,报错的地方是jvalue vmInterpret( JNIEnv env, const vmCode code, const vmResolver *dvmResolver ),函数内部涉及NewLocalRef的地方。

frankgogoland commented 1 year ago

android 10,报错的地方是jvalue vmInterpret( JNIEnv env, const vmCode code, const vmResolver *dvmResolver ),函数内部涉及NewLocalRef的地方。

maoabc commented 1 year ago

要看对应java方法

frankgogoland @.***> 于 2023年2月23日周四 10:40写道:

android 10,报错的地方是jvalue vmInterpret( JNIEnv env, const vmCode code, const vmResolver *dvmResolver ),函数内部涉及NewLocalRef的地方。

— Reply to this email directly, view it on GitHub https://github.com/maoabc/nmmp/issues/67#issuecomment-1441147850, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA27LV25AHU7SQ6ANUYYNCLWY3EZXANCNFSM6AAAAAAVELK6JI . You are receiving this because you commented.Message ID: @.***>

maoabc commented 1 year ago

这个是所有方法入口,光看这个没用,要看什么样的java方法导致的。

mao kai @.***> 于 2023年2月23日周四 11:03写道:

要看对应java方法

frankgogoland @.***> 于 2023年2月23日周四 10:40写道:

android 10,报错的地方是jvalue vmInterpret( JNIEnv env, const vmCode code, const vmResolver *dvmResolver ),函数内部涉及NewLocalRef的地方。

— Reply to this email directly, view it on GitHub https://github.com/maoabc/nmmp/issues/67#issuecomment-1441147850, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA27LV25AHU7SQ6ANUYYNCLWY3EZXANCNFSM6AAAAAAVELK6JI . You are receiving this because you commented.Message ID: @.***>

frankgogoland commented 1 year ago

目前这个问题很麻烦,已经发布到应用市场,有些手机或者系统频繁崩溃,但是报错的只有入口函数,还无法定位到java哪个方法,手边的测试机器还不能复现的。

maoabc commented 1 year ago

别处理对应的java方法,排出一些方法转换就行

maoabc commented 1 year ago

一般不可能看不到从哪个java方法抛出异常的

frankgogoland commented 1 year ago

别处理对应的java方法,排出一些方法转换就行

感谢回复,目前不清楚是哪个方法,因为java很多,混淆的地方也多

maoabc commented 1 year ago

所有转换过的java方法都经过vmInterpret,像这个pc 0000000000072534 /data/app/xxxx-nNaaodSWfKkgesDVybwLbg==/lib/arm64/libnmmp.so, 你吧地址转换为行号,然后看dex2c里的源码,根据源码就能确定

maoabc commented 1 year ago

你给的那个报错信息不全,按理后面应该还有错误信息

maoabc commented 1 year ago

.so自己保留一份没有strip过的,然后根据崩溃栈用ndk-stack得到源码位置,再根据转换后源码位置对应的native方法名确认java方法

frankgogoland commented 1 year ago

嗯,我考虑怎么弄一下,怎么不能上传附件呢?

frankgogoland commented 1 year ago

目前已经定位到函数了,能对某个函数做屏蔽嘛?另外这些函数有的很简单(目前为止有2个),不清楚到底哪里会出现异常。

frankgogoland commented 1 year ago

static jobject Java_com_lucent_easy_help_AssistUtil_T0_Ljava_lang_String_2(JNIEnv *env, jclass jcls ) { regptr_t regs[2]; regs[0] = 0; regs[1] = 0;

u1 reg_flags[2];
reg_flags[0] = 0;
reg_flags[1] = 0;

static const u2 insns[] = {

0x0023, 0x0655, 0x410b, 0x1137, 0x08e5, 0x010a, 0x000b, 0x0000, 0x209e, 0x1ba7, 0x0010, 0x1067, 0x1bab, 0x0000, 0x00e0, 0x0025, 0x0300, 0x0008, 0x0004, 0x0000, 0x7ef3, 0x9544, 0xa879, 0x1316, 0xe0f9, 0x280a, 0x06e7, 0x77a4, 0xd6a2, 0xbeee, 0xf3a6, 0x58e1, 0x1e6f, 0x9c11, 0x05fc, 0x2ceb, }; const u1 *tries = NULL;

const vmCode code = {
        .insns=insns,
        .insnsSize=36,
        .regs=regs,
        .reg_flags=reg_flags,
        .triesHandlers=tries
};

jvalue value = vmInterpret(env,
                            &code,
                            &dvmResolver);
return value.l;

}

比如这样的函数

maoabc commented 1 year ago

绕过那些方法,具体不清楚怎么发生的,一般遇到这类绕过就行了。修改规则文件

maoabc commented 1 year ago

也可能不是这个方法产生的,是之前一些复杂的jni调用,导致在这里刚好触发bug, 调用它的也一并绕过

maoabc commented 1 year ago

com.lucent.easy.help.AssistUtil.T0这个方法经过混淆了,可能需要通过mapping.txt,找到混淆前的名称。

maoabc commented 1 year ago

转换后,看不出原本java代码,opcode及各种索引都变化了,你可以贴这个类的smali或者反编译的java,我尝试去写测试,看看能重现bug吗

frankgogoland commented 1 year ago

具体哪个函数都知道了,我的QQ :1223774014,不方便在这里贴代码,谢谢。

maoabc commented 1 year ago

那就算了,绕过对应方法就行。

frankgogoland commented 1 year ago

麻烦问下规则文件能对某个函数不执行native操作嘛?

maoabc commented 1 year ago

规则只实现了指定需要转换的类及方法,其他没有实现。其他功能可以自己去实现那个过滤接口。