Skip to main content

Android Malware Analysis: SmsWorker ( ͡° ͜ʖ ͡°) (day 78)



Have you ever wonder how to do android malware analysis? Do you want to know how to dissect it and understand the mechanism inside the android malware?

if yes, in this post we will do so some analysis on one of the samples of android malware from china it cames from Baidu antivirus, you can take a look at the samples from this link: https://github.com/ashishb/android-malware/tree/master/BreakBottleneck 

if no, you can just ignore this whole post LOL :)

(kudos for the owner of the GitHub page you make my life easier)

Please be careful when analyzing the samples, don't install it at your real device but install it at the android emulator or contained environment. I'm not responsible for any incident that happens to your device

The idea of this post is to give you some insight on how to do analysis on android malware. We will try to do static analysis and then go to the dynamic analysis.

Remember, the result that you will see here is based on my analysis and methodology, you may have a different approach to analyze this sample but it's up to you if you want to follow it or not.

In short, at the end of the analysis, I found that the malware has a capability to:
  1. Silently to download an app and install it into your mobile 
  2. Capable of sending an SMS without your consent
Also, I found some interesting stuff along with the analysis such as: how mobile GPRS work in China and Public and private key RSA store inside the application

Decompile the APP (Static Analysis)

When I start analyzing android malware, I just straightly decompile the .apk file using apktool (to get smali source code), enjarify (convert apk to jar) and  procyon decompiler (jar to source code)



by getting the smali bytecode of the program I would able to circumvent at any defense mechanism (anti-reverse engineering) that the malware has but fortunately this sample doesn't show any indication of anti-re mechanism so mostly I used apktool to get other resources on the application such as permission, library and resources file of the app

rest of it such as enjarify and procyon basically to get the java source code so I can try to understand the program in more detail.

enjarify: https://github.com/google/enjarify
procyon-decompiler: https://bitbucket.org/mstrobel/procyon/downloads/

as you can see here this is the result of tools, notice that there is some class that named with alphabet don't worry this just means that the tools are not able to retrieve some name of class so they named it based on their algorithm

Let's take a look at the permission file of the android (AndroidManifest.xml) this define how many permission that the application needs to have in order to run it correctly

 'android.permission.INTERNET',
 'android.permission.INSTALL_PACKAGES',
 'android.permission.ACTION_VIEW',
 'android.permission.WRITE_EXTERNAL_STORAGE',
 'android.permission.RESTART_PACKAGES',
 'android.permission.MOUNT_UNMOUNT_FILESYSTEMS',
 'android.permission.READ_PHONE_STATE',
 'android.permission.ACCESS_COARSE_LOCATION',
 'android.permission.ACCESS_NETWORK_STATE',
 'android.permission.READ_PHONE_STATE',
 'android.permission.WRITE_EXTERNAL_STORAGE',
 'android.permission.MOUNT_UNMOUNT_FILESYSTEMS',
 'android.permission.RECEIVE_SMS',
 'android.permission.RECEIVE_WAP_PUSH',
 'android.permission.WRITE_APN_SETTINGS',
 'android.permission.RECEIVE_BOOT_COMPLETED',
 'android.permission.WAKE_LOCK',
 'android.permission.WRITE_APN_SETTINGS',
 'android.permission.CHANGE_NETWORK_STATE',
 'android.permission.ACCESS_WIFI_STATE',
 'android.permission.CHANGE_WIFI_STATE',
 'android.permission.SET_WALLPAPER',
 'android.permission.SEND_SMS'
The one that I bolded it with red is the focus on our analysis, we can see that by just analyzing the permission file we can get a general view of how the application work

In this case, it is able to directly install a package and Malicious applications can use this to add new applications with arbitrarily powerful permissions. Next is to send and receive SMS, Malicious applications may cost you money by sending messages without your confirmation.

Installing the application at the background 

when I look around the permission file I found out that the application register a broadcast receiver and service that responsible for installing an application silently

<receiver android:name="myreceiver.SilenceReceiver">
<intent-filter>
<action android:name="com.ydbl.action.silenceinstall">
</action>
<category android:name="android.intent.category.DEFAULT">
</category>
</intent-filter>
</receiver>

<receiver android:name="myreceiver.InstallReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED">
</action>
<data android:scheme="package">
</data>
</intent-filter>
</receiver>

<service android:name="myreceiver.DownloadService">
<intent-filter>
<action android:name="com.ydbl.action.download">
</action>
<category android:name="android.intent.category.DEFAULT">
</category>
</intent-filter>
</service>

I take a look at each of the class and figure out the workflow of the malware use this three files together


First it starts at myreceiver.DownloadService class is a service class that is running in the background. The class will send a broadcast named "com.ydbl.action.silenceinstall" to the device with two parameters apkname and pkgname

the intent broadcast matches with intent filter from myreceiver.SilenceReceiver this means that the broadcast will be received by this class and as you can see from the diagram this class will install the application based on the value sent by the service class

after the installation complete myreceiver.InstallReceiver will send a notification to the backend server said that the following device has successfully installed an application


Sending and Receiving sms:

looking at the permission file again we can see that there is two class register to handle the SMS:

<receiver android:name="com.android.service.PlugSmsRecevier">
<intent-filter android:priority="1000">
<action android:name="android.provider.Telephony.SMS_RECEIVED">
</action>
<category android:name="android.intent.category.DEFAULT">
</category>
</intent-filter>
</receiver>

<activity android:configChanges="0x000000A0" android:name=".SmsActivity" android:screenOrientation="1">

one is for receiving sms and the other one is for sending an SMS

on com.android.service.PlugSmsReceiver



First, the class expecting intent with "android.provide.Telephone.SMS_RECEIVED" and the intent must contain an object with index pdus inside the object it will have the source number and the SMS content

unfortunately, I could not find any class that has a connection to .SmsActivity I think it's because the decompiler failed to get original class name. So I have to improvise by doing string analysis to do source code by searching for any class that contains the keyword " SmsManager" after a couple of minutes I found out an unnamed class that has the capability to send a message

 



basically, when the function is called it takes two parameters, s will contain the destination number whereas s2 will contain the message that will be sent




Interesting finding:

When looking around again through the rest of the file I found this configuration hardcoded beneath the source code



I guess this is just for setting for personal private communication since it contains APN(Access Point Name) credential, when I try to do some research about what is config means it lead to me to this list of APN https://github.com/signalapp/Signal-Android/blob/master/apntool/apnlists/cyanogenmod.xml

Also, I found this strange configuration beneath the apk called "smsrpt"



I think rpt stands for repeater since SMS repeater use to a message for one number how many times you want, I try to check the IP address but it's not active anymore

Lastly, I found the private and public key used by the app:



I try to found the relation of this private key to the app if there is any encryption or decryption happen inside the app and from a quick result of static analysis.



we can see that the app did do decryption by calling library called "manbodecrypt"



when I try to list the function inside the library we can see that the function name gives us a clue about the operation. I will not go into detail about this

Dynamic Analysis:

I think in dynamic analysis, I don't really much information since most of the link that I found is already dead and this app can only run in ARM device. I try to run it in my AVD but it really slow and keep show me this warning


I try to invoke the silence installer by putting an apk file at the external directory so the app can get and install once I send the correct broadcast



The app did receive my intent but it's not responding anything and just crash again. I also do the same thing with the sms activity but it always lead to the same result

such a shame :(

Conclusion:

I think from all the information we get the app we just analyze here is a trojanized app, it means malicious actor just get a legitimate app from the china app market then insert a bunch of malicious code then repackage it again and release it to the internet

If you have a different opinion about the malware I'm open to suggestion  

Okay we are done I think this is all I can give to you

That's all folks I hope you can get some insight on how to start doing android malware analysis

See you at the next post :)

Comments

Popular posts from this blog

Having fun analyzing nginx log to find malicious attacker in the net (ง'̀-'́)ง (day 37)

  What makes you sleepless at night? is it because of a ghost or scary stories? is it because you have an important meeting tomorrow? or is it because you have an exam? For me, what keeps me up all night is that I keep thinking about what happens to a website that I just created, is it safe from an attacker (certainly not) or did I missing some security adjustments that lead to vulnerability? well I'm not the best secure programmer in the world, I'm still learning and there is a big possibility that I can make a mistake but for me, a mistake can be a valuable investment to myself or yourself to be better so from this idea, I want to know more about what attackers casually do when attacking a website. Here in this post, I'm going to show you how I analyzed attack to the website that I have permission to design and also some interesting findings that I could get from the analysis Background: All of this analysis comes from the traffic that is targeted to th

Utilize Pwntools for crafting ROP chain :') (day 69)

who doesn't like pwntools? it is a very versatile tool and can be customized according to our need using the python script but did you need to know that pwntools itself can help us to automatically craft a rop chain for us? so in this post, I will show you how to make rop chain less painful and make pwntools do all the heavy lifting. To demonstrate this I will use the binary challenge callme 64 bit from ropemporium link: https://ropemporium.com/challenge/callme.html Crashing the app: Like any other exploitation process, we need to crash the program by generating a long string pattern to determine the offset. based on the information from the above figure we can see that we required to provide 40 bytes of offset Fun stuff: now this where the fun stuff began write the following python script: as in the guideline of the challenged said we need to chain the function call by first to call the callme_one function, callme_two function and then callme_three funct

WriteUp PWN tarzan ROP UNICTF ಠ_ಠ (day 61)

So in this post, I'm going to talk about how to solve the Tarzan pwn challenge from UNICTF 2019. Back in the day when the competition is still going I couldn't finish it and don't have any clue to solve this but this time I was able to finish it :) Also in this post, we will be going to be heavily focused on how to utilize pwntools to construct a ROP chain. If you kinda confused about my explanation in this post you can refer to this following youtube video, link: https://www.youtube.com/watch?v=gWU2yOu0COk I build the python script based on this video Ok, let's get started! In this challenge, you will get two binary first go with tarzan and libc-2.29.so by providing .so file it tell us what version library that the target machine is using this could help us to do ROP chain. first, we run the Tarzan binary to get the basic idea of the program work and as you can see it just show you some text, newline and when you try to input something it doesn't gi