/** * Replace method call with calculated result. * Useful for custom string deobfuscation. * * Example for sample from issue https://github.com/skylot/jadx/issues/1251 */importjadx.core.dex.instructions.ConstStringNodeimportjadx.core.dex.instructions.InvokeNodeimportjadx.core.dex.instructions.args.InsnArgimportjadx.core.dex.instructions.args.InsnWrapArgimportjadx.core.dex.instructions.args.RegisterArgvaljadx=getJadxInstance()valmthSignature="com.xshield.aa.iIiIiiiiII(Ljava/lang/String;)Ljava/lang/String;"jadx.replace.insns{mth,insn->if(insnisInvokeNode&&insn.callMth.rawFullId==mthSignature){valstr=getConstStr(insn.getArg(0))if(str!=null){valresultStr=decode(str)log.info{"Decode '$str' to '$resultStr' in $mth"}return@insnsConstStringNode(resultStr)}}null}fungetConstStr(arg:InsnArg):String?{valinsn=when(arg){isInsnWrapArg->arg.wrapInsnisRegisterArg->arg.assignInsnelse->null}if(insnisConstStringNode){returninsn.string}returnnull}/** * Decompiled method, automatically converted to Kotlin by IntelliJ Idea */fundecode(str:String):String{vallength=str.lengthvalcArr=CharArray(length)vari=length-1while(i>=0){vali2=i-1cArr[i]=(str[i].codexor'z'.code).toChar()if(i2<0){break}i=i2-1cArr[i2]=(str[i2].codexor'\u000c'.code).toChar()}returnString(cArr)}
// That is the path relative to the jadx/bin execution directory, or it can be changed to an absolute path.@file:DependsOn("../external_library/okhttp-4.11.0.jar")@file:DependsOn("../external_library/okio-jvm-3.2.0.jar")@file:DependsOn("../external_library/okio-3.2.0.jar")importokhttp3.MediaType.Companion.toMediaTypeimportokhttp3.OkHttpClientimportokhttp3.Requestimportokhttp3.RequestBody.Companion.toRequestBodyimportokhttp3.Responseimportjadx.core.dex.instructions.ConstStringNodeimportjadx.core.dex.instructions.InvokeNodeimportjadx.core.dex.instructions.args.InsnArgimportjadx.core.dex.instructions.args.InsnWrapArgimportjadx.core.dex.instructions.args.RegisterArgvaljadx=getJadxInstance()valmthSignature_qzb="kotlinx.android.extensionss.qz.b(Ljava/lang/String;)Ljava/lang/String;"jadx.replace.insns{mth,insn->if(insnisInvokeNode&&insn.callMth.rawFullId==mthSignature_qzb){valstr=getConstStr(insn.getArg(0))if(str!=null){valresultStr=decrypt(mthSignature_qzb,str)log.info{"Decrypt '$str' to '$resultStr' in $mth"}return@insnsConstStringNode(resultStr)}}null}fungetConstStr(arg:InsnArg):String?{valinsn=when(arg){isInsnWrapArg->arg.wrapInsnisRegisterArg->arg.assignInsnelse->null}if(insnisConstStringNode){returninsn.string}returnnull}// rpc 解密函数fundecrypt(mthSignature:String,param:String):String?{valclient=OkHttpClient()valjson=""" { "method": "${mthSignature}", "param": "${param}" } """.trimIndent()valrequestBody=json.toRequestBody("application/json; charset=utf-8".toMediaType())valrequest=Request.Builder().url("http://127.0.0.1:5000/decrypt").post(requestBody).build()valresponse=client.newCall(request).execute()returnresponse.body?.string().toString()}