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

Added supporting apk patches via docker #636

Closed
wants to merge 9 commits into from
Closed
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
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Use first container to download all necessary packages/deps and copy only the required binaries into a new container
FROM ubuntu:jammy AS builder
WORKDIR /app

# Install necessary tools and clean up in the same layer
RUN apt-get update && apt-get install --no-install-recommends wget unzip openjdk-17-jre -y && \
wget https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip && \
unzip commandlinetools-linux-10406996_latest.zip && \
rm commandlinetools-linux-10406996_latest.zip && \
mkdir -p android_sdk/cmdline-tools/latest && \
mv cmdline-tools/* android_sdk/cmdline-tools/latest/ && \
yes | android_sdk/cmdline-tools/latest/bin/sdkmanager "platform-tools" "build-tools;27.0.3" --channel=0 && \
wget https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.8.1.jar -O ./apktool.jar && \
wget https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool -O ./apktool && \
rm -rf /var/lib/apt/lists/* && \
apt-get autoremove -y

FROM ubuntu:jammy
WORKDIR /app

# Install necessary tools and clean up in the same layer
RUN apt-get update && apt-get install --no-install-recommends openjdk-17-jre python3-pip -y && \
pip install --no-cache-dir --upgrade objection && \
rm -rf /var/lib/apt/lists/* && \
apt-get autoremove -y && \
mkdir android_sdk

# Copy necessary files from builder stage
COPY --from=builder /app/android_sdk/build-tools/27.0.3/aapt2 /app/android_sdk
COPY --from=builder /app/android_sdk/build-tools/27.0.3/aapt /app/android_sdk
COPY --from=builder /app/android_sdk/build-tools/27.0.3/lib /app/android_sdk/lib
COPY --from=builder /app/android_sdk/build-tools/27.0.3/lib64 /app/android_sdk/lib64
COPY --from=builder /app/android_sdk/build-tools/27.0.3/apksigner /app/android_sdk
COPY --from=builder /app/android_sdk/build-tools/27.0.3/zipalign /app/android_sdk
COPY --from=builder /app/android_sdk/platform-tools/adb /app/android_sdk
COPY --from=builder /app/apktool /usr/local/bin/apktool
COPY --from=builder /app/apktool.jar /usr/local/bin/apktool.jar
RUN chmod +x /usr/local/bin/apktool*

ENV PATH=$PATH:/app/android_sdk

ENTRYPOINT ["/bin/sh", "-c"]
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ clean:
$(RM) $(DIST_DIR)/*

frida-agent:
cd agent && npm run build
cd agent && yarn install && yarn build

sdist:
python setup.py sdist
python3 setup.py sdist

testupload:
twine upload dist/* -r testpypi
Expand All @@ -19,3 +19,6 @@ upload:

test:
python -m unittest

build-docker:
docker build --platform linux/amd64 --tag objection:latest .
2 changes: 1 addition & 1 deletion objection/commands/mobile_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def patch_ios_ipa(source: str, codesign_signature: str, provision_file: str, bin
def patch_android_apk(source: str, architecture: str, pause: bool, skip_cleanup: bool = True,
enable_debug: bool = True, gadget_version: str = None, skip_resources: bool = False,
network_security_config: bool = False, target_class: str = None,
use_aapt2: bool = False, gadget_config: str = None, script_source: str = None,
use_aapt2: bool = True, gadget_config: str = None, script_source: str = None,
ignore_nativelibs: bool = True, manifest: str = None, skip_signing: bool = False) -> None:
"""
Patches an Android APK by extracting, patching SMALI, repackaging
Expand Down
2 changes: 1 addition & 1 deletion objection/console/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def patchipa(source: str, gadget_version: str, codesign_signature: str, provisio
@click.option('--skip-signing', '-C', is_flag=True, default=False,
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,
@click.option('--use-aapt2', '-2', is_flag=True, default=True,
help='Use the aapt2 binary instead of aapt as part of the apktool processing.', show_default=False)
@click.option('--gadget-config', '-c', default=None, help=(
'The gadget configuration file to use. '
Expand Down
Loading
Loading