Testing interoperability with closed-source software through - - PowerPoint PPT Presentation

testing interoperability with closed source software
SMART_READER_LITE
LIVE PREVIEW

Testing interoperability with closed-source software through - - PowerPoint PPT Presentation

Testing interoperability with closed-source software through scriptable diplomacy Ole Andr Vadla Ravns Karl Trygve Kalleberg Who are we? Ole Andr Vadla Ravns Karl Trygve Kalleberg Author of Frida, CryptoShark, oSpy, Trusty sidekick


slide-1
SLIDE 1

Testing interoperability with closed-source software through scriptable diplomacy

Ole André Vadla Ravnås Karl Trygve Kalleberg

slide-2
SLIDE 2

Who are we?

Ole André Vadla Ravnås

  • Author of Frida, CryptoShark, oSpy,

libmimic…

  • Developer, hacker and reverse engineer
  • Currently working at NowSecure
  • Doing R+D on mobile platforms

Karl Trygve Kalleberg

  • Trusty sidekick
  • Sporadic contributor to Frida, NixOS,

Spoofax, Stratego/XT, Gentoo (way back) , ...

  • Developer, hacker, forward engineer
  • Working at KolibriFX and Sensonomic
  • Doing all-round backend development

@karltk @oleavr

slide-3
SLIDE 3

What is Frida?

  • Dynamic instrumentation toolkit

○ Inspect and instrument live processes ○ Execute instrumentation scripts inside other processes ○ Scripts are ■ written in JavaScript ■ executed on a JS interpreter running inside the inspected process

  • Multi-platform

○ Windows, Mac, Linux, iOS, Android, QNX

  • Open-source

○ wxWindows Library Licence, Version 3.1

slide-4
SLIDE 4

Demo

frida-trace

slide-5
SLIDE 5

How does Frida work?

Frida

(frida-trace)

Target

bootstrapper Frida process writes bootstrapper code into memory of Target process

slide-6
SLIDE 6

How does Frida work?

Frida Target

bootstrapper Frida hijacks an existing thread in Target and has it execute bootstrapper bootstrapper thread

slide-7
SLIDE 7

How does Frida work?

Frida Target

bootstrapper Bootstrapper loads frida-agent.so into Target’s memory space bootstrapper thread frida-agent.so

slide-8
SLIDE 8

How does Frida work?

Frida Target

bootstrapper Frida-agent.so opens a bidirectional channel between Frida and Target bootstrapper thread frida-agent.so

slide-9
SLIDE 9

How does Frida work?

Frida Target

Frida-agent.so sets up its own thread, and accepts instrumentation scripts from Frida frida-agent.so Frida thread Instrumentation scripts

slide-10
SLIDE 10

Why use Frida for testing?

  • Reach internal, closed-source functionality

○ Lift logic out of closed frameworks into your tests ○ Modify behaviour of closed frameworks to improve testing ○ Theme: black box → grey box testing

  • Caveats apply

○ Warnings as for invasive software composition, especially ■ Brittle: framework internals may change ■ Time-consuming: Reverse-engineering becomes necessary ○ Your test suite may become quite complex quite quickly

slide-11
SLIDE 11

Running example: ConferenceBeats

  • Open-source application for iOS

○ (Almost) available on GitHub

  • Plays material from the Spotify record collection

○ When you recompile it, you can change the list - open source, yeah!

  • For demo purposes only

○ Open-source application on a closed OS, dependent on closed online services + support libraries ○ (= The new world order?)

slide-12
SLIDE 12

#1: Fill in Spotify login automatically

  • Keyword: UI automation
  • Challenges

○ On closed-source iOS ○ Login form is a web form, inside a UIWebView ○ The UIWebView is fully controlled by closed-source Spotify.Framework (abbrev S.F)

  • Solution

○ Inject JavaScript into UIWebView with Frida

slide-13
SLIDE 13

#2a: S.F must always use HTTPS

  • Keyword: Property-based testing
  • Challenges

○ Want to write an assertion over the stream of network calls ○ No control over calls from Spotify.Framework into CFNetwork

  • Solution

○ Use Frida’s tracing features to inspect all calls to CFNetwork

slide-14
SLIDE 14

#2b: S.F must use specific servers

  • Keyword: Property-based testing
  • Challenges

○ Want to write an assertion over the stream of network calls ○ No control over calls from Spotify.Framework into CFNetwork

  • Solution

○ Use Frida’s tracing features to inspect all calls to CFNetwork

slide-15
SLIDE 15

#3: Simulating flaky networks

  • Keyword: Regression testing
  • Challenge

○ Want to ensure 3rd party library gracefully handles flaky network ○ (Current S.F version does not)

  • Solution

○ Hook network calls—simulate lost connection ○ Check for non-empty login popup

slide-16
SLIDE 16

What are other applications for Frida?

  • Networking

○ Emulate captive gateway ○ Apply test properties only for 3rd party libraries, based on stack trace

  • Predictable data

○ Random/unpredictable data sources in framework → deterministic values ■ E.g., for camera, microphone, motion sensors

  • Cross-framework workflows

○ Simulate SMS-based auth

  • Resource starvation

○ Insufficient heap space ○ Insufficient disk space ○ Failure to open camera/mic

  • Time

○ Simulate different passing of time ■ Faster/slower progression ■ “Reverse” (e.g., tz adjust) ○ Will my app work in 2020? ○ Is my video conference still in sync after 2 days?

slide-17
SLIDE 17

Take home messages

  • Frida is applicable to certain kinds of tests

○ Especially regression and integration

  • Succinct test code is possible

○ … even for complicated test scenarios

  • Use sparingly

○ Prefer vendor-provided testing frameworks that are maintained

  • Beware the brittleness

○ Be mindful of any reverse engineering necessary

slide-18
SLIDE 18

Thank you!

frida.re | #frida on freenode.net | @fridadotre