SlideShare a Scribd company logo
1 of 60
Author(s): Ömer Coşkun & Mark de Groot
iOS Hacking: Advanced Pentest & Forensic
Techniques
The supreme art of war is to subdue the enemy without fighting. Sun Tzu
$ whoami
Ömer Coşkun (@0xM3R)
 BEng. Computer Science
Research Assistant in
Quantum Cryptography
& Advanced Topics in AI
2
Industry Experience
KPN – CISO , Ethical
Hacking
Verizon – Threat &
Vulnerability Management
IBM ISS – Threat Intelligence
Interests
Algorithm Design, Programming, Cryptography,
Reverse Engineering, Malware Analysis, OS
Internals, Rootkits
Mark de Groot(@markos1979)
 Industry Experience
KPN – CISO , Ethical Hacking
 Interests
Programming, Cryptography,
Reverse Engineering,
Software Explotation, CTF,
Rfid, SDR
Outline
 Overview
 Motivation
 iOS Security Architecture
 Application Sandbox and SandBox Profiles
 File System Encryption
 iOS Application Reverse Engineering
 iOS 64 bit App Static/Dynamic Analysis
 Hunting for RSA Keys
 iOS Application Penetration Testing
 Application Communication Interception
 Atomizing Pentesting
 Q/A
 Questions ?
3
Motivations
4Analyze existing security mechanism on iOS platform
and circumvention techniques
Automate and speed up mobile penetration tests
Surveillance implants shifted focus to mobile devices
Mobile applications are evolving and tied to
monetary: iOS Mobile Payments, Paypal SDK etc.
iOS Rootkits are not only a theory anymore
Reverse Engineering on ARM Environment is Fun!
iOS Security Architecture
5
 Every app on iOS requires signing information
 Signature information within LC_CODE_SIGNATURE
 SHA1 signature verification (memory pages)
iOS System Security
 Secure BootChain : components signed by Apple
 System software authorization: Firmware
downgrade protection
 Secure Enclave: Apple A7 processors memory
encryption
 TouchID: PassCode Replacement
 KeyBags: Used for system,backup, iCloud Backups
iOS Security Architecture
6
http://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-818.pdf
How does iOS SandBox Work?
7
Source: http://dl.packetstormsecurity.net/papers/general/apple-
sandbox.pdf
How does iOS SandBox Work?
8
How does iOS SandBox Work?
9
Sample SandBox Usage:
iOS Sandbox Profiles (Documented)
kSBXProfileNoInternet
kSBXProfileNoNetwork
kSBXProfileNoWrite
kSBXProfileNoWriteExceptTemporary
kSBXProfilePureComputation
iOS Sandbox Profiles (Undocumented)
sandbox-compilerd
mDNSResponder
apsd
AppleDiags
PasteBoard
Container
MobileSafari
MobileMail
MobileMaps
File Encryption Mechanism
 Every file encrypted with a unique key
 Data Protection engine creates each time AES CBC 256-bit
key and SHA-1 hash per file
 File key stored within the file metadata
 Metadata of all files in the file system is encrypted with a
random key (iOS 1st
installation)
 Per file key unwrapped from Class Key, then supplied to AES
engine
iOS : File System Encryption
10
iOS : File System Encryption (cont’d)
11File API Class
NsFileProtectionNone
NsFileProtectionComplete
NsFileProtectionComplete
UnlessOpen
NsFileProtectionComplete
UntilFirstUserAuthentication
Security Attributes
kSecAttrAccessibleWhenUnlocked
kSecAttrAccessibleAfterFirstUnlock
kSecAttrAccessibleAlways
kSecAttrAccessibleWhenUnlocked
ThisDeviceOnly
kSecAttrAccessibleAfterFirstUnlock
ThisDeviceOnly
kSecAttrAccessibleAlwaysThisDevi
ceOnlyFile Protector with NSData:
File Protector with NSFileManager:
iOS : File System Encryption (cont’d)
Escrow KeyBag Location
/private/var/db/lockdown/
iTunes Backup Location
~/Library/Application Support/MobileSync/Backup/
 Passcode can be brute-forced
 Open Source and Commercial Backup Decryptors
12
iOS : Macoff File Structure
13
struct segment_command_64
{ uint32_t cmd; uint32_t cmdsize;
char segname[16]; uint64_t
vmaddr; uint64_t vmsize;
uint64_t fileoff; uint64_t filesize;
vm_prot_t maxprot; vm_prot_t
initprot; uint32_t nsects; uint32_t
flags; };
https://developer.apple.com/library/mac/documentation/DeveloperT
ools/Conceptual/MachORuntime/index.html
pentestBox:/private/var/mobile/Applications/2587B469-0147-4793-86CE-
B41A1C4468DC/banking.app root# otool -l BankingApp| grep crypt
cryptoff 16384
cryptsize 835584
cryptid 1
Decrypting Binaries (32-bit)
14
cryptoff 16384 -> 0x4000
cryptsize 835584 -> 0xCC000
0x4000 (vm address) + 0x4000 (crypt off) = 0x8000
0x4000 (vm address) + 0x4000 (crypt off) + 0xCC000 (crypt size) = 0xD4000
(gdb) dump memory dump.bin 0x8000 0xD4000 <-- Encrypted binary section
pentestBox:/private/var/mobile/Applications/2587B469-0147-4793-86CE-
B41A1C4468DC/banking.app root# otool -l BankingApp| grep crypt
cryptoff 16384
cryptsize 835584
cryptid 1
Decrypting Binaries (64-bit)
15
cryptoff 16384 -> 0x4000
cryptsize 835584 -> 0xCC000
0x4000 (vm address) + 0x4000 (crypt off) = 0x8000
0x4000 (vm address) + 0x4000 (crypt off) + 0xCC000 (crypt size) = 0xD4000
(lldb) memory read --outfile /tmp/dump.bin –binary 0x8000 0xD4000 <--
Encrypted binary section
Remote debugging : Running debugserver on iOS – running LLDB on Mac
Getting the Debugger running
16All you need are stored under the Xcode IDE directories
Obtain the debug server binary
$ hdiutil attach
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSu
pport/7.1/DeveloperDiskImage.dmg
Create an entity file for debugserver binary signing with following
content
Getting the Debugger running
17
Sign your debugserver binary
and upload it to jailbroken iOS pentest device
Attach target binary for remote debugging
Getting the Debugger running
18
Make sure correct SDK path selected and connect to device:
Stopped thread list available if debuggger connect is made correctly
Debugging x64 iOS App
19
Reversing iOS should be easy in an ideal world :
Malware reversers would know what I mean :)
Reversing iOS Apps
20
IDA Pro correctly resolves the function names as well as
the cross references.
Reversing iOS Apps: Sainte Ida de
Louvain
21
Source: https://www.hex-rays.com/products/ida/
Check for interesting function calls as all the imports are
correctly resolved.
Reversing iOS Apps: Dealing with
Crpyto
22
It seems the application evaluates the certificate here.
Reversing iOS Apps: Dealing with
Crypto
23
https://developer.apple.com/l
ibrary/mac/documentation/S
ecurity/Reference/certifkeytru
stservices/index.html
Check the function prototypes and the definition on Apple Dev.
Data content is being encrypted using public key
before sending it to server.
Reversing iOS Apps: Dealing with
Crypto
24
Calling Convention : C++
ObjectPointer->Function(parameters)
Calling Convention : Objective C
[ObjectPointer Function:parameters]
Reversing iOS Apps: Hunting for
Public Key
25The following function evaluates the certificate .
Check the function prototypes and the definition on Apple Dev.
https://developer.apple.com/l
ibrary/mac/documentation/S
ecurity/Reference/certifkeytru
stservices/index.html
26Cross-references definitely help.
So do the constants and the debug strings. 
Reversing iOS Apps: Hunting for
Public Key
27Preparation for file encryption is literally being done
here.
Reversing iOS Apps: Hunting for
Public Key
Reversing iOS Apps: Hunting for
Public Key
28
Short cheat sheet on LLDB for GDB
junkies.
LLDB Command
(lldb) memory read --outfile
/tmp/mem.bin --binary 0x1000 0x2000
(lldb) disassemble --frame
(lldb) di -f
(lldb) disassemble --start-address
0x1eb8 --count 20
(lldb) image list
GDB Command
(gdb) dump memory
/tmp/mem.bin 0x1000 0x2000
(gdb) disassemble
(gdb) x/20i 0x1eb8
(gdb) info shared
Reversing iOS Apps: Hunting for
Public Key
29Preparation for file encryption is literally being done
here.
30I hope it’s clear to everyone what’s happening here
and the purpose of the function. 
Reversing iOS Apps: Hunting for
Public Key
How to Reversing on iOS Env?
31
Reversing iOS Apps: Hunting for
Public Key
32Set breakpoint to target function and then run until
private keys are pushed into memory.
Dump the memory to a writable location by LLDB debugger .
Memory dump should contain the data we were looking for.
iOS Apps Penetration Testing
33
https://www.owasp.org/index.php/OWASP_Mobile_Security_Project#tab=Top_10_M
obile_Risks
iOS Apps Penetration Testing
34
https://www.owasp.org/index.php/IOS_Application_Security_Testing_Chea
t_Sheet
iOS Apps Penetration Testing:
Network Traffic Analysis
35
https://www.wireshark.org/
iOS Apps Penetration Testing:
Network Traffic Analysis
36
Cacoa Packet
Analyzer:
www.tastycoco
abytes.com/cp
a/
Appeals to MAC funs; unlike WireShark, it doesn’t require
additional libraries such as XQuartz to be installed.
SSL Interception: Function Hooks
37Standard SSLRead function provided by iOS SDK .
iOS Dev Center:
https://develop
er.apple.com/li
brary/mac/doc
umentation/Se
curity/Referenc
e/secureTransp
ortRef/
SSL Interception: Function Hooks
38Standard SSLWrite function provided by iOS SDK .
iOS Dev Center:
https://develop
er.apple.com/li
brary/mac/doc
umentation/Se
curity/Referenc
e/secureTransp
ortRef/
SSL Interception: Function Hooks
39How does a simple implementation of a function hook
implementation on iOS envrionment looks like ?
MSHookFunction ((void *) SSLWrite, (void *) _
hook_SSLWrite, (void **) & call_to_REAL_SSLWrite);
MSHookFunction ((void *) SSLRead, (void *) _
hook_SSLRead, (void **) & call_to_REAL_SSLRead);
SSL Interception: Function Hooks
40Create a hook that will intercept the SSL communication by
hooking application level read/write operation functions .
Hardware/Software
Interception: Captain
Hook Style Hacking 41
Captain Hook Style Hacking: Intercepts 
every function, keeps a copy of the content for herself,  
and then let the function continue as it was supposed to 
… 
SSL Interception: Function Hooks
42
SSL Interception: Function Hooks
43What if some people implements hook functions not only to
see SSL traffic , but rather to reach hardware resources?
This is beyond the
conspiracy theories: for
real!
44
Iphone Rootkit CookBook
45A The following code detects the audio stream.
Source Code:Tripware:
http://www.tripwire.com/state-of-security/vulnerability-
management/creating-iphone-rootkits-and-like-the-nsas-dropout-jeep/
Iphone Rootkit CookBook
(cont’d)
46A Sample hook for enabling iPhone Microphone.
Source Code:Tripware:
http://www.tripwire.com/state-of-security/vulnerability-
management/creating-iphone-rootkits-and-like-the-nsas-dropout-jeep/
Burp Suite: Atomize Everything
47
Burp Suite: http://portswigger.net/burp/
More than standard application communication interception.
Burp Extensions: Installation
Suggested and Most Preferred Way : Burp Suite >Extensions >
BAppStore
Some Extensions require Pro version (not because they
discriminate poor but due to API/functional limitation  )
 Some Extensions have 3rd
party dependencies or wrapper of 3rd
apllication (e.g. PhantomJS, Radamsa etc)
48
How Extensions Work (cont’d)
Class Name Purpose
BurpExtender To write our own extension
BurpExtenderCallBacks To pass to extensions a set of
callback (register actions, mark)
ICookie To retrieve the domain for which
the cookie is in scope
IHTTPRequestResponse To retrieve and update details
about HTTP messages.
IScanIssue To retrieve details of Scanner
issues
IScanQueueItem To retrieve details of items in the
active scan queue.
IScannerInsertionPoint To define an insertion point for
use by active Scanner checks.
IntroderPayloadProcessor To obtain the name of the
payload processor
49
Burp Extensions in a NutShell
Extension Name Purpose
.NET Beautifier Makes VIEWState info human readable
ActiveScan++ Extend passive scanning , path injection,
shellshock etc.
Blazer Generate and fuzz custom AMF messages
Bradamsa Generate intruder payload wisely 
CO2 Set of useful tools : sqlmapper, user generator,
prettier js, ascii payload processor etc.
Logger++ An extension of history feature in Burp; more
detailed and comprehensive
Session Auth Help to identify privilege escalation vulns
WebInspect Connector Newly built, share results between burp and
webinspect
50
Burp Extensions : Additional Scanner Checks
Additional passive Scanner checks: Strict-Transport-
Security, X-Content-Type, X-XSS-Protection. In other
words, checks the modern browser security headers.
51
Burp Extensions : Session Auth
 To Identify authentication privilege escalation
vulnerabilities.
52
Burp Extensions : CO2
53 Set of useful tools : sqlmapper, user generator, prettier js,
ascii payload processor etc.
Fully Automated XSS Verification
 xssValidator extension of Burp Suite could be
leveraged to fully automate XSS verification process.
54
Fully Automated XSS Verification
55 Before starting the XSS verification process, we need
to install at least one wrapper to support extension .
 Enable the payload extension after running wrapper.
Fully Automated XSS Verification
56Enable payload processing unit for xssVerifier.
 Finally, create a grep-and-match rule for intruder.
Fully Automated XSS Verification
57Content of xss.js
Fully Automated XSS Verification
58Let the fun begin 
59Questions ?
60

More Related Content

What's hot

Pentesting iOS Apps - Runtime Analysis and Manipulation
Pentesting iOS Apps - Runtime Analysis and ManipulationPentesting iOS Apps - Runtime Analysis and Manipulation
Pentesting iOS Apps - Runtime Analysis and ManipulationAndreas Kurtz
 
I Want More Ninja – iOS Security Testing
I Want More Ninja – iOS Security TestingI Want More Ninja – iOS Security Testing
I Want More Ninja – iOS Security TestingJason Haddix
 
Pentesting iOS Applications
Pentesting iOS ApplicationsPentesting iOS Applications
Pentesting iOS Applicationsjasonhaddix
 
Pentesting iPhone applications
Pentesting iPhone applicationsPentesting iPhone applications
Pentesting iPhone applicationsSatish b
 
Yow connected developing secure i os applications
Yow connected   developing secure i os applicationsYow connected   developing secure i os applications
Yow connected developing secure i os applicationsmgianarakis
 
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
 
iOS Security and Encryption
iOS Security and EncryptioniOS Security and Encryption
iOS Security and EncryptionUrvashi Kataria
 
Dark Side of iOS [SmartDevCon 2013]
Dark Side of iOS [SmartDevCon 2013]Dark Side of iOS [SmartDevCon 2013]
Dark Side of iOS [SmartDevCon 2013]Kuba Břečka
 
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
 
iPhone forensics on iOS5
iPhone forensics on iOS5iPhone forensics on iOS5
iPhone forensics on iOS5Satish b
 
Jailbreaking iOS
Jailbreaking iOSJailbreaking iOS
Jailbreaking iOSKai Aras
 
Mobile Security Assessment: 101
Mobile Security Assessment: 101Mobile Security Assessment: 101
Mobile Security Assessment: 101wireharbor
 
CNIT 128 2. Analyzing iOS Applications (Part 1)
CNIT 128 2. Analyzing iOS Applications (Part 1)CNIT 128 2. Analyzing iOS Applications (Part 1)
CNIT 128 2. Analyzing iOS Applications (Part 1)Sam Bowne
 
Pentesting web applications
Pentesting web applicationsPentesting web applications
Pentesting web applicationsSatish b
 
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
 
Iphone Presentation for MuMe09
Iphone Presentation for MuMe09Iphone Presentation for MuMe09
Iphone Presentation for MuMe09Gonzalo Parra
 
Introduction to iOS Penetration Testing
Introduction to iOS Penetration TestingIntroduction to iOS Penetration Testing
Introduction to iOS Penetration TestingOWASP
 

What's hot (20)

Pentesting iOS Apps - Runtime Analysis and Manipulation
Pentesting iOS Apps - Runtime Analysis and ManipulationPentesting iOS Apps - Runtime Analysis and Manipulation
Pentesting iOS Apps - Runtime Analysis and Manipulation
 
I Want More Ninja – iOS Security Testing
I Want More Ninja – iOS Security TestingI Want More Ninja – iOS Security Testing
I Want More Ninja – iOS Security Testing
 
Pentesting iOS Applications
Pentesting iOS ApplicationsPentesting iOS Applications
Pentesting iOS Applications
 
Pentesting iPhone applications
Pentesting iPhone applicationsPentesting iPhone applications
Pentesting iPhone applications
 
Pentesting iOS Apps
Pentesting iOS AppsPentesting iOS Apps
Pentesting iOS Apps
 
Yow connected developing secure i os applications
Yow connected   developing secure i os applicationsYow connected   developing secure i os applications
Yow connected developing secure i os applications
 
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
 
iOS Security and Encryption
iOS Security and EncryptioniOS Security and Encryption
iOS Security and Encryption
 
Dark Side of iOS [SmartDevCon 2013]
Dark Side of iOS [SmartDevCon 2013]Dark Side of iOS [SmartDevCon 2013]
Dark Side of iOS [SmartDevCon 2013]
 
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
 
iPhone forensics on iOS5
iPhone forensics on iOS5iPhone forensics on iOS5
iPhone forensics on iOS5
 
Jailbreaking iOS
Jailbreaking iOSJailbreaking iOS
Jailbreaking iOS
 
Mobile Security Assessment: 101
Mobile Security Assessment: 101Mobile Security Assessment: 101
Mobile Security Assessment: 101
 
OWASP for iOS
OWASP for iOSOWASP for iOS
OWASP for iOS
 
iOS Application Exploitation
iOS Application ExploitationiOS Application Exploitation
iOS Application Exploitation
 
CNIT 128 2. Analyzing iOS Applications (Part 1)
CNIT 128 2. Analyzing iOS Applications (Part 1)CNIT 128 2. Analyzing iOS Applications (Part 1)
CNIT 128 2. Analyzing iOS Applications (Part 1)
 
Pentesting web applications
Pentesting web applicationsPentesting web applications
Pentesting web applications
 
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...
 
Iphone Presentation for MuMe09
Iphone Presentation for MuMe09Iphone Presentation for MuMe09
Iphone Presentation for MuMe09
 
Introduction to iOS Penetration Testing
Introduction to iOS Penetration TestingIntroduction to iOS Penetration Testing
Introduction to iOS Penetration Testing
 

Viewers also liked

PTES: PenTest Execution Standard
PTES: PenTest Execution StandardPTES: PenTest Execution Standard
PTES: PenTest Execution StandardSource Conference
 
Bringing SDR to the pentest community - BlackHat USA 2014
Bringing SDR to the pentest community - BlackHat USA 2014Bringing SDR to the pentest community - BlackHat USA 2014
Bringing SDR to the pentest community - BlackHat USA 2014jmichel.p
 
Mobile hacking, pentest, and malware
Mobile hacking, pentest, and malwareMobile hacking, pentest, and malware
Mobile hacking, pentest, and malwareAmmar WK
 
Jamie Bowser - A Touch(ID) of iOS Security
Jamie Bowser - A Touch(ID) of iOS SecurityJamie Bowser - A Touch(ID) of iOS Security
Jamie Bowser - A Touch(ID) of iOS Securitycentralohioissa
 
iOS Forensics: Overcoming iPhone Data Protection
iOS Forensics: Overcoming iPhone Data ProtectioniOS Forensics: Overcoming iPhone Data Protection
iOS Forensics: Overcoming iPhone Data ProtectionAndrey Belenko
 
webhacking
webhackingwebhacking
webhackingAmmar WK
 
iOS secure app development
iOS secure app developmentiOS secure app development
iOS secure app developmentDusan Klinec
 
Playin with Password
Playin with PasswordPlayin with Password
Playin with PasswordAmmar WK
 
Proof Of Concept (PoC) CTF Hack The Dragon Ultah Indonesian BackTrack Team 2015
Proof Of Concept (PoC) CTF Hack The Dragon Ultah Indonesian BackTrack Team 2015Proof Of Concept (PoC) CTF Hack The Dragon Ultah Indonesian BackTrack Team 2015
Proof Of Concept (PoC) CTF Hack The Dragon Ultah Indonesian BackTrack Team 2015Taqrim Ibadi
 
Exploit Development with Python
Exploit Development with PythonExploit Development with Python
Exploit Development with PythonThomas Gregory
 
Automation of Penetration Testing
Automation of Penetration TestingAutomation of Penetration Testing
Automation of Penetration TestingHaydn Johnson
 
Keynote - Jim Geovedi - professional-hackers
Keynote - Jim Geovedi - professional-hackersKeynote - Jim Geovedi - professional-hackers
Keynote - Jim Geovedi - professional-hackersidsecconf
 
Muhammad Abrar Istiadi - How to hack #idsecconf2016 Online CTF
Muhammad Abrar Istiadi - How to hack #idsecconf2016 Online CTFMuhammad Abrar Istiadi - How to hack #idsecconf2016 Online CTF
Muhammad Abrar Istiadi - How to hack #idsecconf2016 Online CTFidsecconf
 

Viewers also liked (20)

Pentest with Metasploit
Pentest with MetasploitPentest with Metasploit
Pentest with Metasploit
 
PTES: PenTest Execution Standard
PTES: PenTest Execution StandardPTES: PenTest Execution Standard
PTES: PenTest Execution Standard
 
Bringing SDR to the pentest community - BlackHat USA 2014
Bringing SDR to the pentest community - BlackHat USA 2014Bringing SDR to the pentest community - BlackHat USA 2014
Bringing SDR to the pentest community - BlackHat USA 2014
 
Mobile hacking, pentest, and malware
Mobile hacking, pentest, and malwareMobile hacking, pentest, and malware
Mobile hacking, pentest, and malware
 
Prepare Yourself to Become Infosec Professional
Prepare Yourself to Become Infosec ProfessionalPrepare Yourself to Become Infosec Professional
Prepare Yourself to Become Infosec Professional
 
Jamie Bowser - A Touch(ID) of iOS Security
Jamie Bowser - A Touch(ID) of iOS SecurityJamie Bowser - A Touch(ID) of iOS Security
Jamie Bowser - A Touch(ID) of iOS Security
 
iOS Forensics: Overcoming iPhone Data Protection
iOS Forensics: Overcoming iPhone Data ProtectioniOS Forensics: Overcoming iPhone Data Protection
iOS Forensics: Overcoming iPhone Data Protection
 
Cracking CTFs - Sysbypass CTF Walkthrough
Cracking CTFs - Sysbypass CTF WalkthroughCracking CTFs - Sysbypass CTF Walkthrough
Cracking CTFs - Sysbypass CTF Walkthrough
 
eMAPT
eMAPTeMAPT
eMAPT
 
webhacking
webhackingwebhacking
webhacking
 
iOS secure app development
iOS secure app developmentiOS secure app development
iOS secure app development
 
Demystifying Apple 'Pie' & TouchID
Demystifying Apple 'Pie' & TouchIDDemystifying Apple 'Pie' & TouchID
Demystifying Apple 'Pie' & TouchID
 
Playin with Password
Playin with PasswordPlayin with Password
Playin with Password
 
Proof Of Concept (PoC) CTF Hack The Dragon Ultah Indonesian BackTrack Team 2015
Proof Of Concept (PoC) CTF Hack The Dragon Ultah Indonesian BackTrack Team 2015Proof Of Concept (PoC) CTF Hack The Dragon Ultah Indonesian BackTrack Team 2015
Proof Of Concept (PoC) CTF Hack The Dragon Ultah Indonesian BackTrack Team 2015
 
Exploit Development with Python
Exploit Development with PythonExploit Development with Python
Exploit Development with Python
 
Automation of Penetration Testing
Automation of Penetration TestingAutomation of Penetration Testing
Automation of Penetration Testing
 
Keynote - Jim Geovedi - professional-hackers
Keynote - Jim Geovedi - professional-hackersKeynote - Jim Geovedi - professional-hackers
Keynote - Jim Geovedi - professional-hackers
 
Muhammad Abrar Istiadi - How to hack #idsecconf2016 Online CTF
Muhammad Abrar Istiadi - How to hack #idsecconf2016 Online CTFMuhammad Abrar Istiadi - How to hack #idsecconf2016 Online CTF
Muhammad Abrar Istiadi - How to hack #idsecconf2016 Online CTF
 
Penetrasi Jaringan
Penetrasi JaringanPenetrasi Jaringan
Penetrasi Jaringan
 
Ethical hacking
Ethical hackingEthical hacking
Ethical hacking
 

Similar to iOS Hacking Guide: Advanced Techniques

Mobile security
Mobile securityMobile security
Mobile securityStefaan
 
iOS (Vulner)ability
iOS (Vulner)abilityiOS (Vulner)ability
iOS (Vulner)abilitySubho Halder
 
Outsmarting smartphones
Outsmarting smartphonesOutsmarting smartphones
Outsmarting smartphonesSensePost
 
Synack at AppSec California with Patrick Wardle
Synack at AppSec California with Patrick WardleSynack at AppSec California with Patrick Wardle
Synack at AppSec California with Patrick WardleSynack
 
Mobile Forensics on a Shoestring Budget
Mobile Forensics on a Shoestring BudgetMobile Forensics on a Shoestring Budget
Mobile Forensics on a Shoestring BudgetBrent Muir
 
The Seven Most Dangerous New Attack Techniques, and What's Coming Next
The Seven Most Dangerous New Attack Techniques, and What's Coming NextThe Seven Most Dangerous New Attack Techniques, and What's Coming Next
The Seven Most Dangerous New Attack Techniques, and What's Coming NextPriyanka Aash
 
The Seven Most Dangerous New Attack Techniques, and What's Coming Next
The Seven Most Dangerous New Attack Techniques, and What's Coming NextThe Seven Most Dangerous New Attack Techniques, and What's Coming Next
The Seven Most Dangerous New Attack Techniques, and What's Coming NextPriyanka Aash
 
Ярослав Воронцов — Пара слов о mobile security.
Ярослав Воронцов — Пара слов о mobile security.Ярослав Воронцов — Пара слов о mobile security.
Ярослав Воронцов — Пара слов о mobile security.DataArt
 
Tsunami of Technologies. Are we prepared?
Tsunami of Technologies. Are we prepared?Tsunami of Technologies. Are we prepared?
Tsunami of Technologies. Are we prepared?msyukor
 
Crisis. advanced malware
Crisis. advanced malwareCrisis. advanced malware
Crisis. advanced malwareYury Chemerkin
 
Hacking Exposed: The Mac Attack
Hacking Exposed: The Mac AttackHacking Exposed: The Mac Attack
Hacking Exposed: The Mac AttackPriyanka Aash
 
Hacking Exposed: The Mac Attack
Hacking Exposed: The Mac AttackHacking Exposed: The Mac Attack
Hacking Exposed: The Mac AttackPriyanka Aash
 
Hacking and Securing iOS Applications by Satish Bomisstty
Hacking and Securing iOS Applications by Satish BomissttyHacking and Securing iOS Applications by Satish Bomisstty
Hacking and Securing iOS Applications by Satish BomissttyClubHack
 
Pwning Windows Mobile applications by Ankit Giri
Pwning Windows Mobile applications by Ankit GiriPwning Windows Mobile applications by Ankit Giri
Pwning Windows Mobile applications by Ankit GiriOWASP Delhi
 
Outsmarting Hackers before your App gets Hacked - iOS Conf SG 2016
Outsmarting Hackers before your App gets Hacked - iOS Conf SG 2016Outsmarting Hackers before your App gets Hacked - iOS Conf SG 2016
Outsmarting Hackers before your App gets Hacked - iOS Conf SG 2016Subho Halder
 
Apple threat-landscape
Apple threat-landscapeApple threat-landscape
Apple threat-landscapeAndrey Apuhtin
 

Similar to iOS Hacking Guide: Advanced Techniques (20)

Mobile security
Mobile securityMobile security
Mobile security
 
iOS (Vulner)ability
iOS (Vulner)abilityiOS (Vulner)ability
iOS (Vulner)ability
 
Outsmarting smartphones
Outsmarting smartphonesOutsmarting smartphones
Outsmarting smartphones
 
Synack at AppSec California with Patrick Wardle
Synack at AppSec California with Patrick WardleSynack at AppSec California with Patrick Wardle
Synack at AppSec California with Patrick Wardle
 
Mobile Forensics on a Shoestring Budget
Mobile Forensics on a Shoestring BudgetMobile Forensics on a Shoestring Budget
Mobile Forensics on a Shoestring Budget
 
The Seven Most Dangerous New Attack Techniques, and What's Coming Next
The Seven Most Dangerous New Attack Techniques, and What's Coming NextThe Seven Most Dangerous New Attack Techniques, and What's Coming Next
The Seven Most Dangerous New Attack Techniques, and What's Coming Next
 
The Seven Most Dangerous New Attack Techniques, and What's Coming Next
The Seven Most Dangerous New Attack Techniques, and What's Coming NextThe Seven Most Dangerous New Attack Techniques, and What's Coming Next
The Seven Most Dangerous New Attack Techniques, and What's Coming Next
 
Ярослав Воронцов — Пара слов о mobile security.
Ярослав Воронцов — Пара слов о mobile security.Ярослав Воронцов — Пара слов о mobile security.
Ярослав Воронцов — Пара слов о mobile security.
 
Tsunami of Technologies. Are we prepared?
Tsunami of Technologies. Are we prepared?Tsunami of Technologies. Are we prepared?
Tsunami of Technologies. Are we prepared?
 
Crisis. advanced malware
Crisis. advanced malwareCrisis. advanced malware
Crisis. advanced malware
 
Hacking Exposed: The Mac Attack
Hacking Exposed: The Mac AttackHacking Exposed: The Mac Attack
Hacking Exposed: The Mac Attack
 
Hacking Exposed: The Mac Attack
Hacking Exposed: The Mac AttackHacking Exposed: The Mac Attack
Hacking Exposed: The Mac Attack
 
News bytes Oct-2011
News bytes  Oct-2011News bytes  Oct-2011
News bytes Oct-2011
 
osi semair.pptx
osi semair.pptxosi semair.pptx
osi semair.pptx
 
Hacking and Securing iOS Applications by Satish Bomisstty
Hacking and Securing iOS Applications by Satish BomissttyHacking and Securing iOS Applications by Satish Bomisstty
Hacking and Securing iOS Applications by Satish Bomisstty
 
Pwning Windows Mobile applications by Ankit Giri
Pwning Windows Mobile applications by Ankit GiriPwning Windows Mobile applications by Ankit Giri
Pwning Windows Mobile applications by Ankit Giri
 
Android sandbox
Android sandboxAndroid sandbox
Android sandbox
 
Nullbyte 6ed. 2019
Nullbyte 6ed. 2019Nullbyte 6ed. 2019
Nullbyte 6ed. 2019
 
Outsmarting Hackers before your App gets Hacked - iOS Conf SG 2016
Outsmarting Hackers before your App gets Hacked - iOS Conf SG 2016Outsmarting Hackers before your App gets Hacked - iOS Conf SG 2016
Outsmarting Hackers before your App gets Hacked - iOS Conf SG 2016
 
Apple threat-landscape
Apple threat-landscapeApple threat-landscape
Apple threat-landscape
 

Recently uploaded

G9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptG9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptMAESTRELLAMesa2
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
Zoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdfZoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdfSumit Kumar yadav
 
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡anilsa9823
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bSérgio Sacani
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRDelhi Call girls
 
Broad bean, Lima Bean, Jack bean, Ullucus.pptx
Broad bean, Lima Bean, Jack bean, Ullucus.pptxBroad bean, Lima Bean, Jack bean, Ullucus.pptx
Broad bean, Lima Bean, Jack bean, Ullucus.pptxjana861314
 
GFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxGFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxAleenaTreesaSaji
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfSumit Kumar yadav
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfSumit Kumar yadav
 
Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Nistarini College, Purulia (W.B) India
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisDiwakar Mishra
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsSérgio Sacani
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsAArockiyaNisha
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...Sérgio Sacani
 
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptxanandsmhk
 
A relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfA relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfnehabiju2046
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxgindu3009
 

Recently uploaded (20)

G9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptG9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.ppt
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
Zoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdfZoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdf
 
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
 
Engler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomyEngler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomy
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
 
Broad bean, Lima Bean, Jack bean, Ullucus.pptx
Broad bean, Lima Bean, Jack bean, Ullucus.pptxBroad bean, Lima Bean, Jack bean, Ullucus.pptx
Broad bean, Lima Bean, Jack bean, Ullucus.pptx
 
GFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxGFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptx
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdf
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdf
 
Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based Nanomaterials
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
 
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
 
A relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfA relative description on Sonoporation.pdf
A relative description on Sonoporation.pdf
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
CELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdfCELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdf
 

iOS Hacking Guide: Advanced Techniques

  • 1. Author(s): Ömer Coşkun & Mark de Groot iOS Hacking: Advanced Pentest & Forensic Techniques The supreme art of war is to subdue the enemy without fighting. Sun Tzu
  • 2. $ whoami Ömer Coşkun (@0xM3R)  BEng. Computer Science Research Assistant in Quantum Cryptography & Advanced Topics in AI 2 Industry Experience KPN – CISO , Ethical Hacking Verizon – Threat & Vulnerability Management IBM ISS – Threat Intelligence Interests Algorithm Design, Programming, Cryptography, Reverse Engineering, Malware Analysis, OS Internals, Rootkits Mark de Groot(@markos1979)  Industry Experience KPN – CISO , Ethical Hacking  Interests Programming, Cryptography, Reverse Engineering, Software Explotation, CTF, Rfid, SDR
  • 3. Outline  Overview  Motivation  iOS Security Architecture  Application Sandbox and SandBox Profiles  File System Encryption  iOS Application Reverse Engineering  iOS 64 bit App Static/Dynamic Analysis  Hunting for RSA Keys  iOS Application Penetration Testing  Application Communication Interception  Atomizing Pentesting  Q/A  Questions ? 3
  • 4. Motivations 4Analyze existing security mechanism on iOS platform and circumvention techniques Automate and speed up mobile penetration tests Surveillance implants shifted focus to mobile devices Mobile applications are evolving and tied to monetary: iOS Mobile Payments, Paypal SDK etc. iOS Rootkits are not only a theory anymore Reverse Engineering on ARM Environment is Fun!
  • 5. iOS Security Architecture 5  Every app on iOS requires signing information  Signature information within LC_CODE_SIGNATURE  SHA1 signature verification (memory pages) iOS System Security  Secure BootChain : components signed by Apple  System software authorization: Firmware downgrade protection  Secure Enclave: Apple A7 processors memory encryption  TouchID: PassCode Replacement  KeyBags: Used for system,backup, iCloud Backups
  • 7. How does iOS SandBox Work? 7 Source: http://dl.packetstormsecurity.net/papers/general/apple- sandbox.pdf
  • 8. How does iOS SandBox Work? 8
  • 9. How does iOS SandBox Work? 9 Sample SandBox Usage: iOS Sandbox Profiles (Documented) kSBXProfileNoInternet kSBXProfileNoNetwork kSBXProfileNoWrite kSBXProfileNoWriteExceptTemporary kSBXProfilePureComputation iOS Sandbox Profiles (Undocumented) sandbox-compilerd mDNSResponder apsd AppleDiags PasteBoard Container MobileSafari MobileMail MobileMaps
  • 10. File Encryption Mechanism  Every file encrypted with a unique key  Data Protection engine creates each time AES CBC 256-bit key and SHA-1 hash per file  File key stored within the file metadata  Metadata of all files in the file system is encrypted with a random key (iOS 1st installation)  Per file key unwrapped from Class Key, then supplied to AES engine iOS : File System Encryption 10
  • 11. iOS : File System Encryption (cont’d) 11File API Class NsFileProtectionNone NsFileProtectionComplete NsFileProtectionComplete UnlessOpen NsFileProtectionComplete UntilFirstUserAuthentication Security Attributes kSecAttrAccessibleWhenUnlocked kSecAttrAccessibleAfterFirstUnlock kSecAttrAccessibleAlways kSecAttrAccessibleWhenUnlocked ThisDeviceOnly kSecAttrAccessibleAfterFirstUnlock ThisDeviceOnly kSecAttrAccessibleAlwaysThisDevi ceOnlyFile Protector with NSData: File Protector with NSFileManager:
  • 12. iOS : File System Encryption (cont’d) Escrow KeyBag Location /private/var/db/lockdown/ iTunes Backup Location ~/Library/Application Support/MobileSync/Backup/  Passcode can be brute-forced  Open Source and Commercial Backup Decryptors 12
  • 13. iOS : Macoff File Structure 13 struct segment_command_64 { uint32_t cmd; uint32_t cmdsize; char segname[16]; uint64_t vmaddr; uint64_t vmsize; uint64_t fileoff; uint64_t filesize; vm_prot_t maxprot; vm_prot_t initprot; uint32_t nsects; uint32_t flags; }; https://developer.apple.com/library/mac/documentation/DeveloperT ools/Conceptual/MachORuntime/index.html
  • 14. pentestBox:/private/var/mobile/Applications/2587B469-0147-4793-86CE- B41A1C4468DC/banking.app root# otool -l BankingApp| grep crypt cryptoff 16384 cryptsize 835584 cryptid 1 Decrypting Binaries (32-bit) 14 cryptoff 16384 -> 0x4000 cryptsize 835584 -> 0xCC000 0x4000 (vm address) + 0x4000 (crypt off) = 0x8000 0x4000 (vm address) + 0x4000 (crypt off) + 0xCC000 (crypt size) = 0xD4000 (gdb) dump memory dump.bin 0x8000 0xD4000 <-- Encrypted binary section
  • 15. pentestBox:/private/var/mobile/Applications/2587B469-0147-4793-86CE- B41A1C4468DC/banking.app root# otool -l BankingApp| grep crypt cryptoff 16384 cryptsize 835584 cryptid 1 Decrypting Binaries (64-bit) 15 cryptoff 16384 -> 0x4000 cryptsize 835584 -> 0xCC000 0x4000 (vm address) + 0x4000 (crypt off) = 0x8000 0x4000 (vm address) + 0x4000 (crypt off) + 0xCC000 (crypt size) = 0xD4000 (lldb) memory read --outfile /tmp/dump.bin –binary 0x8000 0xD4000 <-- Encrypted binary section Remote debugging : Running debugserver on iOS – running LLDB on Mac
  • 16. Getting the Debugger running 16All you need are stored under the Xcode IDE directories Obtain the debug server binary $ hdiutil attach /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSu pport/7.1/DeveloperDiskImage.dmg
  • 17. Create an entity file for debugserver binary signing with following content Getting the Debugger running 17 Sign your debugserver binary and upload it to jailbroken iOS pentest device
  • 18. Attach target binary for remote debugging Getting the Debugger running 18 Make sure correct SDK path selected and connect to device:
  • 19. Stopped thread list available if debuggger connect is made correctly Debugging x64 iOS App 19
  • 20. Reversing iOS should be easy in an ideal world : Malware reversers would know what I mean :) Reversing iOS Apps 20
  • 21. IDA Pro correctly resolves the function names as well as the cross references. Reversing iOS Apps: Sainte Ida de Louvain 21 Source: https://www.hex-rays.com/products/ida/
  • 22. Check for interesting function calls as all the imports are correctly resolved. Reversing iOS Apps: Dealing with Crpyto 22
  • 23. It seems the application evaluates the certificate here. Reversing iOS Apps: Dealing with Crypto 23 https://developer.apple.com/l ibrary/mac/documentation/S ecurity/Reference/certifkeytru stservices/index.html Check the function prototypes and the definition on Apple Dev.
  • 24. Data content is being encrypted using public key before sending it to server. Reversing iOS Apps: Dealing with Crypto 24 Calling Convention : C++ ObjectPointer->Function(parameters) Calling Convention : Objective C [ObjectPointer Function:parameters]
  • 25. Reversing iOS Apps: Hunting for Public Key 25The following function evaluates the certificate . Check the function prototypes and the definition on Apple Dev. https://developer.apple.com/l ibrary/mac/documentation/S ecurity/Reference/certifkeytru stservices/index.html
  • 26. 26Cross-references definitely help. So do the constants and the debug strings.  Reversing iOS Apps: Hunting for Public Key
  • 27. 27Preparation for file encryption is literally being done here. Reversing iOS Apps: Hunting for Public Key
  • 28. Reversing iOS Apps: Hunting for Public Key 28 Short cheat sheet on LLDB for GDB junkies. LLDB Command (lldb) memory read --outfile /tmp/mem.bin --binary 0x1000 0x2000 (lldb) disassemble --frame (lldb) di -f (lldb) disassemble --start-address 0x1eb8 --count 20 (lldb) image list GDB Command (gdb) dump memory /tmp/mem.bin 0x1000 0x2000 (gdb) disassemble (gdb) x/20i 0x1eb8 (gdb) info shared
  • 29. Reversing iOS Apps: Hunting for Public Key 29Preparation for file encryption is literally being done here.
  • 30. 30I hope it’s clear to everyone what’s happening here and the purpose of the function.  Reversing iOS Apps: Hunting for Public Key
  • 31. How to Reversing on iOS Env? 31
  • 32. Reversing iOS Apps: Hunting for Public Key 32Set breakpoint to target function and then run until private keys are pushed into memory. Dump the memory to a writable location by LLDB debugger . Memory dump should contain the data we were looking for.
  • 33. iOS Apps Penetration Testing 33 https://www.owasp.org/index.php/OWASP_Mobile_Security_Project#tab=Top_10_M obile_Risks
  • 34. iOS Apps Penetration Testing 34 https://www.owasp.org/index.php/IOS_Application_Security_Testing_Chea t_Sheet
  • 35. iOS Apps Penetration Testing: Network Traffic Analysis 35 https://www.wireshark.org/
  • 36. iOS Apps Penetration Testing: Network Traffic Analysis 36 Cacoa Packet Analyzer: www.tastycoco abytes.com/cp a/ Appeals to MAC funs; unlike WireShark, it doesn’t require additional libraries such as XQuartz to be installed.
  • 37. SSL Interception: Function Hooks 37Standard SSLRead function provided by iOS SDK . iOS Dev Center: https://develop er.apple.com/li brary/mac/doc umentation/Se curity/Referenc e/secureTransp ortRef/
  • 38. SSL Interception: Function Hooks 38Standard SSLWrite function provided by iOS SDK . iOS Dev Center: https://develop er.apple.com/li brary/mac/doc umentation/Se curity/Referenc e/secureTransp ortRef/
  • 39. SSL Interception: Function Hooks 39How does a simple implementation of a function hook implementation on iOS envrionment looks like ? MSHookFunction ((void *) SSLWrite, (void *) _ hook_SSLWrite, (void **) & call_to_REAL_SSLWrite); MSHookFunction ((void *) SSLRead, (void *) _ hook_SSLRead, (void **) & call_to_REAL_SSLRead);
  • 40. SSL Interception: Function Hooks 40Create a hook that will intercept the SSL communication by hooking application level read/write operation functions .
  • 41. Hardware/Software Interception: Captain Hook Style Hacking 41 Captain Hook Style Hacking: Intercepts  every function, keeps a copy of the content for herself,   and then let the function continue as it was supposed to  … 
  • 43. SSL Interception: Function Hooks 43What if some people implements hook functions not only to see SSL traffic , but rather to reach hardware resources?
  • 44. This is beyond the conspiracy theories: for real! 44
  • 45. Iphone Rootkit CookBook 45A The following code detects the audio stream. Source Code:Tripware: http://www.tripwire.com/state-of-security/vulnerability- management/creating-iphone-rootkits-and-like-the-nsas-dropout-jeep/
  • 46. Iphone Rootkit CookBook (cont’d) 46A Sample hook for enabling iPhone Microphone. Source Code:Tripware: http://www.tripwire.com/state-of-security/vulnerability- management/creating-iphone-rootkits-and-like-the-nsas-dropout-jeep/
  • 47. Burp Suite: Atomize Everything 47 Burp Suite: http://portswigger.net/burp/ More than standard application communication interception.
  • 48. Burp Extensions: Installation Suggested and Most Preferred Way : Burp Suite >Extensions > BAppStore Some Extensions require Pro version (not because they discriminate poor but due to API/functional limitation  )  Some Extensions have 3rd party dependencies or wrapper of 3rd apllication (e.g. PhantomJS, Radamsa etc) 48
  • 49. How Extensions Work (cont’d) Class Name Purpose BurpExtender To write our own extension BurpExtenderCallBacks To pass to extensions a set of callback (register actions, mark) ICookie To retrieve the domain for which the cookie is in scope IHTTPRequestResponse To retrieve and update details about HTTP messages. IScanIssue To retrieve details of Scanner issues IScanQueueItem To retrieve details of items in the active scan queue. IScannerInsertionPoint To define an insertion point for use by active Scanner checks. IntroderPayloadProcessor To obtain the name of the payload processor 49
  • 50. Burp Extensions in a NutShell Extension Name Purpose .NET Beautifier Makes VIEWState info human readable ActiveScan++ Extend passive scanning , path injection, shellshock etc. Blazer Generate and fuzz custom AMF messages Bradamsa Generate intruder payload wisely  CO2 Set of useful tools : sqlmapper, user generator, prettier js, ascii payload processor etc. Logger++ An extension of history feature in Burp; more detailed and comprehensive Session Auth Help to identify privilege escalation vulns WebInspect Connector Newly built, share results between burp and webinspect 50
  • 51. Burp Extensions : Additional Scanner Checks Additional passive Scanner checks: Strict-Transport- Security, X-Content-Type, X-XSS-Protection. In other words, checks the modern browser security headers. 51
  • 52. Burp Extensions : Session Auth  To Identify authentication privilege escalation vulnerabilities. 52
  • 53. Burp Extensions : CO2 53 Set of useful tools : sqlmapper, user generator, prettier js, ascii payload processor etc.
  • 54. Fully Automated XSS Verification  xssValidator extension of Burp Suite could be leveraged to fully automate XSS verification process. 54
  • 55. Fully Automated XSS Verification 55 Before starting the XSS verification process, we need to install at least one wrapper to support extension .  Enable the payload extension after running wrapper.
  • 56. Fully Automated XSS Verification 56Enable payload processing unit for xssVerifier.  Finally, create a grep-and-match rule for intruder.
  • 57. Fully Automated XSS Verification 57Content of xss.js
  • 58. Fully Automated XSS Verification 58Let the fun begin 
  • 60. 60

Editor's Notes

  1. • Encryption and data protection: The architecture and design that protects user data if the device is lost or stolen, or if an unauthorized person attempts to use or modify it. • App security: The systems that enable apps to run securely and without compromising platform integrity. • Network security: Industry-standard networking protocols that provide secure authentication and encryption of data in transmission. Each step of the startup process contains components that are cryptographically signed by Apple to ensure integrity and that proceed only after verifying the chain of trust. The Boot ROM code contains the Apple Root CA public key, which is used to verify that the Low-Level Bootloader (LLB) is signed by Apple before allowing it to load. On a device with an A7 or later A-series processor, the Secure Enclave is a coprocessor also utilizes System Software Authorization to ensure the integrity of its software and prevent downgrade installations. (Secure enclave) IT provides all the cryptographic operations for data protection key The Secure Enclave uses encrypted memory and includes a hardware random number generator Communication between the Secure Enclave and the application processor is isolated to an interrupt-driven mailbox and shared memory data buffers. The keys for both file and keychain Data Protection classes are collected and managed in keybags System keybag is where the wrapped class keys used in normal operation of the device are stored. Backup keybag is created when an encrypted backup is made by iTunes and stored on the computer to which the device is backed up
  2. The MAC Framework defines four interfaces: the KSI (Kernel service entry point) from kernel services to the framework, the API from policy-agnostic user commands to the framework, the KPI between the framework and access control policy modules, and an additional debugging and tracing. KPI between the framework and access control policy modules, and an additional debugging and tracing interface via DTrace probes not shown in this illustration. Kernel programming interface (KPI) is called by kernel services, such as the Virtual File System (VFS) and Inter-Process Communication (IPC), to notify the MAC Frame-work of object events such as allocation and destruction, and to perform access control check KPI between the framework and access control policy modules, and an additional debugging and tracing interface via DTrace probes not shown in this illustration
  3. Sandboxing an application begins with a call to the system function Sandbox_init . This function uses the libsandbox.dylib library to turn a human readable policy definition Mac syscall system call handledby the TrustedBSD subsystem TrustedBSD will pass the sandbox initialization request o the Sandbox.kext kernel extension for processing. The kernel extension will install the sandbox profile rules for the current process. Upon completion, a success return value will be passed back out of the kernel Once the sandbox is initialized, function calls hooked by the TrustedBSD layer will pass Through Sandbox.kext for policy enforcement
  4. Thee sandbox is implemented via a policy module for the TrustedBSD MAC framework user space configurable per process profile even though all 3rd party apps run as the user “mobile” they all have different sandboxes (but they also run with the same sandbox profile) components user space library functions for configuring and starting the sandbox a kernel extension to enforce individual policies a kernel support extension (with regular expression support) to evaluate policy restrictions a Mach server for handling logging (also holds prebuilt configurations
  5. kSBXProfileNoInternet-&amp;gt;TCP/IP networking is prohibited. kSBXProfileNoNetwork-&amp;gt;All sockets-based networking is prohibited. kSBXProfileNoWrite -&amp;gt; File system writes are prohibited. kSBXProfileNoWriteExceptTemporary-&amp;gt;File system writes are restricted to the temporary folder /var/tmp and the folder specified by the confstr(3) configuration variable _CS_DARWIN_USER_TEMP_DIR. kSBXProfilePureComputation-&amp;gt; All operating system services are prohibited. Undocumented: MobileMail UNIX sockets cannot be used. /var/mobile/Applications/* , /var/mobile/Media/* (except DCIM/, com.apple.itdbprep.postprocess.lock and com.apple.itunes.lock_sync) , /var/mobile/Library/Caches/com.apple.mobile.installation.plist , /usr/sbin/fairplayd -&amp;gt; Thesefiles and directories cannot be read apsd, mDNSResponder -&amp;gt; The filesystem cannot be accessed at all.
  6. The per-file key is unwrapped with the class key, then supplied to the hardware AES engine, which decrypts the file as it is read from flash memory. Every time a file on the data partition is created, Data Protection creates a new 256-bit key (the “per-file” key) and gives it to the hardware AES engine, which uses the key to encrypt the file as it is written to flash memory using AES CBC mode. The initialization vector (IV) is calculated with the block offset into the file, encrypted with the SHA-1 hash of the per-file key.
  7. Complete Protection (NSFileProtectionComplete): The class key is protected with a key derived from the user passcode and the device UID. Shortly after the user locks a device (10 seconds, if the Require Password setting is Immediately), the decrypted class key is discarded, rendering all data in this class inaccessible until the user enters the passcode again. SData constants begin with NSDataWritingFileProtection…. …None — The file is not protected and can be read or written at any time. This is the default value. …Complete — Any file with this setting is protected ten seconds after the device is locked. This is the highest level of protection. Files with this setting may not be available when your program is running in the background. When the device is unlocked, these files are unprotected. …CompleteUnlessOpen — Files with this setting are protected ten seconds after the device is locked unless they’re currently open. This allows your program to continue accessing the file while running in the background. When the file is closed, it will be protected if the device is locked. …CompleteUntilFirstUserAuthentication — Files with this setting are protected only between the time the device boots and the first time the user unlocks the device. The files are unprotected from that point until the device is rebooted. This allows your application to open existing files while running in the background. NSData and its mutable subclass NSMutableData provide data objects, object-oriented wrappers for byte buffers. Why use an NSFileManager rather than just using NSData&amp;apos;s writeToFile:atomically: method when creating a new file? The advantage of the NSFileManager method is the attributes field: A dictionary containing the attributes to associate with the new file. You can use these attributes to set the owner and group numbers, file permissions, and modification date. For a list of keys, see “File Attribute Keys.” If you specify nil for attributes, the file is created with a set of default attributes.
  8. Internal version of mmap. Currently used by mmap, exec, and sys5 * shared memory. Handle is either a vnode pointer or NULL for MAP_ANON. Virtual memory protection definitions. -&amp;gt; read, write and execute
  9. Entitlements confer specific capabilities or security permissions to your app. These file(s) define properties that provide your application access to iOS features (such as push notifications) and secure data (such as the user’s keychain).
  10. Don’t be intidimitaded by the assembly instructions STP -&amp;gt; The aarch64 architecture doesn&amp;apos;t have instructions for multiple store and load, i.e. there are no equivalents of stm and ldm from armv7 arch. Instead you must use the stp and ldp instructions for store and loading pairs of registers.
  11. Mark should speak from this slide on
  12. You would wanna do Real time traffic analysis of ios application on a jailbroken device Pipe in tcpdump running on the jailbroken iOS to my pentest machine
  13. It&amp;apos;s run when a shared library is loaded, typically during program startup. he way the constructors and destructors work is that the shared object file contains special sections (.ctors and .dtors on ELF) which contain references to the functions marked with the constructor and destructor attributes, respectively.
  14. BurpExtenderCallBacks – getScannerChecks, getIntruderPayloadProcessors, load/unload extension
  15. Action Message Format (AMF) is a binary format used to serialize object graphs such as ActionScript objects and XML, or send messages between an Adobe Flash client and a remote service, usually a Flash Media Server or third party alternatives Masher - can be used to guess passwords given a word list and a known password specification.
  16. It simply replaces the session identifiers and compares the results whether it yielded any different.
  17. It comes in handy especially bruteforcing weblogins etc.