SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Downloaden Sie, um offline zu lesen
iOS Automation Primitives
April 13, 2016
iOS Automation Primitives
Mikhail Sosonkin
mikhail@synack.com http://debugtrap.com
(Hacking in context)
Security Researcher at SYNACK
Working on low level emulation with QEMU and iPhone automation.
Graduate of Polytechnic University/ISIS Lab 2005
a.k.a New York University Tandon School of Engineering
Masters in Software Engineering from Oxford University 2014
Exeter College
СССР 1986
Intel 8080 Clone
1.78MHz CPU
32KB RAM
2KB ROM
450 Rubles
Wikipedia-RU
Why automation?
Time saving
More thorough
Repeatable
API Discovery
Code Coverage
Discover Preinstalled Malware
Cameras arrived with malware from Amazon
“When you automate tests of UI interactions,
you free critical staff and resources for other
work.” - Apple
Getting started with iOS
- Get iPhone 5s
- Swappa
- Apply Jailbreak
- Install OpenSSH via Cydia
- Use tcprelay to SSH over USB
- Start exploring
- Debugserver
- Objective-c: Phrack 0x42
- http://phrack.org/issues/66/4.html
- iOS App Reverse Engineering
The world’s 1st book of very detailed iOS App reverse engineering skills :)
- TCP Relay
Pangu TaiG
The goal
“We want to dissect and study an application that
we have no developer control over”
Static Analysis
● Use dumpdecrypted by Stefan Esser to acquire the binary
● IDAPro for reverse engineering
● Class-dump to get the Objective-C meta data.
○ Objective-C is automation’s best friend
Let’s explorer how Objective-C
calls methods
@interface TestObject : NSObject { }
-(void)print;
@end
@implementation TestObject
-(void)print { NSLog(@"Test Object"); }
@end
…
TestObject* obj = [TestObject alloc];
[obj print];
__text:0000000100000DB0 mov rsi, cs:classRef_TestObject
__text:0000000100000DB7 mov rdi, cs:selRef_alloc
__text:0000000100000DBE mov [rbp+var_38], rdi
__text:0000000100000DC2 mov rdi, rsi
__text:0000000100000DC5 mov rsi, [rbp+var_38]
__text:0000000100000DC9 call _objc_msgSend
__text:0000000100000DCE mov [rbp+var_18], rax
__text:0000000100000DD2 mov rax, [rbp+var_18]
__text:0000000100000DD6 mov rsi, cs:selRef_print
__text:0000000100000DDD mov rdi, rax
__text:0000000100000DE0 call _objc_msgSend
Static Call
Dynamic Call
[obj print];
objc_msgSend(obj, “print”);
-[TestObject print](obj, “print”);
id objc_msgSend(id self, SEL op, ...)
void __cdecl -[TestObject print]
(struct TestObject *self, SEL)
Dynamic Analysis
● Verbose nature of Objective-C
○ Query Objects
○ Trigger method calls
● Debugging
○ Cycript
○ Frida
○ Custom DYLIB
● Injecting into the App
○ MobileSubstrate
○ DYLD_INSERT_LIBRARIES
Dynamic tools
● Frida
○ Binary Instrumentation using JavaScript
○ Mostly for debugging and tracing
● Cycript
○ Injectable debugger
○ Manipulate and examine objects
○ iOS Spelunking (Talk and OWASP NYC)
■ Showing how to rewire an application to discover more.
Network tools
● MITMProxy
○ Intercept network data
○ Write custom scripts for transformations
● iOS Disable Certificate pinning
○ https://github.com/iSECPartners/ios-ssl-kill-switch
○ WARNING: THIS TWEAK WILL MAKE YOUR DEVICE INSECURE
Available Frameworks
“Appium is an open source test automation framework for use with native,
hybrid and mobile web apps. It drives iOS and Android apps using the
WebDriver protocol.” - Appium
“You can use the Automation instrument to automate user interface tests in
your iOS app through test scripts that you write.” - Apple UI Instruments
All frameworks require
you to be the app
developer!
Not nice for blackbox
testing.
Jailbreakers to the
rescue!
So, you want to roll your own?
● Simulate the user ● Read and understand the UI
Generating Events
● SimulateTouch
○ http://api.iolate.kr/simulatetouch/
○ Generate TouchUp/TouchDown
○ Generate Swipes
● SimulateKeyboard
○ https://github.com/iolate/SimulateKeyboard
○ Generate Key presses
○ Mechanical and Virtual
Reading the UI
● UIView
○ The source of everything
■ Stems from UIApp.keyWindow
○ Constructs a tree structure
○ UILabel
○ UIButton
○ UITextField
○ etc.
Let’s peek in
UILabel and UIButton in a
UIScrollView
Sneaking a peek
cy# UIApp.keyWindow
<UIWindow; frame = (0 0; 320 568); gestureRecognizers = <NSArray>;>
| <TiRootViewNeue; frame = (0 0; 320 568); autoresize = W+H; layer = <CALayer>>
...
<TiUITableViewCell; baseClass = UITableViewCell; text = 'Log On';
| <TiGradientLayer;> (layer)
| <UITableViewCellContentView; frame = (0 0; 256 43.5); layer = <CALayer>>
| | <UITableViewLabel; frame = (74 0; 167 43.5); text = 'Log On'>
| | <UIImageView; frame = (15 0; 44 43.5); layer = <CALayer>>
| <_UITableViewCellSeparatorView; frame = (74 43.5; 182 0.5); layer = <CALayer>>
Putting it all together
“An engine for driving the UI while doing
blackbox testing of an iOS App”
- CHAOTICMARCH (On github)
CHAOTICMARCH
● Lua Scriptable Logic
● Standard functions for touching the device
● Options for record/replay
● Finding UI Components
● Regulating speed of execution
● Support for multiple targets
● Mechanisms for generic logic
● Lightweight injected module
“Lua is a powerful, fast, lightweight, embeddable
scripting language … means "Moon" in Portuguese
… Please do not write it as "LUA", which is both
ugly and confusing”
lua.org
Lua Layout
lua
├── chaotic_march.lua
├── com.gs.pwm.external-1-login.lua
├── com.hdsupply.hdsupplyfm-1-search.lua
├── post_all-click_around.lua
├── pre_all-common.lua
└── pre_all-wait_to_start.lua
Initialization
1. Dylib reads and executes chaotic_march.lua
2. Execute all pre_all*.lua scripts
a. Library functions
b. Generic logic
3. Execute all [bundle_id]*.lua
a. Target specific logic
4. Execute all post_all*.lua
a. Any sort of common clean up
b. Close out the execution
CHAOTICMARCH - Target
“Engine is injected into all apps and so
it has to situate itself”
getBundleID() ->
“com.hdsupply.hdsupplyfm”
Basic Logic
while true do
local button = getButton(clickedButtons)
-- put some info in.
fill_all_fields()
click_button(button)
if(button["text"] ~= nil) then
clickedButtons[button["text"]] = 1
end
usleep(2 * 1000000)
end
Finding elements
local buttons = findOfTypes(
"UIButton", "UINavigationItemButtonView",
"UINavigationItemView", "_UIAlertControllerActionView",
"UISegmentLabel", "UILabel", "")
Basically anything we might consider clickable.
Other interesting functions
inputText(String text) ->
Enter the text into whatever component is holding the focus.
hasTextAt(String txt, boxes_x, boxes_y, box_x, box_y) ->
Same as component but the engine will look for text at a specified box.
findOfTypes(String type1, ..., String "") ->
Returns a dictionary of the locations of particular types of components.
Element representation
{
"x": [x - coordinate, top-left corner],
"y": [y - coordinate],
"width": [number],
"height": [number],
"text": [best guess at text of the button],
"title": [Closest title to the element]
}
Challenges/Research areas
● Identifying an interesting event
● Recording path to event
● Accurately identifying what the user sees
○ Clickables: Not all are buttons
● Instrumentation
● Repeated triggering
● Handling games and custom UI’s
Demo!
● HD Supply test case
● Replay raw touch
● Fill in forms
● Click buttons
Youtube link
Why?
Together we can build a great library
of testing logic for all kinds of apps!
Thank you!
Mikhail Sosonkin
mikhail@synack.com
https://github.com/synack/chaoticmarch
https://www.synack.com/r-d-projects/automating-the-ui-for-blackbox-testing/

Weitere ähnliche Inhalte

Was ist angesagt?

RSA OSX Malware
RSA OSX MalwareRSA OSX Malware
RSA OSX MalwareSynack
 
Black Hat '15: Writing Bad @$$ Malware for OS X
Black Hat '15: Writing Bad @$$ Malware for OS XBlack Hat '15: Writing Bad @$$ Malware for OS X
Black Hat '15: Writing Bad @$$ Malware for OS XSynack
 
Synack at AppSec California 2015 - Geolocation Vulnerabilities
Synack at AppSec California 2015 - Geolocation VulnerabilitiesSynack at AppSec California 2015 - Geolocation Vulnerabilities
Synack at AppSec California 2015 - Geolocation VulnerabilitiesSynack
 
Synack Shakacon OSX Malware Persistence
Synack Shakacon OSX Malware PersistenceSynack Shakacon OSX Malware Persistence
Synack Shakacon OSX Malware PersistenceIvan Einstein
 
Synack at ShmooCon 2015
Synack at ShmooCon 2015Synack at ShmooCon 2015
Synack at ShmooCon 2015Synack
 
Codetainer: a Docker-based browser code 'sandbox'
Codetainer: a Docker-based browser code 'sandbox'Codetainer: a Docker-based browser code 'sandbox'
Codetainer: a Docker-based browser code 'sandbox'Jen Andre
 
ZeroNights: Automating iOS blackbox security scanning
ZeroNights: Automating iOS blackbox security scanningZeroNights: Automating iOS blackbox security scanning
ZeroNights: Automating iOS blackbox security scanningMikhail Sosonkin
 
NYU hacknight, april 6, 2016
NYU hacknight, april 6, 2016NYU hacknight, april 6, 2016
NYU hacknight, april 6, 2016Mikhail Sosonkin
 
Threat stack aws
Threat stack awsThreat stack aws
Threat stack awsJen Andre
 
DEF CON 23: Internet of Things: Hacking 14 Devices
DEF CON 23: Internet of Things: Hacking 14 DevicesDEF CON 23: Internet of Things: Hacking 14 Devices
DEF CON 23: Internet of Things: Hacking 14 DevicesSynack
 
The Mouse is mightier than the sword
The Mouse is mightier than the swordThe Mouse is mightier than the sword
The Mouse is mightier than the swordPriyanka Aash
 
Formatul Portable Executable
Formatul Portable Executable Formatul Portable Executable
Formatul Portable Executable DefCamp
 
Arduino、Web 到 IoT
Arduino、Web 到 IoTArduino、Web 到 IoT
Arduino、Web 到 IoTJustin Lin
 
Sandboxie process isolation with kernel hooks
Sandboxie process isolation with kernel hooksSandboxie process isolation with kernel hooks
Sandboxie process isolation with kernel hooksKarlFrank99
 
Poc2015 os x_kernel_is_as_strong_as_its_weakest_part_liang_shuaitian
Poc2015 os x_kernel_is_as_strong_as_its_weakest_part_liang_shuaitianPoc2015 os x_kernel_is_as_strong_as_its_weakest_part_liang_shuaitian
Poc2015 os x_kernel_is_as_strong_as_its_weakest_part_liang_shuaitianLiang Chen
 
sf bay area dfir meetup (2016-04-30) - OsxCollector
sf bay area dfir meetup (2016-04-30) - OsxCollector   sf bay area dfir meetup (2016-04-30) - OsxCollector
sf bay area dfir meetup (2016-04-30) - OsxCollector Rishi Bhargava
 
Csw2016 economou nissim-getting_physical
Csw2016 economou nissim-getting_physicalCsw2016 economou nissim-getting_physical
Csw2016 economou nissim-getting_physicalCanSecWest
 

Was ist angesagt? (20)

RSA OSX Malware
RSA OSX MalwareRSA OSX Malware
RSA OSX Malware
 
Black Hat '15: Writing Bad @$$ Malware for OS X
Black Hat '15: Writing Bad @$$ Malware for OS XBlack Hat '15: Writing Bad @$$ Malware for OS X
Black Hat '15: Writing Bad @$$ Malware for OS X
 
Synack at AppSec California 2015 - Geolocation Vulnerabilities
Synack at AppSec California 2015 - Geolocation VulnerabilitiesSynack at AppSec California 2015 - Geolocation Vulnerabilities
Synack at AppSec California 2015 - Geolocation Vulnerabilities
 
Synack Shakacon OSX Malware Persistence
Synack Shakacon OSX Malware PersistenceSynack Shakacon OSX Malware Persistence
Synack Shakacon OSX Malware Persistence
 
Synack at ShmooCon 2015
Synack at ShmooCon 2015Synack at ShmooCon 2015
Synack at ShmooCon 2015
 
Codetainer: a Docker-based browser code 'sandbox'
Codetainer: a Docker-based browser code 'sandbox'Codetainer: a Docker-based browser code 'sandbox'
Codetainer: a Docker-based browser code 'sandbox'
 
ZeroNights: Automating iOS blackbox security scanning
ZeroNights: Automating iOS blackbox security scanningZeroNights: Automating iOS blackbox security scanning
ZeroNights: Automating iOS blackbox security scanning
 
NYU hacknight, april 6, 2016
NYU hacknight, april 6, 2016NYU hacknight, april 6, 2016
NYU hacknight, april 6, 2016
 
Sniffing Mach Messages
Sniffing Mach MessagesSniffing Mach Messages
Sniffing Mach Messages
 
Threat stack aws
Threat stack awsThreat stack aws
Threat stack aws
 
DEF CON 23: Internet of Things: Hacking 14 Devices
DEF CON 23: Internet of Things: Hacking 14 DevicesDEF CON 23: Internet of Things: Hacking 14 Devices
DEF CON 23: Internet of Things: Hacking 14 Devices
 
The Mouse is mightier than the sword
The Mouse is mightier than the swordThe Mouse is mightier than the sword
The Mouse is mightier than the sword
 
Formatul Portable Executable
Formatul Portable Executable Formatul Portable Executable
Formatul Portable Executable
 
Arduino、Web 到 IoT
Arduino、Web 到 IoTArduino、Web 到 IoT
Arduino、Web 到 IoT
 
Mach-O Internals
Mach-O InternalsMach-O Internals
Mach-O Internals
 
Sandboxie process isolation with kernel hooks
Sandboxie process isolation with kernel hooksSandboxie process isolation with kernel hooks
Sandboxie process isolation with kernel hooks
 
Poc2015 os x_kernel_is_as_strong_as_its_weakest_part_liang_shuaitian
Poc2015 os x_kernel_is_as_strong_as_its_weakest_part_liang_shuaitianPoc2015 os x_kernel_is_as_strong_as_its_weakest_part_liang_shuaitian
Poc2015 os x_kernel_is_as_strong_as_its_weakest_part_liang_shuaitian
 
Book
BookBook
Book
 
sf bay area dfir meetup (2016-04-30) - OsxCollector
sf bay area dfir meetup (2016-04-30) - OsxCollector   sf bay area dfir meetup (2016-04-30) - OsxCollector
sf bay area dfir meetup (2016-04-30) - OsxCollector
 
Csw2016 economou nissim-getting_physical
Csw2016 economou nissim-getting_physicalCsw2016 economou nissim-getting_physical
Csw2016 economou nissim-getting_physical
 

Andere mochten auch

Synack cirtical infrasructure webinar
Synack cirtical infrasructure webinarSynack cirtical infrasructure webinar
Synack cirtical infrasructure webinarSynack
 
Zeronights 2016 - Automating iOS blackbox security scanning
Zeronights 2016 - Automating iOS blackbox security scanningZeronights 2016 - Automating iOS blackbox security scanning
Zeronights 2016 - Automating iOS blackbox security scanningSynack
 
DEF CON 23: Spread Spectrum Satcom Hacking: Attacking The GlobalStar Simplex ...
DEF CON 23: Spread Spectrum Satcom Hacking: Attacking The GlobalStar Simplex ...DEF CON 23: Spread Spectrum Satcom Hacking: Attacking The GlobalStar Simplex ...
DEF CON 23: Spread Spectrum Satcom Hacking: Attacking The GlobalStar Simplex ...Synack
 
A touch of sin (lee sweet wan)
A touch of sin (lee sweet wan)A touch of sin (lee sweet wan)
A touch of sin (lee sweet wan)Xiao Yun
 
pJapanese director (hayao miyazaki)
pJapanese director (hayao miyazaki)pJapanese director (hayao miyazaki)
pJapanese director (hayao miyazaki)Xiao Yun
 
Leading in Local! Advance Auto Parts Discusses How To Win The Local Marketing...
Leading in Local! Advance Auto Parts Discusses How To Win The Local Marketing...Leading in Local! Advance Auto Parts Discusses How To Win The Local Marketing...
Leading in Local! Advance Auto Parts Discusses How To Win The Local Marketing...Placeable
 
Departures 2008 yojiro takita
Departures 2008 yojiro takitaDepartures 2008 yojiro takita
Departures 2008 yojiro takitaXiao Yun
 
Compare hk,taiwan,sh movies
Compare hk,taiwan,sh moviesCompare hk,taiwan,sh movies
Compare hk,taiwan,sh moviesXiao Yun
 
istilah-istilah jaringan internet dalam komputer
istilah-istilah jaringan internet dalam komputeristilah-istilah jaringan internet dalam komputer
istilah-istilah jaringan internet dalam komputerAbednego Ringgo
 
10 Passos para mudar sua vida completamente
10 Passos para mudar sua vida completamente 10 Passos para mudar sua vida completamente
10 Passos para mudar sua vida completamente Paulo Nagawa
 
Giver (archetypes)
Giver (archetypes)Giver (archetypes)
Giver (archetypes)Xiao Yun
 

Andere mochten auch (17)

Synack cirtical infrasructure webinar
Synack cirtical infrasructure webinarSynack cirtical infrasructure webinar
Synack cirtical infrasructure webinar
 
Zeronights 2016 - Automating iOS blackbox security scanning
Zeronights 2016 - Automating iOS blackbox security scanningZeronights 2016 - Automating iOS blackbox security scanning
Zeronights 2016 - Automating iOS blackbox security scanning
 
DEF CON 23: Spread Spectrum Satcom Hacking: Attacking The GlobalStar Simplex ...
DEF CON 23: Spread Spectrum Satcom Hacking: Attacking The GlobalStar Simplex ...DEF CON 23: Spread Spectrum Satcom Hacking: Attacking The GlobalStar Simplex ...
DEF CON 23: Spread Spectrum Satcom Hacking: Attacking The GlobalStar Simplex ...
 
A touch of sin (lee sweet wan)
A touch of sin (lee sweet wan)A touch of sin (lee sweet wan)
A touch of sin (lee sweet wan)
 
Sips structural insulated panels production line
Sips structural insulated panels production lineSips structural insulated panels production line
Sips structural insulated panels production line
 
pJapanese director (hayao miyazaki)
pJapanese director (hayao miyazaki)pJapanese director (hayao miyazaki)
pJapanese director (hayao miyazaki)
 
Sips structural insulated panel pressing machine
Sips structural insulated panel pressing machineSips structural insulated panel pressing machine
Sips structural insulated panel pressing machine
 
Osb sips structrual insulated panels
Osb sips structrual insulated panelsOsb sips structrual insulated panels
Osb sips structrual insulated panels
 
400 blows
400 blows400 blows
400 blows
 
Osb eps osb structural insulated panels
Osb eps osb structural insulated panelsOsb eps osb structural insulated panels
Osb eps osb structural insulated panels
 
Leading in Local! Advance Auto Parts Discusses How To Win The Local Marketing...
Leading in Local! Advance Auto Parts Discusses How To Win The Local Marketing...Leading in Local! Advance Auto Parts Discusses How To Win The Local Marketing...
Leading in Local! Advance Auto Parts Discusses How To Win The Local Marketing...
 
Departures 2008 yojiro takita
Departures 2008 yojiro takitaDepartures 2008 yojiro takita
Departures 2008 yojiro takita
 
me
meme
me
 
Compare hk,taiwan,sh movies
Compare hk,taiwan,sh moviesCompare hk,taiwan,sh movies
Compare hk,taiwan,sh movies
 
istilah-istilah jaringan internet dalam komputer
istilah-istilah jaringan internet dalam komputeristilah-istilah jaringan internet dalam komputer
istilah-istilah jaringan internet dalam komputer
 
10 Passos para mudar sua vida completamente
10 Passos para mudar sua vida completamente 10 Passos para mudar sua vida completamente
10 Passos para mudar sua vida completamente
 
Giver (archetypes)
Giver (archetypes)Giver (archetypes)
Giver (archetypes)
 

Ähnlich wie iOS Automation Primitives

UIAutomation + Mechanic.js
UIAutomation + Mechanic.jsUIAutomation + Mechanic.js
UIAutomation + Mechanic.jsjaykz52
 
Implementing new WebAPIs
Implementing new WebAPIsImplementing new WebAPIs
Implementing new WebAPIsJulian Viereck
 
Migrating Objective-C to Swift
Migrating Objective-C to SwiftMigrating Objective-C to Swift
Migrating Objective-C to SwiftElmar Kretzer
 
iOS,From Development to Distribution
iOS,From Development to DistributioniOS,From Development to Distribution
iOS,From Development to DistributionTunvir Rahman Tusher
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?Andrey Karpov
 
Advanced Swift Generics
Advanced Swift GenericsAdvanced Swift Generics
Advanced Swift GenericsMax Sokolov
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerC4Media
 
303 TANSTAAFL: Using Open Source iPhone UI Code
303 TANSTAAFL: Using Open Source iPhone UI Code303 TANSTAAFL: Using Open Source iPhone UI Code
303 TANSTAAFL: Using Open Source iPhone UI Codejonmarimba
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろうUnity Technologies Japan K.K.
 
Cocoaheads Montpellier Meetup : 3D Touch for iOS
Cocoaheads Montpellier Meetup : 3D Touch for iOSCocoaheads Montpellier Meetup : 3D Touch for iOS
Cocoaheads Montpellier Meetup : 3D Touch for iOSIdean France
 
Scraping recalcitrant web sites with Python & Selenium
Scraping recalcitrant web sites with Python & SeleniumScraping recalcitrant web sites with Python & Selenium
Scraping recalcitrant web sites with Python & SeleniumRoger Barnes
 
MFF UK - Introduction to iOS
MFF UK - Introduction to iOSMFF UK - Introduction to iOS
MFF UK - Introduction to iOSPetr Dvorak
 
"Revenge of The Script Kiddies: Current Day Uses of Automated Scripts by Top ...
"Revenge of The Script Kiddies: Current Day Uses of Automated Scripts by Top ..."Revenge of The Script Kiddies: Current Day Uses of Automated Scripts by Top ...
"Revenge of The Script Kiddies: Current Day Uses of Automated Scripts by Top ...PROIDEA
 
Back to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDBBack to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDBMongoDB
 
Presentation1 password
Presentation1 passwordPresentation1 password
Presentation1 passwordAnkit Desai
 
Adopting 3D Touch in your apps
Adopting 3D Touch in your appsAdopting 3D Touch in your apps
Adopting 3D Touch in your appsJuan C Catalan
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentanistar sung
 
MFF UK - Advanced iOS Topics
MFF UK - Advanced iOS TopicsMFF UK - Advanced iOS Topics
MFF UK - Advanced iOS TopicsPetr Dvorak
 

Ähnlich wie iOS Automation Primitives (20)

UIAutomation + Mechanic.js
UIAutomation + Mechanic.jsUIAutomation + Mechanic.js
UIAutomation + Mechanic.js
 
The zen of async: Best practices for best performance
The zen of async: Best practices for best performanceThe zen of async: Best practices for best performance
The zen of async: Best practices for best performance
 
Implementing New Web
Implementing New WebImplementing New Web
Implementing New Web
 
Implementing new WebAPIs
Implementing new WebAPIsImplementing new WebAPIs
Implementing new WebAPIs
 
Migrating Objective-C to Swift
Migrating Objective-C to SwiftMigrating Objective-C to Swift
Migrating Objective-C to Swift
 
iOS,From Development to Distribution
iOS,From Development to DistributioniOS,From Development to Distribution
iOS,From Development to Distribution
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?
 
Advanced Swift Generics
Advanced Swift GenericsAdvanced Swift Generics
Advanced Swift Generics
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
303 TANSTAAFL: Using Open Source iPhone UI Code
303 TANSTAAFL: Using Open Source iPhone UI Code303 TANSTAAFL: Using Open Source iPhone UI Code
303 TANSTAAFL: Using Open Source iPhone UI Code
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
 
Cocoaheads Montpellier Meetup : 3D Touch for iOS
Cocoaheads Montpellier Meetup : 3D Touch for iOSCocoaheads Montpellier Meetup : 3D Touch for iOS
Cocoaheads Montpellier Meetup : 3D Touch for iOS
 
Scraping recalcitrant web sites with Python & Selenium
Scraping recalcitrant web sites with Python & SeleniumScraping recalcitrant web sites with Python & Selenium
Scraping recalcitrant web sites with Python & Selenium
 
MFF UK - Introduction to iOS
MFF UK - Introduction to iOSMFF UK - Introduction to iOS
MFF UK - Introduction to iOS
 
"Revenge of The Script Kiddies: Current Day Uses of Automated Scripts by Top ...
"Revenge of The Script Kiddies: Current Day Uses of Automated Scripts by Top ..."Revenge of The Script Kiddies: Current Day Uses of Automated Scripts by Top ...
"Revenge of The Script Kiddies: Current Day Uses of Automated Scripts by Top ...
 
Back to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDBBack to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDB
 
Presentation1 password
Presentation1 passwordPresentation1 password
Presentation1 password
 
Adopting 3D Touch in your apps
Adopting 3D Touch in your appsAdopting 3D Touch in your apps
Adopting 3D Touch in your apps
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app development
 
MFF UK - Advanced iOS Topics
MFF UK - Advanced iOS TopicsMFF UK - Advanced iOS Topics
MFF UK - Advanced iOS Topics
 

Kürzlich hochgeladen

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 

Kürzlich hochgeladen (20)

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 

iOS Automation Primitives

  • 2. iOS Automation Primitives Mikhail Sosonkin mikhail@synack.com http://debugtrap.com (Hacking in context)
  • 3. Security Researcher at SYNACK Working on low level emulation with QEMU and iPhone automation. Graduate of Polytechnic University/ISIS Lab 2005 a.k.a New York University Tandon School of Engineering Masters in Software Engineering from Oxford University 2014 Exeter College
  • 4. СССР 1986 Intel 8080 Clone 1.78MHz CPU 32KB RAM 2KB ROM 450 Rubles Wikipedia-RU
  • 5. Why automation? Time saving More thorough Repeatable API Discovery Code Coverage Discover Preinstalled Malware Cameras arrived with malware from Amazon “When you automate tests of UI interactions, you free critical staff and resources for other work.” - Apple
  • 6. Getting started with iOS - Get iPhone 5s - Swappa - Apply Jailbreak - Install OpenSSH via Cydia - Use tcprelay to SSH over USB - Start exploring - Debugserver - Objective-c: Phrack 0x42 - http://phrack.org/issues/66/4.html - iOS App Reverse Engineering The world’s 1st book of very detailed iOS App reverse engineering skills :) - TCP Relay
  • 8. The goal “We want to dissect and study an application that we have no developer control over”
  • 9. Static Analysis ● Use dumpdecrypted by Stefan Esser to acquire the binary ● IDAPro for reverse engineering ● Class-dump to get the Objective-C meta data. ○ Objective-C is automation’s best friend
  • 10. Let’s explorer how Objective-C calls methods
  • 11. @interface TestObject : NSObject { } -(void)print; @end @implementation TestObject -(void)print { NSLog(@"Test Object"); } @end … TestObject* obj = [TestObject alloc]; [obj print];
  • 12. __text:0000000100000DB0 mov rsi, cs:classRef_TestObject __text:0000000100000DB7 mov rdi, cs:selRef_alloc __text:0000000100000DBE mov [rbp+var_38], rdi __text:0000000100000DC2 mov rdi, rsi __text:0000000100000DC5 mov rsi, [rbp+var_38] __text:0000000100000DC9 call _objc_msgSend __text:0000000100000DCE mov [rbp+var_18], rax __text:0000000100000DD2 mov rax, [rbp+var_18] __text:0000000100000DD6 mov rsi, cs:selRef_print __text:0000000100000DDD mov rdi, rax __text:0000000100000DE0 call _objc_msgSend Static Call Dynamic Call
  • 13. [obj print]; objc_msgSend(obj, “print”); -[TestObject print](obj, “print”); id objc_msgSend(id self, SEL op, ...) void __cdecl -[TestObject print] (struct TestObject *self, SEL)
  • 14. Dynamic Analysis ● Verbose nature of Objective-C ○ Query Objects ○ Trigger method calls ● Debugging ○ Cycript ○ Frida ○ Custom DYLIB ● Injecting into the App ○ MobileSubstrate ○ DYLD_INSERT_LIBRARIES
  • 15. Dynamic tools ● Frida ○ Binary Instrumentation using JavaScript ○ Mostly for debugging and tracing ● Cycript ○ Injectable debugger ○ Manipulate and examine objects ○ iOS Spelunking (Talk and OWASP NYC) ■ Showing how to rewire an application to discover more.
  • 16. Network tools ● MITMProxy ○ Intercept network data ○ Write custom scripts for transformations ● iOS Disable Certificate pinning ○ https://github.com/iSECPartners/ios-ssl-kill-switch ○ WARNING: THIS TWEAK WILL MAKE YOUR DEVICE INSECURE
  • 17. Available Frameworks “Appium is an open source test automation framework for use with native, hybrid and mobile web apps. It drives iOS and Android apps using the WebDriver protocol.” - Appium “You can use the Automation instrument to automate user interface tests in your iOS app through test scripts that you write.” - Apple UI Instruments
  • 18. All frameworks require you to be the app developer! Not nice for blackbox testing. Jailbreakers to the rescue!
  • 19. So, you want to roll your own? ● Simulate the user ● Read and understand the UI
  • 20. Generating Events ● SimulateTouch ○ http://api.iolate.kr/simulatetouch/ ○ Generate TouchUp/TouchDown ○ Generate Swipes ● SimulateKeyboard ○ https://github.com/iolate/SimulateKeyboard ○ Generate Key presses ○ Mechanical and Virtual
  • 21. Reading the UI ● UIView ○ The source of everything ■ Stems from UIApp.keyWindow ○ Constructs a tree structure ○ UILabel ○ UIButton ○ UITextField ○ etc.
  • 22. Let’s peek in UILabel and UIButton in a UIScrollView
  • 23. Sneaking a peek cy# UIApp.keyWindow <UIWindow; frame = (0 0; 320 568); gestureRecognizers = <NSArray>;> | <TiRootViewNeue; frame = (0 0; 320 568); autoresize = W+H; layer = <CALayer>> ... <TiUITableViewCell; baseClass = UITableViewCell; text = 'Log On'; | <TiGradientLayer;> (layer) | <UITableViewCellContentView; frame = (0 0; 256 43.5); layer = <CALayer>> | | <UITableViewLabel; frame = (74 0; 167 43.5); text = 'Log On'> | | <UIImageView; frame = (15 0; 44 43.5); layer = <CALayer>> | <_UITableViewCellSeparatorView; frame = (74 43.5; 182 0.5); layer = <CALayer>>
  • 24. Putting it all together
  • 25. “An engine for driving the UI while doing blackbox testing of an iOS App” - CHAOTICMARCH (On github)
  • 26. CHAOTICMARCH ● Lua Scriptable Logic ● Standard functions for touching the device ● Options for record/replay ● Finding UI Components ● Regulating speed of execution ● Support for multiple targets ● Mechanisms for generic logic ● Lightweight injected module
  • 27. “Lua is a powerful, fast, lightweight, embeddable scripting language … means "Moon" in Portuguese … Please do not write it as "LUA", which is both ugly and confusing” lua.org
  • 28. Lua Layout lua ├── chaotic_march.lua ├── com.gs.pwm.external-1-login.lua ├── com.hdsupply.hdsupplyfm-1-search.lua ├── post_all-click_around.lua ├── pre_all-common.lua └── pre_all-wait_to_start.lua
  • 29. Initialization 1. Dylib reads and executes chaotic_march.lua 2. Execute all pre_all*.lua scripts a. Library functions b. Generic logic 3. Execute all [bundle_id]*.lua a. Target specific logic 4. Execute all post_all*.lua a. Any sort of common clean up b. Close out the execution
  • 30. CHAOTICMARCH - Target “Engine is injected into all apps and so it has to situate itself” getBundleID() -> “com.hdsupply.hdsupplyfm”
  • 31. Basic Logic while true do local button = getButton(clickedButtons) -- put some info in. fill_all_fields() click_button(button) if(button["text"] ~= nil) then clickedButtons[button["text"]] = 1 end usleep(2 * 1000000) end
  • 32. Finding elements local buttons = findOfTypes( "UIButton", "UINavigationItemButtonView", "UINavigationItemView", "_UIAlertControllerActionView", "UISegmentLabel", "UILabel", "") Basically anything we might consider clickable.
  • 33. Other interesting functions inputText(String text) -> Enter the text into whatever component is holding the focus. hasTextAt(String txt, boxes_x, boxes_y, box_x, box_y) -> Same as component but the engine will look for text at a specified box. findOfTypes(String type1, ..., String "") -> Returns a dictionary of the locations of particular types of components.
  • 34. Element representation { "x": [x - coordinate, top-left corner], "y": [y - coordinate], "width": [number], "height": [number], "text": [best guess at text of the button], "title": [Closest title to the element] }
  • 35. Challenges/Research areas ● Identifying an interesting event ● Recording path to event ● Accurately identifying what the user sees ○ Clickables: Not all are buttons ● Instrumentation ● Repeated triggering ● Handling games and custom UI’s
  • 36. Demo! ● HD Supply test case ● Replay raw touch ● Fill in forms ● Click buttons Youtube link
  • 37. Why? Together we can build a great library of testing logic for all kinds of apps!