Quick and Easy Android Malware Analysis - Part 3 Digging In!

Hope you brought your shovel as we start to take apart this malware and look at it's internal code. To get started we will need to pull the APK from the device to our local system. To do this you will need to turn on usb debugging on the phone or emulator from the settings menu of Android (Check out this link if you don't know how https://www.kingoapp.com/root-tutorials/how-to-enable-usb-debugging-mode-on-android.htm). Now that you have your phone/emulator connected to your system you can now download the malicious APK.

In our case we already have the APK but for those situations when you might now already have it downloaded you use the adb pull  command (e.g. adb pull /data/app/bad.apk)to pull the package from the device. After you have completed this process we can now start the static analysis of APK.

The main tool for performing static analysis of the APK is a decompiler. I prefer JEB (https://www.pnfsoftware.com/jeb2/) but it requires a subscription. A free decompiler that does a fairly decent job is JD-GUI (http://jd.benow.ca) and that is the tool we will use. So go download and install JD-GUI. The only issue we have now is that we need to obtain the Jar or Class files from the APK as that is what JD-GUI can use. To do this we will use a tool called dex2jar which can be obtained from https://sourceforge.net/p/dex2jar. Then all we need to do is run the command d2j-dex2jar.sh and the tool will do the rest.

Now sometimes dex2jar is able to decompile the code without any errors but other times it produces a bunch of errors. We should be able to get most of the information we need even if there are errors though but just remember that in case you run into a situation that dex2jar is unable to help you.

$ ../dex2jar-2.0/d2j-dex2jar.sh classes.dex 
dex2jar classes.dex -> ./classes-dex2jar.jar

When dex2jar works the next step is easy as all you have to do is take the classes-dex2jar.jar file and open it in JD-GUI.


JD-GUI Window
Once opened you will see the programs structure and then you can start statically analyzing the APK to determine if it is malicious or not.

JD-GUI MisoSMS Decompiled
That is pretty much it when the APK is not protected in some way shape or form. From what we can see in this APK is that this app seems to send SMS messages containing phone information such as contacts. Well that's the end of this post that I'm sure people have been waiting for; hopefully, my next post doesn't take me this long.

Comments

Popular posts from this blog

And now for something completely different...

Been awhile hasn't it.

Well I guess it's time to start this back up.