Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Dex not properly decompiled/recompiled #2955

Closed
cronel opened this issue Nov 26, 2022 · 3 comments
Closed

[BUG] Dex not properly decompiled/recompiled #2955

cronel opened this issue Nov 26, 2022 · 3 comments

Comments

@cronel
Copy link

cronel commented Nov 26, 2022

Information

  1. Apktool Version (apktool -version) - apktool_2.7.0
  2. Operating System (Mac, Linux, Windows) - Windows 10
  3. APK From? (Playstore, ROM, Other) - Playstore

Stacktrace/Logcat

No Stacktrace (stated in main text why there is no trace)

Steps to Reproduce

  1. java -jar apktool_2.7.0.jar d BoldBeast_Latest_Apktool.apk -r
  2. java -jar apktool_2.7.0.jar b BoldBeast_Latest_Apktool
  3. Uber Signer
  4. SAI install bundle apks (all with same signature)

Frameworks

I used framework and same problem happened and nothing changed, also faster and easier way I used was to omit resource decompiling by -r option and main problem is from dex.

APK

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

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? Yes
  2. If you are trying to install a modified apk, did you resign it? Yes, also resigned other apks in bundle and problem isn't from singing or bundles.
  3. Are you using the latest apktool version? Yes

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, for resources using --use-aapt2 or -r solves it's errors but main problem is for dex part, when I use -s to not do any change to dex, the app works correctly but when I want to decompile and recompile it without any changes, problem arise and that has no error in apktool 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 (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


because I really need to decompile and recompile this app, tried to use -s -r and then decompiled and recompiled with baksmali and it's same as apktool (maybe both use same code)


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

@iBotPeaches
Copy link
Owner

I see the library files you mentioned aren't found, so a bit confused.

➜  2955 unzip -l com.boldbeast.voiprecorder_16_apps.evozi.com.apk | grep '.so$'
   223064  1980-00-00 00:00   assets/bin/arm64-v8a/libbbmp3lame.so
   169492  1980-00-00 00:00   assets/bin/armeabi-v7a/libbbmp3lame.so
    18344  1980-00-00 00:00   lib/arm64-v8a/libbbbasefunc.so
   223064  1980-00-00 00:00   lib/arm64-v8a/libbbmp3lame.so
   243896  1980-00-00 00:00   lib/arm64-v8a/libbbrecserver2.so
   166216  1980-00-00 00:00   lib/arm64-v8a/libbbvoip.so
    18096  1980-00-00 00:00   lib/armeabi-v7a/libbbbasefunc.so
   169492  1980-00-00 00:00   lib/armeabi-v7a/libbbmp3lame.so
   116444  1980-00-00 00:00   lib/armeabi-v7a/libbbrecserver2.so
   133200  1980-00-00 00:00   lib/armeabi-v7a/libbbvoip.so
➜  2955 

I believe those all cleanly align with the files you mentioned above. What would help here is the logcat during the crash so we can see the exact error Android is throwing when resolving these shared objects.

@cronel
Copy link
Author

cronel commented Dec 8, 2022

what I found based on exact analysis of this app was that it uses root, native lib, obfuscation, ... and I think these have caused apktool to fail at decompiling and recompiling it correctly.

there is no single logcat because each step that I fix a new problem arises.

for example I patched a hash checksum of dex in libbbvoip.so library using IDA pro and thought game is over but again got error related to async task and threads (monitor-enter,...) in:

"smali/com/boldbeast/voiprecorder/i.smali - b() function"
and "smali/com/boldbeast/voiprecorder/ui/root/RootFragment$d$a.smali" which is runnable.
above lines run when you click on check callRecordingFix

if libbbvoip.so isn't patched app's process will end after entering the app if dex is recompiled and I upload patched libbbvoip.so which is inside armeabi-v7a apk lib folder but for smali side best thing you can do for research on this and finding true problem is to decompile it yourself and debug using smalidea. (LogCat I got was VerifyError: Rejecting class because it failed compile-time verification for runnables I mentioned or one of them doesn't run at all and I don't know why doesn't run maybe because it has started from beggining of the app and doesn't run on click but generally they fail and need your debugging and I couldn't fully understand them)

also the apk version you mentioned above is older veriosn and get newer version (2.2) from google play itself because it has split apks too.

thank you very much

libbbvoip.zip

@iBotPeaches
Copy link
Owner

Okay thanks for the detailed explanation, but reading this again I'm just not sure what to make of it. I think the summarized idea is loading native modules is having issues.

I've been tracking this (albeit still unsolved) here - #2490

So I'll close this for that one

@iBotPeaches iBotPeaches closed this as not planned Won't fix, can't repro, duplicate, stale Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants