iOS Hacking: Advanced Pentest & Forensic Techniques
iOS Hacking: Advanced Pentest & Forensic Techniques
Techniques
Author(s): mer Cokun & Mark de Groot
The supreme art of war is to subdue the enemy without
fighting. Sun Tzu
$ whoami
mer Cokun (@0xM3R)
BEng. Computer
Science
Research Assistant in
Quantum Cryptography
& Advanced Topics in AI
Industry Experience
KPN CISO , Ethical
Hacking
Verizon Threat &
Vulnerability Management
Interests
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 ?
Motivations
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
monitory: iOS Mobile Payments, Paypal SDK etc.
iOS Rootkits are not only a theory anymore
Reverse Engineering on ARM Environment is Fun!
http://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-818.pdf
Source: http://dl.packetstormsecurity.net/papers/general/applesandbox.pdf
kSBXProfileNoNetwork
sandbox-compilerd
kSBXProfileNoWrite
mDNSResponder
kSBXProfileNoWriteExceptTemporary
apsd
kSBXProfilePureComputation
AppleDiags
PasteBoard
Container
MobileSafari
MobileMail
MobileMaps
10
Security Attributes
kSecAttrAccessibleWhenUnlocke
d
11
kSecAttrAccessibleAfterFirstUnloc
k
kSecAttrAccessibleAlways
kSecAttrAccessibleWhenUnlocke
dThisDeviceOnly
kSecAttrAccessibleAfterFirstUnloc
kThisDeviceOnly
kSecAttrAccessibleAlwaysThisDe
viceOnly
File Protector with NSFileManager:
12
/private/var/db/lockdown/
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/DeveloperTo
ols/Conceptual/MachORuntime/index.html
14
cryptoff 16384
cryptsize 835584
cryptid 1
15
cryptoff 16384
cryptsize 835584
cryptid 1
16
$ hdiutil attach
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSu
pport/7.1/DeveloperDiskImage.dmg
17
18
19
20
Source: https://www.hex-rays.com/products/ida/
21
22
23
24
ObjectPointer->Function(parameters)
[ObjectPointer Function:parameters]
25
26
27
28
GDB Command
LLDB Command
(gdb) disassemble
(gdb) x/20i 0x1eb8
29
30
31
32
33
https://www.owasp.org/index.php/OWASP_Mobile_Security_Project#tab=Top_10_
Mobile_Risks
https://www.owasp.org/index.php/IOS_Application_Security_Testing_Che
at_Sheet
34
https://www.wireshark.org/
35
36
Cacoa Packet
Analyzer:
www.tastycoco
abytes.com/cp
a/
37
iOS Dev
Center:
https://develop
er.apple.com/li
brary/mac/doc
umentation/Se
curity/Referenc
e/secureTransp
ortRef/
38
iOS Dev
Center:
https://develop
er.apple.com/li
brary/mac/doc
umentation/Se
curity/Referenc
e/secureTransp
ortRef/
39
40
Hardware/Software
Interception: Captain
Hook Style Hacking
41
42
43
44
This is beyond the
conspiracy theories:
for real!
Source Code:Tripware:
http://www.tripwire.com/state-of-security/vulnerabilitymanagement/creating-iphone-rootkits-and-like-the-nsas-dropoutjeep/
45
Source Code:Tripware:
http://www.tripwire.com/state-of-security/vulnerabilitymanagement/creating-iphone-rootkits-and-like-the-nsas-dropoutjeep/
46
47
48
Purpose
BurpExtender
BurpExtenderCallBacks
ICookie
IHTTPRequestResponse
IScanIssue
IScanQueueItem
IScannerInsertionPoint
IntroderPayloadProcessor
49
Extension Name
Purpose
.NET Beautifier
ActiveScan++
Blazer
Burp Extensions
in a NutShell
Generate and fuzz custom AMF messages
Bradamsa
CO2
Logger++
Session Auth
WebInspect Connector
50
51
52
53
54
55
56
Content of xss.js
57
58
59
Questions ?
60