Skip to content

Commit 5898fe5

Browse files
committed
WIP: Try setting up an emulator in CI
1 parent 4c20195 commit 5898fe5

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,30 @@ jobs:
4646
asset_name: android-frida-interception-script-${{ github.ref }}.js
4747
file: ./build/android-frida-interception-script.js
4848
tag: ${{ github.ref }}
49-
repo_token: ${{ secrets.GITHUB_TOKEN }}
49+
repo_token: ${{ secrets.GITHUB_TOKEN }}
50+
51+
test-android:
52+
steps:
53+
- uses: actions/checkout@v4
54+
- name: Set up Python
55+
uses: actions/setup-python@v5
56+
with:
57+
python-version: '3.11'
58+
- name: Set up Android SDK and Emulator
59+
uses: reactivecircus/android-emulator-runner@v2
60+
with:
61+
api-level: 30
62+
target: google_apis
63+
arch: x86_64
64+
profile: pixel_3a
65+
emulator-options: -no-window -no-audio -no-boot-anim
66+
disable-animations: true
67+
script: |
68+
adb devices
69+
echo "Emulator started."
70+
- name: Install Frida CLI
71+
run: |
72+
pip install --user frida-tools
73+
echo "$HOME/.local/bin" >> $GITHUB_PATH
74+
- name: Prepare emulator
75+
run: bash test/setup-emulator.sh

test/setup-emulator.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Assumes: Android emulator/device is available via ADB and Frida CLI is installed on computer
5+
# Wait for device, install APK, and set up Frida server (all idempotent)
6+
7+
# Wait for emulator/device to be available
8+
adb wait-for-device
9+
adb shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
10+
echo "Emulator/device booted."
11+
12+
# Download and install APK if not already installed
13+
APK_PATH="/tmp/pinning-demo.apk"
14+
APK_URL="https://github.com/httptoolkit/android-ssl-pinning-demo/releases/download/v1.4.1/pinning-demo.apk"
15+
PACKAGE="app.htp.demo"
16+
if ! adb shell pm list packages | grep -q "$PACKAGE"; then
17+
wget -q $APK_URL -O $APK_PATH
18+
adb install -r $APK_PATH
19+
echo "APK installed."
20+
else
21+
echo "APK already installed."
22+
fi
23+
24+
# Set up Frida server
25+
FRIDA_VERSION=$(frida --version)
26+
FRIDA_SERVER_URL="https://github.com/frida/frida/releases/download/${FRIDA_VERSION}/frida-server-${FRIDA_VERSION}-android-x86_64.xz"
27+
FRIDA_SERVER_LOCAL="/tmp/frida-server"
28+
FRIDA_SERVER_REMOTE="/data/local/tmp/frida-server"
29+
30+
if ! adb shell pgrep -f frida-server > /dev/null; then
31+
if [ ! -f $FRIDA_SERVER_LOCAL ]; then
32+
wget -q $FRIDA_SERVER_URL -O /tmp/frida-server.xz
33+
unxz -f /tmp/frida-server.xz
34+
chmod +x $FRIDA_SERVER_LOCAL
35+
fi
36+
adb root || true
37+
adb remount || true
38+
adb push $FRIDA_SERVER_LOCAL $FRIDA_SERVER_REMOTE
39+
adb shell "chmod 755 $FRIDA_SERVER_REMOTE"
40+
adb shell "$FRIDA_SERVER_REMOTE &"
41+
echo "Frida server started on device."
42+
else
43+
echo "Frida server already running."
44+
fi

0 commit comments

Comments
 (0)