Mobile Application Security Testing ASSESSMENT & CODE REVIEW



Similar documents
Mobile Application Security and Penetration Testing Syllabus

ios Testing Tools David Lindner Director of Mobile and IoT Security

Mobile Application Hacking for ios. 3-Day Hands-On Course. Syllabus

SYLLABUS MOBILE APPLICATION SECURITY AND PENETRATION TESTING. MASPT at a glance: v1.0 (28/01/2014) 10 highly practical modules

ABSTRACT' INTRODUCTION' COMMON'SECURITY'MISTAKES'' Reverse Engineering ios Applications

Mobile Application Hacking for Android and iphone. 4-Day Hands-On Course. Syllabus

Pentesting Android Apps. Sneha Rajguru

Advanced ANDROID & ios Hands-on Exploitation

Mobile Application Security: Who, How and Why

Enterprise Application Security Workshop Series

Penetration Testing for iphone Applications Part 1

Bypassing SSL Pinning on Android via Reverse Engineering

Pentesting iphone & ipad Apps Hack In Paris 2011 June 17

Pentesting iphone Applications. Satishb3

Pentesting ios Apps Runtime Analysis and Manipulation. Andreas Kurtz

Introduction to Android

Android & ios Application Vulnerability Assessment & Penetration Testing Training. 2-Day hands on workshop on VAPT of Android & ios Applications

AGENDA. Background. The Attack Surface. Case Studies. Binary Protections. Bypasses. Conclusions

Blackbox Android. Breaking Enterprise Class Applications and Secure Containers. Marc Blanchou Mathew Solnik 10/13/

CompTIA Mobile App Security+ Certification Exam (ios Edition) Live exam IOS-001 Beta Exam IO1-001

Pentesting Mobile Applications

Please Complete Speaker Feedback Surveys. SecurityTube.net

Security Testing Guidelines for mobile Apps

Introduction to IBM Worklight Mobile Platform

Table of Contents 7 8

APPLICATION SECURITY: FROM WEB TO MOBILE. DIFFERENT VECTORS AND NEW ATTACK

GOTO: H[a]CK. Practical ios Applications Hacking Mathieu RENARD mathieu.renard[-at-]gotohack.org mathieu.renard[-at-]sogeti.

BlackBerry Enterprise Service 10. Secure Work Space for ios and Android Version: Security Note

Android Programming and Security

Securing ios Applications. Dr. Bruce Sams, OPTIMAbit GmbH

AppConnect FAQ for MobileIron Technology Partners! AppConnect Overview

Secure your ios applications and uncover hidden vulnerabilities by conducting penetration tests

Defending Behind The Device Mobile Application Risks

Android Security Evaluation Framework

Enterprise Apps: Bypassing the Gatekeeper

AppUse - Android Pentest Platform Unified

Pen Testing ios Apps

Enterprise Mobility Management

INTRODUCTION TO ANDROID CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 11 02/15/2011

Reversing Android Malware

Example of Standard API

Introduction to Android Development. Jeff Avery CS349, Mar 2013

Android Security. Device Management and Security. by Stephan Linzner & Benjamin Reimold

Android Packer. facing the challenges, building solutions. Rowland YU. Senior Threat Researcher Virus Bulletin 2014

Unwrapping the Truth: Analysis of Mobile App Wrapping. Ron Gutierrez

TACKYDROID. Pentesting Android Applications in Style

Sandy. The Malicious Exploit Analysis. Static Analysis and Dynamic exploit analysis. Garage4Hackers

XenMobile Logs Collection Guide

CompTIA Mobile App Security+ Certification Exam (Android Edition) Live exam ADR-001 Beta Exam AD1-001

Practical Attacks against Mobile Device Management (MDM) Michael Shaulov, CEO Daniel Brodie, Security Researcher Lacoon Mobile Security

BYOD AND NEXT- GENERATION MOBILE SECURITY

Legal notices. Legal notices. For legal notices, see

Mobile Applications: The True Potential Risks Where to look for information when performing a Pentest on a Mobile Application

How To Develop Android On Your Computer Or Tablet Or Phone

New Features in XE8. Marco Cantù RAD Studio Product Manager

2tre. Hacking ios Applications. GOTO: H[a]CK. Cliquez pour modifier le style des sous-titres du masque

Security Vulnerabilities in 3rd-Party ios Applications

Practical Attacks against Mobile Device Management Solutions

BYOD: End-to-End Security

Threema security assessment

Building Secure Mobile Applications Using MaaS360 SDK and IBM Worklight

WebView addjavascriptinterface Remote Code Execution 23/09/2013

Hacking your Droid ADITYA GUPTA

Messing with the Android Runtime

ios Security The Never-Ending Story of Malicious Profiles Adi Sharabani Yair Amit CEO & Co-Founder Skycure CTO & Co-Founder

Building a Mobile App Security Risk Management Program. Copyright 2012, Security Risk Advisors, Inc. All Rights Reserved

MASTER'S THESIS. Android Application Security with OWASP Mobile Top James King 2014

When Security Gets in the Way. PenTesting Mobile Apps That Use Certificate Pinning

Spyware Analysis. Security Event - April 28, 2004 Page 1

Citrix Worx App SDK Overview

the cross platform mobile apps dream Click to edit Master title style Click to edit Master text styles Third level Fourth level» Fifth level

How Security Testing can ensure Your Mobile Application Security. Yohannes, CEHv8, ECSAv8, ISE, OSCP(PWK) Information Security Consultant

Total Enterprise Mobility

BYOD Guidance: BlackBerry Secure Work Space

Penetration Testing for iphone / ipad Applications

OWASP NZ Day 2011 Testing Mobile Applications

ANDROID BASED MOBILE APPLICATION DEVELOPMENT and its SECURITY

Using the Apple Configurator and MaaS3360

Improve your mobile application security with IBM Worklight

Jordan Jozwiak November 13, 2011

SAP Mobile - Webinar Series SAP Mobile Platform 3.0 Security Concepts and Features

Security Guide. BlackBerry Enterprise Service 12. for ios, Android, and Windows Phone. Version 12.0

Leave The App Alone! - Attack and Defense of Android App Hijack

BYPASSING THE ios GATEKEEPER

That Point of Sale is a PoS

Android Security Joshua Hodosh and Tim Leek

Android v ios Mobile Operating Systems

Guidance End User Devices Security Guidance: Apple ios 7

Adobe Marketing Cloud Bloodhound for Mac 3.0

Extending the Survey123 for ArcGIS Mobile App

With a single download, the ADT Bundle includes everything you need to begin developing apps:

Introduction to Native Android Development with NDK

Analysis of advanced issues in mobile security in android operating system

labs Attacking JAVA Serialized Communication By: Manish S. Saindane

Transcription:

Mobile Application Security Testing ASSESSMENT & CODE REVIEW Sept. 31 st 2014

Presenters ITAC 2014 Bishop Fox Francis Brown Partner Joe DeMesy Security Associate 2

Introductions FRANCIS BROWN Hi, I m Fran Partner at Bishop Fox You may remember me from such hacks as: RFID Thief Diggity Search Tool Suite Sharepoint Hacking 3

Introductions JOE DEMESY Hi, I m Joe Associate at Bishop Fox I like computers That run a POSIX OS* Phones are cool too Open source projects: Root the Box ispy 4

Agenda COVERED TODAY Breaking ios Apps Static analysis Dynamic analysis The future of ios assessments Protections & counter-measures Breaking Android Apps Static Analysis Dynamic Analysis Protections & counter-measures 5

App Security Requirements OUR TARGETS Scenarios Online Finance Point of Sale Streaming Media Mobile Device Management (MDM) Games (cheating, etc.) 6

THE GOLDEN RULE APPLICATION SECURITY

Users are Evil EVERY LAST ONE OF EM They have complete control Do not trust them Design applications and APIs accordingly 8

IOS DYNAMIC ANALYSIS BREAKING IOS APPLICATIONS

ios Prerequisites WHAT YOU NEED TO START Mac & Xcode HTTP Proxy Burp Suite Pro ($300) MitM Proxy ($0) ARM Disassembler (optional) Hopper ($90) IDA Pro ($600+) Jailbroken ios Device SSH access 10

INTERCEPTING HTTP TRAFFIC BREAKING MOBILE APPLICATIONS

HTTP Proxy Setup PROXY SETTINGS 12

HTTP Proxy Setup INTERCEPTING HTTPS TRAFFIC 13

HTTP Proxy Setup INTERCEPTING HTTPS TRAFFIC 14

The SSL Certificate Chain CERTIFICATE VALIDATION Root Intermediate Leaf 15

SSL Certificate Chain CERTIFICATE VALIDATION Root Intermediate #1 Intermediate #2 Intermediate #3 Leaf 16

Burp Suite Pro ADDING A TRUSTED ROOT CERTIFICATE 17

Burp Suite Pro ADDING A TRUSTED ROOT CERTIFICATE 18

Burp Suite Pro ADDING A TRUSTED ROOT CERTIFICATE 19

Burp Suite Pro ADDING A TRUSTED ROOT CERTIFICATE 20

HTTP Proxy Setup INTERCEPTING HTTPS TRAFFIC 21

HTTP Proxy Setup SECURE TRAFFIC INTERCEPTION 22

HTTP Proxy Setup INTERCEPTING HTTPS TRAFFIC 23

ACME Certificate Pinning NON-BROWSER CERTIFICATE VALIDATION ACME Root ACME Intermediate Application Leaf 24

IOS DYNAMIC ANALYSIS BREAKING IOS APPLICATIONS

Operating System Security Model WHY WE NEED TO JAILBREAK Signed Binaries Modifying binaries Code injection Runtime modification App Sandbox Debugging Filesystem access 26

DEMONSTRATION CODE INJECTION TECHNIQUES

APP STORE ENCRYPTION BREAKING IOS APPLICATIONS

Binary Encryption GETTING PLAINTEXT BINS Encrypted Binaries AppStore Clutch Rasticrac No Encryption Provisioned Device Test Flight, etc. 29

Clutch Usage DECRYPTING IOS BINARIES Open source (GitHub) Decrypts ios applications and repackages them Saves apps in: /var/root/documents/cracked Saves apps as.ipa files (they re just ZIPs) Use: clutch <app name> 30

The IPA Archive Format NOT DELICIOUS BEER Foobar.ipa itunesmetadata. plist itunesartwork Payload/ Foobar.app Foobar 31

itunes Metadata SOFTWARE VERSION BUNDLE ID 32

ARM Disassembly I AM IN YOUR BINARIES CHANGING YOUR CODE 33

ARM Decompiler I AM IN UR BINARIES MODIF IN UR CODEZ 34

XOR is Not Obfuscation JAILBREAK DETECTION BYPASSES 35

Modifying ARM Assembly ASSEMBLE INSTRUCTION 36

Modifying ARM Assembly PRODUCE NEW EXECUTABLE 37

OBJECTIVE-C HEADERS STATIC ANALYSIS

Class Dump OBJECTIVE-C CLASS INTERFACES 39

#import <XXUnknownSuperclass.h> // Unknown library @class NSString; @interface XXasymEncryptor : XXUnknownSuperclass { NSString* _publickeyid; NSString* _privatekeyid; } @property(copy, nonatomic) NSString* privatekeyid; @property(copy, nonatomic) NSString* publickeyid; -(id)privatequerydict; -(id)publicquerydict; -(void)decryptwithprivatekey; -(void)encryptwithpublickey; -(void)keysplease; -(id)decryptdata:(id)data; -(id)encryptdata:(id)data; -(id)init; @end

#import <XXUnknownSuperclass.h> // Unknown library @class NSString; @interface XXasymEncryptor : XXUnknownSuperclass { NSString* _publickeyid; NSString* _privatekeyid; } @property(copy, nonatomic) NSString* privatekeyid; @property(copy, nonatomic) NSString* publickeyid; -(id)privatequerydict; -(id)publicquerydict; -(void)decryptwithprivatekey; -(void)encryptwithpublickey; -(void)keysplease; -(id)decryptdata:(id)data; -(id)encryptdata:(id)data; -(id)init; @end Hmmmm

MOBILE SUBSTRATE CODE INJECTION TECHNIQUES

The Objective-C Runtime MESSAGE PASSING ios App Call Type? Obj C objc_msgsend Native C Execute Code 43

The Objective-C Runtime MESSAGE PASSING ios App Mobile Substrate (Our code runs here) Call Type? Obj C Native C objc_msgsend Execute Code 44

Jailbreak Detection Code BYPASSING COMMON DETECTION METHODS Fork() Stat() / Lstat() Cydia /apt/ Etc dyld_count() dyld_get_image_name() 45

Jailbreak Detection Code BYPASSING COMMON DETECTION METHODS @class NSString; @interface DeviceSecurity: { BOOL _jbstatus; } @property(assign, nonatomic) BOOL jbstatus; +(BOOL)isJailbroken; @end 46

Theos + Logos + Mobile Substrate CLASS AND METHOD HOOKING #import "substrate.h" %hook DeviceSecurity -(BOOL) isjailbroken { %log; // Logos built-in logging return NO; // Return FALSE } %end 47

Certificate Bypasses TRUST ME BYPASS #import "substrate.h" /* New function definition */ OSStatus new_sectrustevaluate(sectrustref trust, SecTrustResultType *result) { *result = ksectrustresultproceed; return errsecsuccess; } %ctor { /* Hook the function */ MSHookFunction((void *)SecTrustEvaluate, (void *)new_sectrustevaluate, (void **)&original_sectrustevaluate); } 48

CYCRIPT RUNTIME MODIFICATION

Cycript is Black Magic RUNTIME MODIFICATION TECHNIQUES JavaScript REPL JavaScript + Cycript language extensions Objective-C runtime is merged into the REPL Attach to running apps 50

Cycript Basics ATTACHING TO A PROCESS iphone:~root# cycript p AlienBlue cy# UIApp @"<UIApplication: 0x8ba2c0>" cy# UIApp.keyWindow.delegate @"<CustomNavigationController: 0x836900>" cy# ui(uiapp.keywindow, "Foobar") <UILabel: 0x82f0d0; frame = (132 12; 55 21); text = 'Foobar'; clipstobounds = YES; userinteractionenabled = NO; layer = <CALayer: 0x82f190>> 51

Cycript Basics ATTACHING TO A PROCESS cy# var label = new Instance(0x82f0d0) @"<UILabel: 0x82f0d0; frame = (132 12; 55 21); text = 'Reddits'; clipstobounds = YES; userinteractionenabled = NO; layer = <CALayer: 0x82f190>> cy# label.text @"Foobar" cy# label.text = @"Barfoo" @"Barfoo" 52

DEMONSTRATION CYCRIPT IN ACTION

ISPY WELCOME TO THE FUTURE

ispy Assessment Framework YOUR ONE-STOP-SHOP FOR IOS HACKING Under Active Development Easy to use Web GUI Class dumps / Instance tracking Automatic jailbreak-detection bypasses Automatic SSL certificate pinning bypasses Re-implemented objc_msgsend Automatic detection of vulnerable function calls Easy to use soft-breakpoints More on the way! 56

DEMONSTRATION ISPY IN ACTION

ispy GITHUB REPOS https://github.com/bishopfox 58

COUNTER- MEASURES PROTECTING IOS APPLICATIONS

Defense Against the Dark Arts ON DISK & IN MEMORY 1. Security code 1. Assembly and/or C 2. Inline functions 3. Objective-C obfuscation 2. Certificate pinning 1. Whitelist root authorities 3. Change release Metaforic Commercial AppMinder BSD Licensed a) http://appminder.nesolabs.de/ 60

AppMinder FREE N EASY OBFUSCATION 61

ANDROID APP SECURITY JAVA JAVA JAVA JAVA JAVA JAVA

Android Prerequisites WHAT YOU NEED TO START Linux / Mac / Windows HTTP Proxy Burp Suite Pro ($300) MitM Proxy ($0) ADT Eclipse Bundle Substrate plug-in Procyon (Java decompiler) Dex2jar (bytecode converter) Rooted Device Cydia Substrate 63

Android Application Packages GOOGLE PLAY STORE APKs are signed Not encrypted APK Extractor Direct Download 64

Decompiling Dalvik Bytecode GETTING SOURCE CODE 65

Dex2jar + Procyon TWO STEP DECOMPILATION $ dex2jar Foobar.apk dex2jar foobar.apk -> Foobar-dex2jar.jar $ procyon jar Foobar-dex2jar.jar o src/ Decompiling com/foobar/parser... Decompiling com/foobar/xmlwriter... 66

Decompiled Android Code SOURCE SORTA 67

DYNAMIC ANALYSIS ON ANDROID

The Android Zygote APPLICATION INSTANTIATION 69

Cydia Substration ANDROID FUNCTION HOOKING Class to hook Method to hook 70

Cydia Substration ANDROID FUNCTION HOOKING 71

Cydia Substration ANDROID FUNCTION HOOKING 72

Cydia Substration ANDROID FUNCTION HOOKING 73

Cydia Substration ANDROID FUNCTION HOOKING 74

Cydia Substration ANDROID FUNCTION HOOKING 75

Cydia Substration ANDROID FUNCTION HOOKING 76

Android LogCat RESULTS Filter by tag 77

COUNTER- MEASURES PROTECTING ANDROID APPLICATIONS

Android Application Security DREAMING OF ELECTRIC SHEEP Security subroutines C / C++ (NDK) Assembly Inline functions Avoid kernel calls if possible Java bytecode obfuscation Certificate pinning 79

CONCLUSIONS MOBILE APPLICATION SECURITY

Management Not Security BYOD VERTICAL CLOUD INTEGRATION WITH APT SYNERGY MDM is Mobile Device Management Client-side enforcement Devices lie 81

Mobile Security IN A NUT SHELL Client-side enforcement Your architecture is probably broken, fix that instead If the business model dictates that you must Perhaps the revenue model depends on it Perhaps you have to integrate with legacy code Perhaps there s some other crazy reason for on-device security 82

Client-side Enforcement YOU CAN TRY, BUT IT IS NOT GOING TO WORK 83

Good Hunting!

Contact Us bishopfox.com contact@bishopfox.com @bishopfox on the Twitters github.com/bishopfox We re hiring!

Image Citations Internet Image: LobStoR/Wikimedia iphone Image: Zach Vega/Wikimedia Hacker Image: chanpipat/freedigitalphotos.net Lock Image: Stuart Miles/FreeDigitalPhotos.net Binary Image: noegranado/flickr Creative Commons