A Comprehensive Guide to r2Frida

Reading time: Reading time 3 minutes

In iOS app security, the ability to seamlessly blend static and dynamic analysis capabilities is paramount. One tool that stands out in this domain is r2frida. This unique tool combines the robust binary analysis functionalities of Radare2 with the dynamic instrumentation features of Frida, creating a potent toolkit for dissecting iOS applications and fortifying their security posture.

Table of Content

What is r2Frida?

r2frida acts as a bridge between two renowned tools: Radare2 and Frida

Radare2 is a leading open-source framework for reverse engineering. It offers a comprehensive toolchain with well-maintained functionalities and extensibility through other programming languages and tools. 

On the other hand, Frida is a dynamic instrumentation toolkit that simplifies the inspection and manipulation of running processes by injecting custom JavaScript code.

As a self-contained plugin for Radare2, r2frida is designed to be user-friendly. It leverages the strengths of both tools to enable the instrumentation of remote processes. This integration facilitates seamless static and dynamic analysis, significantly enhancing the efficiency and depth of iOS app security research. By combining Radare2's static analysis prowess with Frida's real-time dynamic capabilities, security researchers can easily perform more effective and thorough examinations and manipulations of iOS applications.

Features of r2frida

r2frida boasts an extensive array of powerful features catering to both Android and iOS platforms:

Attach radare2 to processes

Seamlessly connect to any local or remote process via USB or TCP for comprehensive analysis. This feature is handy for in-depth inspections and application debugging, allowing researchers to gain insights into a process's internal workings.

Memory management

Effortlessly read and write memory from the target process to uncover vulnerabilities. This capability is crucial for easily identifying security flaws such as buffer overflows, memory corruption, and unauthorized data access.

Integration with Frida

Leverage Frida's maps, symbols, imports, classes, and methods within Radare2 for enhanced analysis. This integration allows researchers to access and manipulate applications' internal structures, providing a deeper understanding of their behavior and potential security weaknesses.

Script execution

To customize analysis, execute unmodified Frida scripts and snippets in C, JavaScript, or TypeScript to customize analysis. This feature offers flexibility and control, enabling researchers to tailor their analysis to specific needs and scenarios.

Dynamic analysis

Enhance analysis by replacing method implementations, creating hooks, and loading libraries and frameworks in the target process. Dynamic analysis is essential for monitoring and modifying applications' runtime behavior, helping researchers identify and mitigate security threats in real-time.

To delve deeper into r2frida's capabilities and discover more features, visit the r2frida repository.


r2Frida installation

Installing r2frida is a breeze, especially when you use r2pm, the Radare2 package manager. Just execute the following command, and you're good to go:

r2pm -ci r2frida

For further guidance and alternative installation methods, refer to the r2frida repository.


r2Frida examples

Here are some practical examples of how to use r2frida in various scenarios:

Attaching to a process

You can attach, spawn, or launch any program by name or PID (Process ID):

r2 frida://attach/usb//12345        # attach to given pid in the first usb device
r2 frida://spawn/usb//appname       # spawn an app in the first resolved usb device
r2 frida://launch/usb//appname      # spawn+resume an app in the first usb device

Inspecting loaded libraries

To see the loaded libraries, use the command  il . You can filter the results with Radare2's internal grep using the command  ~ . For example, to find loaded libraries with the keywords "SSL" and "crypto," use the following command:

[0x10489fafc]> :il~crypto,ssl
0x00000001a5954000 0x00000001a59cc000 libcorecrypto.dylib
0x000000019a1d1000 0x000000019a28e000 libboringssl.dylib

Searching memory for specific keywords

To search in memory for a specific keyword, you may use the search command  :/ String: 

[0x10489fafc]> :/ Jail
Searching 4 bytes: 4a 61 69 6cSearching 4 bytes in
[0x0000000104750000-0x0000000104b80000]hits: 12
0x104aecda0 hit3_0 Jailbreak Detection
0x104aece88 hit3_1 JailbreakDetectionViewController.swift
0x104aecebe hit3_2 Jailbroken
0x104aeceda hit3_3 Jailbroken, Exiting !
0x104aecf0a hit3_4 Jailbroken, the application will now exit
0x104aecf9e hit3_5 JailbreakDetectionViewController
0x104aeebb0 hit3_6 JailbreakDetection
0x104aef93a hit3_7 Jailbroken
0x104b1f634 hit3_8 Jailbroken
0x104b47e9b hit3_9 Jailbroken
0x104b53396 hit3_10 JailbreakDetection
0x104b67f00 hit3_11 JailbreakDetectionViewController


Outputting results in JSON format

To output the results in JSON format, use the command  :/j String: 

[0x10489fafc]> :/j Jail
Searching 4 bytes: 4a 61 69 6cSearching 4 bytes in
[0x0000000104750000-0x0000000104b80000]hits: 12
[{"address":"0x104aecda0","size":4,"flag":"hit4_0","content":"Jailbreak Detection"}, {"address":"0x104aece88","size":4,"flag":"hit4_1","content":"JailbreakDetectionViewController.swift"},{"address":"0x104aecebe","size":4,"flag":"hit4_2","content":"Jailbroken"},{"address":"0x104aeceda","size":4,"flag":"hit4_3","content":"Jailbroken, Exiting !"},{"address":"0x104aecf0a","size":4,"flag":"hit4_4","content":"Jailbroken, the application will now exit"},{"address":"0x104aecf9e","size":4,"flag":"hit4_5","content":"JailbreakDetectionViewController"},{"address":"0x104aeebb0","size":4,"flag":"hit4_6","content":"JailbreakDetection"},{"address":"0x104aef93a","size":4,"flag":"hit4_7","content":"Jailbroken"},{"address":"0x104b1f634","size":4,"flag":"hit4_8","content":"Jailbroken"},{"address":"0x104b47e9b","size":4,"flag":"hit4_9","content":"Jailbroken"},{"address":"0x104b53396","size":4,"flag":"hit4_10","content":"JailbreakDetection"},{"address":"0x104b67f00","size":4,"flag":"hit4_11","content":"JailbreakDetectionViewController"}]


Running Frida JavaScript code

You can also run Frida JavaScript code using the following  : .  followed by the name of the script:

[0x1041a3afc]> :. script.js

For more examples, you can visit the r2frida wiki.


In a nutshell, r2frida is an indispensable tool for security researchers honing in on iOS applications.

By bridging the gap between Radare2's static analysis and dynamic instrumentation, r2frida offers a comprehensive solution for in-depth security analysis. Its extensive array of powerful features, ease of installation, and comprehensive capabilities make it a valuable addition to any security researcher's toolkit. Whether aiming to uncover vulnerabilities, analyze memory, or manipulate running processes, r2frida equips you with the tools to bolster your iOS app security posture.

Ready to take your iOS security analysis to the next level? Explore r2frida today and enhance your iOS app security posture with this indispensable tool.


Published on Jun 11, 2024
Vinay Kumar Rasala
Written by Vinay Kumar Rasala
Vinay Kumar Rasala serves as a security research associate at Appknox, a leading security suite for automating mobile security in enterprises. He specializes in ethical hacking and penetration testing and has actively collaborated with numerous enterprises, strengthening their APIs and mobile and web apps against cyber threats.
Vinay is passionate about exploring new technologies, mainly iOS tweaks, reverse engineering, and programming. In his free time, he enjoys playing open-world games and experimenting with cooking.


Chat With Us

Using Other Product?

Switch to Appknox

2 Weeks Free Trial!

Get Started Now