mobile code mining for discovery and exploits nullcongoa2013

80
Mobile Code Mining For Discovery and Exploits

Upload: blueinfy-solutions

Post on 19-Jan-2017

264 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Mobile code mining for discovery and exploits nullcongoa2013

Mobile Code Mining For Discovery and Exploits

Page 2: Mobile code mining for discovery and exploits nullcongoa2013

Who Am I? Hemil Shah – [email protected]

Co-CEO & Director, Blueinfy Solutions

Past experience

eSphere Security, HBO, KPMG, IL&FS, Net SquareInterest

Web and mobile security researchPublished research

Articles / Papers – Packstroem, etc.Web Tools – wsScanner, scanweb2.0, AppMap, AppCodeScan, AppPrint etc.

Mobile Tools – FSDroid, iAppliScan, DumpDroid

[email protected] http://www.blueinfy.comBlog – http://blog.blueinfy.com/

Page 3: Mobile code mining for discovery and exploits nullcongoa2013

Enterprise Technology Trend

2007. Web services would rocket from $1.6 billion in 2004 to $34 billion. [IDC]

2008. Web Services or Service-Oriented Architecture (SOA) would surge ahead. [Gartner]

2009. Enterprise 2.0 in action and penetrating deeper into the corporate environment

2010. Flex/HTML5/Cloud/API2012. HTML5/Mobile era.

Page 4: Mobile code mining for discovery and exploits nullcongoa2013

Past, Present and Future

Cloud

2010

Focus

Page 5: Mobile code mining for discovery and exploits nullcongoa2013

Mobile Infrastructure

www mail

intranetrouter

DMZ

Internet

VPN

Dial-up

Other Offices

Exchangefirewall

Database RAS

Page 6: Mobile code mining for discovery and exploits nullcongoa2013

Mobile App Environment

WebServer

Static pages only(HTML,HTM, etc.)Web

Client

ScriptedWeb

EngineDynamic pages

(ASP,DHTML, PHP,CGI, etc.)

ASP.NET on .Net Framework,J2EE App Server,

Web Services,etc.

ApplicationServers

And IntegratedFramework

Internet DMZ Trusted

WWEEBB

SSEERRVVIICCEESS

Mobile

SOAP/JSON etc.

DB

X

Internal/Corporate

Page 7: Mobile code mining for discovery and exploits nullcongoa2013

Mobile Apps

Page 8: Mobile code mining for discovery and exploits nullcongoa2013

Mobile Changes

Application Infrastructure

Changing dimension Web Mobile(AI1) Protocols HTTP & HTTPS JSON, SOAP, REST etc. over

HTTP & HTTPS

(AI2) Information structures

HTML transfer JSON, JS Objects, XML, etc.

(AI3) Technology Java, DotNet, PHP, Python and so on

Cocoa, Java with Platform SDKs, HTML5

(AI4) Information Store/Process

Mainly on Server Side Client and Server Side

Page 9: Mobile code mining for discovery and exploits nullcongoa2013

Mobile Changes

Security Threats

Changing dimension Web Mobile

(T1) Entry points Structured Scattered and multiple

(T2) Dependencies Limited Multiple technologies Information sources Protocols

(T3) Vulnerabilities Server side [Typical injections]

Web services [Payloads] Client side [Local Storage]

(T4) Exploitation Server side exploitation Both server and client side exploitation

Page 10: Mobile code mining for discovery and exploits nullcongoa2013

Mobile Attacks

Page 11: Mobile code mining for discovery and exploits nullcongoa2013

Insecure Storage

Page 12: Mobile code mining for discovery and exploits nullcongoa2013

Insecure Storage

Why application needs to store data• Ease of use for the user• Popularity• Competition• Activity with single click• Decrease Transaction time• Post/Get information to/from Social Sites

9 out of 10 applications have this vulnerability

Page 13: Mobile code mining for discovery and exploits nullcongoa2013

Insecure Storage

How attacker can gain access• Wifi • Default password after jail breaking (alpine)• Adb over wifi• Physical Theft• Temporary access to device

Page 14: Mobile code mining for discovery and exploits nullcongoa2013

Insecure Storage

What information we usually find• Authentication Credentials• Authorization tokens• Financial Statements• Credit card numbers• Owner’s Information – Physical Address, Name,

Phone number• Social Engineering Sites profile/habbits• SQL Queries

Page 15: Mobile code mining for discovery and exploits nullcongoa2013

DEMO

Page 16: Mobile code mining for discovery and exploits nullcongoa2013

Insecure Network Communication

Page 17: Mobile code mining for discovery and exploits nullcongoa2013

Insecure Network Channel

• Easy to perform MiM attacks as Mobile devices uses untrusted network i.e open/Public WiFi, HotSpot, Carrier’s Network

• Application deals with sensitive data i.e. • Authentication credentials• Authorization token• PII Information (Privacy Violation) (Owner Name,

Phone number, UDID)

Page 18: Mobile code mining for discovery and exploits nullcongoa2013

Insecure Network Channel

• Can sniff the traffic to get an access to sensitive data

• SSL is the best way to secure communication channel

• Common Issues• Does not deprecate HTTP requests• Allowing invalid certificates• Sensitive information in GET requests

Page 19: Mobile code mining for discovery and exploits nullcongoa2013

Session token

Page 20: Mobile code mining for discovery and exploits nullcongoa2013

Unauthorized Dialing/SMS

Page 21: Mobile code mining for discovery and exploits nullcongoa2013

Unauthorized Dialing/SMS

• Social Engineering using Mobile Devices• Attacker plays with user’s mind• User installs application• Application sends premium rate SMS or a

premium rate phone call to unknown number• Used by Malware/Trojans

Page 22: Mobile code mining for discovery and exploits nullcongoa2013

AndroidOS.FakePlayer

August 2010• Sends costly International SMS• One SMS Costs – 25 USD (INR 1250)• Application Sends SMS to –

• 3353 & 3354 numbers in Russia

Page 23: Mobile code mining for discovery and exploits nullcongoa2013

GGTracker

June 2010• Another Application which sends International

SMS• One SMS Costs – 40 USD (INR 2000)• Application Sends Premium SMS to US

numbers

Page 24: Mobile code mining for discovery and exploits nullcongoa2013

UI Impersonation

Page 25: Mobile code mining for discovery and exploits nullcongoa2013

UI Impersonation

• Attack has been there since long• On a mobile stack, known as UI impersonation• Other names are Phishing Attack, ClickJacking• Attacker plays with user’s mind and try to

impersonate as other user or other application

Page 26: Mobile code mining for discovery and exploits nullcongoa2013

UI Impersonation

• Victim looses credit card information or authentication credentials or secret

• One application can create local PUSH notification as it is created from apple store

• Flow in review process of AppStore – Anyone can name anything to their application

Page 27: Mobile code mining for discovery and exploits nullcongoa2013

NetFlix

Oct -2011• Steals users “netflix” account information• Application shows error message to user

“Compatibility issues with the user’s hardware” when user enters username and password

• Once error message, application uninstalls itself

Page 28: Mobile code mining for discovery and exploits nullcongoa2013

Activity Monitoring

Page 29: Mobile code mining for discovery and exploits nullcongoa2013

Activity Monitoring

• Sending a blind carbon copy of each email to attacker

• Listening all phone calls• Email contact list, pictures to attacker• Read all emails stored on the device• Usual intension of Spyware/Trojans

Page 30: Mobile code mining for discovery and exploits nullcongoa2013

Activity Monitoring

Attacker can monitor – • Audio Files• Video• Pictures• Location• Contact List• Call/Browser/SMS History• Data files

Page 31: Mobile code mining for discovery and exploits nullcongoa2013

Android.Pjapps

Early 2010• Steal/Change users information• PjApps Application –

• Send and monitor incoming SMS messages• Read/write to the user's browsing history and bookmarks• Install packages and Open Sockets• Write to external storage• Read the phone's state

Page 32: Mobile code mining for discovery and exploits nullcongoa2013

System Modification

Page 33: Mobile code mining for discovery and exploits nullcongoa2013

System Modification

• Application will attempt to modify system configuration to hide itself (Historically this is known as ROOTKIT)

• Configuration changes makes certain attack possible i.e. – • Modifying device proxy to get user’s activity

monitoring• Configure BCC email sending to attacker

Page 34: Mobile code mining for discovery and exploits nullcongoa2013

iKee – iPhone Worm

“ikee” iPhone WormChange root password Change wallpaper to Ricky Martin.

After infected by “ikee“iPhone look like this

Page 35: Mobile code mining for discovery and exploits nullcongoa2013

PII Information Leakage

Page 36: Mobile code mining for discovery and exploits nullcongoa2013

PII Information Leakage

• Application usually have access to user’s private information i.e. Owner Name, Location, Physical Address, AppID, Phone Number

• This information needs to be handled very carefully as per the law in some countries

• Storing this information in plain text is not allowed in some countries

Page 37: Mobile code mining for discovery and exploits nullcongoa2013

DEMO

Page 38: Mobile code mining for discovery and exploits nullcongoa2013

Hardcoded Secrets

Page 39: Mobile code mining for discovery and exploits nullcongoa2013

Hardcoded Secrets

• Easiest way for developer to solve complex issues/functionality

• Attacker can get this information by either reverse engineering application or by checking local storage

Page 40: Mobile code mining for discovery and exploits nullcongoa2013

DEMO

Page 41: Mobile code mining for discovery and exploits nullcongoa2013

Language Specific Issues

Page 42: Mobile code mining for discovery and exploits nullcongoa2013

Language Specific Issues

• Application in iOS are developed in Objective-C language which is derived from classic C language

• Along with this derivation, it also derives security issues in C language i.e. overflow attacks

Page 43: Mobile code mining for discovery and exploits nullcongoa2013

SQL Injection in Local database

Page 44: Mobile code mining for discovery and exploits nullcongoa2013

SQL Injection in Local database

• Most Mobile platforms uses SQLite as database to store information on the device

• Using any SQLite Database Browser, it is possible to access database logs which has queries and other sensitive database information

• In case application is not filtering input, SQL Injection on local database is possible

Page 45: Mobile code mining for discovery and exploits nullcongoa2013

DEMO

Page 46: Mobile code mining for discovery and exploits nullcongoa2013

Information in Common Services

Page 47: Mobile code mining for discovery and exploits nullcongoa2013

Common Services

• KeyBoard, Clipboard are shared amongst all the applications.

• Information stored in clipboard can be accessed by all the application

• Sensitive information should not be allowed to copy/paste in the application

Page 48: Mobile code mining for discovery and exploits nullcongoa2013

DEMO

Page 49: Mobile code mining for discovery and exploits nullcongoa2013

Server Side Issues

Page 50: Mobile code mining for discovery and exploits nullcongoa2013

Server Side Issues

• Most Application makes server side calls to either web services or some other component. Security of server side component is equally important as client side

• Controls to be tested on the server side – Security Control Categories for Server Side Application– Authentication, Access Controls/Authorization, API misuse, Path traversal, Sensitive information leakage,

Page 51: Mobile code mining for discovery and exploits nullcongoa2013

Server Side Issues

• Error handling, Session management, Protocol abuse, Input validations, XSS, CSRF, Logic bypass, Insecure crypto, DoS, Malicious Code Injection, SQL injection, XPATH and LDAP injections, OS command injection, Parameter manipulations, BruteForce, Buffer Overflow, HTTP response splitting, HTTP replay, XML injection, Canonicalization, Logging and auditing.

Page 52: Mobile code mining for discovery and exploits nullcongoa2013

Mobile Top 10 - OWASP• Insecure Data Storage

• Weak Server Side Controls

• Insufficient Transport Layer Protection

• Client Side Injection

• Poor Authorization and Authentication

• Improper Session Handling

• Security Decisions Via Untrusted Inputs

• Side Channel Data Leakage

• Broken Cryptography

• Sensitive Information Disclosure

Page 53: Mobile code mining for discovery and exploits nullcongoa2013

Decompiling Android Applications

Page 54: Mobile code mining for discovery and exploits nullcongoa2013

Decompiling android application

• Using Apktool - http://code.google.com/p/android-apktool/

• Using Dex2Jar - http://code.google.com/p/dex2jar/

• Using aapt (Bundled with Android SDK)

Page 55: Mobile code mining for discovery and exploits nullcongoa2013

Use Apktool to convert the XML to readable format

Android manifest file:

APK Tool

Page 56: Mobile code mining for discovery and exploits nullcongoa2013

DEMO

Page 57: Mobile code mining for discovery and exploits nullcongoa2013

Use dex2jar to convert classes.dex file in the extracted folder to .class files

Use JAD to convert the class files into JAVA files

Dex2Jar and JAD

Page 58: Mobile code mining for discovery and exploits nullcongoa2013

DEMO

Page 59: Mobile code mining for discovery and exploits nullcongoa2013

Aapt• Android Asset Packaging Tool

• Allows you to view , create and update Zip-compatible archives

View components in an apk:

Page 60: Mobile code mining for discovery and exploits nullcongoa2013

DEMO

Page 61: Mobile code mining for discovery and exploits nullcongoa2013

Looking in to Code

Page 62: Mobile code mining for discovery and exploits nullcongoa2013

Static Code Analysis

• Introduce in Mac OS X v10.6, XCode 3.2, Clang analyzer merged into XCode. • Memory leakage warning• Run from Build->Analyze• Innovative shows you complete flow of

object start to end• Configure as a automatic analysis during

build process

Page 63: Mobile code mining for discovery and exploits nullcongoa2013

Static Code Analysis

Potential Memory Leak

Page 64: Mobile code mining for discovery and exploits nullcongoa2013

Static Code Analysis

Dead store – variable never used

Page 65: Mobile code mining for discovery and exploits nullcongoa2013

Static Code Analysis

Uninitialized Variable

Page 66: Mobile code mining for discovery and exploits nullcongoa2013

Static Code Analysis

Type Size Mismatch

Page 67: Mobile code mining for discovery and exploits nullcongoa2013

Static Code Analysis

Object used after release

Page 68: Mobile code mining for discovery and exploits nullcongoa2013

Code Analysis with AppCodeScan

• Semi automated tool• Ability to expand with custom rules• Simple tracing utility to verify and track

vulnerabilities• Simple HTML reporting which can be

converted to PDF

Page 69: Mobile code mining for discovery and exploits nullcongoa2013

AppCodeScan

• Sophisticated tool consist of two components • Code Scanning• Code Tracer

• Allows you to trace back the variable• AppCodeScan is not complete automated

static code analyzer.• It only relies on regex and lets you find

SOURCE of the SINK

Page 70: Mobile code mining for discovery and exploits nullcongoa2013

DEMO

Page 71: Mobile code mining for discovery and exploits nullcongoa2013

ScanDroid

• Ruby script to scan through source code (Pattern matching) for APIs

• Also takes care about reverse engineering application

• Make list of permissions• No code trace• No reporting

Page 72: Mobile code mining for discovery and exploits nullcongoa2013

Rules in AppCodeScan

• Writing rules is very straight forward• In an XML file which is loaded at run time• This release has rules for iOS and Android for

- Local Storage, Unsafe APIs, SQL Injection, Network Connection, SSL Certificate Handling, Client Side Exploitation, URL Handlers, Logging, Credential Management and Accessing PII.

Page 73: Mobile code mining for discovery and exploits nullcongoa2013

Sample Rules - Android

Page 74: Mobile code mining for discovery and exploits nullcongoa2013

Android DEMO

Page 75: Mobile code mining for discovery and exploits nullcongoa2013

Sample Rules - iOS

Page 76: Mobile code mining for discovery and exploits nullcongoa2013

iOS DEMO

Page 77: Mobile code mining for discovery and exploits nullcongoa2013

Debuggable flag in Android

• One of the key attribute in android manifest file• Under “application” section• Describes debugging in enabled• If “Debuggable”attribute is set o true, the application

will try to connect to a local unix socket “@jdwp-control”

• Using JDWP, It is possible to gain full access to the Java process and execute arbitrary code in the context of the debugable application

Page 78: Mobile code mining for discovery and exploits nullcongoa2013

CheckDebuggable Script

• Checks in APK whether debuggable is enabled

• Script can be found at – http://www.espheresecurity.com/resourcestools.html

• Paper can be found at - http://www.espheresecurity.com/CheckDebuggable.pdf

Page 79: Mobile code mining for discovery and exploits nullcongoa2013

DEMO

Page 80: Mobile code mining for discovery and exploits nullcongoa2013

Conclusion – Questions?