如下是错误,应该是context传参null有问题吧,看不明白
[main]D/Psdk_so_lib: SUPPORT LIST:
58APP 58同镇 SDKDemo 招财猫 中华英才 安居客 58同镇站长 58校校
赶集 云车市 58钱柜 58二手车 金融保险 58公寓商家 58公寓管家 58好借
58商家通 58在线大学 58车商通 58白菜商家版 58新车 58到家精选 58商办通 灵活就业
优信拍卖家端 优信拍 58用车 58达人版 58直播
58车服 58全景拍摄 城阳智慧务工平台 EncryptDemo 58到家
2022-04-06 11:27:16.638 [http-apr-48080-exec-3] WARN c.g.unidbg.linux.ARM32SyscallHandler.hook - handleInterrupt intno=2, NR=-1073743984, svcNumber=0x113, PC=unicorn@0xfffe01c4, syscall=null
java.lang.UnsupportedOperationException: android/content/Context->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;
at com.github.unidbg.utils.WuBaAppSignUtils$1.callObjectMethod(WuBaAppSignUtils.java:95)
at com.github.unidbg.linux.android.dvm.DvmMethod.callObjectMethod(DvmMethod.java:59)
at com.github.unidbg.linux.android.dvm.DalvikVM$20.handle(DalvikVM.java:363)
at com.github.unidbg.linux.ARM32SyscallHandler.hook(ARM32SyscallHandler.java:103)
at unicorn.Unicorn$NewHook.onInterrupt(Unicorn.java:128)
at unicorn.Unicorn.emu_start(Native Method)
at com.github.unidbg.AbstractEmulator.emulate(AbstractEmulator.java:357)
at com.github.unidbg.AbstractEmulator.eFunc(AbstractEmulator.java:445)
at com.github.unidbg.arm.AbstractARMEmulator.eFunc(AbstractARMEmulator.java:208)
at com.github.unidbg.Module.emulateFunction(Module.java:156)
at com.github.unidbg.linux.android.dvm.DvmObject.callJniMethod(DvmObject.java:115)
at com.github.unidbg.linux.android.dvm.DvmClass.callStaticJniMethodObject(DvmClass.java:250)
at com.github.unidbg.utils.WuBaAppSignUtils.myJni(WuBaAppSignUtils.java:109)
at com.github.unidbg.utils.WuBaAppSignUtils.encrypt(WuBaAppSignUtils.java:217)
at com.github.servlet.YdjjEncryptServlet.doPost(YdjjEncryptServlet.java:32)
at com.github.servlet.YdjjEncryptServlet.doGet(YdjjEncryptServlet.java:25)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2555)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2544)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
2022-04-06 11:27:16.708 [http-apr-48080-exec-3] WARN com.github.unidbg.AbstractEmulator.emulate - emulate RX@0x400027e5[libcom_wuba_uc_rsa.so]0x27e5 exception sp=unicorn@0xbffff6e8, msg=android/content/Context->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;, offset=85ms
2022-04-06 11:27:16.712 [http-apr-48080-exec-3] INFO c.g.unidbg.utils.WuBaAppSignUtils.encrypt - 加密接收到的字符为info:[test]
[main]D/Psdk_so_lib: no power!
2022-04-06 11:27:16.733 [http-apr-48080-exec-3] INFO c.g.unidbg.utils.WuBaAppSignUtils.encrypt - 加密结果:[]
libcom_wuba_uc_rsa.so.zip public class RsaCryptService { private static final String TAG = "RsaCryptService"; private static boolean initSuccess;
}
下面是我java代码 // 密码加密 public static String encrypt(String info) throws IOException { // 1、需要调用的so文件所在路径 String soFilePath = "/disk/apps/wubaapp/libcom_wuba_uc_rsa.so"; // 2、需要调用函数所在的Java类完整路径,比如a/b/c/d等等,注意需要用/代替. String classPath = "com/wuba/uc/RsaCryptService"; // 3、需要调用函数的函数签名,我这里调用EncryptUtils中的getGameKey方法,由于此方法没有参数列表,所以不需要传入 String methodEncryp = "encrypt([B)Ljava/lang/String;"; // 输出getGameKey方法调用结果 WuBaAppSignUtils encryptUtilsJni = new WuBaAppSignUtils(soFilePath, classPath); //调用native init方法 String methodInit = "init(Landroid/content/Context;)V"; encryptUtilsJni.myJni(methodInit, encryptUtilsJni.vm.resolveClass("android/content/Context").newObject(null)); byte[] bytes = (byte[]) null; if(StringUtils.isNotBlank(info)) { bytes = info.getBytes(); } logger.info("加密接收到的字符为info:[{}]", info); String encryption = encryptUtilsJni.myJni(methodEncryp, new ByteArray(encryptUtilsJni.vm, bytes)); logger.info("加密结果:[{}]", encryption); encryptUtilsJni.destroy(); return encryption; }
如下是错误,应该是context传参null有问题吧,看不明白 [main]D/Psdk_so_lib: SUPPORT LIST: 58APP 58同镇 SDKDemo 招财猫 中华英才 安居客 58同镇站长 58校校 赶集 云车市 58钱柜 58二手车 金融保险 58公寓商家 58公寓管家 58好借 58商家通 58在线大学 58车商通 58白菜商家版 58新车 58到家精选 58商办通 灵活就业 优信拍卖家端 优信拍 58用车 58达人版 58直播 58车服 58全景拍摄 城阳智慧务工平台 EncryptDemo 58到家 2022-04-06 11:27:16.638 [http-apr-48080-exec-3] WARN c.g.unidbg.linux.ARM32SyscallHandler.hook - handleInterrupt intno=2, NR=-1073743984, svcNumber=0x113, PC=unicorn@0xfffe01c4, syscall=null java.lang.UnsupportedOperationException: android/content/Context->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences; at com.github.unidbg.utils.WuBaAppSignUtils$1.callObjectMethod(WuBaAppSignUtils.java:95) at com.github.unidbg.linux.android.dvm.DvmMethod.callObjectMethod(DvmMethod.java:59) at com.github.unidbg.linux.android.dvm.DalvikVM$20.handle(DalvikVM.java:363) at com.github.unidbg.linux.ARM32SyscallHandler.hook(ARM32SyscallHandler.java:103) at unicorn.Unicorn$NewHook.onInterrupt(Unicorn.java:128) at unicorn.Unicorn.emu_start(Native Method) at com.github.unidbg.AbstractEmulator.emulate(AbstractEmulator.java:357) at com.github.unidbg.AbstractEmulator.eFunc(AbstractEmulator.java:445) at com.github.unidbg.arm.AbstractARMEmulator.eFunc(AbstractARMEmulator.java:208) at com.github.unidbg.Module.emulateFunction(Module.java:156) at com.github.unidbg.linux.android.dvm.DvmObject.callJniMethod(DvmObject.java:115) at com.github.unidbg.linux.android.dvm.DvmClass.callStaticJniMethodObject(DvmClass.java:250) at com.github.unidbg.utils.WuBaAppSignUtils.myJni(WuBaAppSignUtils.java:109) at com.github.unidbg.utils.WuBaAppSignUtils.encrypt(WuBaAppSignUtils.java:217) at com.github.servlet.YdjjEncryptServlet.doPost(YdjjEncryptServlet.java:32) at com.github.servlet.YdjjEncryptServlet.doGet(YdjjEncryptServlet.java:25) at javax.servlet.http.HttpServlet.service(HttpServlet.java:624) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2555) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2544) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) 2022-04-06 11:27:16.708 [http-apr-48080-exec-3] WARN com.github.unidbg.AbstractEmulator.emulate - emulate RX@0x400027e5[libcom_wuba_uc_rsa.so]0x27e5 exception sp=unicorn@0xbffff6e8, msg=android/content/Context->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;, offset=85ms 2022-04-06 11:27:16.712 [http-apr-48080-exec-3] INFO c.g.unidbg.utils.WuBaAppSignUtils.encrypt - 加密接收到的字符为info:[test] [main]D/Psdk_so_lib: no power! 2022-04-06 11:27:16.733 [http-apr-48080-exec-3] INFO c.g.unidbg.utils.WuBaAppSignUtils.encrypt - 加密结果:[]