Analysing Backdoor.AndroidOS.Obad.a

Today i am going to write about my own analysis of “The Most Sophisticated Android Trojan which Kaspersky Labs blogged about here.

http://www.securelist.com/en/blog/8106/The_most_sophisticated_Android_Trojan

I’ve managed to grab a copy of the sample from Mila Parkour
I’ve placed a copy of the sample here and the pw to the archive is “infected“.
F7BE25E4F19A3A82D2E206DE8AC979C8
MD5: F7BE25E4F19A3A82D2E206DE8AC979C8

For this particular Android malware, if you simply use dex2jar+JD-GUI, you will realised that most of the methods can’t be decompiled.

Furthermore, i’ve realised that the method which it managed to decompiled looked slightly wrong too.
This is the method which i will discuss for now
1

Initial Analysis:
I will go through with my manual approach as well

Basically for a start, i would recommend you to use apktool first.

You should see something like this after running the above command.

Now let’s take a look at the AndroidManifest.xml file, you should see the the permissions requested by the APK file like here.

From the AndroidManifest.xml, we also know the following
1.) This malware have several “service” entries.
Furthermore, if we look up http://developer.android.com/guide/topics/manifest/intent-filter-element.html we can see that it indicates to have a high priority.
2.) There is an Activity entry and under the “intent” tag of this Activity entry. It indicates to start as the main entry point according to http://developer.android.com/reference/android/content/Intent.html#ACTION_MAIN

According to the official diagram from Android, we should be looking at “OnCreate” function first.
activity_lifecycle

3.) Earlier on, i’ve written that there are several “Service” being started by this app. According to http://developer.android.com/reference/android/app/Service.html We should be looking at “OnCreate” or “StartService” in those class file(s).

This “Service” is running in the background even when the user is not directly interacting with the application.

Analysis of Dalvik Code:
Normally i would suggest looking at the “onCreate” function first. Iin order to have a better understanding of Dalvik byte code, it’s probably better to have either of the following 2 links:
http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html
http://source.android.com/tech/dalvik/dalvik-bytecode.html

Now before we go to “OnCreate“, earlier on i’ve mentioned that Dex2Jar screwed it up right.
According to the AndroidManifest.xml, the file with “android.intent.action.MAIN” intention is OclIIOlC. But let’s look at “cOIcOOo” method in this smali file, “OclIIOlC” first.

In order to understand better, it would be preferred to take a look at the original smali code and then this one which i have added with comments.

Now compare it with this snippet which i’ve attached here. This should be the way to reverse the Dalvik Opcode back to Java source code…i think.

Ok, i’ve also mentioned before on why AVs and some of the tools don’t work.
Most of the better Android malware nowadays uses Reflection API.
Reflection can allow a program to create a “function pointer” and invoke the target function by using it. You can see it’s common usage in ExploitKits or those Java exploits.

You will see it when you start reversing “OnCreate” function now.
This is the pseudo Java source code for “onCreate” which i have decompiled manually.

We can see from the pseudo Java code that all external methods are called via Reflection.
Now if you go through each class, you will discover that each class had it’s own way of decrypting the strings but the general logic is quite similar.
Now that we have gone through the decrypting method and the onCreate method. The rest of the class files are not a problem. :D

I’ll update this blog post as i reverse it as it’s tiring to reverse it while changing diapers in between. xDDD

BR,
[ Gunther ]

picoCTF 2013 – DDoS Detection (85pts)

It appears a SYN-flood style DDoS has been carried out on this system. Send us a list of the IP addresses of the attackers (in any order, separated by spaces), so we can track them down and stop them.

Pcap available to download here, or available to analyse online at CloudShark

Ok, as usual here is the backup of the file.
syn_attack

Let’s open the pcap file with wireshark.
Since we are looking for traces, we can use a quick filter, “tcp.flags.syn==1

Using the above filter, we should have this.
Now let’s remove all the IPs for Google, Twitter and we should have all the IPs of the attackers.

Since the key to this challenge is the IPs of the attackers.
Their IPs are as follows:

BR,
[ Gunther ] of ARTeam

picoCTF 2013 – PHP2 (85pts)

We found a simple web page that seems to want us to authenticate, but we can’t figure out how… can you?

Accessing the given link, we will see this.
3

Ok, let’s view the source of the page and see whether there are more clues for this.
Immediately,we can see that it’s asking use to take a look at “index.phps” for more clues.
4

Looking at “index.phps”, we can see the actual code for the challenge minus the key of course. :P
5

Ok, we need to have the url like this.

https://picoctf.com/problems/php2/?id=admin

BUT, there is a call to urldecode before the check.
Thus, the above url will not be allowed.
So how are we going to bypass that?
Since there are no further filter and checks, one of the easiest is to use “Double Encoding
Using the following url:

https://picoctf.com/problems/php2/?id=%2561%2564%256d%2569%256e

We will see this.
2

The key is
Key: b4cc845aa05ed9b0ce823cb04f253e27

BR,
[ Gunther ] of ARTeam

picoCTF 2013 – Python Eval 1 (85pts)

A wise master wishes to teach you an ancient art: Python Eval 1.

Accessing that link you will see basically it’s telling us that using Python’s “eval” is wrong and dangerous.
If you had read about this, http://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html.
You will realise that it’s possible to read the value of “flag”.
In Python, a type object has a __bases__ attribute which returns the list of all its base classes. It also has a __subclasses__ method that returns the list of all types that inherit from it.
Thus, there are many ways to solve this.
I will show 2 methods which allows us to read the value of flag.
The first example here explicitly reads the value of flag.

2

The 2nd method here allows me to execute /bin/sh.
You can import modules dynamically in Python.
The built-in __import__ function accomplishes the same goal as using the import statement, but it’s an actual function, and it takes a string as an argument.

Then i will proceed to cat task1.py as shown here.
3

As we can see from the 2 examples, the key is “eval_is_best_thing_evar
The following are some good read which i’ll recommend for better understanding.

http://www.diveintopython.net/object_oriented_framework/defining_classes.html

http://www.diveintopython.net/functional_programming/dynamic_import.html

BR,
[ Gunther ] of ARTeam

picoCTF 2013 – Robomunication (80pts)

We recorded the following communication between two robots. Find out what evil things they are plotting, and recover their secret key!

As usual, this is the backup of robo.mp3.
robo

AFter hearing it for 5times, i realised the robotics sounds equate to Morse Code.

So finally i’m able to decode that to the following.

The key to this challenge is “BOOPBEEP

BR,
[ Gunther ] of ARTeam

picoCTF 2013 – Pilot Logic (75pts)

You’ve gotten a partial dump of the disk from the hangar’s machine, and you’re pretty sure the pilot’s password is cleverly hidden somewhere within it…

The disk image can be found on the shell machines at /problems/pilot_logic.img and the contents of the image are available in /problems/pilot_logic/

I’ve uploaded the pilot_image here.
Backup of pilot_image

Well, the clue was “pilot’s password”.
Immediately, i opened the file using FTK Imager and look for files under pilotbot’s directories. :D
FTK Imager is a free and useful tool. You can grab a copy of that here. http://www.accessdata.com/support/product-downloads
2

We can see clearly that the key to this challenge is “You can’t take the sky from me

BR,
[ Gunther ] of ARTeam

picoCTF 2013 – Client-Side is the Best Side (75pts)

Luckily the ship has a web-based authentication system! Hmm…even though you don’t know the password, I bet you can still get in!

When we visits the provided link, we will see something like this.
2

So it’s asking us for our credentials, but let’s view the page’s source first.
Upon doing that, we saw this interesting function.
3
Ah, so if we can figure out the correct password, we will be re-directed to “aebe515f7c62b96ad7de047c11aa3228.html
Well, why waste time on figuring out the correct password if something important is stored on “aebe515f7c62b96ad7de047c11aa3228.html

Let’s visit https://picoctf.com/problems/aebe515f7c62b96ad7de047c11aa3228.html
W00t H00t, visiting the above url, we saw this.
4

For those, who are still interested in finding out the password to reach the final url.
Just do a quick search on “03318769a5ee1354f7479acc69755e7c” using your favourite search engine and you will know that is the md5 hash of “dinosaur

The key to this challenge is
Key: cl13nt_s1d3_1s_w0rst_s1d3

BR,
[ Gunther ] of ARTeam

picoCTF 2013 – RSA (70pts)

Math is cool! Use the RSA algorithm to decode the secret message, c, p, q, and e are parameters for the RSA algorithm. Problem

This is the backup of the problem.
rsa

I didn’t solve this in time but after looking online on the RSA algorithm, i’ve finally figured it out that it wasn’t too difficult since we were given all the necessary values to decrypt the message.
This is my solution written in python based on this webpage’s algorithm.

BR,
[ Gunther ] of ARTeam

picoCTF 2013 – NAVSAT (70pts)

Near the Sun, you find a malfunctioning warp beacon which is broadcasting a distress signal in a navigational channel. It looks like it’s been damaged by solar radiation, and some of its data have been corrupted. If you can recover it, perhaps it will point at you to something interesting.

This is the backup of the original recovery.zip
recovery
If you tried to unzip the file, there is a Mag7-BW folder comprising of 2 files, Chart-15.pdf & key.txt
However, we can’t extract key.txt with most of the tools out there.
So i’ve decided to use Notepad++ to read the zip file since key.txt is just a text file. I’m sure i can find some useful strings in there.
So i did a quick find on “key” and i’ve found this.
2

The key is “Next stop Tau Eridani

BR,
[ Gunther ] of ARTeam