mirror of
https://github.com/httptoolkit/frida-interception-and-unpinning.git
synced 2026-10-11 10:22:12 +02:00
Try setting up an emulator in CI
This commit is contained in:
@@ -46,4 +46,64 @@ jobs:
|
||||
asset_name: android-frida-interception-script-${{ github.ref }}.js
|
||||
file: ./build/android-frida-interception-script.js
|
||||
tag: ${{ github.ref }}
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
test-android:
|
||||
name: Test on Android emulator
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
api-level: [30]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Install Frida CLI
|
||||
run: |
|
||||
pip install --user frida-tools
|
||||
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||
|
||||
# Apparently significantly improves emulator performance:
|
||||
- name: Enable KVM
|
||||
run: |
|
||||
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
|
||||
sudo udevadm control --reload-rules
|
||||
sudo udevadm trigger --name-match=kvm
|
||||
|
||||
# Cache the emulator AVD:
|
||||
- name: AVD cache
|
||||
uses: actions/cache@v4
|
||||
id: avd-cache
|
||||
with:
|
||||
path: |
|
||||
~/.android/avd/*
|
||||
~/.android/adb*
|
||||
key: avd-${{ matrix.api-level }}
|
||||
|
||||
- name: Create AVD and cache snapshot
|
||||
if: steps.avd-cache.outputs.cache-hit != 'true'
|
||||
uses: reactivecircus/android-emulator-runner@v2
|
||||
with:
|
||||
api-level: ${{ matrix.api-level }}
|
||||
target: google_apis
|
||||
force-avd-creation: false
|
||||
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||
script: |
|
||||
echo "Generated AVD snapshot for caching."
|
||||
|
||||
- name: Run tests
|
||||
uses: reactivecircus/android-emulator-runner@v2
|
||||
with:
|
||||
api-level: ${{ matrix.api-level }}
|
||||
target: google_apis
|
||||
force-avd-creation: false
|
||||
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||
script: |
|
||||
adb devices
|
||||
bash test/android/setup-emulator.sh
|
||||
echo "Emulator ready to test"
|
||||
adb shell pgrep -f frida-server
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Assumes: Android emulator/device is available via ADB and Frida CLI is installed on computer
|
||||
# Wait for device, install APK, and set up Frida server (all idempotent)
|
||||
|
||||
# Wait for emulator/device to be available
|
||||
adb wait-for-device
|
||||
adb shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
|
||||
echo "Emulator/device booted."
|
||||
|
||||
# Download and install APK if not already installed
|
||||
APK_PATH="/tmp/pinning-demo.apk"
|
||||
APK_URL="https://github.com/httptoolkit/android-ssl-pinning-demo/releases/download/v1.4.1/pinning-demo.apk"
|
||||
PACKAGE="tech.httptoolkit.pinning_demo"
|
||||
if ! adb shell pm list packages | grep -q "$PACKAGE"; then
|
||||
wget -q $APK_URL -O $APK_PATH
|
||||
adb install -r $APK_PATH
|
||||
echo "APK installed."
|
||||
else
|
||||
echo "APK already installed."
|
||||
fi
|
||||
|
||||
# Set up Frida server
|
||||
FRIDA_VERSION=$(frida --version)
|
||||
FRIDA_SERVER_URL="https://github.com/frida/frida/releases/download/${FRIDA_VERSION}/frida-server-${FRIDA_VERSION}-android-x86.xz"
|
||||
FRIDA_SERVER_LOCAL="/tmp/frida-server"
|
||||
FRIDA_SERVER_REMOTE="/data/local/tmp/frida-server"
|
||||
|
||||
if ! adb shell pgrep -f frida-server > /dev/null; then
|
||||
if [ ! -f $FRIDA_SERVER_LOCAL ]; then
|
||||
wget -q $FRIDA_SERVER_URL -O /tmp/frida-server.xz
|
||||
unxz -f /tmp/frida-server.xz
|
||||
chmod +x $FRIDA_SERVER_LOCAL
|
||||
fi
|
||||
adb root || true
|
||||
sleep 1
|
||||
adb push $FRIDA_SERVER_LOCAL $FRIDA_SERVER_REMOTE
|
||||
echo 'Pushed'
|
||||
adb shell "chmod 755 $FRIDA_SERVER_REMOTE"
|
||||
echo 'chmoded'
|
||||
adb shell "ls -l $FRIDA_SERVER_REMOTE"
|
||||
adb shell "$FRIDA_SERVER_REMOTE" &
|
||||
echo "Frida server started on device."
|
||||
else
|
||||
echo "Frida server already running."
|
||||
fi
|
||||
Reference in New Issue
Block a user