sensepost / objection

📱 objection - runtime mobile exploration
GNU General Public License v3.0
7.46k stars 854 forks source link

Unable to find smali to patch Error #332

Closed declan554 closed 4 years ago

declan554 commented 4 years ago

I am trying to patch a apk that has been packed with DexProtector to run Dynamic analysis on the apk. I am getting the bellow error run I run the command. I am able to decompile it using Apktool manually.

C:\Users\3053584\AppData\Local\Android\Sdk\platform-tools>objection patchapk -D --source app-release.apk No architecture specified. Determining it using adb... Detected target device architecture as: armeabi-v7a Using latest Github gadget version: 12.8.14 Patcher will be using Gadget version: 12.8.14 Unpacking app-release.apk App already has android.permission.INTERNET Target class not specified, searching for launchable activity instead... Smali not found in smali directory. This might be a multidex APK. Searching... Traceback (most recent call last): File "c:\users\3053584\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "c:\users\3053584\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\3053584\AppData\Local\Programs\Python\Python37-32\Scripts\objection.exe__main.py", line 9, in File "c:\users\3053584\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 764, in call__ return self.main(args, kwargs) File "c:\users\3053584\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 717, in main rv = self.invoke(ctx) File "c:\users\3053584\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "c:\users\3053584\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 956, in invoke return ctx.invoke(self.callback, ctx.params) File "c:\users\3053584\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 555, in invoke return callback(args, kwargs) File "c:\users\3053584\appdata\local\programs\python\python37-32\lib\site-packages\objection\console\cli.py", line 352, in patchapk patch_android_apk(locals()) File "c:\users\3053584\appdata\local\programs\python\python37-32\lib\site-packages\objection\commands\mobile_packages.py", line 175, in patch_android_apk patcher.inject_load_library(target_class=target_class) File "c:\users\3053584\appdata\local\programs\python\python37-32\lib\site-packages\objection\utils\patchers\android.py", line 713, in inject_load_library target_class if target_class else self._get_launchable_activity()) File "c:\users\3053584\appdata\local\programs\python\python37-32\lib\site-packages\objection\utils\patchers\android.py", line 538, in _determine_smali_path_for_class raise Exception('Unable to find smali to patch!') Exception: Unable to find smali to patch! Cleaning up temp files... Failed to cleanup with error: [WinError 2] The system cannot find the file specified: 'C:\Users\3053584\AppData\Local\Temp\tmpml6h38zu.apktemp.objection.apk'

leonjza commented 4 years ago

Exception: Unable to find smali to patch!

This is the important part of the error. objection tries to automatically determine a suitable place to patch the target APK so that the Frida gadget can be loaded, usually in the class for the launchable activity. That logic is here. There are many reasons why it could fail, but in most cases you can just specify a different class to target and it should launch ok. The patchapk sub command takes the --target-class flag (ref), where you can specify a fully qualified class to use instead of the launchable activity parsed from the apps manifest.

kqvanity commented 1 year ago

@leonjza

but in most cases you can just specify a different class to target and it should launch ok.

How am I supposed to find out which class to load?

leonjza commented 1 year ago

How am I supposed to find out which class to load?

You can use a decompiler to look for classes.

kqvanity commented 1 year ago

You can use a decompiler to look for classes.

What class am I looking for exactly, if the Android manifest's main Activity isn't the one?