Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

COMP5618/COMP4618—Applied Cybersecurity S2 2023

Tutorial - 4

This tutorial focuses on the static analysis of mobile apps. The idea of static analysis is to inspect the code of a program and understand its purpose without actually executing it. While in this tutorial we do static analysis of Android apps, similar techniques are applied for malware analysis as well.

1 Setup for Azure Cloud Users

If you are using Azure Cloud environment, Android Studio is set up in your virtual machine (Windows). apktool is also installed. However, you will need some additional setup.

• Android Virtual Device configured in the Android emulator.

• JDK requirements for Android studio (if not installed). Use Android Studio to download the latest Android SDK.

•  Create an Android Virtual Device (The latest Pixel)

2 Setup on local VirtualBox

If you are not using the Azure Cloud environment you will need to follow these steps:


• Install Android studio in your Kali VM & and configure a working Android Virtual Device in the Android emulator. Usually, this installation takes a very long time (one hour or more), so I suggest doing it before the tutorial class.

 Instructions on installing Android Studio can be found here https://developer.android.com/studio/install

• This lab can also be completed without using the Kali VM. If your Kali VM is too slow or does not have space, you can install Android Studio in the host operating system.

•  Get the JDK requirements for Android Studio. Use the Android Studio to download the latest Android SDK. (You can also use this command to install OpenJDK: -sudo apt-get install

openjdk-11-jdk )

• Install apktool (either in the Kali machine or the host operating system, depending on where you install Android Studio). Compile apktool file with "-r" flag. The latest apktool compilation might change the name of resources which leads to an error, simply compile with the "-r" flag.

•  Create an Android Virtual Device (The latest Pixel).  Your setup should also be similar to Figure 1.

3 Inspecting Certificates

•  Decompile the apps given in Task1.zip using the apktool.

•  Check the certificates of the apps (Hint: Use keytool, jarsigner or openssl command line tools).

•  Figure out which apps came from the same developer.

 Help - https://theether.net/kb/100207.

4 Basic App Changes

• Task2.zip contains a simple Android application.

• The two buttons switch the colour of the USYD logo from greyscale to colour and vice versa.



• Verify the app behaviour using the emulator -  ./adb  install  task2.apk

•  Decompile the app using apktool & switch the image file names to switch the button functions (i.e., When the grey scale button is pressed, the logo is shown).

•  Recompile the application and create a new apk file. - apktool  b

•  Sign the application with a new key. You may have to create a new key using keytool.

• Install in the emulator and verify - e.g.,  ./adb  install  /tmp/task2_new.apk


5 Editing Smali Code

•  Previous example was just renaming files. In this task, we actually modify the smali code to change the program logic.

• Follow the following two links for an example that actually changes the decompiled code. • Link 1, Link 2

6 Create a short screencast video and submit

Create a short screencast video to show that you have completed the tutorial and upload into Canvas. Include the following in the video.

• Inspecting certificates - Show which two apps are from the same developer and explain why.

•  Basic App Changes - Show that you have switched the images and recompiled the app correctly. Include a demonstration of the app running in the emulator.

•  Editing Smali Code - Show that now the app is running correctly in the emulator, which means showing that the name of the image has been changed and the Smali code has been modified.