sensepost / objection

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

APK with android:extractNativeLibs=false breaks after patching #351

Closed dvalter closed 4 years ago

dvalter commented 4 years ago

Describe the bug Android apps with android:extractNativeLibs=false won't work after patching

To Reproduce Steps to reproduce the behavior:

  1. Set extractNativeLibs to false in the manifest
  2. Patch that apk
  3. Try to install that apk

Expected behavior App will be installed

Evidence / Logs / Screenshots In logcat: E NativeLibraryHelper: Library 'libfrida-gadget.so' is compressed - will not be able to open it directly from apk. In adb install output:

> adb install app.objection.apk 
Performing Streamed Install
adb: failed to install app.objection.apk: Failure [INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2]

Environment (please complete the following information):

Possible fix Remove extractNativeLibs flag from the manifest during patching

leonjza commented 4 years ago

Could you try using apktool to manually decode the patched APK objection produces -> modify the manifest as suggested -> repackaging again with apktool and checking if it works? This should be a relatively simple check to add to the patcher though.

StingraySA commented 4 years ago

@dvalter I've tried to replicate your error, but with my app it succeeds, and runs on an AVD.

<?xml version="1.0" encoding="utf-8" standalone="no"?>

Can you possibly send us a copy of your full error message and maybe your manifest file to help us in replicating the error you are seeing?

dvalter commented 4 years ago

@leonjza it's exactly what I tried and it worked for me. @StingraySA I managed to replicate the same behavior on a basic template from Android Studio. There're my apk's. app-debug.apk.gz app-debug.objection.apk.gz

leonjza commented 4 years ago

PR #353 just landed, which will fix this in the next release! 🎉

dvalter commented 4 years ago

Thank you for a great tool and a quick response to this issue. I tested the APK I originally had this problem with, and now code from master patches it correctly.

harshitshah4 commented 2 years ago

@leonjza I know this ticket is closed, but is there a way to include libfrida-gadget.so file without compression in the first place ? Modifying AndroidManifest.xml is time consuming. Probably editing apktool.yml works ?