Setting Up FRIDA on Windows and Android

The tutorial consists of the following parts:

1. FRIDA Introduction.

2. Setting up Frida on Windows

  • Necessary Requirements for setting up.
  • Configuring adb and Python.
  • Verifying Installation/configuration.

3. Setting up Frida on Android

  • Necessary Requirements for setting up.
  • Downloading frida-server
  • Configuring your device for frida-server
  • Setting up frida-server
  • Executing frida-server

What is FRIDA?

FRIDA is a dynamic instrumentation toolkit for developers, reverse-engineers, and security researchers.

Features:

Scriptable
Inject your own scripts into black box processes. Hook any function, spy on crypto APIs or trace private application code, no source code needed. Edit, hit save, and instantly see the results. All without compilation steps or program restarts.

Portable
Works on Windows, macOS, GNU/Linux, iOS, Android, and QNX. Install the Node.js bindings from npm, grab a Python package from PyPI, or use Frida through its Swift bindings, .NET bindings, Qt/Qml bindings, or C API.

Free
Frida is and will always be free software (free as in freedom). We want to empower the next generation of developer tools, and help other free software developers achieve interoperability through reverse engineering.

Battle-tested
Frida are proud that NowSecure is using Frida to do fast, deep analysis of mobile apps at scale. Frida has a comprehensive test-suite and has gone through years of rigorous testing across a broad range of use-cases.

Setting Up FRIDA on Windows

1. Necessary Requirements for setting up:

  • adb (Android-Debug Bridge) - Get it here.
  • Python (Latest version recommended) - Get it here.

2. Configuring adb and Python:
Adb:
adb comes pre-installed so you dont have really have to go through the installation process. You can extract the folder present in the archive to wherever you desire and just open a command prompt in that particular folder to access adb functionalities but it is recommended to add the adb executeable to system environment variables thus sparing you the hassle to redirect to adb’s folder everytime you intend to use it. I will show the process later on.

Python:
Python link mentioned above has many Python variants, so make sure you download the compatible variant. During installation, it is necessary to remember where Python is being installed, as you will need that later when assigning environment variables. Although there is an option to add Python to environment variables automatically during installation, but I prefer to do it manually. You can let Python add itself to environment variables automatically if you wish.

Assigning Environment Variables:
Now that you have successfully set-up adb and Python, its time to add both of them to system environment variables.

But why add adb and Python Environment Variables Path?

Without the PATH variable, we would need to run programs using absolute paths. The PATH variable prevents us from having to write out the entire path to a program on the CLI every time we run it. Essentially, it’s just a variable that stores a bunch of shortcuts.

When you enter a command on the CLI without using the absolute path, the operating system checks the PATH variable. It reads through values assigned to the PATH variable from left to right — Unix separates values with : Windows with ; — until it finds the value that contains the path to your program. If it does not find the path, well then… “All you need to do is add it to your PATH variable.”

Example:

Executing adb WITHOUT Environment variables:

Executing adb WITH Environment variables:

Adding to System Variables’ Path:

To add Python and adb, follow the steps described below:

After you have reached the “Edit Environment Variable” Window, follow these steps:

  • Click on “New” and add the folder to where you have put adb.[/SIZE]
  • Repeat the same step again and add the Python directory.
  • Next, add another folder named “Scripts” inside your Python directory. This is to add “pip.exe” to system environment variables. PIP is used to install frida hence the reason why we also add it to environment variables path .

3. Verifying Installation/configuration:

After you are done following above steps, enter these commands in cmd to verify that all above steps have been executed successfully.

adb --version //For verifying adb
Python --version //For verifying Python
pip --version //For verifying pip

If all goes well, the above screen should be your result. If you face any errors, read the steps again.

4. Installing FRIDA:
To install frida, enter the following command in your command prompt:

pip install frida

After frida has been installed, enter this command in your command prompt:

pip install frida-tools

After both of them have been installed, you can verify that both of the above dependencies have been successfully installed, in order to do that, simply enter the two commands again. If both are properly installed, your terminal will look something like this:

This concludes installation and setting up of Frida on Windows.

Setting up FRIDA on Android (Rooted Phones or Rooted Emulators)

1. Necessary Requirements for setting up:

  • Proper configuration of Frida in Windows.[/LEFT]
  • Frida-Server - Get it here.

2. Downloading Frida-Server:

  • Download frida-server depending on your device architecture from the link provided above. There are alot of files, so make sure you download the one that says “frida-server” alongside the architecture type in its name.
  • To find out your device’s architecture, simply download CPU-Z from playstore and check your device’s architecture from the app. Here’s an example:

  • Depending on my CPU arch type, I download the variant named “frida-server-12.9.7-android-x86.xz”. Files update frequently, so the versions may not be the same as shown above.

3. Configuring your device for FRIDA:

  • In order to access android, it is necessary to add the frida-server to android and run it from there. But first, we will configure our device so that no error occurs during the process of moving frida-server to our device.
  • First, connect your device to computer. Make sure you have USB-Debugging enabled in the developer option of your device.
  • Confirm that adb is communication properly with your device with the following command:
adb devices
  • If your device is properly connected, your terminal will look like this:

Note: Sometimes emulators such as NOX or MEMU fail to connect to adb automatically, in order to connect them manually, enter the following commands:

adb connect 127.0.0.1:62001  //Tested on Nox 6.6.0.5
adb connect 127.0.0.1:21503  //Tested on Memu 7.1.6

After you have successfully connected adb to your device, its time to access adb shell and remount your device to allow read-write processes from adb. To do so enter the followng commands.

adb shell //Entering device's shell
su // Switching to super user
mount -o rw,remount rootfs /   //Remounting with read-write access

4. Setting Up Frida-Server:

Now that you have downloaded the server and configured your device, its time to push the “frida-server” into your android device. To do so, follow these steps:

Extract the server you have just downloaded using winrar in any folder you wish.

Goto the directory where you extracted the server, open cmd there and enter the following command:

adb push name_of_android_server_file directory_where_you_would_like_to_push_the_file_to_in_your_device

If all goes without errors, your terminal will look like this:

5. Executing FRIDA-Server:

Now that the server is successfully pushed into your device, its time to execute the server. To do so, enter the following commands:

adb shell  //Entering device's shell
cd Directory_where_you_pushed_the_server  //Accessing the folder where the server is
chmod 0777 name_of_the_server_file  //Granting read-write permissions to the file

./name_of_the_server_file //executing the server

If all goes well, your terminal will look like this:

To verify that the server is indeed working as intended, execute this command:

frida-ps -U //Showing processes of your device (attached via USB or emulator)
  • If you see alot of processes, it means that frida is working properly. If not, read the steps again.

This concludes the tutorial. FRIDA is now ready to use on your device!

3 Likes

plz post a frida tutorial too

What in particular are you looking for in frida?