SlideShare a Scribd company logo
Frida
Runtime Debugging
By: Bhargav Gajera,
Vitthal Shinde
Installation
Android:
Download Link: https://github.com/frida/frida/releases
Push it in Android Path : “/data/local/tmp/”
System:
Command: pip install frida-tools
Refer : https://pypi.org/project/frida/
Installation
Easy Way:
Command: frida-push
● pip install frida-push
● It will identify your device’s architecture from adb
● Download the appropriate server
● Install it
● Run it
Start using Frida
Android ADB:
Command: /data/local/tmp/frida-server &
Base System:
Command: frida -U -f “<PackageName>” --no-pause
Start using Frida
Want to attach Quickly on whatever is running on screen ?
Base System:
Command: frida -U -F
Codeshare
What is it ?
Ans: Repo for universal method hooks & bypass
URL: https://codeshare.frida.re/browse
How do I use it ?
Command: frida -U -f “<PackageName>” --codeshare <URI> --no-pause
Docs
All the documentation is listed under:
● URL: https://frida.re/docs/home/
Javascript API docs are available under:
● URL: https://frida.re/docs/javascript-api/
Frida and Scripts
1. Interactive way
➢ Write scripts inside terminal.
2. Attach scripts
➢ Write scripts in file and pass it as argument.
3. Python
➢ Create python file to do the same
Frida Interactive
Command: frida -U -f “<PackageName>” --no-pause
➢ An interactive shell will spawn
➢ Write your code in shell
Frida with JS File
Command: frida -U -f “<PackageName>” -l “<JSFile>” --no-pause
➢ Write your javascript code in a file.
➢ Use “-l” option to provide file in argument.
➢ Code will execute side by side of the application execution.
Frida with Python File
Command: python <PythonFile>.py
➢ Import frida in python code.
➢ Use inbuilt frida functions to:
○ Get USB device
○ Spawn targeted application
○ Attach to it’s PID
○ Create script
○ Load the script
○ Resume the application execution
Setup Vulnerable Environment
● App : InsecureBankv2
○ Link: https://github.com/dineshshetty/Android-InsecureBankv2
● Server : Inside Directory “AndroLabServer”
○ Install pip requirements
○ # python app.py
Setup Vulnerable Environment
● Configure the application
○ Navigate to More -> Preferences
○ Give ip of your base system where app.py is running
● Login Credentials :
○ dinesh/Dinesh@123$
○ jack/Jack@123$
Find Loaded classes
Code :
Java.perform(function(){
Java.enumerateLoadedClasses({
"onMatch": function(className){
console.log(className)
},
"onComplete":function()
{}
})
});
Find Loaded classes
These many classes ? Really ??
Find Loaded classes with known names
Java.perform(function(){
Java.enumerateLoadedClasses({
onMatch:function(className)
{
if(className.toLowerCase().lastIndexOf("<Identifier>")>0)
{
console.log(className);
}
},
onComplete:function()
{}
});
});
Find Loaded classes with known names
Identify Classes being used
● How to Identify which class contains method when an event
is called ?
○ Enumerate classes before event.
○ Enumerate classes after event.
○ Find newly loaded classes
Hooking Functions
Java.perform(function(){
var varName = Java.use("<className>");
varName.funName.implementation=function()
{
console.log(“Function Called”)
}
})
Identify Functions being called
● How to Identify which method is being invoked ?
Newbie's way:
➢ Hook suspicious methods
and add console.log()
Identify Functions being called
If you are hooking all suspicious functions...
Identify Functions being called
● How to Identify which method is being invoked ?
Professional’s way:
➢ Hook all methods of a class and
○ Log whenever it is being called
○ Log all Arguments
○ Log Return value
Identify Functions being called
● Script be Like...
Hooking Overloaded Functions
Java.perform(function(){
var varName = Java.use("class path");
varName.funName.overload(<args_type>).implementation=function(args)
{
// Your implementation.
}
})
Implement custom function
Further we will see…
● Dive deep into creating custom logic.
● How can we overwrite original function.
● How to create variable of desired classes.
● How to use such variables and use it to get information from hooked
function.
● etc, etc, etc...
Using --no-pause
Command: frida -U -f <Package> --no-pause
● Will immediately spawn and start execution of the application
● Load the script side by side
● What if the function mentioned in script executes before scripts is loaded?
Without --no-pause
Command: frida -U -f <Package> -l <script>
● Will create a process of the application.
● Will hold the execution of first frame of the application
● We can load the script by pasting it now in the terminal.
● Use “ %resume ” to continue the execution.
Analyzing hooked function
Java.perform(function(){
var varName = Java.use("class path");
varName.funName.overload(<args_type>).implementation=function(args)
{
console.log(“Function called”);
console.log(“Arguments are : ”,args);
}}) ;
Show Time...
● DEMO...

More Related Content

PDF
Android application penetration testing
PDF
Mobile Application Penetration Testing
PDF
Pentesting like a grandmaster BSides London 2013
PPTX
Pentesting Android Apps
PDF
Pwning mobile apps without root or jailbreak
PDF
Introduction to Frida
PDF
Android Security & Penetration Testing
PPTX
Android pentesting
Android application penetration testing
Mobile Application Penetration Testing
Pentesting like a grandmaster BSides London 2013
Pentesting Android Apps
Pwning mobile apps without root or jailbreak
Introduction to Frida
Android Security & Penetration Testing
Android pentesting

What's hot (20)

PDF
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
PDF
Need Of Security Operations Over SIEM
PDF
Firmware Extraction & Fuzzing - Jatan Raval
PPTX
Spring Security 5
PPTX
Android Application Penetration Testing - Mohammed Adam
PDF
Hunting Lateral Movement in Windows Infrastructure
PPTX
Here Be Dragons: The Unexplored Land of Active Directory ACLs
PPTX
Pentesting ReST API
PDF
Spring framework aop
PDF
Threat Hunting Workshop
PDF
APIsecure 2023 - Android Applications and API Hacking, Gabrielle Botbol
PDF
Windows Threat Hunting
PPTX
Pentesting Android Applications
PDF
Exploiting Deserialization Vulnerabilities in Java
PDF
PHDays 2018 Threat Hunting Hands-On Lab
PPT
A Brief Introduction in SQL Injection
PDF
Penetration Testing AWS
ODP
OWASP Secure Coding
PPTX
iOS Application Static Analysis - Deepika Kumari.pptx
PDF
Android pentesting
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Need Of Security Operations Over SIEM
Firmware Extraction & Fuzzing - Jatan Raval
Spring Security 5
Android Application Penetration Testing - Mohammed Adam
Hunting Lateral Movement in Windows Infrastructure
Here Be Dragons: The Unexplored Land of Active Directory ACLs
Pentesting ReST API
Spring framework aop
Threat Hunting Workshop
APIsecure 2023 - Android Applications and API Hacking, Gabrielle Botbol
Windows Threat Hunting
Pentesting Android Applications
Exploiting Deserialization Vulnerabilities in Java
PHDays 2018 Threat Hunting Hands-On Lab
A Brief Introduction in SQL Injection
Penetration Testing AWS
OWASP Secure Coding
iOS Application Static Analysis - Deepika Kumari.pptx
Android pentesting
Ad

Similar to Frida Android run time hooking - Bhargav Gajera & Vitthal Shinde (20)

PDF
FRIDA 101 Android
PDF
Android Platform Debugging and Development
PDF
MOBILE PENTESTING Frida.pdf
PDF
PHP Development Tools
PDF
Deploying Symfony | symfony.cat
PDF
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
PDF
OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build You...
PDF
OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce
PPTX
Fastlane
PDF
Null Dubai Humla_Romansh_Yadav_Android_app_pentesting
PDF
Speed up your development environment PHP + Nginx + Fedora + PG
KEY
Movable Type 5.2 Overview at MTDDC 2012
KEY
Node.js basics
PDF
Pyramid Deployment and Maintenance
PDF
Grunt & Front-end Workflow
PDF
Containerized IDEs.pdf
PDF
EuroPython 2013 - Python3 TurboGears Training
PDF
Android Platform Debugging and Development
PDF
Helpful pre commit hooks for Python and Django
PDF
OpenStack Murano introduction
FRIDA 101 Android
Android Platform Debugging and Development
MOBILE PENTESTING Frida.pdf
PHP Development Tools
Deploying Symfony | symfony.cat
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build You...
OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce
Fastlane
Null Dubai Humla_Romansh_Yadav_Android_app_pentesting
Speed up your development environment PHP + Nginx + Fedora + PG
Movable Type 5.2 Overview at MTDDC 2012
Node.js basics
Pyramid Deployment and Maintenance
Grunt & Front-end Workflow
Containerized IDEs.pdf
EuroPython 2013 - Python3 TurboGears Training
Android Platform Debugging and Development
Helpful pre commit hooks for Python and Django
OpenStack Murano introduction
Ad

More from NSConclave (20)

PDF
RED-TEAM_Conclave
PPTX
Create a Custom Plugin in Burp Suite using the Extension
PPTX
IOT SECURITY ASSESSMENT Pentester's Approach
PPTX
Debugging Android Native Library
PPTX
Burp Suite Extension Development
PDF
Log Analysis
PDF
Regular Expression Injection
PDF
HTML5 Messaging (Post Message)
PDF
Node.js Deserialization
PDF
RIA Cross Domain Policy
PDF
LDAP Injection
PDF
Python Deserialization Attacks
PDF
Sandboxing
PDF
NoSql Injection
PDF
Thick Client Testing Advanced
PDF
Thick Client Testing Basics
PDF
Markdown
PDF
Docker 101
PDF
Security Architecture Consulting - Hiren Shah
PDF
OSINT: Open Source Intelligence - Rohan Braganza
RED-TEAM_Conclave
Create a Custom Plugin in Burp Suite using the Extension
IOT SECURITY ASSESSMENT Pentester's Approach
Debugging Android Native Library
Burp Suite Extension Development
Log Analysis
Regular Expression Injection
HTML5 Messaging (Post Message)
Node.js Deserialization
RIA Cross Domain Policy
LDAP Injection
Python Deserialization Attacks
Sandboxing
NoSql Injection
Thick Client Testing Advanced
Thick Client Testing Basics
Markdown
Docker 101
Security Architecture Consulting - Hiren Shah
OSINT: Open Source Intelligence - Rohan Braganza

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
MYSQL Presentation for SQL database connectivity
PDF
KodekX | Application Modernization Development
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Approach and Philosophy of On baking technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Cloud computing and distributed systems.
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Big Data Technologies - Introduction.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
The Rise and Fall of 3GPP – Time for a Sabbatical?
Review of recent advances in non-invasive hemoglobin estimation
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
The AUB Centre for AI in Media Proposal.docx
Network Security Unit 5.pdf for BCA BBA.
MYSQL Presentation for SQL database connectivity
KodekX | Application Modernization Development
“AI and Expert System Decision Support & Business Intelligence Systems”
Diabetes mellitus diagnosis method based random forest with bat algorithm
Approach and Philosophy of On baking technology
Building Integrated photovoltaic BIPV_UPV.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Cloud computing and distributed systems.
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Electronic commerce courselecture one. Pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Big Data Technologies - Introduction.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Unlocking AI with Model Context Protocol (MCP)

Frida Android run time hooking - Bhargav Gajera & Vitthal Shinde

  • 1. Frida Runtime Debugging By: Bhargav Gajera, Vitthal Shinde
  • 2. Installation Android: Download Link: https://github.com/frida/frida/releases Push it in Android Path : “/data/local/tmp/” System: Command: pip install frida-tools Refer : https://pypi.org/project/frida/
  • 3. Installation Easy Way: Command: frida-push ● pip install frida-push ● It will identify your device’s architecture from adb ● Download the appropriate server ● Install it ● Run it
  • 4. Start using Frida Android ADB: Command: /data/local/tmp/frida-server & Base System: Command: frida -U -f “<PackageName>” --no-pause
  • 5. Start using Frida Want to attach Quickly on whatever is running on screen ? Base System: Command: frida -U -F
  • 6. Codeshare What is it ? Ans: Repo for universal method hooks & bypass URL: https://codeshare.frida.re/browse How do I use it ? Command: frida -U -f “<PackageName>” --codeshare <URI> --no-pause
  • 7. Docs All the documentation is listed under: ● URL: https://frida.re/docs/home/ Javascript API docs are available under: ● URL: https://frida.re/docs/javascript-api/
  • 8. Frida and Scripts 1. Interactive way ➢ Write scripts inside terminal. 2. Attach scripts ➢ Write scripts in file and pass it as argument. 3. Python ➢ Create python file to do the same
  • 9. Frida Interactive Command: frida -U -f “<PackageName>” --no-pause ➢ An interactive shell will spawn ➢ Write your code in shell
  • 10. Frida with JS File Command: frida -U -f “<PackageName>” -l “<JSFile>” --no-pause ➢ Write your javascript code in a file. ➢ Use “-l” option to provide file in argument. ➢ Code will execute side by side of the application execution.
  • 11. Frida with Python File Command: python <PythonFile>.py ➢ Import frida in python code. ➢ Use inbuilt frida functions to: ○ Get USB device ○ Spawn targeted application ○ Attach to it’s PID ○ Create script ○ Load the script ○ Resume the application execution
  • 12. Setup Vulnerable Environment ● App : InsecureBankv2 ○ Link: https://github.com/dineshshetty/Android-InsecureBankv2 ● Server : Inside Directory “AndroLabServer” ○ Install pip requirements ○ # python app.py
  • 13. Setup Vulnerable Environment ● Configure the application ○ Navigate to More -> Preferences ○ Give ip of your base system where app.py is running ● Login Credentials : ○ dinesh/Dinesh@123$ ○ jack/Jack@123$
  • 14. Find Loaded classes Code : Java.perform(function(){ Java.enumerateLoadedClasses({ "onMatch": function(className){ console.log(className) }, "onComplete":function() {} }) });
  • 15. Find Loaded classes These many classes ? Really ??
  • 16. Find Loaded classes with known names Java.perform(function(){ Java.enumerateLoadedClasses({ onMatch:function(className) { if(className.toLowerCase().lastIndexOf("<Identifier>")>0) { console.log(className); } }, onComplete:function() {} }); });
  • 17. Find Loaded classes with known names
  • 18. Identify Classes being used ● How to Identify which class contains method when an event is called ? ○ Enumerate classes before event. ○ Enumerate classes after event. ○ Find newly loaded classes
  • 19. Hooking Functions Java.perform(function(){ var varName = Java.use("<className>"); varName.funName.implementation=function() { console.log(“Function Called”) } })
  • 20. Identify Functions being called ● How to Identify which method is being invoked ? Newbie's way: ➢ Hook suspicious methods and add console.log()
  • 21. Identify Functions being called If you are hooking all suspicious functions...
  • 22. Identify Functions being called ● How to Identify which method is being invoked ? Professional’s way: ➢ Hook all methods of a class and ○ Log whenever it is being called ○ Log all Arguments ○ Log Return value
  • 23. Identify Functions being called ● Script be Like...
  • 24. Hooking Overloaded Functions Java.perform(function(){ var varName = Java.use("class path"); varName.funName.overload(<args_type>).implementation=function(args) { // Your implementation. } })
  • 25. Implement custom function Further we will see… ● Dive deep into creating custom logic. ● How can we overwrite original function. ● How to create variable of desired classes. ● How to use such variables and use it to get information from hooked function. ● etc, etc, etc...
  • 26. Using --no-pause Command: frida -U -f <Package> --no-pause ● Will immediately spawn and start execution of the application ● Load the script side by side ● What if the function mentioned in script executes before scripts is loaded?
  • 27. Without --no-pause Command: frida -U -f <Package> -l <script> ● Will create a process of the application. ● Will hold the execution of first frame of the application ● We can load the script by pasting it now in the terminal. ● Use “ %resume ” to continue the execution.
  • 28. Analyzing hooked function Java.perform(function(){ var varName = Java.use("class path"); varName.funName.overload(<args_type>).implementation=function(args) { console.log(“Function called”); console.log(“Arguments are : ”,args); }}) ;