29
Android System Architecture And Pen-testing of Android applications Yavuz Han

Android System Architecture And  Pen-testing of Android applications

  • Upload
    yavuzwb

  • View
    1.402

  • Download
    3

Embed Size (px)

DESCRIPTION

Its about the Android System architecture and pentesting of Android applications(for begining)

Citation preview

Page 1: Android System Architecture  And  Pen-testing of Android applications

Android System Architecture And

Pen-testing of Android applications

Yavuz Han

Page 2: Android System Architecture  And  Pen-testing of Android applications

What is Android ?

• A software platform and operating system for mobile devices

• Based on the Linux kernel(Kernel 2.6)• Developed by Google and later Open Handset

Aliance(OHA)• Also writing managed code in the Java

Language• C/C++ also but not supported

Page 3: Android System Architecture  And  Pen-testing of Android applications

Android Architecture

Page 4: Android System Architecture  And  Pen-testing of Android applications

Applications

• First layer in system architecture• These include the applications shipped with

android like the email client, SMS client, maps, browsers and also the applications developed and distributed through the Android market.

Page 5: Android System Architecture  And  Pen-testing of Android applications

Application Framework

• Second layer in system architecture• These include the programs that manage the

basic functions of the phone like resource allocation, voice call management, etc

Page 6: Android System Architecture  And  Pen-testing of Android applications

Libraries

• The layer above to the Linux kernel is the Android’s native libraries.

• These libraries are written in C/C++ languages.• These libraries also run as processes within the

underlying Linux kernel. • The libraries are nothing but a set of instructions

that tell the device how to handle different kinds of data (e.g. The media libraries support playing or recording various audio/video formats)

Page 7: Android System Architecture  And  Pen-testing of Android applications

Some of the key libraries are listed below:

• SQLite:This is a lightweight yet powerful relational database engine available for all applications to store data.

• Webkit:This is a browser engine providing tools for browsing web pages.

• Surface Manager: This is responsible for the graphics on the device screens

• OpenGL: Used to render 2D or 3D graphics to the screen

Page 8: Android System Architecture  And  Pen-testing of Android applications

Android Runtime

• This is located on the same layer as the libraries layer.• It consists of the core JAVA libraries and the Dalvik

virtual machine.• The core Java libraries are used for developing

Android based applications.• Dalvik VMs help in achieving the following: - better memory management -an application cannot interfere with other applications without permissions - threading support

Page 9: Android System Architecture  And  Pen-testing of Android applications

• The diagram below is a pictorial representation of the Android environment.

• It can be observed that each Android application runs under a separate virtual instance and each application has a unique user-id assigned to it.

Page 10: Android System Architecture  And  Pen-testing of Android applications

Linux Kernel

• This is last layer in system architecture• Device drivers, power management, process

management and networking services depend on the layer

• Android using Linux kernel 2.6 and android developed over time have been harmonized.

• Android is not exactly Linux.

Page 11: Android System Architecture  And  Pen-testing of Android applications

Penetration testing of Android apps

• The applications in Android can be mainly classified into two categories:

-Android browser-based applications

-Android-based applications (Android application package files – .apk extension files)

Page 12: Android System Architecture  And  Pen-testing of Android applications

Android Filesystem Access

We want to analyze files within the device,so how do we do this ?

ADB (windows,linux,mac)

Page 13: Android System Architecture  And  Pen-testing of Android applications

Android FileSystem Access

• Android Debug Bridge (adb) command -Access a shell -Pull/push files -Many more

Page 14: Android System Architecture  And  Pen-testing of Android applications

Example of ADB

Page 15: Android System Architecture  And  Pen-testing of Android applications

Quick look at some apps• We’re going to use Android’s default mail client

(Note – this is for a rooted device)•Navigate to the shared_prefs directory of the application

Page 16: Android System Architecture  And  Pen-testing of Android applications

Quick look at some apps • •cat (read) the file

Page 17: Android System Architecture  And  Pen-testing of Android applications

Data Storage

SQLite

-Single file relational database

-Supportet by Android & iPhone APIs to store Application settings/data

Page 18: Android System Architecture  And  Pen-testing of Android applications

• Using the ADB shell, we can browse to the database folder and access the data as shown below:

Page 19: Android System Architecture  And  Pen-testing of Android applications

Logging

• Applications may leak data through gratuitous logging

• In older versions of Android, the browser would log URLs visited

-This also logged session Ids for websites that put it in the GET request

Page 20: Android System Architecture  And  Pen-testing of Android applications

Viewing Android Logs

• We can use ‘adb logcat’ command

Page 21: Android System Architecture  And  Pen-testing of Android applications

Android Client Analysis

• Android Application Layout -Apps are packaged in an APK file (zip archive) -What is in it ? -Dalvik class files(.dex) -Assets and Resources -Android Manifest.xml -APKs stored at /data/app on a device Can extract this

Page 22: Android System Architecture  And  Pen-testing of Android applications

Android Application Layout

Page 23: Android System Architecture  And  Pen-testing of Android applications

Android Application Layout

Page 24: Android System Architecture  And  Pen-testing of Android applications

Android Manifest.xml

• Enumerates permissions • We are most interested in permissions and metadata

Page 25: Android System Architecture  And  Pen-testing of Android applications

Analyzing an APK

• The files inside an APK are not directly useful -Need to unpack the XML,disassemble the dex class files

We are using some tool for reverse engineering Android apk files

Page 26: Android System Architecture  And  Pen-testing of Android applications

Decompilation

• This way eassier than other ways• You may be familiar with jad or jdgui -Use dex2jar to get a (JVM) jar from an apk*Perform “source review” on decompiled app Does not work for all apks

Page 27: Android System Architecture  And  Pen-testing of Android applications

Decompilation

Page 28: Android System Architecture  And  Pen-testing of Android applications

Protection

• We must treat the mobile device as hostile• Don’t store sensitive data unencrypted!• Doing encryption well is HARD• Best practice: don’t store any sensitive data on

device

Page 29: Android System Architecture  And  Pen-testing of Android applications

THANK YOU

QUESTİONS