SlideShare una empresa de Scribd logo
1 de 51
Descargar para leer sin conexión
iOS applications auditing


                                   AppSec Forum
                                       Western Switzerland




Julien Bachmann / julien@scrt.ch
›   Motivations
›   Quick review of the environment
›   Common flaws
›   Information gathering
›   Network analysis
›   Software reverse engineering
Preamble

›       Security engineer @ SCRT
›       Teacher @ HEIG-VD
    ›    Areas of interest focused on reverse engineering,
         software vulnerabilities, mobile devices security
         and OS internals
›       Not an Apple fanboy
    ›    But like all the cool kids...
›       Goals
    ›    This presentation aims at sharing experience and
         knowledge in iOS apps pentesting
›       Contact
    ›    @milkmix_
motivations | why ?

›       More and more applications
    ›    Most of Fortune-500 are deploying iPads
    ›    Growth in mobile banking
    ›    Mobile eShop
    ›    Internal applications
›       Need for security
    ›    Access and storage of sensitive information
    ›    Online payments
environment | devices

›       Latest devices
    ›    Apple A5 / A5X / A6 / A6X
    ›    Based on ARMv7 specifications
›       Processor
    ›    RISC
    ›    Load-store architecture
    ›    Fixed length 32-bits instructions
environment | simulator

›       Beware
    ›    Simulator != emulator
›       More like a sandbox
    ›    Code compiled for Intel processors
    ›    32-bits
    ›    ~/Library/Application Support/iPhone Simulator/<v>/Applications/<id>/
environment | applications

›       Localisation
    ›    ~/Music/iTunes/iTunes Music/Mobile Applications/
    ›    /var/mobile/Applications/<guid>/<appname>.app/
›       .ipa
    ›    Used to deploy applications
    ›    Zip file
environment | applications

›       .plist
    ›    Used to store properties
    ›    XML files, sometimes in a binary format
    ›    Associates keys (CFString, CFNumber, …) with values
›       plutil (1)
    ›    Convert binary plist file to its XML representation
flaws | communication snooping

›       Secure by default
    ›    Well... at least if the developer is using URLs starting with HTTPS://
›       Even if a fake certificate is presented !
    ›    The DidFailWithError method is called
flaws | communication snooping

›       Ok, but what about real life ?
    ›    A lot of development environments are using self-signed certificates
    ›    No built-in method to include certificates in the simulator
›       Obviously, what did the developers ?
    ›    Let's check what's on stackoverflow.com...
flaws | communication snooping

›       How to (potentialy) wreak havoc
    ›    Implement the two following delegates only to bypass certificates validation
    ›    CanAuthenticateAgainstProtectionSpace
    ›    DidReceiveAuthenticationChallenge
flaws | data storage

›       Most applications are working connected
    ›       Still some information locally stored
        ›     plist
        ›     SQLite3 databases
        ›     ...
    ›       Could include sensitive data
›       Built-in protection
    ›       Data Protection API since iOS 4.0
        ›     http://code.google.com/p/iphone-dataprotection/
    ›       New attributes when working on files, Keychain entries or databases
    ›       Automatically used when calling
                NSURLCredentialStorage:setDefaultCredential but could not change
                protection type
flaws | data storage



Attribute                                          Definition
kSecAttrAccessibleWhenUnlocked                     Only if unlocked

kSecAttrAccessibleAfterFirstUnlock                 Unlocked at least once

kSecAttrAccessibleAlways                           Do not use Data Protection API

kSecAttrAccessibleWhenUnlockedThisDeviceOnly       Only if unlocked, but do not store in backups

kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly   Unlocked at least once, but do not store in backups

kSecAttrAccessibleAlwaysThisDeviceOnly             Do not store in backups
flaws | data storage

›       Cryptographic primitives
    ›       Common Crypto Library
        ›        CCCrypt()
             ›     kCCEncrypt
             ›     kCCDecrypt
flaws | information disclosure

›       The previous seems obvious, but...
    ›    Logs ?
    ›    Automagically created files ?
flaws | external interactions

›       Files handling
    ›    CFBundleDocumentTypes in Info.plist
›       IPC-like mechanism
    ›    URIs handlers
    ›    CFBundleURLTypes in Info.plist
    ›    Implementation of handleOpenURL or OpenURL
flaws | external interactions

›       Memory management vulnerabilities
    ›    Objective-C classes are well protected
    ›    Still possible to introduce vulnerabilities if developing custom parsing
         functions for homegrown protocol
    ›    Beware to the old threats : format strings
    ›    Most likely result : app crash due to software exploitation protections
›       HTML / Javascript injection
    ›    UIWebView controller used to render web pages
    ›    More related to server side vulnerabilities
flaws | server side

›       Most of the time, included in the scope of the audit
    ›    Lot of applications are communicating with web-services
›       Common flaws
    ›    No need to present the Top10
info gathering | apple's tools

›       First idea most people will have
    ›    Let's jailbreak it !
›       There is another way
    ›    Stealthier to do a first recon
    ›    Still, jailbreaking the auditor's device is mandatory
    ›    Kudos to the jailbreakers teams for their work !
info gathering | apple's tools

›   Activate developer mode
info gathering | apple's tools

›       Access application's files
    ›    Only works for applications compiled in debug mode
info gathering | apple's tools

›   Console / Application's logs
info gathering | getting access to the device

›       Now you can do it
    ›    Enough documentation on jailbreaking online
›       Personnal choice
    ›    Create a firmware with the smalest footprint as jailbreak detection
         mechanisms mostly check for Cydia presence
    ›    Use device that can be pwned using bootloader vulnerability in DFU mode
    ›    Use tcprelay.py relying on usbmux to ssh to the device through the usb
             cable
info gathering | keychain items

›       Keychain Dumper
    ›    https://github.com/ptoomey3/Keychain-Dumper
network analysis | communication snooping

›       Main idea
    ›    Use {burp ;zap ;...} to intercept the trafic and manipulate it
›       Problem
    ›    What about if the developers are using SSL and best-practices ?
network analysis | communication snooping

›       If you are doing an assignment mixing pentest and code review
    ›       Use the Simulator
›       Certificates store
    ›       Based on a SQLite3 database
    ›       ~/Library/Application Support/iPhone
                Simulator/<sdk>/Library/Keychains/TrustStore.sqlite3
    ›       GDSSecurity released a script automating the insertion of x509 certificates
                in the database
        ›     https://github.com/GDSSecurity/Add-Trusted-Certificate-to-iOS-Simulator
network analysis | communication snooping

›       Using a device
    ›    Generate CA and sign certificate
    ›    Upload the CA to the device using Apple Configurator
network analysis | communication snooping

›       Won't go further on this subject
    ›    Joins classic web service pentesting
    ›    Except you are using a specific application and not a browser
reverse engineering | why ?

›       Pentesting is not code review
    ›    If you want to understand an application behavior you have to reverse it
›       Static
    ›    Hexdump
    ›    otool
    ›    IDA Pro
    ›    Hopper
›       Dynamic
    ›    GDB
reverse engineering | ida pro
reverse engineering | hopper
reverse engineering | hopper
reverse engineering | need to know

›       Architecture
    ›    File format for Objective-C executables
    ›    ARM basics
›       Language
    ›    Objective-C basics
    ›    ARM assembly basics
›       AppStore
    ›    How to decrypt AppStore binaries
reverse engineering | appstore

›       Applications from the AppStore are encrypted
    ›    DRM
    ›    Fair Play like
›       Do it manually
    ›    GDB, set, go !
›       Automatic
    ›    Crackulous (won't work on executables compiled with PIE)
    ›    Clutch
reverse engineering | obj-c to arm

›       Objective-C
    ›    [ObjectPointer Method:42]
›       C++ equivalent
    ›    ObjectPointer->Method(42)
›       Pseudo C generated by the compiler
    ›    objc_msgSend(ObjectPointer, "Method", 42)
›       ARM assembly
    ›
reverse engineering | obj-c to arm

›       Reflective language
    ›    Access to own definition




    ›    Call methods from names
reverse engineering | where to begin ?

›       Main class
    ›    Derived from UIApplicationDelegate
    ›    Implements applicationDidFinishLaunching or
         applicationDidFinishLaunchingWithOptions
›       Views
    ›    Derived from UI*ViewController
    ›    Implement viewDidLoad
reverse engineering | extracting class info

›   class-dump
reverse engineering | static analysis

›       Goals
    ›    Understand the application's algorithms
›       Tools
    ›    IDA Pro
    ›    Hopper
    ›    fixobjc.idc to resolve XREFs and parse Obj-C structures
    ›    Built-in functionality since version 6.2
reverse engineering | dynamic analysis

›       Goals
    ›    Understand the application's algorithms
    ›    Allows to tamper data
›       But data tampering is not done with Burp ?
    ›    What happens when the protocol is encrypted ?
    ›    Need to find the function encrypting the data
    ›    Set breakpoint
    ›    Modify the data in-memory
reverse engineering | dynamic analysis

›       GDB
    ›    Provided by Apple as part of iOS SDK
    ›    Standalone version or gdbserver with gdb version for ARM targets
    ›    Advantage of gdbserver is ability to launch GUI applications
    ›    Highly recommend gdbinit* by @osxreverser
›       Entitlement
    ›    Binary will not run out-of-the-box on iDevices
    ›    Need to add entitlements after extracting ARMv7 binary
    ›    ldid to the rescue




    * http://reverse.put.as/gdbinit/
reverse engineering | dynamic analysis
reverse engineering | dynamic analysis

›       Startup
    ›    # ~/debugserver-armv7 -x spring <app>
    ›    gdb$ set shlib-path-substitutions /
             /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platf
             orm/Developer/SDKs/iPhoneOS5.1.sdk/
    ›    gdb$ target remote-macosx localhost:1999
    ›    gdb$ source ~/gdbinit8
    ›    gdb$ b [InsomniOneViewController viewDidLoad]
    ›    gdb$ c
    ›    gdb$ regarm
reverse engineering | dynamic analysis

›   Warning
reverse engineering | dynamic analysis

›       Inspect / modify memory
    ›    gdb$ po $r2
    ›    gdb$ set {int}0xcafebabe = 1337
›       For large amount of data
    ›    $ cat data.mod | hexdump -ve '1/4 "set {unsigned char *}( <addr> +
             %#2_ax) = %#02xn"' > data.gdb
reverse engineering | instrumentation

›       Automating an attack
    ›    Suppose you found something (SQL injection, …)
    ›    Possible to call methods using gdb's call directive
    ›    Too slow to modify data on the fly by hands
›       Solution
    ›    Use code injection to modify the behaviour of the application
    ›    Modify data automagically
reverse engineering | instrumentation

›       This is where you start loving Objective-C
    ›       Hooking is a bundled feature
    ›       It's called 'swizzling'
›       Principle
    ›       Use the functions provided by Apple, like
        ›      class_replaceMethod
        ›      method_exchangeimplementations
reverse engineering | instrumentation
reverse engineering | instrumentation
reverse engineering | instrumentation

›       Injecting into process
    ›    DYLD_PRELOAD for stand-alone launch
    ›    DYLD_INSERT_LIBRARIES and SpringBoard.plist modification to inject in
             all graphical applications
Questions ?

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

IDA Vulnerabilities and Bug Bounty  by Masaaki Chida
IDA Vulnerabilities and Bug Bounty  by Masaaki ChidaIDA Vulnerabilities and Bug Bounty  by Masaaki Chida
IDA Vulnerabilities and Bug Bounty  by Masaaki Chida
 
iOS Application Pentesting
iOS Application PentestingiOS Application Pentesting
iOS Application Pentesting
 
Security Testing with Zap
Security Testing with ZapSecurity Testing with Zap
Security Testing with Zap
 
Secure Node Code (workshop, O'Reilly Security)
Secure Node Code (workshop, O'Reilly Security)Secure Node Code (workshop, O'Reilly Security)
Secure Node Code (workshop, O'Reilly Security)
 
Introduction to iOS Penetration Testing
Introduction to iOS Penetration TestingIntroduction to iOS Penetration Testing
Introduction to iOS Penetration Testing
 
Programming for the Internet of Things
Programming for the Internet of ThingsProgramming for the Internet of Things
Programming for the Internet of Things
 
[Wroclaw #2] iOS Security - 101
[Wroclaw #2] iOS Security - 101[Wroclaw #2] iOS Security - 101
[Wroclaw #2] iOS Security - 101
 
CODE BLUE 2014 : [Keynote] IDA and digital security by Ilfak Guilfanov
CODE BLUE 2014 : [Keynote] IDA and digital security by Ilfak GuilfanovCODE BLUE 2014 : [Keynote] IDA and digital security by Ilfak Guilfanov
CODE BLUE 2014 : [Keynote] IDA and digital security by Ilfak Guilfanov
 
How to reverse engineer Android applications
How to reverse engineer Android applicationsHow to reverse engineer Android applications
How to reverse engineer Android applications
 
Authentication Without Authentication
Authentication Without AuthenticationAuthentication Without Authentication
Authentication Without Authentication
 
Forensic Analysis of the Raspberry PI 400
Forensic Analysis of the Raspberry PI 400Forensic Analysis of the Raspberry PI 400
Forensic Analysis of the Raspberry PI 400
 
DevSecCon Singapore 2019: Workshop - Burp extension writing workshop
DevSecCon Singapore 2019: Workshop - Burp extension writing workshopDevSecCon Singapore 2019: Workshop - Burp extension writing workshop
DevSecCon Singapore 2019: Workshop - Burp extension writing workshop
 
Phonegap 2.x
Phonegap 2.xPhonegap 2.x
Phonegap 2.x
 
Agility Requires Safety
Agility Requires SafetyAgility Requires Safety
Agility Requires Safety
 
Started In Security Now I'm Here
Started In Security Now I'm HereStarted In Security Now I'm Here
Started In Security Now I'm Here
 
IOT Exploitation
IOT Exploitation	IOT Exploitation
IOT Exploitation
 
Voice Applications with Adhearsion @ ATLAUG 2012
Voice Applications with Adhearsion @ ATLAUG 2012Voice Applications with Adhearsion @ ATLAUG 2012
Voice Applications with Adhearsion @ ATLAUG 2012
 
IoT security zigbee -- Null Meet bangalore
IoT security zigbee -- Null Meet bangaloreIoT security zigbee -- Null Meet bangalore
IoT security zigbee -- Null Meet bangalore
 
Is My App Secure ?
 Is My App Secure ? Is My App Secure ?
Is My App Secure ?
 
TxJS 2011
TxJS 2011TxJS 2011
TxJS 2011
 

Destacado

ASFWS 2012 Discours de bienvenue ASFWS 2012
 ASFWS 2012 Discours de bienvenue ASFWS 2012 ASFWS 2012 Discours de bienvenue ASFWS 2012
ASFWS 2012 Discours de bienvenue ASFWS 2012
Cyber Security Alliance
 

Destacado (9)

Flyer AppSec Forum 2011
Flyer AppSec Forum 2011Flyer AppSec Forum 2011
Flyer AppSec Forum 2011
 
2011 - Appel à contributions: conférenciers et instructeurs (CFP / CFT)
2011 - Appel à contributions: conférenciers et instructeurs (CFP / CFT)2011 - Appel à contributions: conférenciers et instructeurs (CFP / CFT)
2011 - Appel à contributions: conférenciers et instructeurs (CFP / CFT)
 
ASFWS 2012 Discours de bienvenue ASFWS 2012
 ASFWS 2012 Discours de bienvenue ASFWS 2012 ASFWS 2012 Discours de bienvenue ASFWS 2012
ASFWS 2012 Discours de bienvenue ASFWS 2012
 
ASFWS 2011: Harmonizing Identity and Privacy in Digital Identity and Authenti...
ASFWS 2011: Harmonizing Identity and Privacy in Digital Identity and Authenti...ASFWS 2011: Harmonizing Identity and Privacy in Digital Identity and Authenti...
ASFWS 2011: Harmonizing Identity and Privacy in Digital Identity and Authenti...
 
ASFWS 2011 - Malware: quelles limites pour les applications ebanking?
ASFWS 2011 - Malware: quelles limites pour les applications ebanking?ASFWS 2011 - Malware: quelles limites pour les applications ebanking?
ASFWS 2011 - Malware: quelles limites pour les applications ebanking?
 
2010 - Intégration de l'authentification: les mesures proposées par OWASP
2010 - Intégration de l'authentification: les mesures proposées par OWASP2010 - Intégration de l'authentification: les mesures proposées par OWASP
2010 - Intégration de l'authentification: les mesures proposées par OWASP
 
ASFWS 2011 - Secure software development for mobile devices
ASFWS 2011 - Secure software development for mobile devicesASFWS 2011 - Secure software development for mobile devices
ASFWS 2011 - Secure software development for mobile devices
 
ASFWS 2012 Discours de bienvenue
 ASFWS 2012 Discours de bienvenue ASFWS 2012 Discours de bienvenue
ASFWS 2012 Discours de bienvenue
 
ASFWS 2012 - Theory vs Practice in implementing Software Security related act...
ASFWS 2012 - Theory vs Practice in implementing Software Security related act...ASFWS 2012 - Theory vs Practice in implementing Software Security related act...
ASFWS 2012 - Theory vs Practice in implementing Software Security related act...
 

Similar a ASFWS 2012 - Audit d’applications iOS par Julien Bachmann

Thick Application Penetration Testing - A Crash Course
Thick Application Penetration Testing - A Crash CourseThick Application Penetration Testing - A Crash Course
Thick Application Penetration Testing - A Crash Course
NetSPI
 
ch4-Software is Everywhere
ch4-Software is Everywherech4-Software is Everywhere
ch4-Software is Everywhere
ssuser06ea42
 
Hacking Tizen : The OS of Everything - Nullcon Goa 2015
Hacking Tizen : The OS of Everything - Nullcon Goa 2015Hacking Tizen : The OS of Everything - Nullcon Goa 2015
Hacking Tizen : The OS of Everything - Nullcon Goa 2015
Ajin Abraham
 

Similar a ASFWS 2012 - Audit d’applications iOS par Julien Bachmann (20)

iOS-Application-Security-iAmPr3m
iOS-Application-Security-iAmPr3miOS-Application-Security-iAmPr3m
iOS-Application-Security-iAmPr3m
 
Meetup - retour sur la DrupalCon Dublin 2016
Meetup - retour sur la DrupalCon Dublin 2016Meetup - retour sur la DrupalCon Dublin 2016
Meetup - retour sur la DrupalCon Dublin 2016
 
Enterprise iPad Development Without Notes
Enterprise iPad Development Without NotesEnterprise iPad Development Without Notes
Enterprise iPad Development Without Notes
 
Outsmarting SmartPhones
Outsmarting SmartPhonesOutsmarting SmartPhones
Outsmarting SmartPhones
 
Pentesting iOS Applications
Pentesting iOS ApplicationsPentesting iOS Applications
Pentesting iOS Applications
 
Thick Application Penetration Testing - A Crash Course
Thick Application Penetration Testing - A Crash CourseThick Application Penetration Testing - A Crash Course
Thick Application Penetration Testing - A Crash Course
 
iOS application (in)security
iOS application (in)securityiOS application (in)security
iOS application (in)security
 
ch4-Software is Everywhere
ch4-Software is Everywherech4-Software is Everywhere
ch4-Software is Everywhere
 
Edge computing in practice using IoT, Tensorflow and Google Cloud
Edge computing in practice using IoT, Tensorflow and Google CloudEdge computing in practice using IoT, Tensorflow and Google Cloud
Edge computing in practice using IoT, Tensorflow and Google Cloud
 
Hacking Tizen : The OS of Everything - Nullcon Goa 2015
Hacking Tizen : The OS of Everything - Nullcon Goa 2015Hacking Tizen : The OS of Everything - Nullcon Goa 2015
Hacking Tizen : The OS of Everything - Nullcon Goa 2015
 
Mobile Security Assessment: 101
Mobile Security Assessment: 101Mobile Security Assessment: 101
Mobile Security Assessment: 101
 
Pentesting iPhone applications
Pentesting iPhone applicationsPentesting iPhone applications
Pentesting iPhone applications
 
iOS Client Side Analysis
iOS Client Side AnalysisiOS Client Side Analysis
iOS Client Side Analysis
 
Pentesting Mobile Applications (Prashant Verma)
Pentesting Mobile Applications (Prashant Verma)Pentesting Mobile Applications (Prashant Verma)
Pentesting Mobile Applications (Prashant Verma)
 
Thick Application Penetration Testing: Crash Course
Thick Application Penetration Testing: Crash CourseThick Application Penetration Testing: Crash Course
Thick Application Penetration Testing: Crash Course
 
[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...
[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...
[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...
 
Please, Please, PLEASE Defend Your Mobile Apps!
Please, Please, PLEASE Defend Your Mobile Apps!Please, Please, PLEASE Defend Your Mobile Apps!
Please, Please, PLEASE Defend Your Mobile Apps!
 
Architectural Patterns in IoT Cloud Platforms
Architectural Patterns in IoT Cloud PlatformsArchitectural Patterns in IoT Cloud Platforms
Architectural Patterns in IoT Cloud Platforms
 
2022 APIsecure_Are your APIs Rugged Enough?
2022 APIsecure_Are your APIs Rugged Enough?2022 APIsecure_Are your APIs Rugged Enough?
2022 APIsecure_Are your APIs Rugged Enough?
 
Evaluating iOS Applications
Evaluating iOS ApplicationsEvaluating iOS Applications
Evaluating iOS Applications
 

Más de Cyber Security Alliance

Killing any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureKilling any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented feature
Cyber Security Alliance
 

Más de Cyber Security Alliance (20)

Bug Bounty @ Swisscom
Bug Bounty @ SwisscomBug Bounty @ Swisscom
Bug Bounty @ Swisscom
 
Robots are among us, but who takes responsibility?
Robots are among us, but who takes responsibility?Robots are among us, but who takes responsibility?
Robots are among us, but who takes responsibility?
 
iOS malware: what's the risk and how to reduce it
iOS malware: what's the risk and how to reduce itiOS malware: what's the risk and how to reduce it
iOS malware: what's the risk and how to reduce it
 
Why huntung IoC fails at protecting against targeted attacks
Why huntung IoC fails at protecting against targeted attacksWhy huntung IoC fails at protecting against targeted attacks
Why huntung IoC fails at protecting against targeted attacks
 
Corporations - the new victims of targeted ransomware
Corporations - the new victims of targeted ransomwareCorporations - the new victims of targeted ransomware
Corporations - the new victims of targeted ransomware
 
Blockchain for Beginners
Blockchain for Beginners Blockchain for Beginners
Blockchain for Beginners
 
Le pentest pour les nuls #cybsec16
Le pentest pour les nuls #cybsec16Le pentest pour les nuls #cybsec16
Le pentest pour les nuls #cybsec16
 
Introducing Man in the Contacts attack to trick encrypted messaging apps
Introducing Man in the Contacts attack to trick encrypted messaging appsIntroducing Man in the Contacts attack to trick encrypted messaging apps
Introducing Man in the Contacts attack to trick encrypted messaging apps
 
Understanding the fundamentals of attacks
Understanding the fundamentals of attacksUnderstanding the fundamentals of attacks
Understanding the fundamentals of attacks
 
Rump : iOS patch diffing
Rump : iOS patch diffingRump : iOS patch diffing
Rump : iOS patch diffing
 
An easy way into your sap systems v3.0
An easy way into your sap systems v3.0An easy way into your sap systems v3.0
An easy way into your sap systems v3.0
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande Modem
 
Easy public-private-keys-strong-authentication-using-u2 f
Easy public-private-keys-strong-authentication-using-u2 fEasy public-private-keys-strong-authentication-using-u2 f
Easy public-private-keys-strong-authentication-using-u2 f
 
Create a-strong-two-factors-authentication-device-for-less-than-chf-100
Create a-strong-two-factors-authentication-device-for-less-than-chf-100Create a-strong-two-factors-authentication-device-for-less-than-chf-100
Create a-strong-two-factors-authentication-device-for-less-than-chf-100
 
Offline bruteforce attack on wi fi protected setup
Offline bruteforce attack on wi fi protected setupOffline bruteforce attack on wi fi protected setup
Offline bruteforce attack on wi fi protected setup
 
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
 
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScriptWarning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
 
Killing any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureKilling any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented feature
 
Rump attaque usb_caralinda_fabrice
Rump attaque usb_caralinda_fabriceRump attaque usb_caralinda_fabrice
Rump attaque usb_caralinda_fabrice
 
Operation emmental appsec
Operation emmental appsecOperation emmental appsec
Operation emmental appsec
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
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
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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...
 
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
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
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
 
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
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

ASFWS 2012 - Audit d’applications iOS par Julien Bachmann

  • 1. iOS applications auditing AppSec Forum Western Switzerland Julien Bachmann / julien@scrt.ch
  • 2. Motivations › Quick review of the environment › Common flaws › Information gathering › Network analysis › Software reverse engineering
  • 3. Preamble › Security engineer @ SCRT › Teacher @ HEIG-VD › Areas of interest focused on reverse engineering, software vulnerabilities, mobile devices security and OS internals › Not an Apple fanboy › But like all the cool kids... › Goals › This presentation aims at sharing experience and knowledge in iOS apps pentesting › Contact › @milkmix_
  • 4. motivations | why ? › More and more applications › Most of Fortune-500 are deploying iPads › Growth in mobile banking › Mobile eShop › Internal applications › Need for security › Access and storage of sensitive information › Online payments
  • 5. environment | devices › Latest devices › Apple A5 / A5X / A6 / A6X › Based on ARMv7 specifications › Processor › RISC › Load-store architecture › Fixed length 32-bits instructions
  • 6. environment | simulator › Beware › Simulator != emulator › More like a sandbox › Code compiled for Intel processors › 32-bits › ~/Library/Application Support/iPhone Simulator/<v>/Applications/<id>/
  • 7. environment | applications › Localisation › ~/Music/iTunes/iTunes Music/Mobile Applications/ › /var/mobile/Applications/<guid>/<appname>.app/ › .ipa › Used to deploy applications › Zip file
  • 8. environment | applications › .plist › Used to store properties › XML files, sometimes in a binary format › Associates keys (CFString, CFNumber, …) with values › plutil (1) › Convert binary plist file to its XML representation
  • 9. flaws | communication snooping › Secure by default › Well... at least if the developer is using URLs starting with HTTPS:// › Even if a fake certificate is presented ! › The DidFailWithError method is called
  • 10. flaws | communication snooping › Ok, but what about real life ? › A lot of development environments are using self-signed certificates › No built-in method to include certificates in the simulator › Obviously, what did the developers ? › Let's check what's on stackoverflow.com...
  • 11. flaws | communication snooping › How to (potentialy) wreak havoc › Implement the two following delegates only to bypass certificates validation › CanAuthenticateAgainstProtectionSpace › DidReceiveAuthenticationChallenge
  • 12. flaws | data storage › Most applications are working connected › Still some information locally stored › plist › SQLite3 databases › ... › Could include sensitive data › Built-in protection › Data Protection API since iOS 4.0 › http://code.google.com/p/iphone-dataprotection/ › New attributes when working on files, Keychain entries or databases › Automatically used when calling NSURLCredentialStorage:setDefaultCredential but could not change protection type
  • 13. flaws | data storage Attribute Definition kSecAttrAccessibleWhenUnlocked Only if unlocked kSecAttrAccessibleAfterFirstUnlock Unlocked at least once kSecAttrAccessibleAlways Do not use Data Protection API kSecAttrAccessibleWhenUnlockedThisDeviceOnly Only if unlocked, but do not store in backups kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly Unlocked at least once, but do not store in backups kSecAttrAccessibleAlwaysThisDeviceOnly Do not store in backups
  • 14. flaws | data storage › Cryptographic primitives › Common Crypto Library › CCCrypt() › kCCEncrypt › kCCDecrypt
  • 15. flaws | information disclosure › The previous seems obvious, but... › Logs ? › Automagically created files ?
  • 16. flaws | external interactions › Files handling › CFBundleDocumentTypes in Info.plist › IPC-like mechanism › URIs handlers › CFBundleURLTypes in Info.plist › Implementation of handleOpenURL or OpenURL
  • 17. flaws | external interactions › Memory management vulnerabilities › Objective-C classes are well protected › Still possible to introduce vulnerabilities if developing custom parsing functions for homegrown protocol › Beware to the old threats : format strings › Most likely result : app crash due to software exploitation protections › HTML / Javascript injection › UIWebView controller used to render web pages › More related to server side vulnerabilities
  • 18. flaws | server side › Most of the time, included in the scope of the audit › Lot of applications are communicating with web-services › Common flaws › No need to present the Top10
  • 19. info gathering | apple's tools › First idea most people will have › Let's jailbreak it ! › There is another way › Stealthier to do a first recon › Still, jailbreaking the auditor's device is mandatory › Kudos to the jailbreakers teams for their work !
  • 20. info gathering | apple's tools › Activate developer mode
  • 21. info gathering | apple's tools › Access application's files › Only works for applications compiled in debug mode
  • 22. info gathering | apple's tools › Console / Application's logs
  • 23. info gathering | getting access to the device › Now you can do it › Enough documentation on jailbreaking online › Personnal choice › Create a firmware with the smalest footprint as jailbreak detection mechanisms mostly check for Cydia presence › Use device that can be pwned using bootloader vulnerability in DFU mode › Use tcprelay.py relying on usbmux to ssh to the device through the usb cable
  • 24. info gathering | keychain items › Keychain Dumper › https://github.com/ptoomey3/Keychain-Dumper
  • 25. network analysis | communication snooping › Main idea › Use {burp ;zap ;...} to intercept the trafic and manipulate it › Problem › What about if the developers are using SSL and best-practices ?
  • 26. network analysis | communication snooping › If you are doing an assignment mixing pentest and code review › Use the Simulator › Certificates store › Based on a SQLite3 database › ~/Library/Application Support/iPhone Simulator/<sdk>/Library/Keychains/TrustStore.sqlite3 › GDSSecurity released a script automating the insertion of x509 certificates in the database › https://github.com/GDSSecurity/Add-Trusted-Certificate-to-iOS-Simulator
  • 27. network analysis | communication snooping › Using a device › Generate CA and sign certificate › Upload the CA to the device using Apple Configurator
  • 28. network analysis | communication snooping › Won't go further on this subject › Joins classic web service pentesting › Except you are using a specific application and not a browser
  • 29. reverse engineering | why ? › Pentesting is not code review › If you want to understand an application behavior you have to reverse it › Static › Hexdump › otool › IDA Pro › Hopper › Dynamic › GDB
  • 33. reverse engineering | need to know › Architecture › File format for Objective-C executables › ARM basics › Language › Objective-C basics › ARM assembly basics › AppStore › How to decrypt AppStore binaries
  • 34. reverse engineering | appstore › Applications from the AppStore are encrypted › DRM › Fair Play like › Do it manually › GDB, set, go ! › Automatic › Crackulous (won't work on executables compiled with PIE) › Clutch
  • 35. reverse engineering | obj-c to arm › Objective-C › [ObjectPointer Method:42] › C++ equivalent › ObjectPointer->Method(42) › Pseudo C generated by the compiler › objc_msgSend(ObjectPointer, "Method", 42) › ARM assembly ›
  • 36. reverse engineering | obj-c to arm › Reflective language › Access to own definition › Call methods from names
  • 37. reverse engineering | where to begin ? › Main class › Derived from UIApplicationDelegate › Implements applicationDidFinishLaunching or applicationDidFinishLaunchingWithOptions › Views › Derived from UI*ViewController › Implement viewDidLoad
  • 38. reverse engineering | extracting class info › class-dump
  • 39. reverse engineering | static analysis › Goals › Understand the application's algorithms › Tools › IDA Pro › Hopper › fixobjc.idc to resolve XREFs and parse Obj-C structures › Built-in functionality since version 6.2
  • 40. reverse engineering | dynamic analysis › Goals › Understand the application's algorithms › Allows to tamper data › But data tampering is not done with Burp ? › What happens when the protocol is encrypted ? › Need to find the function encrypting the data › Set breakpoint › Modify the data in-memory
  • 41. reverse engineering | dynamic analysis › GDB › Provided by Apple as part of iOS SDK › Standalone version or gdbserver with gdb version for ARM targets › Advantage of gdbserver is ability to launch GUI applications › Highly recommend gdbinit* by @osxreverser › Entitlement › Binary will not run out-of-the-box on iDevices › Need to add entitlements after extracting ARMv7 binary › ldid to the rescue * http://reverse.put.as/gdbinit/
  • 42. reverse engineering | dynamic analysis
  • 43. reverse engineering | dynamic analysis › Startup › # ~/debugserver-armv7 -x spring <app> › gdb$ set shlib-path-substitutions / /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platf orm/Developer/SDKs/iPhoneOS5.1.sdk/ › gdb$ target remote-macosx localhost:1999 › gdb$ source ~/gdbinit8 › gdb$ b [InsomniOneViewController viewDidLoad] › gdb$ c › gdb$ regarm
  • 44. reverse engineering | dynamic analysis › Warning
  • 45. reverse engineering | dynamic analysis › Inspect / modify memory › gdb$ po $r2 › gdb$ set {int}0xcafebabe = 1337 › For large amount of data › $ cat data.mod | hexdump -ve '1/4 "set {unsigned char *}( <addr> + %#2_ax) = %#02xn"' > data.gdb
  • 46. reverse engineering | instrumentation › Automating an attack › Suppose you found something (SQL injection, …) › Possible to call methods using gdb's call directive › Too slow to modify data on the fly by hands › Solution › Use code injection to modify the behaviour of the application › Modify data automagically
  • 47. reverse engineering | instrumentation › This is where you start loving Objective-C › Hooking is a bundled feature › It's called 'swizzling' › Principle › Use the functions provided by Apple, like › class_replaceMethod › method_exchangeimplementations
  • 48. reverse engineering | instrumentation
  • 49. reverse engineering | instrumentation
  • 50. reverse engineering | instrumentation › Injecting into process › DYLD_PRELOAD for stand-alone launch › DYLD_INSERT_LIBRARIES and SpringBoard.plist modification to inject in all graphical applications