SlideShare a Scribd company logo
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
OSS TOOLS: CREATING A
REVERSE ENGINEERING
PLUGIN FOR R2FRIDA
Merging the power of static & dynamic analysis
© Copyright 2018 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
ALL THINGS MOBILE DEVSECOPS
Subscribe Here
https://www.nowsecure.com/go/subscribe/
Semi-monthly Newsletter
Delivered 1st & 3rd Wednesdays of the month
Resources for the Mobile DevSecOps journey
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
ASK A QUESTION ANY TIME
Use the “Ask a Question” tab below the slides
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
NOWSECURE COMPANY INNOVATION TIMELINE
NowSecure Sponsorship
of OSS FRIDA & RADARE
(2015)
Launch NowSecure INTEL
for Production AppStore
Monitoring (2018)
Launch NowSecure Workstation
Complete Analyst Mobile
AppSec Testing Kit (2015)
ViaForensics
Founded (2009)
Launch Mobile Forensic
Analysis Services (2010)
Launch Mobile App Pen
Testing Services (2012)
NowSecure Series A
& Company Rename
(2014)
Launch NowSecure AUTO for
Shift Left CI/CD-integrated
Mobile AppSec Testing (2017)
Publish Books “Android Forensics”
& “iOS Forensics” (2011)
NOWSECURE MISSION: Saving the World from Unsafe Mobile Apps
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
On a scale of 1 to 5, rate your level of knowledge of mobile app security.
1. beginner
2. novice
3. intermediate
4. advanced
5. expert
POLL #1
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
AGENDA
INTRODUCTION
WHAT IS R2 & FRIDA?
WHAT’S NEW IN R2 & FRIDA?
WHAT IS R2FRIDA?
EXTENDING R2FRIDA WITH PLUGINS
Q&A
MODERATOR
BRIAN REED
CMO, NOWSECURE
SERGI ALVAREZ I CAPILLA
AUTHOR OF RADARE2
SPEAKER
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
WHO AM I?
▪ My name is Sergi Àlvarez i Capilla
▪ But most people know me as pancake
▪ Author of radare2, r2frida, applesign,
fsmon, valabind, acr, 0xFFFF, and many,
many other open source tools out there.
▪ Senior Mobile Security Research Engineer
▪ Working at NowSecure
▪ Spend my time building new tools and find
new ways to improve our products that make
safer Mobile apps.
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
On a scale of 1 to 5, rate your level of experience with r2.
1. beginner
2. novice
3. intermediate
4. advanced
5. expert
POLL #2
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
WHAT’S R2?
▪ 13yo OpenSource RE framework (tools + apis)
▪ It started as a simple hexadecimal editor for forensics.
▪ Quickly evolved, adding support for analysis,
disassembling, debugging, emulation, ...
▪ Cover many topics related to computer security:
▪ Exploiting, fuzzing, cracking, SRE, forensics..
▪ It’s written in C: small, fast and portable
▪ Easy to script with an expressive commandline shell
▪ Can be extended with plugins written in native or
dynamic languages
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
On a scale of 1 to 5, rate your level of experience with Frida.
1. beginner
2. novice
3. intermediate
4. advanced
5. expert
POLL #3
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
WHAT’S FRIDA?
Dynamic instrumentation toolkit written by my colleague Ole André
▪ Written in C with bindings for JavaScript and Python
▪ It’s the best introspection tooling for iOS and Android
▪ Injects an egg with a JS interpreter into the target process.
▪ At this point you can instrument the entire process with js
▪ Provides APIs to read/write memory, list symbols, add traces, ..
▪ Modify the behaviour or trace protocols, APIs, behaviours, ..
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
WHAT’S NEW IN R2 AND FRIDA?
There are ~500 commits/month in r2,
▪ So it’s hard to describe all the
improvements and new features in
a single slide.
Both projects have a solid userbase
and the main development focus is on
improving the core, cleanup/ refactor,
and improve usability.
▪ Frida
▪ Crashlog retrieval for iOS/Android
▪ Shorter APIs and more OO
▪ New Kernel APIs for tfp0
▪ ChromeDev tools
▪ Radare2
▪ Better graphs + navigation
▪ Improved Code and type analysis
▪ Performance improvements
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
WHAT’S R2FRIDA?
IO plugin for radare2 that uses Frida as backend.
Extends the scripting and static analysis capabilities of r2 with all the dynamic
analysis, code injection and tracing facilities of Frida.
▪ Works seamlessly on iOS, Android, macOS, Linux and Windows.
▪ Read/Write remote process memory from r2
▪ Type short commands instead of writing code
▪ Also can access remote filesystems
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
R2FRIDA OVERVIEW
▪ Radare2 runs in host
▪ r2frida is an r2 plugin that links
against the Frida SDK
▪ Spawn/attach local/remote
processes.
▪ Extend agent commands with plugins
▪ Frida-Server runs in the device
▪ Provides Interface to talk to inspect
processes and attach from host.
▪ End to end r2pipe
▪ r2frida commands mimic r2 ones
▪ Handle sync and async
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
WHAT’S NEW IN R2FRIDA v3.4
▪ New URI handler schema
▪ frida://usb/deviceid/spawn/appname
▪ Improved trace-logs support
▪ Trace logs are now cached and accessible via dtl
▪ All traces generate a JSON message sent to host for later postprocessing
▪ Trace-logs have counters, timestamp, module name, symbol name, address, ...
▪ Binary information listed depends on the current seek
▪ Added command to get the entrypoint of the program
▪ Fuzzy resolution of objc methods by using the objc: prefix
▪ Support remote FileSystems on all unix targets
▪ Retrieve crashlog message from device (ios + android only)
▪ Improved support for Android tracing and return injection
▪ Faster addr2name and name2addr resolutions
▪ Safer pointer/data auto-identification with isObjC and such
▪ Resolve thread and file descriptor names
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
SIMPLE R2FRIDA EXAMPLE DEMO
Attach to a running while hello world program and change the program behaviour at runtime
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
EXTENDING R2FRIDA WITH PLUGINS
R2 can interpret scripts in several languages, interact with r2 via r2pipe.
▪ Use r2pipe to script anything in r2frida from Rust, Python, Ruby, NodeJS, Java, ...
Run Frida oneliners (or run a js file in the agent) from the r2 shell
▪ Useful for small stuff, but kind of annoying for large code snippets
The R2Frida plugin API can extend the r2frida commands
▪ Load/Unload and List those plugins
▪ Loaded in the agent side and fully compatible with Frida scripts
▪ Allows to run r2 commands from the agent side
▪ r2frida global object to access trace logs or register new commands
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
HELLO WORLD PLUGIN EXAMPLE
Basic plugin example looks like this:
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
What else can be interesting for the analyst to have in r2frida?
▪ UI interaction commands
▪ Cookie tracing and curlification of http traffic
▪ Use your own custom trace hooks
▪ Integration with Frida CodeShare
▪ Web interface on top of the internal r2’s http webserver
▪ Expose a fake filesystem to the process
▪ Bypass anti-debugging or authentication protections
▪ OS-specific features
BEYOND THE HELLO WORLD
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
CREATING THE PLUGIN
Open your favourite editor and create this hookurl.js
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
RUNNING THE PLUGIN
The ‘urls’ command will show all the URLs captured from the NSURL traces
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
EXTRACTING URLS FROM LOGS
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
By typing:
▪ dtf objc:NSURL.^URLWithString:$ ooo
We get noisy messages with the trace information
▪ e hook.verbose=false
We can list the trace
▪ dtlj~{}
And finally get the QR codes with the plugin:
▪ .hookurl qrs
TRACING NSURL INTO QR CODES
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
BACKTRACE GRAPHS
hookurls btgraph
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
REMOTE FILESYSTEM ACCESS DEMO
▪ IO plugins can expose commands to support mounting remote
filesystems and accessible via the ‘m’ command
▪ ‘mo’ command will open a remote file in memory for local analysis
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
WEBUI AND R2PIPE
With r2frida, it is also possible to use any r2pipe script or the Web browser
with your custom interface to automate Frida and r2 at the same time.
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
FINAL WORDS
▪ Radare2 and Frida are powerful open source tools
▪ They provide many ways to extend them and integrate with other tools
▪ R2frida is also open-source and combines the power of both
▪ Bring the state of the art in Reverse Engineering Mobile to the analyst
▪ https://rada.re
▪ https://github.com/nowsecure/r2frida
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
bit.ly/Connect-2019
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
MONDAY - DAY 1
Mobile Security Analysts Toolbox
In depth OSS Training Sessions
▪ Frida
▪ Radare
▪ r2Frida
▪ Capstone
▪ Ret2dec
▪ ZigBee
▪ And more…
Monday Night Party
NOWSECURE CONNECT19 OSS TRACK
TUESDAY - DAY 2
Mobile OSS tools hackathon
▪ Multiple tools and tracks
New OSS Tool Launch Sessions
▪ Multiple new OSS tools
Tool Creator’s Panel
Contest Awards
bit.ly/Connect-2019
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
NOWSECURE COMING ATTRACTIONS
NowSecure Connect 2019
Jun 3-4, 2019 | Washington D.C.
Black Hat USA (Training + Conference)
Aug 3-8, 2019 | Las Vegas, NV
r2con
Sep 4-7, 2019 | Barcelona, Spain
Webinar: Integrating Security into the
Mobile App DevOps Ecosystem
May 22, 2019
© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.
OPEN Q&A
Use the “Ask a Question” tab below the slides
BRIAN REED
CMO
PANCAKE
Radare2 Author

More Related Content

PDF
Debunking the Top 5 Myths About Mobile AppSec
NowSecure
 
PDF
Building a Mobile App Pen Testing Blueprint
NowSecure
 
PDF
CASE STUDY - Ironclad Messaging & Secure App Dev for Regulated Industries
NowSecure
 
PDF
Android P Security Updates: What You Need to Know
NowSecure
 
PDF
A Risk-Based Mobile App Security Testing Strategy
NowSecure
 
PDF
iOS recon with Radare2
NowSecure
 
PDF
Top OSS for Mobile AppSec Testing: The Latest on R2 and FRIDA
NowSecure
 
PDF
Android Q & iOS 13 Privacy Enhancements
NowSecure
 
Debunking the Top 5 Myths About Mobile AppSec
NowSecure
 
Building a Mobile App Pen Testing Blueprint
NowSecure
 
CASE STUDY - Ironclad Messaging & Secure App Dev for Regulated Industries
NowSecure
 
Android P Security Updates: What You Need to Know
NowSecure
 
A Risk-Based Mobile App Security Testing Strategy
NowSecure
 
iOS recon with Radare2
NowSecure
 
Top OSS for Mobile AppSec Testing: The Latest on R2 and FRIDA
NowSecure
 
Android Q & iOS 13 Privacy Enhancements
NowSecure
 

What's hot (20)

PDF
Mobile App Security Predictions 2019
NowSecure
 
PDF
From Tangled Mess to Organized Flow: A Mobile DevSecOps Reference Architecture
NowSecure
 
PDF
5 Tips for Agile Mobile App Security Testing
NowSecure
 
PDF
85% of App Store Apps Fail OWASP Mobile Top 10: Are you exposed?
NowSecure
 
PDF
Mobile Penetration Testing: Episode III - Attack of the Code
NowSecure
 
PDF
How Android and iOS Security Enhancements Complicate Threat Detection
NowSecure
 
PDF
Mobile Penetration Testing: Episode 1 - The Forensic Menace
NowSecure
 
PDF
5 Mobile App Security MUST-DOs in 2018
NowSecure
 
PPTX
Backstage Tour of Identity - London Identity Summit
ForgeRock
 
PDF
The fundamentals of Android and iOS app security
NowSecure
 
PPTX
I mas appsecusa-nov13-v2
drewz lin
 
PDF
Mobile Defense-in-Dev (Depth)
Prathan Phongthiproek
 
PDF
Identity Relationship Management - The Right Approach for a Complex Digital W...
ForgeRock
 
PDF
Cyber Kill Chain: Web Application Exploitation
Prathan Phongthiproek
 
PDF
OWASP Mobile Top 10
NowSecure
 
PDF
iOS and Android security: Differences you need to know
NowSecure
 
PDF
OWASP Mobile Security: Top 10 Risks for 2017
TecsyntSolutions
 
PDF
OWASP Mobile Top 10 Deep-Dive
Prathan Phongthiproek
 
PDF
Mobile App Hacking In A Nutshell
Prathan Phongthiproek
 
PDF
Mobile Hacking
Novizul Evendi
 
Mobile App Security Predictions 2019
NowSecure
 
From Tangled Mess to Organized Flow: A Mobile DevSecOps Reference Architecture
NowSecure
 
5 Tips for Agile Mobile App Security Testing
NowSecure
 
85% of App Store Apps Fail OWASP Mobile Top 10: Are you exposed?
NowSecure
 
Mobile Penetration Testing: Episode III - Attack of the Code
NowSecure
 
How Android and iOS Security Enhancements Complicate Threat Detection
NowSecure
 
Mobile Penetration Testing: Episode 1 - The Forensic Menace
NowSecure
 
5 Mobile App Security MUST-DOs in 2018
NowSecure
 
Backstage Tour of Identity - London Identity Summit
ForgeRock
 
The fundamentals of Android and iOS app security
NowSecure
 
I mas appsecusa-nov13-v2
drewz lin
 
Mobile Defense-in-Dev (Depth)
Prathan Phongthiproek
 
Identity Relationship Management - The Right Approach for a Complex Digital W...
ForgeRock
 
Cyber Kill Chain: Web Application Exploitation
Prathan Phongthiproek
 
OWASP Mobile Top 10
NowSecure
 
iOS and Android security: Differences you need to know
NowSecure
 
OWASP Mobile Security: Top 10 Risks for 2017
TecsyntSolutions
 
OWASP Mobile Top 10 Deep-Dive
Prathan Phongthiproek
 
Mobile App Hacking In A Nutshell
Prathan Phongthiproek
 
Mobile Hacking
Novizul Evendi
 
Ad

Similar to OSS Tools: Creating a Reverse Engineering Plug-in for r2frida (20)

PDF
MOBILE PENTESTING Frida.pdf
Adityamd4
 
PDF
Introduction to Frida
AbhishekJaiswal270
 
PDF
Webinar–Mobile Application Hardening Protecting Business Critical Apps
Synopsys Software Integrity Group
 
PPTX
Bypass Security Checking with Frida
Satria Ady Pradana
 
PDF
The Hookshot: Runtime Exploitation
Prathan Phongthiproek
 
PPTX
Pentesting Android Apps using Frida (Beginners)
Chandrapal Badshah
 
PDF
FRIDA 101 Android
Tony Thomas
 
PDF
DBI-Assisted Android Application Reverse Engineering
Sahil Dhar
 
PDF
Sergi Álvarez + Roi Martín - radare2: From forensics to bindiffing [RootedCON...
RootedCON
 
PDF
Radare2 @ ndh2k15 : First r2babies steps
Maijin
 
PDF
Radare2 - An Introduction by Anto Joseph
Anthony Jose
 
PPTX
Bypass Security Checking with Frida
Satria Ady Pradana
 
PDF
Android application security testing
Mykhailo Antonishyn
 
PDF
Breaking Secure Mobile Applications - Hack In The Box 2014 KL
iphonepentest
 
PDF
Pentester++
CTruncer
 
PPTX
Frida - Objection Tool Usage
n|u - The Open Security Community
 
PDF
Unit 4 Reverse Engineering Tools Functionalities & Use-Cases.pdf
ChatanBawankar
 
PPTX
Mobile App Penetration Testing Bsides312
wphillips114
 
PDF
Frida Android run time hooking - Bhargav Gajera & Vitthal Shinde
NSConclave
 
PPTX
28c3 in 15
antitree
 
MOBILE PENTESTING Frida.pdf
Adityamd4
 
Introduction to Frida
AbhishekJaiswal270
 
Webinar–Mobile Application Hardening Protecting Business Critical Apps
Synopsys Software Integrity Group
 
Bypass Security Checking with Frida
Satria Ady Pradana
 
The Hookshot: Runtime Exploitation
Prathan Phongthiproek
 
Pentesting Android Apps using Frida (Beginners)
Chandrapal Badshah
 
FRIDA 101 Android
Tony Thomas
 
DBI-Assisted Android Application Reverse Engineering
Sahil Dhar
 
Sergi Álvarez + Roi Martín - radare2: From forensics to bindiffing [RootedCON...
RootedCON
 
Radare2 @ ndh2k15 : First r2babies steps
Maijin
 
Radare2 - An Introduction by Anto Joseph
Anthony Jose
 
Bypass Security Checking with Frida
Satria Ady Pradana
 
Android application security testing
Mykhailo Antonishyn
 
Breaking Secure Mobile Applications - Hack In The Box 2014 KL
iphonepentest
 
Pentester++
CTruncer
 
Frida - Objection Tool Usage
n|u - The Open Security Community
 
Unit 4 Reverse Engineering Tools Functionalities & Use-Cases.pdf
ChatanBawankar
 
Mobile App Penetration Testing Bsides312
wphillips114
 
Frida Android run time hooking - Bhargav Gajera & Vitthal Shinde
NSConclave
 
28c3 in 15
antitree
 
Ad

More from NowSecure (13)

PDF
Jeff's Journey: Best Practices for Securing Mobile App DevOps
NowSecure
 
PDF
iOS 12 Preview - What You Need To Know
NowSecure
 
PDF
Mobile Apps & Connected Healthcare: Managing 3rd-Party Mobile App Risk
NowSecure
 
PDF
What attackers know about your mobile apps that you don’t: Banking & FinTech
NowSecure
 
PDF
Solving for Compliance: Mobile app security for banking and financial services
NowSecure
 
PDF
Leaky Mobile Apps: What You Need to Know
NowSecure
 
PDF
Vetting Mobile Apps for Corporate Use: Security Essentials
NowSecure
 
PDF
Cutting out the middleman: Man-in-the-middle attacks and prevention for mobil...
NowSecure
 
PDF
Delivering secure mobile financial services (MFS) - "Frictionless" vs diligence
NowSecure
 
PDF
Next-level mobile app security: A programmatic approach
NowSecure
 
PDF
Mobile App Crashworthiness - Securing Vehicle-to-Device (V2D) Interfaces and ...
NowSecure
 
PDF
Cybersecurity Fundamentals for Bar Associations
NowSecure
 
PDF
Mobile Penetration Testing: Episode II - Attack of the Code
NowSecure
 
Jeff's Journey: Best Practices for Securing Mobile App DevOps
NowSecure
 
iOS 12 Preview - What You Need To Know
NowSecure
 
Mobile Apps & Connected Healthcare: Managing 3rd-Party Mobile App Risk
NowSecure
 
What attackers know about your mobile apps that you don’t: Banking & FinTech
NowSecure
 
Solving for Compliance: Mobile app security for banking and financial services
NowSecure
 
Leaky Mobile Apps: What You Need to Know
NowSecure
 
Vetting Mobile Apps for Corporate Use: Security Essentials
NowSecure
 
Cutting out the middleman: Man-in-the-middle attacks and prevention for mobil...
NowSecure
 
Delivering secure mobile financial services (MFS) - "Frictionless" vs diligence
NowSecure
 
Next-level mobile app security: A programmatic approach
NowSecure
 
Mobile App Crashworthiness - Securing Vehicle-to-Device (V2D) Interfaces and ...
NowSecure
 
Cybersecurity Fundamentals for Bar Associations
NowSecure
 
Mobile Penetration Testing: Episode II - Attack of the Code
NowSecure
 

OSS Tools: Creating a Reverse Engineering Plug-in for r2frida

  • 1. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute.© Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. OSS TOOLS: CREATING A REVERSE ENGINEERING PLUGIN FOR R2FRIDA Merging the power of static & dynamic analysis
  • 2. © Copyright 2018 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. ALL THINGS MOBILE DEVSECOPS Subscribe Here https://www.nowsecure.com/go/subscribe/ Semi-monthly Newsletter Delivered 1st & 3rd Wednesdays of the month Resources for the Mobile DevSecOps journey
  • 3. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. ASK A QUESTION ANY TIME Use the “Ask a Question” tab below the slides
  • 4. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. NOWSECURE COMPANY INNOVATION TIMELINE NowSecure Sponsorship of OSS FRIDA & RADARE (2015) Launch NowSecure INTEL for Production AppStore Monitoring (2018) Launch NowSecure Workstation Complete Analyst Mobile AppSec Testing Kit (2015) ViaForensics Founded (2009) Launch Mobile Forensic Analysis Services (2010) Launch Mobile App Pen Testing Services (2012) NowSecure Series A & Company Rename (2014) Launch NowSecure AUTO for Shift Left CI/CD-integrated Mobile AppSec Testing (2017) Publish Books “Android Forensics” & “iOS Forensics” (2011) NOWSECURE MISSION: Saving the World from Unsafe Mobile Apps
  • 5. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. On a scale of 1 to 5, rate your level of knowledge of mobile app security. 1. beginner 2. novice 3. intermediate 4. advanced 5. expert POLL #1
  • 6. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. AGENDA INTRODUCTION WHAT IS R2 & FRIDA? WHAT’S NEW IN R2 & FRIDA? WHAT IS R2FRIDA? EXTENDING R2FRIDA WITH PLUGINS Q&A MODERATOR BRIAN REED CMO, NOWSECURE SERGI ALVAREZ I CAPILLA AUTHOR OF RADARE2 SPEAKER
  • 7. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. WHO AM I? ▪ My name is Sergi Àlvarez i Capilla ▪ But most people know me as pancake ▪ Author of radare2, r2frida, applesign, fsmon, valabind, acr, 0xFFFF, and many, many other open source tools out there. ▪ Senior Mobile Security Research Engineer ▪ Working at NowSecure ▪ Spend my time building new tools and find new ways to improve our products that make safer Mobile apps.
  • 8. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. On a scale of 1 to 5, rate your level of experience with r2. 1. beginner 2. novice 3. intermediate 4. advanced 5. expert POLL #2
  • 9. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. WHAT’S R2? ▪ 13yo OpenSource RE framework (tools + apis) ▪ It started as a simple hexadecimal editor for forensics. ▪ Quickly evolved, adding support for analysis, disassembling, debugging, emulation, ... ▪ Cover many topics related to computer security: ▪ Exploiting, fuzzing, cracking, SRE, forensics.. ▪ It’s written in C: small, fast and portable ▪ Easy to script with an expressive commandline shell ▪ Can be extended with plugins written in native or dynamic languages
  • 10. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. On a scale of 1 to 5, rate your level of experience with Frida. 1. beginner 2. novice 3. intermediate 4. advanced 5. expert POLL #3
  • 11. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. WHAT’S FRIDA? Dynamic instrumentation toolkit written by my colleague Ole André ▪ Written in C with bindings for JavaScript and Python ▪ It’s the best introspection tooling for iOS and Android ▪ Injects an egg with a JS interpreter into the target process. ▪ At this point you can instrument the entire process with js ▪ Provides APIs to read/write memory, list symbols, add traces, .. ▪ Modify the behaviour or trace protocols, APIs, behaviours, ..
  • 12. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. WHAT’S NEW IN R2 AND FRIDA? There are ~500 commits/month in r2, ▪ So it’s hard to describe all the improvements and new features in a single slide. Both projects have a solid userbase and the main development focus is on improving the core, cleanup/ refactor, and improve usability. ▪ Frida ▪ Crashlog retrieval for iOS/Android ▪ Shorter APIs and more OO ▪ New Kernel APIs for tfp0 ▪ ChromeDev tools ▪ Radare2 ▪ Better graphs + navigation ▪ Improved Code and type analysis ▪ Performance improvements
  • 13. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. WHAT’S R2FRIDA? IO plugin for radare2 that uses Frida as backend. Extends the scripting and static analysis capabilities of r2 with all the dynamic analysis, code injection and tracing facilities of Frida. ▪ Works seamlessly on iOS, Android, macOS, Linux and Windows. ▪ Read/Write remote process memory from r2 ▪ Type short commands instead of writing code ▪ Also can access remote filesystems
  • 14. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. R2FRIDA OVERVIEW ▪ Radare2 runs in host ▪ r2frida is an r2 plugin that links against the Frida SDK ▪ Spawn/attach local/remote processes. ▪ Extend agent commands with plugins ▪ Frida-Server runs in the device ▪ Provides Interface to talk to inspect processes and attach from host. ▪ End to end r2pipe ▪ r2frida commands mimic r2 ones ▪ Handle sync and async
  • 15. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. WHAT’S NEW IN R2FRIDA v3.4 ▪ New URI handler schema ▪ frida://usb/deviceid/spawn/appname ▪ Improved trace-logs support ▪ Trace logs are now cached and accessible via dtl ▪ All traces generate a JSON message sent to host for later postprocessing ▪ Trace-logs have counters, timestamp, module name, symbol name, address, ... ▪ Binary information listed depends on the current seek ▪ Added command to get the entrypoint of the program ▪ Fuzzy resolution of objc methods by using the objc: prefix ▪ Support remote FileSystems on all unix targets ▪ Retrieve crashlog message from device (ios + android only) ▪ Improved support for Android tracing and return injection ▪ Faster addr2name and name2addr resolutions ▪ Safer pointer/data auto-identification with isObjC and such ▪ Resolve thread and file descriptor names
  • 16. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. SIMPLE R2FRIDA EXAMPLE DEMO Attach to a running while hello world program and change the program behaviour at runtime
  • 17. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. EXTENDING R2FRIDA WITH PLUGINS R2 can interpret scripts in several languages, interact with r2 via r2pipe. ▪ Use r2pipe to script anything in r2frida from Rust, Python, Ruby, NodeJS, Java, ... Run Frida oneliners (or run a js file in the agent) from the r2 shell ▪ Useful for small stuff, but kind of annoying for large code snippets The R2Frida plugin API can extend the r2frida commands ▪ Load/Unload and List those plugins ▪ Loaded in the agent side and fully compatible with Frida scripts ▪ Allows to run r2 commands from the agent side ▪ r2frida global object to access trace logs or register new commands
  • 18. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. HELLO WORLD PLUGIN EXAMPLE Basic plugin example looks like this:
  • 19. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. What else can be interesting for the analyst to have in r2frida? ▪ UI interaction commands ▪ Cookie tracing and curlification of http traffic ▪ Use your own custom trace hooks ▪ Integration with Frida CodeShare ▪ Web interface on top of the internal r2’s http webserver ▪ Expose a fake filesystem to the process ▪ Bypass anti-debugging or authentication protections ▪ OS-specific features BEYOND THE HELLO WORLD
  • 20. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. CREATING THE PLUGIN Open your favourite editor and create this hookurl.js
  • 21. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. RUNNING THE PLUGIN The ‘urls’ command will show all the URLs captured from the NSURL traces
  • 22. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. EXTRACTING URLS FROM LOGS
  • 23. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. By typing: ▪ dtf objc:NSURL.^URLWithString:$ ooo We get noisy messages with the trace information ▪ e hook.verbose=false We can list the trace ▪ dtlj~{} And finally get the QR codes with the plugin: ▪ .hookurl qrs TRACING NSURL INTO QR CODES
  • 24. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. BACKTRACE GRAPHS hookurls btgraph
  • 25. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. REMOTE FILESYSTEM ACCESS DEMO ▪ IO plugins can expose commands to support mounting remote filesystems and accessible via the ‘m’ command ▪ ‘mo’ command will open a remote file in memory for local analysis
  • 26. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. WEBUI AND R2PIPE With r2frida, it is also possible to use any r2pipe script or the Web browser with your custom interface to automate Frida and r2 at the same time.
  • 27. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. FINAL WORDS ▪ Radare2 and Frida are powerful open source tools ▪ They provide many ways to extend them and integrate with other tools ▪ R2frida is also open-source and combines the power of both ▪ Bring the state of the art in Reverse Engineering Mobile to the analyst ▪ https://rada.re ▪ https://github.com/nowsecure/r2frida
  • 28. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. bit.ly/Connect-2019
  • 29. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. MONDAY - DAY 1 Mobile Security Analysts Toolbox In depth OSS Training Sessions ▪ Frida ▪ Radare ▪ r2Frida ▪ Capstone ▪ Ret2dec ▪ ZigBee ▪ And more… Monday Night Party NOWSECURE CONNECT19 OSS TRACK TUESDAY - DAY 2 Mobile OSS tools hackathon ▪ Multiple tools and tracks New OSS Tool Launch Sessions ▪ Multiple new OSS tools Tool Creator’s Panel Contest Awards bit.ly/Connect-2019
  • 30. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. NOWSECURE COMING ATTRACTIONS NowSecure Connect 2019 Jun 3-4, 2019 | Washington D.C. Black Hat USA (Training + Conference) Aug 3-8, 2019 | Las Vegas, NV r2con Sep 4-7, 2019 | Barcelona, Spain Webinar: Integrating Security into the Mobile App DevOps Ecosystem May 22, 2019
  • 31. © Copyright 2019 NowSecure, Inc. All Rights Reserved. Proprietary information. Do not distribute. OPEN Q&A Use the “Ask a Question” tab below the slides BRIAN REED CMO PANCAKE Radare2 Author