diff --git a/objection/utils/patchers/android.py b/objection/utils/patchers/android.py index a843a9d3..e368484d 100644 --- a/objection/utils/patchers/android.py +++ b/objection/utils/patchers/android.py @@ -10,6 +10,7 @@ import delegator import requests import semver +import subprocess from .base import BasePlatformGadget, BasePlatformPatcher, objection_path from .github import Github @@ -304,18 +305,40 @@ def _get_appt_output(self): """ if not self.aapt: - o = delegator.run(self.list2cmdline([ - self.required_commands['aapt']['location'], - 'dump', - 'badging', - self.apk_source - ]), timeout=self.command_run_timeout) - - if len(o.err) > 0: - click.secho('An error may have occurred while running aapt.', fg='red') - click.secho(o.err, fg='red') - - self.aapt = o.out + cmd = self.list2cmdline([ + self.required_commands['aapt']['location'], + 'dump', + 'badging', + self.apk_source + ]) + + try: + o = delegator.run(cmd, timeout=self.command_run_timeout) + + if len(o.err) > 0: + click.secho('An error may have occurred while running aapt.', fg='red') + click.secho(o.err, fg='red') + + self.aapt = o.out + + except ValueError: + result = subprocess.run( + cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + timeout=self.command_run_timeout, + shell=True, + encoding='utf-8' + ) + + self.aapt = result.stdout + error_output = result.stderr + + if result.returncode != 0: + click.secho('An error may have occurred while running aapt.', fg='red') + click.secho(error_output, fg='red') + + return self.aapt