SlideShare a Scribd company logo
1 of 37
iPhoneRootkit? There’s an App for That! Eric Monti – Sr. Security Researcher emonti@trustwave.com
Overview Understanding Jailbreaks Security hurdles Background Applying security attack patterns for “good” … to modify and leverage them for some “mayhem”  Reverse Engineering iPhone jailbreaks and apps Repurposing and patching available tools “Malicious” PoC Rootkits - also in the PoC sense ... please don’t root my phone “for reals” Not 0-day, the real “star” of the show isn’t even mine Jailbreak community are the real rockstars!!! The bug is patched and fully disclosed since research began But… I did some tinkering and am still covering relatively new subject-matter and hopefully interesting attack patterns
My Motivation I am not a iPhone Jailbreak team member but I’m a fan JailbreakMe.com 2.0 Launched around BH/Defcon 2010 Whole security community got intrigued I’ve been focused on product engineering last several months  Really enjoy it (not knocking it!!!) but sometimes I miss embedded stuff And… defcon had me all “fired up” for reversing and vuln research SpiderLabs pen-testers officially propose an exploit “It’d be cool to demo a nefarious jailbreak to clients” !!! / !!! Sounds fun! Drop everything. Start reverse engineering jailbreakme.com
Agenda iPhone Security Overview Jailbreaking Background Reversing Redux Weaponization Demo
iPhone/iOS Security Overview
History
iOS Security From 10,000 Meters Bootloader verifies… Signed firmware, verifies… Signed kernel, verifies… Signed Applications installed from the app store Apple signed everything! Actually a sound design on paper (barring implementation problems)
Architecture Overview Applications Processor ARM (6 or 7 depending on idevice/version) XNU Based Kernel (think OS X lite on ARM) Implements Kernel and Application Signing from bootloader down. Baseband Modem ARM Largely separated from App. processor Mostly interesting to carrier unlock, but not rootkit (yet?) Hardware Encryption Introduced in iPhone 3GS Low-level data encryption on NAND storage
OS Environment Two partitions make upfilesystem Root partition at / (read-only from factory) Kernel, Base OS, Core APIs User Partition at /private/var (read-write) All third party apps User data Two users for pretty much everything “root” - system services, kernel “mobile” - apps and data running as you, the user Basic Unix security rules apply System libraries and APIs approximate OS X / Darwin
Application Security  Code signing All apps must be signed by Apple Signatures stored in mach-o header section Check implemented in kernel as an enhanced execv() Sandbox Applications run as “mobile” Chroot sandbox ostensibly restricts apps to their own data Can’t alter the OS or other apps Reality: Apple’s .app authorization process plays the biggest role in iOS security Private APIs are accessible but apps using them are usually rejected Advanced functionality is all there, just not “approved of” Exploit code running in signed apps or on jailbroken devices can still do lots of interesting things with and to the underlying system.
Jailbreaks
Jailbreak Landscape Remote client-sides have been few and far between Obviously more exciting for security research Obviously more potential for abuse Par for exploits is in restore and FW updates over USB Fertile territory for jailbreaks, JB nerds, and still very cool Security impact for ‘evil maid’ style bad-guy attacks Very impressive work is consistent from the JB community ,[object Object]
But this is just how I do adoration and idolizationInternets have loads of tech details for learning Patience!Gotta wade through lots of fanboi noise to find the good stuff JB teams have cool info on wikis, but it’s not always up to date Github!!! Jailbreak-team stalker’s paradise!
Jailbreakme.com: A Thing to Behold Author: Comex backed up by other jailbreak team ,[object Object]
Every iDevice Apple makes, almost all modern versions affected
Handled like pros
Implementation, to presentation, to disclosure, to the timing of the release
Jailbreak released around BH / Defcon
iPhone 4G out for just a month or so.
Jailbreakers had been waiting patiently and were not disappointed
Released right after a crucial US legal decision on jailbreaking
Now officially legal in US
Prior status was fuzzy
Source for exploit released after Apple releases security fix (iOS 4.0.2)
See http://github.com/comex/star,[object Object]
How? The “star” PDF Exploit – Code execution Classic stack overflow BoF in CoreGraphicsCFF(Compact Font Format) handling long strings Overwrites $pc (EIP for ARM) Code still runs as “mobile” at this point Leverages IOSurface (IOKit) bug for privilege escalation and sandbox escape The IOKit Vulnerability – Priv. escalation / escaping the sandbox Kernel integer overflow in handling of IOSurface properties Calls setuid(0) inside Safari getting root Dominoes all fall down from there The Jailbreak Phase – Set up residence on the iDevice Patches out Kernel code signing Installs a basic jailbreak filesystem along with Cydia (apt-get) “Polite” and clean - Even calls setuid(501) back to “mobile” once it’s finished.
Reversing the Binary “star” Exploit
Reversing the Exploit Binaries (pre-source) First few weeks, no source was released for JailbreakMe.com Curious and impatient. Not sure if Comex would release Began reversing the binaries within a few days of the JB release Staring at opaque hex-dumps and peeling the onion one layer at a time Fun and soothing – Like catnip for my O.C.D.
All for Naught? Got a patch working. Was happy! Turned out to be a total waste of time Comex released the source about a week after I’d finished testing my PoC No use crying over spilled code. Better to smarter and proceed by branching his github project and working source for the demo in this presentation.  “star” turned out to be pretty awesome as a source package too and patching was much easier.  Bonus: Been meaning to apply some objective-C reading I’d done months back. Maybe not a total waste? Got to dabble in iPhone reversing and ARM assembly Was fun and I scratched an itch I’d needed to. Pure source patching was too easy Process makes for a more interesting talk
Reversing Steps Analyzed the PDF Barebones PDF. Viewer shows one “empty” page Compare PDFs between iOS device/version A single zlib deflated font section is the only difference Deflate this chunk  Strings and investigation show an un-stripped Mach-O DYLIB lives here Wrote a quick file splitter “extract_payload” Found 3 parts CFF Font egg Macho_1 Macho_2
… continued: egg  Malformed Times-Roman CFF Font ...
… continued: Exploit ARM Code * extract from comex/star source
IOKit Integer Overflow XML Extract
installui.dylibEntrypoint iui_go initializes the installer environment and calls the objective-C [Dude start] method
class-dump on installui.dylib (aka macho_1)
Wad.bin What gets downloaded and installed for the jailbroken device? Wad.bin pseudo-code structure XZ’edtarball contents  Stripped down Unix dir structure and CLI programs (bash et al)  Cydia.app for downloading more packages
Weaponizing

More Related Content

What's hot

Eclipse 3.7 : Tips and tricks
Eclipse 3.7 : Tips and tricksEclipse 3.7 : Tips and tricks
Eclipse 3.7 : Tips and tricksTomasz Zarna
 
IzPack - fOSSa 2009
IzPack - fOSSa 2009IzPack - fOSSa 2009
IzPack - fOSSa 2009julien.ponge
 
From printed circuit boards to exploits
From printed circuit boards to exploitsFrom printed circuit boards to exploits
From printed circuit boards to exploitsvirtualabs
 
Sandbox detection: leak, abuse, test - Hacktivity 2015
Sandbox detection: leak, abuse, test - Hacktivity 2015Sandbox detection: leak, abuse, test - Hacktivity 2015
Sandbox detection: leak, abuse, test - Hacktivity 2015Zoltan Balazs
 
What Mr. Spock would possibly say about modern unit testing: pragmatic and em...
What Mr. Spock would possibly say about modern unit testing: pragmatic and em...What Mr. Spock would possibly say about modern unit testing: pragmatic and em...
What Mr. Spock would possibly say about modern unit testing: pragmatic and em...Yaroslav Yermilov
 
Hacking with Remote Admin Tools (RAT)
 Hacking with Remote Admin Tools (RAT) Hacking with Remote Admin Tools (RAT)
Hacking with Remote Admin Tools (RAT)Zoltan Balazs
 
FusionInventory at LSM/RMLL 2012
FusionInventory at LSM/RMLL 2012FusionInventory at LSM/RMLL 2012
FusionInventory at LSM/RMLL 2012Nouh Walid
 
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 ChidaCODE BLUE
 
44CON 2014 - Researching Android Device Security with the Help of a Droid Arm...
44CON 2014 - Researching Android Device Security with the Help of a Droid Arm...44CON 2014 - Researching Android Device Security with the Help of a Droid Arm...
44CON 2014 - Researching Android Device Security with the Help of a Droid Arm...44CON
 
Rat Pack Remote Control – an Internet of Things basics hands on workshop by S...
Rat Pack Remote Control – an Internet of Things basics hands on workshop by S...Rat Pack Remote Control – an Internet of Things basics hands on workshop by S...
Rat Pack Remote Control – an Internet of Things basics hands on workshop by S...Codemotion
 
IzPack - PoitouJUG
IzPack - PoitouJUGIzPack - PoitouJUG
IzPack - PoitouJUGjulien.ponge
 
Introduction to iOS Penetration Testing
Introduction to iOS Penetration TestingIntroduction to iOS Penetration Testing
Introduction to iOS Penetration TestingOWASP
 

What's hot (13)

Eclipse 3.7 : Tips and tricks
Eclipse 3.7 : Tips and tricksEclipse 3.7 : Tips and tricks
Eclipse 3.7 : Tips and tricks
 
IzPack - fOSSa 2009
IzPack - fOSSa 2009IzPack - fOSSa 2009
IzPack - fOSSa 2009
 
From printed circuit boards to exploits
From printed circuit boards to exploitsFrom printed circuit boards to exploits
From printed circuit boards to exploits
 
Sandbox detection: leak, abuse, test - Hacktivity 2015
Sandbox detection: leak, abuse, test - Hacktivity 2015Sandbox detection: leak, abuse, test - Hacktivity 2015
Sandbox detection: leak, abuse, test - Hacktivity 2015
 
What Mr. Spock would possibly say about modern unit testing: pragmatic and em...
What Mr. Spock would possibly say about modern unit testing: pragmatic and em...What Mr. Spock would possibly say about modern unit testing: pragmatic and em...
What Mr. Spock would possibly say about modern unit testing: pragmatic and em...
 
Hacking with Remote Admin Tools (RAT)
 Hacking with Remote Admin Tools (RAT) Hacking with Remote Admin Tools (RAT)
Hacking with Remote Admin Tools (RAT)
 
FusionInventory at LSM/RMLL 2012
FusionInventory at LSM/RMLL 2012FusionInventory at LSM/RMLL 2012
FusionInventory at LSM/RMLL 2012
 
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
 
44CON 2014 - Researching Android Device Security with the Help of a Droid Arm...
44CON 2014 - Researching Android Device Security with the Help of a Droid Arm...44CON 2014 - Researching Android Device Security with the Help of a Droid Arm...
44CON 2014 - Researching Android Device Security with the Help of a Droid Arm...
 
Rat Pack Remote Control – an Internet of Things basics hands on workshop by S...
Rat Pack Remote Control – an Internet of Things basics hands on workshop by S...Rat Pack Remote Control – an Internet of Things basics hands on workshop by S...
Rat Pack Remote Control – an Internet of Things basics hands on workshop by S...
 
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
 
IzPack - PoitouJUG
IzPack - PoitouJUGIzPack - PoitouJUG
IzPack - PoitouJUG
 
Introduction to iOS Penetration Testing
Introduction to iOS Penetration TestingIntroduction to iOS Penetration Testing
Introduction to iOS Penetration Testing
 

Similar to EkoParty 2010: iPhone Rootkit? There's an App for that.

NYU Hacknight: iOS and OSX ABI
NYU Hacknight: iOS and OSX ABINYU Hacknight: iOS and OSX ABI
NYU Hacknight: iOS and OSX ABIMikhail Sosonkin
 
108484130 pod2g-jailbreak-techniques-wwjc-2012
108484130 pod2g-jailbreak-techniques-wwjc-2012108484130 pod2g-jailbreak-techniques-wwjc-2012
108484130 pod2g-jailbreak-techniques-wwjc-2012wtreterte
 
Flash security past_present_future_final_en
Flash security past_present_future_final_enFlash security past_present_future_final_en
Flash security past_present_future_final_enSunghun Kim
 
Timings of Init : Android Ramdisks for the Practical Hacker
Timings of Init : Android Ramdisks for the Practical HackerTimings of Init : Android Ramdisks for the Practical Hacker
Timings of Init : Android Ramdisks for the Practical HackerStacy Devino
 
iPhone Development: Zero to Sixty
iPhone Development: Zero to SixtyiPhone Development: Zero to Sixty
iPhone Development: Zero to SixtyThomas Swift
 
Android and ios cracking, hackintosh included !
Android and ios cracking, hackintosh included !Android and ios cracking, hackintosh included !
Android and ios cracking, hackintosh included !Veduruparthy Bharat
 
Find your own iOS kernel bug
Find your own iOS kernel bugFind your own iOS kernel bug
Find your own iOS kernel bugGustavo Martinez
 
It's Assembler, Jim, but not as we know it: (ab)using binaries from embedded ...
It's Assembler, Jim, but not as we know it: (ab)using binaries from embedded ...It's Assembler, Jim, but not as we know it: (ab)using binaries from embedded ...
It's Assembler, Jim, but not as we know it: (ab)using binaries from embedded ...Priyanka Aash
 
Rooting an Android phone
Rooting an Android phoneRooting an Android phone
Rooting an Android phoneArnav Gupta
 
Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]RootedCON
 
iOS Hacking: Advanced Pentest & Forensic Techniques
iOS Hacking: Advanced Pentest & Forensic TechniquesiOS Hacking: Advanced Pentest & Forensic Techniques
iOS Hacking: Advanced Pentest & Forensic TechniquesÖmer Coşkun
 
CONFidence 2015: iOS Hacking: Advanced Pentest & Forensic Techniques - Omer S...
CONFidence 2015: iOS Hacking: Advanced Pentest & Forensic Techniques - Omer S...CONFidence 2015: iOS Hacking: Advanced Pentest & Forensic Techniques - Omer S...
CONFidence 2015: iOS Hacking: Advanced Pentest & Forensic Techniques - Omer S...PROIDEA
 
BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...
BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...
BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...MindShare_kk
 
History of Android Security – from linux to jelly bean
History of Android Security – from linux to jelly beanHistory of Android Security – from linux to jelly bean
History of Android Security – from linux to jelly beanJung Pil (J.P.) Choi
 
[CB19] I KNOW WHAT YOU DID LAST NIGHT : Pwning The State-Of-The-Art the IoT H...
[CB19] I KNOW WHAT YOU DID LAST NIGHT : Pwning The State-Of-The-Art the IoT H...[CB19] I KNOW WHAT YOU DID LAST NIGHT : Pwning The State-Of-The-Art the IoT H...
[CB19] I KNOW WHAT YOU DID LAST NIGHT : Pwning The State-Of-The-Art the IoT H...CODE BLUE
 
Taking Control of Your Mobile Device - Rooting-n-Roms
Taking Control of Your Mobile Device - Rooting-n-RomsTaking Control of Your Mobile Device - Rooting-n-Roms
Taking Control of Your Mobile Device - Rooting-n-Romsjimboks
 
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)Shota Shinogi
 

Similar to EkoParty 2010: iPhone Rootkit? There's an App for that. (20)

NYU Hacknight: iOS and OSX ABI
NYU Hacknight: iOS and OSX ABINYU Hacknight: iOS and OSX ABI
NYU Hacknight: iOS and OSX ABI
 
108484130 pod2g-jailbreak-techniques-wwjc-2012
108484130 pod2g-jailbreak-techniques-wwjc-2012108484130 pod2g-jailbreak-techniques-wwjc-2012
108484130 pod2g-jailbreak-techniques-wwjc-2012
 
Flash security past_present_future_final_en
Flash security past_present_future_final_enFlash security past_present_future_final_en
Flash security past_present_future_final_en
 
Timings of Init : Android Ramdisks for the Practical Hacker
Timings of Init : Android Ramdisks for the Practical HackerTimings of Init : Android Ramdisks for the Practical Hacker
Timings of Init : Android Ramdisks for the Practical Hacker
 
iOS jailbreaking
iOS jailbreakingiOS jailbreaking
iOS jailbreaking
 
iPhone Development: Zero to Sixty
iPhone Development: Zero to SixtyiPhone Development: Zero to Sixty
iPhone Development: Zero to Sixty
 
Android and ios cracking, hackintosh included !
Android and ios cracking, hackintosh included !Android and ios cracking, hackintosh included !
Android and ios cracking, hackintosh included !
 
Find your own iOS kernel bug
Find your own iOS kernel bugFind your own iOS kernel bug
Find your own iOS kernel bug
 
It's Assembler, Jim, but not as we know it: (ab)using binaries from embedded ...
It's Assembler, Jim, but not as we know it: (ab)using binaries from embedded ...It's Assembler, Jim, but not as we know it: (ab)using binaries from embedded ...
It's Assembler, Jim, but not as we know it: (ab)using binaries from embedded ...
 
Rooting an Android phone
Rooting an Android phoneRooting an Android phone
Rooting an Android phone
 
Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]
 
iOS Hacking: Advanced Pentest & Forensic Techniques
iOS Hacking: Advanced Pentest & Forensic TechniquesiOS Hacking: Advanced Pentest & Forensic Techniques
iOS Hacking: Advanced Pentest & Forensic Techniques
 
CONFidence 2015: iOS Hacking: Advanced Pentest & Forensic Techniques - Omer S...
CONFidence 2015: iOS Hacking: Advanced Pentest & Forensic Techniques - Omer S...CONFidence 2015: iOS Hacking: Advanced Pentest & Forensic Techniques - Omer S...
CONFidence 2015: iOS Hacking: Advanced Pentest & Forensic Techniques - Omer S...
 
BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...
BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...
BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...
 
History of Android Security – from linux to jelly bean
History of Android Security – from linux to jelly beanHistory of Android Security – from linux to jelly bean
History of Android Security – from linux to jelly bean
 
[CB19] I KNOW WHAT YOU DID LAST NIGHT : Pwning The State-Of-The-Art the IoT H...
[CB19] I KNOW WHAT YOU DID LAST NIGHT : Pwning The State-Of-The-Art the IoT H...[CB19] I KNOW WHAT YOU DID LAST NIGHT : Pwning The State-Of-The-Art the IoT H...
[CB19] I KNOW WHAT YOU DID LAST NIGHT : Pwning The State-Of-The-Art the IoT H...
 
Pwnstaller
PwnstallerPwnstaller
Pwnstaller
 
Taking Control of Your Mobile Device - Rooting-n-Roms
Taking Control of Your Mobile Device - Rooting-n-RomsTaking Control of Your Mobile Device - Rooting-n-Roms
Taking Control of Your Mobile Device - Rooting-n-Roms
 
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
 
OWASP: iOS Spelunking
OWASP: iOS SpelunkingOWASP: iOS Spelunking
OWASP: iOS Spelunking
 

Recently uploaded

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Recently uploaded (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

EkoParty 2010: iPhone Rootkit? There's an App for that.

  • 1. iPhoneRootkit? There’s an App for That! Eric Monti – Sr. Security Researcher emonti@trustwave.com
  • 2. Overview Understanding Jailbreaks Security hurdles Background Applying security attack patterns for “good” … to modify and leverage them for some “mayhem” Reverse Engineering iPhone jailbreaks and apps Repurposing and patching available tools “Malicious” PoC Rootkits - also in the PoC sense ... please don’t root my phone “for reals” Not 0-day, the real “star” of the show isn’t even mine Jailbreak community are the real rockstars!!! The bug is patched and fully disclosed since research began But… I did some tinkering and am still covering relatively new subject-matter and hopefully interesting attack patterns
  • 3. My Motivation I am not a iPhone Jailbreak team member but I’m a fan JailbreakMe.com 2.0 Launched around BH/Defcon 2010 Whole security community got intrigued I’ve been focused on product engineering last several months Really enjoy it (not knocking it!!!) but sometimes I miss embedded stuff And… defcon had me all “fired up” for reversing and vuln research SpiderLabs pen-testers officially propose an exploit “It’d be cool to demo a nefarious jailbreak to clients” !!! / !!! Sounds fun! Drop everything. Start reverse engineering jailbreakme.com
  • 4. Agenda iPhone Security Overview Jailbreaking Background Reversing Redux Weaponization Demo
  • 7. iOS Security From 10,000 Meters Bootloader verifies… Signed firmware, verifies… Signed kernel, verifies… Signed Applications installed from the app store Apple signed everything! Actually a sound design on paper (barring implementation problems)
  • 8. Architecture Overview Applications Processor ARM (6 or 7 depending on idevice/version) XNU Based Kernel (think OS X lite on ARM) Implements Kernel and Application Signing from bootloader down. Baseband Modem ARM Largely separated from App. processor Mostly interesting to carrier unlock, but not rootkit (yet?) Hardware Encryption Introduced in iPhone 3GS Low-level data encryption on NAND storage
  • 9. OS Environment Two partitions make upfilesystem Root partition at / (read-only from factory) Kernel, Base OS, Core APIs User Partition at /private/var (read-write) All third party apps User data Two users for pretty much everything “root” - system services, kernel “mobile” - apps and data running as you, the user Basic Unix security rules apply System libraries and APIs approximate OS X / Darwin
  • 10. Application Security Code signing All apps must be signed by Apple Signatures stored in mach-o header section Check implemented in kernel as an enhanced execv() Sandbox Applications run as “mobile” Chroot sandbox ostensibly restricts apps to their own data Can’t alter the OS or other apps Reality: Apple’s .app authorization process plays the biggest role in iOS security Private APIs are accessible but apps using them are usually rejected Advanced functionality is all there, just not “approved of” Exploit code running in signed apps or on jailbroken devices can still do lots of interesting things with and to the underlying system.
  • 12.
  • 13. But this is just how I do adoration and idolizationInternets have loads of tech details for learning Patience!Gotta wade through lots of fanboi noise to find the good stuff JB teams have cool info on wikis, but it’s not always up to date Github!!! Jailbreak-team stalker’s paradise!
  • 14.
  • 15. Every iDevice Apple makes, almost all modern versions affected
  • 17. Implementation, to presentation, to disclosure, to the timing of the release
  • 19. iPhone 4G out for just a month or so.
  • 20. Jailbreakers had been waiting patiently and were not disappointed
  • 21. Released right after a crucial US legal decision on jailbreaking
  • 24. Source for exploit released after Apple releases security fix (iOS 4.0.2)
  • 25.
  • 26. How? The “star” PDF Exploit – Code execution Classic stack overflow BoF in CoreGraphicsCFF(Compact Font Format) handling long strings Overwrites $pc (EIP for ARM) Code still runs as “mobile” at this point Leverages IOSurface (IOKit) bug for privilege escalation and sandbox escape The IOKit Vulnerability – Priv. escalation / escaping the sandbox Kernel integer overflow in handling of IOSurface properties Calls setuid(0) inside Safari getting root Dominoes all fall down from there The Jailbreak Phase – Set up residence on the iDevice Patches out Kernel code signing Installs a basic jailbreak filesystem along with Cydia (apt-get) “Polite” and clean - Even calls setuid(501) back to “mobile” once it’s finished.
  • 27. Reversing the Binary “star” Exploit
  • 28. Reversing the Exploit Binaries (pre-source) First few weeks, no source was released for JailbreakMe.com Curious and impatient. Not sure if Comex would release Began reversing the binaries within a few days of the JB release Staring at opaque hex-dumps and peeling the onion one layer at a time Fun and soothing – Like catnip for my O.C.D.
  • 29. All for Naught? Got a patch working. Was happy! Turned out to be a total waste of time Comex released the source about a week after I’d finished testing my PoC No use crying over spilled code. Better to smarter and proceed by branching his github project and working source for the demo in this presentation. “star” turned out to be pretty awesome as a source package too and patching was much easier. Bonus: Been meaning to apply some objective-C reading I’d done months back. Maybe not a total waste? Got to dabble in iPhone reversing and ARM assembly Was fun and I scratched an itch I’d needed to. Pure source patching was too easy Process makes for a more interesting talk
  • 30. Reversing Steps Analyzed the PDF Barebones PDF. Viewer shows one “empty” page Compare PDFs between iOS device/version A single zlib deflated font section is the only difference Deflate this chunk Strings and investigation show an un-stripped Mach-O DYLIB lives here Wrote a quick file splitter “extract_payload” Found 3 parts CFF Font egg Macho_1 Macho_2
  • 31. … continued: egg Malformed Times-Roman CFF Font ...
  • 32. … continued: Exploit ARM Code * extract from comex/star source
  • 33. IOKit Integer Overflow XML Extract
  • 34. installui.dylibEntrypoint iui_go initializes the installer environment and calls the objective-C [Dude start] method
  • 36. Wad.bin What gets downloaded and installed for the jailbroken device? Wad.bin pseudo-code structure XZ’edtarball contents Stripped down Unix dir structure and CLI programs (bash et al) Cydia.app for downloading more packages
  • 38.
  • 39. The jailbreakme.comPDFs’ installui.dylib had code to ensure they’d been downloaded from “jailbreakme.com”. I couldn’t leave that
  • 40. Not sure what motivation Comex had for this
  • 41. Patching out all the gui pop-ups
  • 42. Didn’t want the victim to realized they were being ‘kitted
  • 43. I hadn’t learned the wonders of usbmuxd and libimobiledevice for live syslog yet so I left a single popup for debugging/troubleshooting
  • 44. Would patch it out last
  • 45. Preparing a modified wad.bin with our “rootkit”
  • 46.
  • 47. Turns out you only really need to understand a few machine instructions to patch programs.
  • 48.
  • 49. Prison Riot: Serving the Exploit riot_server: A simple ruby sinatra web server. Serves up a page using JS to ID the client User Agent Heavy JS Profile Assembles the PDF components for our IP PDF exploit pulls down our wad.binrootkitfilesystem
  • 50. Goal: Complete Remote iDevice Control
  • 51.
  • 52. Patched unix utilities like ‘ls’, ‘ps’, ‘find’, ‘netstat’ from the JB filesystem
  • 53. Hiding from actual jailbreakers (rockin’ it like it’s 1990)
  • 54. Port knock daemon called “bindwatch” fakes its name on argv[0]
  • 55. Spawns a bind-shell called, wait for it …. “bindshell” also fakes argv[0]
  • 56. Trivial app to record AIFF on the mic – remote eavesdrop
  • 57. Patched “veency” to hide itself a little better
  • 58. Nice opensourceiPhone VNC server by saurik
  • 59. Runs via a DYLIB in MobileSubstrate
  • 60. Mostly just removed the GUI configplist from System Preferences
  • 61. Coded a trivial CLI obj-C program to configure and start veencywithout the gui
  • 63. I’m still getting my feet wet in the kernel. Ongoing research…
  • 64. More leveraging of JB kernel hacks and opensourceiPhone apps for guidance
  • 65. Kernel space on iPhone isn’t as “easy” as some other mobiles (cough Linux)
  • 66.
  • 67. The Demo Victim Vanilla un-jailbrokeniPhone 3g running iOS 4.0.1
  • 69.
  • 70. Once broken treat it just like the other computers you own
  • 71. Patch! Cydia is your apt-get (literally)
  • 73. Monitoring (periodic md5 filesystem checks are probably sane)
  • 74. We need to see more AV and defense-ware for iOS
  • 75. Don’t expect Apple to facilitate this very much
  • 76.

Editor's Notes

  1. Apple designed iOS and iDevices with propriety and DRM in mindThey also got some security as part of the package
  2. Always reaffirmingwhen you get source to something after you’ve reversed it. Learn what you did right, and wrong.
  3. Spanish not so good. Before my first trip to south america I learned:How to order a beer, order one more, and ask for the bathroomLearning to patch binaries in a foreign instruction set is the same wayMention ARM6 and ARM7 have differences. Thumb2 instruction sets
  4. Cydia and other package repos conform to opensourceStandards. Source is often available. But we can apply similarBinary patching to apps for which there is no source.
  5. Delivering web-based client-sides is pretty standard fare nowadaysBut, with mobiles there are lots of interesting ways to lay the bait.Things like SMS, Twitter, and so on offer a great platform for worming.