Skip to main content

Control Which Frida-Server Version the Device Uses

At any point, you can downgrade or upgrade the version of Frida being used by rooted or jailbroken devices. This is useful if you require a specific Frida version for your testing.

Run a Custom frida-server on Android

  1. Download the latest frida-server binary for the arm64 architecture. This can be built from source or you can download a precompiled package from the release tags on Frida's GitHub. Specifically, you're looking for frida-server-{RELEASE-NUMBER}-android-arm64.xz.

    wget https://github.com/frida/frida/releases/download/x.y.z/frida-server-x.y.z-android-arm64.xz
  2. Decompress the file.

    xz -d frida-server-x.y.z-android-arm64.xz
  3. Connect to the device using the adb connect command provided in the UI.

    adb connect {Services IP}:5001
  4. Become super user.

    adb root
  5. Push the frida-server file to the virtual device.

    note

    You can also drop frida-server into this path directly from the files tab if seeing slow adb uploads.

    adb push frida-server-x.y.z-android-arm64 /data/local/tmp
  6. Make the file executable.

    adb shell chmod +x /data/local/tmp/frida-server-x.y.z-android-arm64
  7. Before starting the frida-server you've pushed to the device, stop or remove the built-in frida-server to avoid conflicts.

    To stop:

    adb shell stop fridaserver

    To remove, you can find the path with:

    adb shell which frida-server

    Then remount the root filesystem as read-write:

    adb shell mount -o remount,rw /

    Then remove:

    adb shell rm /vendor/bin/frida-server
  8. Start your uploaded frida-server.

    adb shell /data/local/tmp/frida-server-x.y.z-android-arm64 

    Optionally, specify the interface frida-server listens on, additionally adding a & to tell frida-server to run in the background. Frida-server listens on 127.0.0.1:27042 by default.

    For simplicity, we'll make frida-server listen on all interfaces:

    adb shell /data/local/tmp/frida-server-x.y.z-android-arm64 -l 0.0.0.0 &

    Confirm frida-server is running:

    netstat -tuln | grep 27042
  9. With frida-server listening on all interfaces (0.0.0.0) and you have an Android device connected via adb, you can start spawning and attaching to apps.

    Webview spawn and attach example:

    % frida -U -f org.chromium.webview_shell
    ____
    / _ | Frida 16.6.6 - A world-class dynamic instrumentation toolkit
    | (_| |
    > _ | Commands:
    /_/ |_| help -> Displays the help system
    . . . . object? -> Display information about 'object'
    . . . . exit/quit -> Exit
    . . . .
    . . . . More info at https://frida.re/docs/home/
    . . . .
    . . . . Connected to Corellium Generic (id=10.11.1.81:5001)
    Spawned `org.chromium.webview_shell`. Resuming main thread!
    [Corellium Generic::org.chromium.webview_shell ]->

If you have more than one device connected to the host machine over adb, then the scripts and different commands may have issues identifying which device to talk to. When connecting to a device over TCP/IP, the "serial number" becomes the IP address and port. This means you can identify the devices using the Services IP for both adb and frida commands like below:

adb -s 10.30.71.1:5001 shell /data/local/tmp/frida-server -l {Host IP}

Script to Change the frida-server version on Android

Recommended way to use script:

  1. Copy the script contents, then create a .sh file on your local workstation and paste the script contents into it.

  2. Use the device's files tab to drop the script somewhere on the device's filesystem.

  3. In the device terminal, run su to become root user.

  4. Run the bash script on the device, passing in the the frida-server version you want to run as a command line argument.

Example:

./change_frida_version.sh 16.5.6

#!/bin/bash
# Pass in frida-server version as command line argument
FRIDA_VERSION=$1
# Remount root filesystem to read write
mount -o remount,rw /
# Pull frida-server package
if wget -O frida-server.xz \
"https://github.com/frida/frida/releases/download/${FRIDA_VERSION}/frida-server-${FRIDA_VERSION}-android-arm64.xz"; then
busybox xz -d frida-server.xz
else
echo "[+] Failed to download frida-server."
exit 1
fi
# Kill any existing frida-server process
pkill -9 frida-server >/dev/null 2>&1 || true
# Start frida-server on all interfaces
mv frida-server /data/local/tmp/ && chmod 755 /data/local/tmp/frida-server && nohup /data/local/tmp/frida-server -l 0.0.0.0 >/dev/null 2>&1 &
echo "[+] Started frida-server version $FRIDA_VERSION listening on all interfaces (0.0.0.0)."

Replace the Built-In Frida Server on iOS

Complete the following steps to replace the frida-server binary for iOS.

  1. Create the file and paste in the script below (recommended to first ssh into the device before attempting to edit the file).

    vim frida_update.sh
  2. Make the script executable for your user.

    chmod u+x frida_update.sh
  3. Run the script from the root directory of your iOS device and pass in the version of frida-server you would like to run.

    cd ~
    ./frida_update 16.0.5
  4. You can verify the frida-server was updated.

    frida-server --version

You can now begin interacting with the device's frida-server.

Script to Replace the Version of frida-server on your iOS Device

#!/bin/bash
FRIDA_VER=$1
# contains plist
cd /Library/LaunchDaemons/
# move plist to root
mv re.frida.server.plist ~
cd ~
# unload service
launchctl unload re.frida.server.plist
# stash plist
mv re.frida.server.plist /Library/LaunchDaemons
mv /Library/LaunchDaemons/re.frida.server.plist /Library/LaunchDaemons/re.frida.server.backup
# fetch FRIDA
wget -O /tmp/frida_${FRIDA_VER}_iphoneos-arm.deb https://github.com/frida/frida/releases/download/${FRIDA_VER}/frida_${FRIDA_VER}_iphoneos-arm.deb
# update server, agent and plist
dpkg -i /tmp/frida_${FRIDA_VER}_iphoneos-arm.deb
# restore plist
mv /Library/LaunchDaemons/re.frida.server.backup /Library/LaunchDaemons/re.frida.server.plist
# launch service using new plist
launchctl load /Library/LaunchDaemons/re.frida.server.plist
# delete package
rm /tmp/frida_${FRIDA_VER}_iphoneos-arm.deb