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

Expand use_aapt2 cli arg for which aapt version we use for badge dumping #703

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion objection/commands/mobile_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def patch_android_apk(source: str, architecture: str, pause: bool, skip_cleanup:

click.secho('Patcher will be using Gadget version: {0}'.format(github_version), fg='green')

patcher = AndroidPatcher(skip_cleanup=skip_cleanup, skip_resources=skip_resources, manifest=manifest, only_main_classes=only_main_classes)
patcher = AndroidPatcher(skip_cleanup=skip_cleanup, skip_resources=skip_resources, manifest=manifest, only_main_classes=only_main_classes, use_aapt2=use_aapt2)

# ensure that we have all of the commandline requirements
if not patcher.are_requirements_met():
Expand Down
2 changes: 1 addition & 1 deletion objection/console/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def patchipa(source: str, gadget_version: str, codesign_signature: str, provisio
help='Skip signing the apk file.', show_default=False)
@click.option('--target-class', '-t', help='The target class to patch.', default=None)
@click.option('--use-aapt2', '-2', is_flag=True, default=False,
help='Use the aapt2 binary instead of aapt as part of the apktool processing.', show_default=False)
help='Use the aapt2 binary instead of aapt as part of the apktool processing and for badge dumping.', show_default=False)
@click.option('--gadget-config', '-c', default=None, help=(
'The gadget configuration file to use. '
'Refer to https://frida.re/docs/gadget/ for more information.'), show_default=False)
Expand Down
14 changes: 9 additions & 5 deletions objection/utils/patchers/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ class AndroidPatcher(BasePlatformPatcher):
}
}

def __init__(self, skip_cleanup: bool = False, skip_resources: bool = False, manifest: str = None, only_main_classes: bool = False):
def __init__(self, skip_cleanup: bool = False, skip_resources: bool = False, manifest: str = None, only_main_classes: bool = False, use_aapt2: bool = False):
if use_aapt2:
self.required_commands['aapt2'] = {'installation': 'apt install aapt2 (Kali Linux)'}
super(AndroidPatcher, self).__init__()

self.apk_source = None
Expand All @@ -210,6 +212,7 @@ def __init__(self, skip_cleanup: bool = False, skip_resources: bool = False, man
self.skip_cleanup = skip_cleanup
self.skip_resources = skip_resources
self.manifest = manifest
self.use_aapt2 = use_aapt2

self.keystore = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../assets', 'objection.jks')
self.netsec_config = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../assets',
Expand Down Expand Up @@ -304,15 +307,16 @@ def _get_appt_output(self):
"""

if not self.aapt:
o = delegator.run(self.list2cmdline([
self.required_commands['aapt']['location'],
cmd = self.list2cmdline([
self.required_commands['aapt2' if self.use_aapt2 else 'aapt']['location'],
'dump',
'badging',
self.apk_source
]), timeout=self.command_run_timeout)
])
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(f'An error may have occurred while running aapt cmd: {cmd}.', fg='red')
click.secho(o.err, fg='red')

self.aapt = o.out
Expand Down