JesusFreke / smali

smali/baksmali
6.26k stars 1.07k forks source link

[BUG] Dex not properly decompiled/recompiled #860

Open cronel opened 1 year ago

cronel commented 1 year ago

Information

Baksmali Version - [v2.5.2] Operating System- Windows 10

Steps to Reproduce

java -jar apktool_2.7.0.jar d BoldBeast_Latest_Apktool.apk -r -s baksmali decompile recompile dex and replace original dex with recompiled java -jar apktool_2.7.0.jar b BoldBeast_Latest_Apktool Uber Signer (also resigned other apks in bundle and problem isn't from singing or bundles) SAI install bundle apks (all with same signature)


Hello, there is a unique app for recording VOIP calls:

https://play.google.com/store/apps/details?id=com.boldbeast.voiprecorder

I tried to decompiled and recompile it using apktool (with no resource decode or dex decompile by apktool) then decompiled/recompiled dex, when I don't do any change to dex, the app works correctly but when I want to decompile and recompile it's dex without any changes, problem arise and that has no error in baksmali and app gets installed properly and opens propery but when I click grant root button, it crashes and there is nothing about crash in logcat so I had to debug it using smalidea and found where exactly the crash is, it's at loading a native library (which I checked and it doesn't exist in lib folder so maybe what they do is to create these libs dynamically or they make symlinks or ... becaue this is a root app and has magisk module and does things in root level that ordinary apps don't do and it has native libraries)


here is exact path to where crash happens:

"smali\com\boldbeast\voiprecorder\BBJni.smali" : const-string v2, "bbvoip" Line 743: invoke-static {v2}, Ljava/lang/System;->loadLibrary(Ljava/lang/String;)V


if I don't do any change to dex (no decompile) it works but if any decompile and recompile without any change at all, app fails at this point (same for apktool and baksmali recompiling of dex) (I checked and there is no signature or integrity check and problem is from what I mentioned)


also I searched in all smali in \smali\com to find more native libs loading and found below ones:

"smali\com\boldbeast\base\BBBaseFunc.smali" : const-string v1, "bbbasefunc" Line 110: invoke-static {v1}, Ljava/lang/System;->loadLibrary(Ljava/lang/String;)V

"smali\com\boldbeast\voiprecorder\BBRootService.smali" : const-string v0, "bbrecserver2" Line 53: invoke-static {v0}, Ljava/lang/System;->loadLibrary(Ljava/lang/String;)V

also after recompile it mistakenly says can't get root access (becaue it can't load libs)


also checked module files and found there are native libs there too but they aren't ones loaded in above and I couldn't find libs loaded in above lines anywhere from app libs folder or modules libs folder in root and I don't know what developer does that decompile and recompile breaks it! (most likely it's some kind of root actions which ordinary apps don't do)

below is path of magisk module and libs and other files are there: /data/adb/modules/CallRecordingFix


apktool and baksmali fail similarly

I hope you work on this because this is a clear bug in decompiling and recompiling dex for native libs.


MrIkso commented 1 year ago

App have a signature check. It's not related to this project.