android attacks

58
© Blueinfy Solutions Android Attacks

Upload: blueinfy-solutions

Post on 19-Jan-2017

274 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Android attacks

© Blueinfy Solutions

Android Attacks

Page 2: Android attacks

© Blueinfy Solutions

Insecure Data Storage

• Storing sensitive information on device – a major threat

• Phone can be hacked or stolen• Imagine site access, username, passwords,

tokens etc. get harvested• Malware used to attack local system and fetch

information out.• What are the options?

Page 3: Android attacks

© Blueinfy Solutions

Insecure calls

• Storage can be accessed by third party• If device is rooted then access to sensitive

information• Poor permission can allow cross access• One app accessing information of other• Information not encrypted

Page 4: Android attacks

© Blueinfy Solutions

Bird eye view

Page 5: Android attacks

© Blueinfy Solutions

Storage calls• Shared Preferences

– Store private primitive data in key-value pairs.• Internal Storage

– Store private data on the device memory.• External Storage

– Store public data on the shared external storage.• SQLite Databases

– Store structured data in a private database.• Network Connection

– Store data on the web with your own network server.

Page 6: Android attacks

© Blueinfy Solutions

Accessing with adb# cd bank.Onecd bank.One# lslscachedatabasesfileslib# cd filescd files# lslsPublicKeyremembersettingstemp_file# cat remembercat rememberjackjack123#

Got user/pass in clear text

Page 7: Android attacks

© Blueinfy Solutions

Weak Server Side Controls

• Backend Application Security• Protocols• OWASP Top 10 for AppSec

Page 8: Android attacks

© Blueinfy Solutions

Analyzing HTTP traffic

• Security assessment needs sound knowledge of HTTP analysis

• Tools and mind needed to analyze the traffic• What to look for? – methods, cookie,

querysting etc.• All part of HTTP – Response analysis is equally

important.

Page 9: Android attacks

© Blueinfy Solutions

JSON• JSON (JavaScript Object Notation) - a

lightweight data-interchange format • Based on JavaScript Programming Language

(Standard ECMA-262)• Completely language independent • C-family of languages, including C, C++, C#,

Java, JavaScript, Perl, Python, and many others.

• Interchangeable is the Key.

Page 10: Android attacks

© Blueinfy Solutions

JSON– object

• {}{ members }

– members• pair

pair , members– pair

• string : value– array

• [][ elements ]

• elements• value value , elements

• value• stringnumberobjectarraytruefalsenull

Page 11: Android attacks

© Blueinfy Solutions

JSON

• Example { "firstName": "John", "lastName": "Smith",

"address": { "streetAddress": "21 2nd Street", "city": "New York", "state": "NY", "postalCode": 10021 }, "phoneNumbers": [ "212 732-1234", "646 123-4567" ] }

Page 12: Android attacks

© Blueinfy Solutions

JSON call

• Calling JSON services

Page 13: Android attacks

© Blueinfy Solutions

JSON fetch

• Fetch attribute

Page 14: Android attacks

© Blueinfy Solutions

Insufficient Transport Layer Protection

• Poor or no Encryption during transit• Poor certification validations• Man in the middle opening• Traffic over HTTP• Token passing• Device ID over poor channel

Page 15: Android attacks

© Blueinfy Solutions

Session with token only

Page 16: Android attacks

© Blueinfy Solutions

Client Side Injection

• Native or Web apps– Using poor libs– Abusing APIs

• Popular injections – XSS, SQLi, XPATH etc.• Payment and SMS • Mixed usage

– Using webview

Page 17: Android attacks

© Blueinfy Solutions

SQLite

Page 18: Android attacks

© Blueinfy Solutions

What is SQLite?

• SQLite is an in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.

• It is the database which is zero configured , that means like other database you do not need to configure it in your system.

• At the end, it is a comma separated file (CSV file)

Page 19: Android attacks

© Blueinfy Solutions

SQLite Commands

• The standard SQLite commands to interact with relational databases are similar as SQL.

• They are CREATE, SELECT, INSERT, UPDATE, DELETE, and DROP.

• Data Manipulation Language

Command Description

INSERT Creates a record

UPDATE Modifies records

DELETE Deletes records

Page 20: Android attacks

© Blueinfy Solutions

Cont.• Data Query Language:

• Data Definition Language:

Command Description

SELECT Retrieves certain records from one or more tables

Command Description

CREATE Creates a new table, a view of a table, or other object in database

ALTER Modifies an existing database object, such as a table.

DROP Deletes an entire table, a view of a table or other object in the database.

Page 21: Android attacks

© Blueinfy Solutions

SQLite – Create Database

• The following command will create a new database or will open the database if it has been created.

• sqlite3 [database name].db

Page 22: Android attacks

© Blueinfy Solutions

Retrieving Master Table

• This command will retrieve the master table. • For example:- variable=* FROM SQLITE_MASTER; --

Page 23: Android attacks

© Blueinfy Solutions

SQLite Version

• This command retrieves the version number of the db.

Page 24: Android attacks

© Blueinfy Solutions

SQLite – Create Table

• For example:- create table [newtablename](id int, name text);

• By using .tables on the command shell the newly created designation table is shown.

Page 25: Android attacks

© Blueinfy Solutions

SQLite – Drop Table

• drop table users;--

Page 26: Android attacks

© Blueinfy Solutions

SQLite – Insert Query

• INSERT INTO TABLE_NAME (column1, column2, column3,...Ncolumn) VALUES (value1, value2, value3,...Nvalue);

Page 27: Android attacks

© Blueinfy Solutions

Extending/Appending queries

• By altering the select query the injected DELETE query removes all records from the company table.

Page 28: Android attacks

© Blueinfy Solutions

SQLite – OR 1=1

• ‘* from [tablename] where id=1 OR 1=1;’

Page 29: Android attacks

© Blueinfy Solutions

Adding User

• insert into users values(15,’user15’)

Page 30: Android attacks

© Blueinfy Solutions

Side Channel Data Leakage

• Platform issues – sandboxing or disable controls– Cache– Logs, Keystrokes, screenshots etc.– Temp files

• 3rd Party libs (AD networks and analytics)

Page 31: Android attacks

© Blueinfy Solutions

Unauthorized Dialing/SMS

Page 32: Android attacks

© Blueinfy Solutions

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 33: Android attacks

© Blueinfy Solutions

GGTracker• June 2010• Another Application which sends

International SMS• One SMS Costs – 40 USD (NOK 200)• Application Sends Premium SMS to US

numbers

Page 34: Android attacks

© Blueinfy Solutions

UI Impersonation

Page 35: Android attacks

© Blueinfy Solutions

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 36: Android attacks

© Blueinfy Solutions

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

• Classic example is - Netflix Application in AppStore

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

Page 37: Android attacks

© Blueinfy Solutions

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 and uninstalls itself

• More than 10000 users lost their details in a week

Page 38: Android attacks

© Blueinfy Solutions

Activity Monitoring

Page 39: Android attacks

© Blueinfy Solutions

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 40: Android attacks

© Blueinfy Solutions

Activity Monitoring

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

Page 41: Android attacks

© Blueinfy Solutions

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 42: Android attacks

© Blueinfy Solutions

System Modification

Page 43: Android attacks

© Blueinfy Solutions

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 44: Android attacks

© Blueinfy Solutions

Information in Common Services

Page 45: Android attacks

© Blueinfy Solutions

Information in 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 46: Android attacks

© Blueinfy Solutions

Logical Issues

Page 47: Android attacks

© Blueinfy Solutions

Logical Issues

• Authentication flags and privilege escalations at application layer

• Critical parameter manipulation and access to unauthorized information/content

• Business constraint exploitation• Identity or profile extraction• Denial of Services (DoS) with business logic

Page 48: Android attacks

© Blueinfy Solutions

In Memory Analysis

Page 49: Android attacks

© Blueinfy Solutions

In memory analysis

• Using in built command in ADB named “dumpsys”

• Command to get memory dump – # Dumpsys meminfo

• Can be run only by “su” (Rooting a device is mandatory)

Page 50: Android attacks

© Blueinfy Solutions

Uncovering vulnerability from Manifest File

Page 51: Android attacks

© Blueinfy Solutions

Quick Recap of Manifest tags

• Manifest• Application• Activity• Activity-alias• Receiver• Service• Uses-permission

Page 52: Android attacks

© Blueinfy Solutions

Decompiling Android Applications

Page 53: Android attacks

© Blueinfy Solutions

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 54: Android attacks

© Blueinfy Solutions

Use Apktool to convert the XML to readable format

Android manifest file:

APK Tool

Page 55: Android attacks

© Blueinfy Solutions

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 56: Android attacks

© Blueinfy Solutions

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 57: Android attacks

© Blueinfy Solutions

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 58: Android attacks

© Blueinfy Solutions

Conclusion