Prerequisites to follow the steps

Computer with Android SDK Installed

A Non Rooted mobile device to install the app.

Topics Involved:

Information gathering

Attacking Vulnerable Activity Components

Securing the applications

Information gathering

  1. Decompile the app with APK tool.

  2. Analyze AndroidManifest.xml file for exported Activity components.


Every Android App has a package name and every Activity has its own Class name inside the package. The initial steps are to find out the name of the package and names of the available sensitive activities. Though there are other methods to get this information, looking at the AndroidManifest.xml is a good approach. We can get the AndroidManifest.xml file by decompiling the application using APKTOOL.


  1. Download APKTOOL from the link below.

    https://code.google.com/p/android-apktool/downloads/list

  2. Place the test application in the same folder as in APKTOOL.


  3. Now, decompile the APK file using the following command as shown in the figure:

    apktool d testapp.apk




As shown in the figure below, we should now be able to see a new folder named “testapp” with the AndroidManifest.xml file inside it.



Now, we need to search for the package name and its activities.

All the activities will be registered in AndroidManifest.xml file using <activity></activity> tags. So, anything inside these tags will be an activity. Looking at the AndroidManifest.xml file, we are able to see two Activity Components and the package name as shown in the figure below.



By examining the above figure, it is clear that we got the following information about the app.

com.isi.testapp is the name of the package.

com.isi.testapp.Welcome could be the activity we are getting after providing the correct password.


Attacking Vulnerable Activity Components

Our job now is to launch Welcome activity without providing any password in the first screen.

We can perform attacks on vulnerable activity components in several ways, as mentioned below.

  1. Launching sensitive Activities with Activity Manager Tool.

  2. Using a Malicious App to invoke Activities of other apps.

  3. We can also use Mercury framework for performing these attacks, which will be covered in later articles.


Launching sensitive activities with Activity manager tool

Activity Manager is a tool that comes preinstalled with Android SDK and can be used along with “adb shell”. This tool can be used to launch Activities and Services of an application. We can even pass intents using it.

So, let’s begin.


  1. Connect the device to the computer and get a shell on the device using the following command:

    adb shell


  2. Type in the following command to launch the Welcome activity:

    am start –n com.isi.testapp/.Welcome


We should now see the welcome screen fired up without providing the password.

Using a Malicious App to invoke Activities of other apps

Another way of invoking other application’s activities is to write a malicious app and feed it with the name of the package and activity to be launched. The figure below is a code snippet to launch an activity where incom.isi.testapp.Welcome is the activity to be launched. In our case, the malicious app doesn’t require any permission to launch the “Welcome” activity of the vulnerable app.



Using Mercury framework

The same attack can be reproduced with Mercury framework. We will discuss Mercury framework later in this series.

Securing the application components


  1. Setting android:exported attribute’s value to false

    In the AndroidManifest.xml file of our application, we should add the following attribute to the application component to be secured. In our case com.isi.testapp.Welcome
    is the activity to be secured.



    The above code restricts other applications or any system component other than the current app from accessing this Activity. Only applications that have the same user id as the current app will be able to access this Activity.


  2. Limiting access with custom permissions

    The android:exported attribute is not the only way to limit an activity’s exposure to other applications. We can also impose permission-based restrictions by defining custom permissions for an activity. This is helpful if the developer wants to limit the access to his app’s components to those apps which have permissions.


Note: The above security controls are applicable to any other Application component which we discussed in the beginning of the article.

References:

http://developer.android.com/guide/components/index.html