MobSF / Mobile-Security-Framework-MobSF

Mobile Security Framework (MobSF) is an automated, all-in-one mobile application (Android/iOS/Windows) pen-testing, malware analysis and security assessment framework capable of performing static and dynamic analysis.
https://opensecurity.in
GNU General Public License v3.0
16.68k stars 3.16k forks source link

Stuck on Decompiling to Java with jadx with large APK #2329

Closed H-Maa closed 5 months ago

H-Maa commented 5 months ago

ENVIRONMENT

OS and Version: Windows 11 Home 10.0.22621 N/A Build 22621
Python Version: 3.11.4
MobSF Version: v3.9.3 beta

EXPLANATION OF THE ISSUE

What happens, under which versions, under what conditions, when, and what were you expecting instead.

Stuck on "Decompiling to Java with jadx" during static analysis, even after waiting 20 minutes. I'm trying to analyze TikTok 32.9.1 APK which is 285MB. CPU usage goes up to 100% and ram to 16gb (I have 32gb)

STEPS TO REPRODUCE THE ISSUE

1. Start MobileSF through docker
2. Upload apk with GUI

LOG FILE

[INFO] 28/Jan/2024 03:11:52 - Reading Code Signing Certificate
[INFO] 28/Jan/2024 03:11:53 - Getting Signature Versions
[INFO] 28/Jan/2024 03:11:55 - Running APKiD 2.1.5
[INFO] 28/Jan/2024 03:12:11 - Trackers Database is outdated!
[INFO] 28/Jan/2024 03:12:11 - Updating Trackers Database....
[INFO] 28/Jan/2024 03:12:11 - Detecting Trackers
[INFO] 28/Jan/2024 03:12:22 - APK -> JAVA
[INFO] 28/Jan/2024 03:12:22 - Decompiling to Java with jadx

Attached full log below. log.txt

Tried increasing ram limit to 8gb in both jadx and jadx-gui scripts, and JADX_GUI_OPTS='"-j 1"'.

github-actions[bot] commented 5 months ago

👋 @H-Maa Issues is only for reporting a bug/feature request. For limited support, questions, and discussions, please join MobSF Slack channel Please include all the requested and relevant information when opening a bug report. Improper reports will be closed without any response.

H-Maa commented 5 months ago

After 30 minutes jadx times out and it continues with the analysis.

[WARNING] 28/Jan/2024 03:42:23 - Decompiling with jadx timed out
[INFO] 28/Jan/2024 03:42:23 - Converting classes12.dex to Smali Code
[INFO] 28/Jan/2024 03:42:23 - Converting classes.dex to Smali Code
[INFO] 28/Jan/2024 03:42:23 - Converting classes28.dex to Smali Code
[INFO] 28/Jan/2024 03:42:23 - Converting classes15.dex to Smali Code

Not sure if this is an issue?

ohyeah521 commented 5 months ago

@H-Maa pls upload the apk file,i'll test it.

H-Maa commented 5 months ago

@H-Maa pls upload the apk file,i'll test it.

Here you go. https://mega.nz/file/8FAjkTjJ#GSb1Mbt9AWxnGm0XHrnRa0ADHgq5kufkGLKMOR--fEk

ohyeah521 commented 5 months ago

This application is too big, it has 207175 classes and 1157284 methods. You can try to increase the jvm memory.

ajinabraham commented 5 months ago

This is not a bug in MobSF.

@H-Maa MobSF has a timeout for jadx decompiling after 30 minutes. You can either increase the timeout using the environment variable or increase the JVM memory here: https://github.com/MobSF/Mobile-Security-Framework-MobSF/blob/0a69464576e5be4eea0482367896825f65a15103/mobsf/StaticAnalyzer/tools/jadx/bin/jadx#L89

If either of these doesn't work, then this is a JADX issue and you probably want to report it to https://github.com/skylot/jadx

H-Maa commented 5 months ago

This is not a bug in MobSF.

@H-Maa MobSF has a timeout for jadx decompiling after 30 minutes. You can either increase the timeout using the environment variable or increase the JVM memory here:

https://github.com/MobSF/Mobile-Security-Framework-MobSF/blob/0a69464576e5be4eea0482367896825f65a15103/mobsf/StaticAnalyzer/tools/jadx/bin/jadx#L89

If either of these doesn't work, then this is a JADX issue and you probably want to report it to https://github.com/skylot/jadx

I tried increasing memory as you said but that did not help. I also never have any issue with decompiling this apk with jadx, at most it uses 4-4.5gb of ram so there should be plenty left.

ajinabraham commented 5 months ago

Did you run the exact command line arguments https://github.com/MobSF/Mobile-Security-Framework-MobSF/blob/0a69464576e5be4eea0482367896825f65a15103/mobsf/StaticAnalyzer/views/android/converter.py#L90 when you ran jadx decompiler independently?

H-Maa commented 5 months ago

No, I used jadx-gui. I'll try it with command line.

ohyeah521 commented 5 months ago

Your problem has nothing to do with mobsf, you should report it to jadx

H-Maa commented 5 months ago

Did you run the exact command line arguments

https://github.com/MobSF/Mobile-Security-Framework-MobSF/blob/0a69464576e5be4eea0482367896825f65a15103/mobsf/StaticAnalyzer/views/android/converter.py#L90 when you ran jadx decompiler independently?

I tried it with command line using the same arguments, and it finished decompiling but did experience errors.

ERROR -   Method: com.ss.android.ugc.aweme.ecommerce.base.pdp.vm.PdpViewModel.HG0():java.lang.String
ERROR -   Method: com.ss.android.ugc.aweme.ecommerce.base.sku.vm.SkuPanelViewModel.eG0(java.util.Map, android.view.View):void
ERROR -   Method: com.ss.android.ugc.aweme.main.bottomobserver.BottomPublishObserver.LIZ():void
ERROR -   Method: com.ss.android.ugc.aweme.poi.map.lynxmap.LynxMapElement.LJJIIJZLJL(com.lynx.react.bridge.ReadableMap):X.KSP
ERROR -   Method: com.ss.android.ugc.aweme.profile.ui.I18nAbsProfileFragmentV2.Yq(com.ss.android.ugc.aweme.profile.ui.I18nAbsProfileFragmentV2, X.Tqr):X.Tqr
ERROR -   Method: com.ss.android.ugc.aweme.search.pages.result.topsearch.core.ui.jedi.SearchJediMixFeedFragment.ws(int, X.YBj):void
ERROR -   Method: com.ss.android.ugc.aweme.share.core.ui.SkeletonSharePanelFragment.initView():void
ERROR -   Method: com.ss.android.ugc.aweme.wavepublish.dm.service.DMPublishServiceImpl.createPhotoPublishEditModel(java.lang.String, java.lang.String, int, boolean, boolean, boolean, boolean):X.DsM<java.lang.Boolean, com.ss.android.ugc.aweme.shortvideo.BaseShortVideoContext>
ERROR -   Method: com.ss.android.ugc.aweme.wavepublish.dm.service.DMPublishServiceImpl.createVideoPublishEditModel(java.lang.String, java.lang.String, int, int, long, int, int, int, int, boolean, boolean, boolean, java.lang.String):X.DsM<java.lang.Boolean, com.ss.android.ugc.aweme.shortvideo.BaseShortVideoContext>
ERROR -   Method: com.ss.android.ugc.gamora.editorpro.tts.TTSFragment.Br(boolean):void
ERROR -   Method: com.ss.ttlivestreamer.core.effect.EffectWrapper.onExpressionDetectResultCallback(int):void
ERROR -   Method: com.sun.jna.NativeLibrary.loadLibrary(java.lang.String, java.util.Map<java.lang.String, ?>):com.sun.jna.NativeLibrary
ERROR -   Method: kotlin.jvm.internal.AFqS86S0000000_8.invoke():java.lang.Object
ERROR -   Method: kotlin.jvm.internal.AqS152S0200000_8.invoke$178(kotlin.jvm.internal.AqS152S0200000_8, java.lang.Object):java.lang.Object
ERROR -   Method: kotlin.jvm.internal.AqS55S1100000_1.invoke$36(kotlin.jvm.internal.AqS55S1100000_1, java.lang.Object):java.lang.Object
ERROR -   Method: kotlin.jvm.internal.AqS9S2200000_1.invoke$6(kotlin.jvm.internal.AqS9S2200000_1, java.lang.Object):java.lang.Object
ERROR - finished with errors, count: 158

If this confirms the issue is jadx, I will try raising an issue there.