SlideShare a Scribd company logo
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/

More Related Content

What's hot (20)

PDF
RSA OSX Malware
Synack
 
PDF
Black Hat '15: Writing Bad @$$ Malware for OS X
Synack
 
PDF
Synack at AppSec California 2015 - Geolocation Vulnerabilities
Synack
 
PDF
Synack Shakacon OSX Malware Persistence
Ivan Einstein
 
PDF
Synack at ShmooCon 2015
Synack
 
PDF
Codetainer: a Docker-based browser code 'sandbox'
Jen Andre
 
PDF
ZeroNights: Automating iOS blackbox security scanning
Mikhail Sosonkin
 
PDF
NYU hacknight, april 6, 2016
Mikhail Sosonkin
 
PDF
Sniffing Mach Messages
Mikhail Sosonkin
 
PDF
Threat stack aws
Jen Andre
 
PDF
DEF CON 23: Internet of Things: Hacking 14 Devices
Synack
 
PDF
The Mouse is mightier than the sword
Priyanka Aash
 
PPT
Formatul Portable Executable
DefCamp
 
PDF
Arduino、Web 到 IoT
Justin Lin
 
ODP
Mach-O Internals
Anthony Shoumikhin
 
PDF
Sandboxie process isolation with kernel hooks
KarlFrank99
 
PDF
Poc2015 os x_kernel_is_as_strong_as_its_weakest_part_liang_shuaitian
Liang Chen
 
PDF
Book
luis_lmro
 
PDF
sf bay area dfir meetup (2016-04-30) - OsxCollector
Rishi Bhargava
 
PDF
Csw2016 economou nissim-getting_physical
CanSecWest
 
RSA OSX Malware
Synack
 
Black Hat '15: Writing Bad @$$ Malware for OS X
Synack
 
Synack at AppSec California 2015 - Geolocation Vulnerabilities
Synack
 
Synack Shakacon OSX Malware Persistence
Ivan Einstein
 
Synack at ShmooCon 2015
Synack
 
Codetainer: a Docker-based browser code 'sandbox'
Jen Andre
 
ZeroNights: Automating iOS blackbox security scanning
Mikhail Sosonkin
 
NYU hacknight, april 6, 2016
Mikhail Sosonkin
 
Sniffing Mach Messages
Mikhail Sosonkin
 
Threat stack aws
Jen Andre
 
DEF CON 23: Internet of Things: Hacking 14 Devices
Synack
 
The Mouse is mightier than the sword
Priyanka Aash
 
Formatul Portable Executable
DefCamp
 
Arduino、Web 到 IoT
Justin Lin
 
Mach-O Internals
Anthony Shoumikhin
 
Sandboxie process isolation with kernel hooks
KarlFrank99
 
Poc2015 os x_kernel_is_as_strong_as_its_weakest_part_liang_shuaitian
Liang Chen
 
Book
luis_lmro
 
sf bay area dfir meetup (2016-04-30) - OsxCollector
Rishi Bhargava
 
Csw2016 economou nissim-getting_physical
CanSecWest
 

Viewers also liked (17)

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

Similar to iOS Automation Primitives (20)

PPTX
iOS Application Exploitation
Positive Hack Days
 
PPT
Automating UI testing
Adam Siton
 
PDF
Pentesting iOS Apps - Runtime Analysis and Manipulation
Andreas Kurtz
 
PDF
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
PROIDEA
 
PDF
Find your own iOS kernel bug
Gustavo Martinez
 
PDF
Cucumber meets iPhone
Erin Dees
 
PDF
iOS Application Security
Egor Tolstoy
 
PDF
英文【Xu hao chen xiaobo】find your_own_ios_kernel_bug
Wang Hao Lee
 
PPTX
iOS Developer Interview Questions
Clark Davidson
 
PDF
Introduction to iOS Penetration Testing
OWASP
 
PDF
Macruby intro
Peter Lind
 
PPTX
Setting Apple's UI Automation Free with Appium
mobiletestsummit
 
PDF
2011 py con
Eing Ong
 
PDF
Ruxmon April 2014 - Introduction to iOS Penetration Testing
eightbit
 
PDF
CNIT 128: 3. Attacking iOS Applications (Part 2)
Sam Bowne
 
PPTX
Beyond the 'cript practical i os reverse engineering lascon
Nino Ho
 
PPTX
open-west
Konnor Willison
 
PDF
2a Analyzing iOS Apps Part 1
Sam Bowne
 
PDF
ASFWS 2012 - Audit d’applications iOS par Julien Bachmann
Cyber Security Alliance
 
PPTX
Pentesting iOS Applications
jasonhaddix
 
iOS Application Exploitation
Positive Hack Days
 
Automating UI testing
Adam Siton
 
Pentesting iOS Apps - Runtime Analysis and Manipulation
Andreas Kurtz
 
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
PROIDEA
 
Find your own iOS kernel bug
Gustavo Martinez
 
Cucumber meets iPhone
Erin Dees
 
iOS Application Security
Egor Tolstoy
 
英文【Xu hao chen xiaobo】find your_own_ios_kernel_bug
Wang Hao Lee
 
iOS Developer Interview Questions
Clark Davidson
 
Introduction to iOS Penetration Testing
OWASP
 
Macruby intro
Peter Lind
 
Setting Apple's UI Automation Free with Appium
mobiletestsummit
 
2011 py con
Eing Ong
 
Ruxmon April 2014 - Introduction to iOS Penetration Testing
eightbit
 
CNIT 128: 3. Attacking iOS Applications (Part 2)
Sam Bowne
 
Beyond the 'cript practical i os reverse engineering lascon
Nino Ho
 
open-west
Konnor Willison
 
2a Analyzing iOS Apps Part 1
Sam Bowne
 
ASFWS 2012 - Audit d’applications iOS par Julien Bachmann
Cyber Security Alliance
 
Pentesting iOS Applications
jasonhaddix
 
Ad

Recently uploaded (20)

PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
July Patch Tuesday
Ivanti
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Python basic programing language for automation
DanialHabibi2
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
July Patch Tuesday
Ivanti
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Python basic programing language for automation
DanialHabibi2
 

iOS Automation Primitives

  • 2. iOS Automation Primitives Mikhail Sosonkin [email protected] 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!