SlideShare uma empresa Scribd logo
1 de 45
Baixar para ler offline
iOS Runtime Hacking
Crash Course
Michael Gianarakis
WAHCKon[2]
#whoami
@mgianarakis
Managing Consultant at SpiderLabs
We're hiring!
What Is This Presentation
About?
• Quick and dirty intro to runtime hacking on iOS
• Help people get up to speed quickly
• Hopefully practical
• Focussed on third-party apps
What It’s Not
• No data security
• No transport security
• Not touching on remediation/protection
• For more comprehensive presentations on iOS
pen testing or how to secure apps go to
eightbit.io/presentations
Outline
• Objective-C Basics
• Setting Up The Environment
• Mapping Out the Application
• Dumping and Modifying Variables
• Manipulating Functions at Runtime
• Swift Considerations
Objective-C Basics
Objective-C
• Native iOS applications are written in Objective-C
• Objective-C is a superset of C
• Objective-C is basically C with Smalltalk-style
messaging and object syntax
Syntax
Syntax
Syntax
// Sending the message “method” to the object pointed to by the pointer obj
[obj method: argument1: argument2];
Important Takeaways
• Understand basic OO principles
• Rudimentary understanding of MVC
• Basic Objective-C
• How to call methods (embrace the square
bracket!)
• How to read and write variables
Setting Up The
Environment
Requirements
• Jailbroken device
• openssh (via Cydia)
• class-dump-z (http://code.google.com/p/networkpx/wiki/class_dump_z)
• cycript (http://www.cycript.org/debs/ or Cydia)
• gdb (via Cydia) or lldbdebugserver (http://iphonedevwiki.net/index.php/
Debugserver)
• CydiaSubstrate (via Cydia)
• Clutch (https://github.com/KJCracks/Clutch)
• For a slightly outdated guide on setting up the environment see eightbit.io/post/
64319534191/how-to-set-up-an-ios-pen-testing-environment
Mapping Out The
Application
Mapping Out The Application
• The most important part
• Objective-C apps store a bunch of useful runtime
information in the executable
• This information provides great insight into how an
application functions (and thus is useful for finding
bugs)
Decrypting Binaries
• Apps downloaded from the App Store are
protected with Apple’s FairPlay DRM
• Certain portions of the binary are encrypted
• Need to decrypt these portions before we can
analyse the binary
Decrypting Binaries
• Can do it manually by extracting the encrypted
portion after the loader decrypts it and then patch
the decrypted portion it into the binary
• Plenty of tools to automate this for you
• dumpdecrypted
• Clutch and Rasticrac
Decrypting Binaries
• Not going to demonstrate this as there are plenty
of guides on the web and it’s not very interesting
• NOTE: Piracy is not cool
Obtaining a Class Dump
• Using the excellent class-dump-z tool you can
extract all of the runtime information stored in the
binary in a what is essentially the equivalent of an
Objective-C header file
• class-dump-z -aAkRzb [BINARY]
Example: Class Dump
Other Options
• Disassemblers such as IDA or Hopper
• Great for lower level insight
• Swift binaries
• otool
• weak_class_dump.cy (https://github.com/limneos/
weak_classdump)
Dumping and
Modifying Variables
Retrieving Sensitive
Information
• Very easy to retrieve sensitive information at
runtime including:
• Credentials
• Encryption keys
• PII
• Sensitive business data
Quick and Dirty Approach
• Review the class dump (grep ftw)
• pin, password, passcode, pinlock, key, aes,
account, credentials, creditCard, username,
address, phone, session, token
• Hook into the running application with Cycript and
retrieve the information
Cycript
• Ridiculous name (pronounced script)
• Even more ridiculous premise
• “programming language designed to blend
the barrier between Objective-C and
JavaScript”
• Really great tool for interrogating and
manipulating the runtime of an app
Example: Retrieving
A User’s PIN
Manipulating
Functions at Runtime
Manipulating the Runtime
• Objective-C can observe and modify it’s own
behaviour at runtime
• Can call methods directly, modify functions and
even create your own classes and methods
• This has obvious security implications
What can you do?
• Break security checks
• Jailbreak checks
• Debug prevention
• Certificate validation
• Bypass authentication
• Subvert business logic
• Get the highest possible score in Flappy Bird
Quick and Dirty Approach
• Review the class dump
• Look for sensitive functions
• Identify simple logic
• Hook into the running application with Cycript and
call or modify the functions
Example:
Authentication Bypass
Example: Jailbreak
Detection
Phonegap/Cordova
Persistence
• Using Cycript to modify the behaviour at runtime
obviously will not persist when the application is
terminated
• For a POC on say a pen-test or a bug report it’s
usually not a problem
• However there may be instances where you want
the modification to be persistent
Why persistence?
• Security checks hindering testing
• Jailbreak prevention
• Anti-debug protection
• Transport security controls (e.g. cert pinning)
• Development of tools
• For a jailbreak or actual malware
How?
• Inject a library into every new process via the
DYLD_INSERT_LIBRARIES environment variable
#chmod +r hook.dylib
#launchctl setenv DYLD_INSERT_LIBRARIES /var/
root/ hook.dylib
CydiaSubstrate + Theos
• CydiaSubstrate simplifies hooking with a global injected dylib
• Can just install from Cydia
• Theos is a port of the build tools to other platforms
• So you don’t have to be an Apple fanboy to build hooks
• Focus on the logic of the hook
• Also available on iOS
• http://iphonedevwiki.net/index.php/Theos/Setup
Example: Hooking
Swift Considerations
What is Swift?
• Compiled language created by Apple
• Released publicly in 2014 at WWDC
• Intended to replace Objective-C eventually
Characteristics
• Uses the same runtime
• Binary compatibility with Objective-C
• No dynamic dispatch
Issues with Swift Apps
• Runtime manipulation limited for pure Swift apps
(i.e. a Swift-only runtime)
• Harder to analyse
• No class dump
• Name mangling
Assessing Swift Apps
• Can still do some runtime manipulation with the
Objective-C bridge enabled
• Realistically until we get Swift only frameworks all
apps will have this
• Can still do limited hooking with CydiaSubstrate
• Disassemblers for analysing Swift binaries
• Hopper scripts to demangle Swift names (https://
github.com/Januzellij/hopperscripts)
Questions?

Mais conteúdo relacionado

Mais procurados

QA / Testing Tools, Automation Testing, Online & Classroom Training
QA / Testing Tools, Automation Testing, Online & Classroom Training QA / Testing Tools, Automation Testing, Online & Classroom Training
QA / Testing Tools, Automation Testing, Online & Classroom Training AnanthReddy38
 
How to really obfuscate your pdf malware
How to really obfuscate your pdf malwareHow to really obfuscate your pdf malware
How to really obfuscate your pdf malwarezynamics GmbH
 
Facilitating Idiomatic Swift with Objective-C
Facilitating Idiomatic Swift with Objective-CFacilitating Idiomatic Swift with Objective-C
Facilitating Idiomatic Swift with Objective-CAaron Taylor
 
Introduction to mobile reversing
Introduction to mobile reversingIntroduction to mobile reversing
Introduction to mobile reversingjduart
 
Tech breakfast 18
Tech breakfast 18Tech breakfast 18
Tech breakfast 18James Leone
 
iOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h editioniOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h editionJorge Ortiz
 
Typescript in 30mins
Typescript in 30mins Typescript in 30mins
Typescript in 30mins Udaya Kumar
 
ScalaClean at ScalaSphere 2019
ScalaClean at ScalaSphere 2019ScalaClean at ScalaSphere 2019
ScalaClean at ScalaSphere 2019Rory Graves
 
Robot framework - Lord of the Rings
Robot framework - Lord of the RingsRobot framework - Lord of the Rings
Robot framework - Lord of the RingsAsheesh Mehdiratta
 
InvokeDynamic for Mere Mortals [JavaOne 2015 CON7682]
InvokeDynamic for Mere Mortals [JavaOne 2015 CON7682]InvokeDynamic for Mere Mortals [JavaOne 2015 CON7682]
InvokeDynamic for Mere Mortals [JavaOne 2015 CON7682]David Buck
 
Weaving aspects in PHP with the help of Go! AOP library
Weaving aspects in PHP with the help of Go! AOP libraryWeaving aspects in PHP with the help of Go! AOP library
Weaving aspects in PHP with the help of Go! AOP libraryAlexander Lisachenko
 
Introduction to TypeScript by Winston Levi
Introduction to TypeScript by Winston LeviIntroduction to TypeScript by Winston Levi
Introduction to TypeScript by Winston LeviWinston Levi
 
Does The Delphi IDE Narrow You? Extend It! - ITDevConX European Delphi Confer...
Does The Delphi IDE Narrow You? Extend It! - ITDevConX European Delphi Confer...Does The Delphi IDE Narrow You? Extend It! - ITDevConX European Delphi Confer...
Does The Delphi IDE Narrow You? Extend It! - ITDevConX European Delphi Confer...Marco Breveglieri
 
TypeScript Modules
TypeScript ModulesTypeScript Modules
TypeScript ModulesNoam Kfir
 

Mais procurados (19)

Zend Code in ZF 2.0
Zend Code in ZF 2.0Zend Code in ZF 2.0
Zend Code in ZF 2.0
 
QA / Testing Tools, Automation Testing, Online & Classroom Training
QA / Testing Tools, Automation Testing, Online & Classroom Training QA / Testing Tools, Automation Testing, Online & Classroom Training
QA / Testing Tools, Automation Testing, Online & Classroom Training
 
How to really obfuscate your pdf malware
How to really obfuscate your pdf malwareHow to really obfuscate your pdf malware
How to really obfuscate your pdf malware
 
Facilitating Idiomatic Swift with Objective-C
Facilitating Idiomatic Swift with Objective-CFacilitating Idiomatic Swift with Objective-C
Facilitating Idiomatic Swift with Objective-C
 
Diving into Java Class Loader
Diving into Java Class LoaderDiving into Java Class Loader
Diving into Java Class Loader
 
Introduction to mobile reversing
Introduction to mobile reversingIntroduction to mobile reversing
Introduction to mobile reversing
 
Tech breakfast 18
Tech breakfast 18Tech breakfast 18
Tech breakfast 18
 
iOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h editioniOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h edition
 
Typescript in 30mins
Typescript in 30mins Typescript in 30mins
Typescript in 30mins
 
ScalaClean at ScalaSphere 2019
ScalaClean at ScalaSphere 2019ScalaClean at ScalaSphere 2019
ScalaClean at ScalaSphere 2019
 
Robot framework - Lord of the Rings
Robot framework - Lord of the RingsRobot framework - Lord of the Rings
Robot framework - Lord of the Rings
 
InvokeDynamic for Mere Mortals [JavaOne 2015 CON7682]
InvokeDynamic for Mere Mortals [JavaOne 2015 CON7682]InvokeDynamic for Mere Mortals [JavaOne 2015 CON7682]
InvokeDynamic for Mere Mortals [JavaOne 2015 CON7682]
 
Weaving aspects in PHP with the help of Go! AOP library
Weaving aspects in PHP with the help of Go! AOP libraryWeaving aspects in PHP with the help of Go! AOP library
Weaving aspects in PHP with the help of Go! AOP library
 
Introduction to TypeScript by Winston Levi
Introduction to TypeScript by Winston LeviIntroduction to TypeScript by Winston Levi
Introduction to TypeScript by Winston Levi
 
Does The Delphi IDE Narrow You? Extend It! - ITDevConX European Delphi Confer...
Does The Delphi IDE Narrow You? Extend It! - ITDevConX European Delphi Confer...Does The Delphi IDE Narrow You? Extend It! - ITDevConX European Delphi Confer...
Does The Delphi IDE Narrow You? Extend It! - ITDevConX European Delphi Confer...
 
TypeScript intro
TypeScript introTypeScript intro
TypeScript intro
 
TypeScript Modules
TypeScript ModulesTypeScript Modules
TypeScript Modules
 
Typescript ppt
Typescript pptTypescript ppt
Typescript ppt
 
Introduction to Core Java Programming
Introduction to Core Java ProgrammingIntroduction to Core Java Programming
Introduction to Core Java Programming
 

Semelhante a Wahckon[2] - iOS Runtime Hacking Crash Course

CrikeyCon 2015 - iOS Runtime Hacking Crash Course
CrikeyCon 2015 - iOS Runtime Hacking Crash CourseCrikeyCon 2015 - iOS Runtime Hacking Crash Course
CrikeyCon 2015 - iOS Runtime Hacking Crash Courseeightbit
 
Runtime Analysis on Mobile Applications (February 2017)
Runtime Analysis on Mobile Applications (February 2017)Runtime Analysis on Mobile Applications (February 2017)
Runtime Analysis on Mobile Applications (February 2017)Sandeep Jayashankar
 
Breaking Secure Mobile Applications - Hack In The Box 2014 KL
Breaking Secure Mobile Applications - Hack In The Box 2014 KLBreaking Secure Mobile Applications - Hack In The Box 2014 KL
Breaking Secure Mobile Applications - Hack In The Box 2014 KLiphonepentest
 
Kubernetes and container security
Kubernetes and container securityKubernetes and container security
Kubernetes and container securityVolodymyr Shynkar
 
Aleksei Dremin - Application Security Pipeline - phdays9
Aleksei Dremin - Application Security Pipeline - phdays9Aleksei Dremin - Application Security Pipeline - phdays9
Aleksei Dremin - Application Security Pipeline - phdays9Alexey Dremin
 
Security research over Windows #defcon china
Security research over Windows #defcon chinaSecurity research over Windows #defcon china
Security research over Windows #defcon chinaPeter Hlavaty
 
YOW! Connected 2014 - Developing Secure iOS Applications
YOW! Connected 2014 - Developing Secure iOS ApplicationsYOW! Connected 2014 - Developing Secure iOS Applications
YOW! Connected 2014 - Developing Secure iOS Applicationseightbit
 
iOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersiOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersRyanISI
 
Threat Modeling the CI/CD Pipeline to Improve Software Supply Chain Security ...
Threat Modeling the CI/CD Pipeline to Improve Software Supply Chain Security ...Threat Modeling the CI/CD Pipeline to Improve Software Supply Chain Security ...
Threat Modeling the CI/CD Pipeline to Improve Software Supply Chain Security ...Denim Group
 
Webinar–Mobile Application Hardening Protecting Business Critical Apps
Webinar–Mobile Application Hardening Protecting Business Critical AppsWebinar–Mobile Application Hardening Protecting Business Critical Apps
Webinar–Mobile Application Hardening Protecting Business Critical AppsSynopsys Software Integrity Group
 
XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...
XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...
XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...The Linux Foundation
 
iOS Application Security
iOS Application SecurityiOS Application Security
iOS Application SecurityEgor Tolstoy
 
Alexey Sintsov- SDLC - try me to implement
Alexey Sintsov- SDLC - try me to implementAlexey Sintsov- SDLC - try me to implement
Alexey Sintsov- SDLC - try me to implementDefconRussia
 
DEF CON 27 - workshop - RICHARD GOLD - mind the gap
DEF CON 27 - workshop - RICHARD GOLD - mind the gapDEF CON 27 - workshop - RICHARD GOLD - mind the gap
DEF CON 27 - workshop - RICHARD GOLD - mind the gapFelipe Prado
 
How to avoid microservice pitfalls
How to avoid microservice pitfallsHow to avoid microservice pitfalls
How to avoid microservice pitfallsParticular Software
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsAmazon Web Services
 

Semelhante a Wahckon[2] - iOS Runtime Hacking Crash Course (20)

CrikeyCon 2015 - iOS Runtime Hacking Crash Course
CrikeyCon 2015 - iOS Runtime Hacking Crash CourseCrikeyCon 2015 - iOS Runtime Hacking Crash Course
CrikeyCon 2015 - iOS Runtime Hacking Crash Course
 
Runtime Analysis on Mobile Applications (February 2017)
Runtime Analysis on Mobile Applications (February 2017)Runtime Analysis on Mobile Applications (February 2017)
Runtime Analysis on Mobile Applications (February 2017)
 
Breaking Secure Mobile Applications - Hack In The Box 2014 KL
Breaking Secure Mobile Applications - Hack In The Box 2014 KLBreaking Secure Mobile Applications - Hack In The Box 2014 KL
Breaking Secure Mobile Applications - Hack In The Box 2014 KL
 
iOS Application Exploitation
iOS Application ExploitationiOS Application Exploitation
iOS Application Exploitation
 
Kubernetes and container security
Kubernetes and container securityKubernetes and container security
Kubernetes and container security
 
Aleksei Dremin - Application Security Pipeline - phdays9
Aleksei Dremin - Application Security Pipeline - phdays9Aleksei Dremin - Application Security Pipeline - phdays9
Aleksei Dremin - Application Security Pipeline - phdays9
 
Stackato v6
Stackato v6Stackato v6
Stackato v6
 
Security research over Windows #defcon china
Security research over Windows #defcon chinaSecurity research over Windows #defcon china
Security research over Windows #defcon china
 
YOW! Connected 2014 - Developing Secure iOS Applications
YOW! Connected 2014 - Developing Secure iOS ApplicationsYOW! Connected 2014 - Developing Secure iOS Applications
YOW! Connected 2014 - Developing Secure iOS Applications
 
iOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersiOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for Beginners
 
Threat Modeling the CI/CD Pipeline to Improve Software Supply Chain Security ...
Threat Modeling the CI/CD Pipeline to Improve Software Supply Chain Security ...Threat Modeling the CI/CD Pipeline to Improve Software Supply Chain Security ...
Threat Modeling the CI/CD Pipeline to Improve Software Supply Chain Security ...
 
Webinar–Mobile Application Hardening Protecting Business Critical Apps
Webinar–Mobile Application Hardening Protecting Business Critical AppsWebinar–Mobile Application Hardening Protecting Business Critical Apps
Webinar–Mobile Application Hardening Protecting Business Critical Apps
 
Kku2011
Kku2011Kku2011
Kku2011
 
XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...
XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...
XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...
 
iOS Application Security
iOS Application SecurityiOS Application Security
iOS Application Security
 
Alexey Sintsov- SDLC - try me to implement
Alexey Sintsov- SDLC - try me to implementAlexey Sintsov- SDLC - try me to implement
Alexey Sintsov- SDLC - try me to implement
 
DEF CON 27 - workshop - RICHARD GOLD - mind the gap
DEF CON 27 - workshop - RICHARD GOLD - mind the gapDEF CON 27 - workshop - RICHARD GOLD - mind the gap
DEF CON 27 - workshop - RICHARD GOLD - mind the gap
 
How to avoid microservice pitfalls
How to avoid microservice pitfallsHow to avoid microservice pitfalls
How to avoid microservice pitfalls
 
DevOps intro
DevOps introDevOps intro
DevOps intro
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
 

Mais de eightbit

Defcon 25 Packet Hacking Village - Finding Your Way to Domain Access
Defcon 25 Packet Hacking Village - Finding Your Way to Domain AccessDefcon 25 Packet Hacking Village - Finding Your Way to Domain Access
Defcon 25 Packet Hacking Village - Finding Your Way to Domain Accesseightbit
 
AusCERT - Developing Secure iOS Applications
AusCERT - Developing Secure iOS ApplicationsAusCERT - Developing Secure iOS Applications
AusCERT - Developing Secure iOS Applicationseightbit
 
CrikeyCon 2017 - Rumours of our Demise Have Been Greatly Exaggerated
CrikeyCon 2017  - Rumours of our Demise Have Been Greatly ExaggeratedCrikeyCon 2017  - Rumours of our Demise Have Been Greatly Exaggerated
CrikeyCon 2017 - Rumours of our Demise Have Been Greatly Exaggeratedeightbit
 
Online Retailer's Conference 2013 - Hacking Mobile Applications - Industry Ca...
Online Retailer's Conference 2013 - Hacking Mobile Applications - Industry Ca...Online Retailer's Conference 2013 - Hacking Mobile Applications - Industry Ca...
Online Retailer's Conference 2013 - Hacking Mobile Applications - Industry Ca...eightbit
 
Ruxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration TestingRuxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration Testingeightbit
 
OWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration TestingOWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration Testingeightbit
 

Mais de eightbit (6)

Defcon 25 Packet Hacking Village - Finding Your Way to Domain Access
Defcon 25 Packet Hacking Village - Finding Your Way to Domain AccessDefcon 25 Packet Hacking Village - Finding Your Way to Domain Access
Defcon 25 Packet Hacking Village - Finding Your Way to Domain Access
 
AusCERT - Developing Secure iOS Applications
AusCERT - Developing Secure iOS ApplicationsAusCERT - Developing Secure iOS Applications
AusCERT - Developing Secure iOS Applications
 
CrikeyCon 2017 - Rumours of our Demise Have Been Greatly Exaggerated
CrikeyCon 2017  - Rumours of our Demise Have Been Greatly ExaggeratedCrikeyCon 2017  - Rumours of our Demise Have Been Greatly Exaggerated
CrikeyCon 2017 - Rumours of our Demise Have Been Greatly Exaggerated
 
Online Retailer's Conference 2013 - Hacking Mobile Applications - Industry Ca...
Online Retailer's Conference 2013 - Hacking Mobile Applications - Industry Ca...Online Retailer's Conference 2013 - Hacking Mobile Applications - Industry Ca...
Online Retailer's Conference 2013 - Hacking Mobile Applications - Industry Ca...
 
Ruxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration TestingRuxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration Testing
 
OWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration TestingOWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration Testing
 

Último

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 

Último (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Wahckon[2] - iOS Runtime Hacking Crash Course

  • 1. iOS Runtime Hacking Crash Course Michael Gianarakis WAHCKon[2]
  • 3. What Is This Presentation About? • Quick and dirty intro to runtime hacking on iOS • Help people get up to speed quickly • Hopefully practical • Focussed on third-party apps
  • 4. What It’s Not • No data security • No transport security • Not touching on remediation/protection • For more comprehensive presentations on iOS pen testing or how to secure apps go to eightbit.io/presentations
  • 5. Outline • Objective-C Basics • Setting Up The Environment • Mapping Out the Application • Dumping and Modifying Variables • Manipulating Functions at Runtime • Swift Considerations
  • 7. Objective-C • Native iOS applications are written in Objective-C • Objective-C is a superset of C • Objective-C is basically C with Smalltalk-style messaging and object syntax
  • 10. Syntax // Sending the message “method” to the object pointed to by the pointer obj [obj method: argument1: argument2];
  • 11. Important Takeaways • Understand basic OO principles • Rudimentary understanding of MVC • Basic Objective-C • How to call methods (embrace the square bracket!) • How to read and write variables
  • 13. Requirements • Jailbroken device • openssh (via Cydia) • class-dump-z (http://code.google.com/p/networkpx/wiki/class_dump_z) • cycript (http://www.cycript.org/debs/ or Cydia) • gdb (via Cydia) or lldbdebugserver (http://iphonedevwiki.net/index.php/ Debugserver) • CydiaSubstrate (via Cydia) • Clutch (https://github.com/KJCracks/Clutch) • For a slightly outdated guide on setting up the environment see eightbit.io/post/ 64319534191/how-to-set-up-an-ios-pen-testing-environment
  • 15. Mapping Out The Application • The most important part • Objective-C apps store a bunch of useful runtime information in the executable • This information provides great insight into how an application functions (and thus is useful for finding bugs)
  • 16. Decrypting Binaries • Apps downloaded from the App Store are protected with Apple’s FairPlay DRM • Certain portions of the binary are encrypted • Need to decrypt these portions before we can analyse the binary
  • 17. Decrypting Binaries • Can do it manually by extracting the encrypted portion after the loader decrypts it and then patch the decrypted portion it into the binary • Plenty of tools to automate this for you • dumpdecrypted • Clutch and Rasticrac
  • 18. Decrypting Binaries • Not going to demonstrate this as there are plenty of guides on the web and it’s not very interesting • NOTE: Piracy is not cool
  • 19. Obtaining a Class Dump • Using the excellent class-dump-z tool you can extract all of the runtime information stored in the binary in a what is essentially the equivalent of an Objective-C header file • class-dump-z -aAkRzb [BINARY]
  • 21. Other Options • Disassemblers such as IDA or Hopper • Great for lower level insight • Swift binaries • otool • weak_class_dump.cy (https://github.com/limneos/ weak_classdump)
  • 23. Retrieving Sensitive Information • Very easy to retrieve sensitive information at runtime including: • Credentials • Encryption keys • PII • Sensitive business data
  • 24. Quick and Dirty Approach • Review the class dump (grep ftw) • pin, password, passcode, pinlock, key, aes, account, credentials, creditCard, username, address, phone, session, token • Hook into the running application with Cycript and retrieve the information
  • 25. Cycript • Ridiculous name (pronounced script) • Even more ridiculous premise • “programming language designed to blend the barrier between Objective-C and JavaScript” • Really great tool for interrogating and manipulating the runtime of an app
  • 26.
  • 29. Manipulating the Runtime • Objective-C can observe and modify it’s own behaviour at runtime • Can call methods directly, modify functions and even create your own classes and methods • This has obvious security implications
  • 30. What can you do? • Break security checks • Jailbreak checks • Debug prevention • Certificate validation • Bypass authentication • Subvert business logic • Get the highest possible score in Flappy Bird
  • 31. Quick and Dirty Approach • Review the class dump • Look for sensitive functions • Identify simple logic • Hook into the running application with Cycript and call or modify the functions
  • 35. Persistence • Using Cycript to modify the behaviour at runtime obviously will not persist when the application is terminated • For a POC on say a pen-test or a bug report it’s usually not a problem • However there may be instances where you want the modification to be persistent
  • 36. Why persistence? • Security checks hindering testing • Jailbreak prevention • Anti-debug protection • Transport security controls (e.g. cert pinning) • Development of tools • For a jailbreak or actual malware
  • 37. How? • Inject a library into every new process via the DYLD_INSERT_LIBRARIES environment variable #chmod +r hook.dylib #launchctl setenv DYLD_INSERT_LIBRARIES /var/ root/ hook.dylib
  • 38. CydiaSubstrate + Theos • CydiaSubstrate simplifies hooking with a global injected dylib • Can just install from Cydia • Theos is a port of the build tools to other platforms • So you don’t have to be an Apple fanboy to build hooks • Focus on the logic of the hook • Also available on iOS • http://iphonedevwiki.net/index.php/Theos/Setup
  • 41. What is Swift? • Compiled language created by Apple • Released publicly in 2014 at WWDC • Intended to replace Objective-C eventually
  • 42. Characteristics • Uses the same runtime • Binary compatibility with Objective-C • No dynamic dispatch
  • 43. Issues with Swift Apps • Runtime manipulation limited for pure Swift apps (i.e. a Swift-only runtime) • Harder to analyse • No class dump • Name mangling
  • 44. Assessing Swift Apps • Can still do some runtime manipulation with the Objective-C bridge enabled • Realistically until we get Swift only frameworks all apps will have this • Can still do limited hooking with CydiaSubstrate • Disassemblers for analysing Swift binaries • Hopper scripts to demangle Swift names (https:// github.com/Januzellij/hopperscripts)