Analyzing Ramnit used in Seamless campaign
FirstSeamless campaign which is a Drive-by Download attack campaign uses Ramnit banking trojan. Many articles about Seamless campaign are published. For example, Cisco Umbrella, Malware-Traffic-Analysis and traffic.moe. Seamless has been using Ramnit since it began to be observed. Once run, Ramnit injects code into the web page to steal information such as credit cards. Ramnit is a previously reported banking trojan, but since I didn't know much about it, so I investigated about it.
Seamless Campaign TrafficFirst, about Seamless campaign. Seamless campaign consists of the following traffic.
When reaching Seamless's Pre-Gate from the ad network, Pre-Gate gets the user's time zone information and sends it to the server. If the user belongs to the target time zone, Pre-Gate redirects the user to Gate via several redirectors. The user reads the landing page of the RIG Exploit Kit at Gate, which attacks and sends Ramnit.
Seamless is sensitive to the user's geolocation. Pre-Gate exists for each target country. For example, Pre-Gate for USA redirect to Gate for USA and Ramnit for USA is sent.
Ramnit TrafficRamnit uses the original protocol when communicating with C2. Following this protocol, I try to extract the configs and modules from the traffic of Ramnit and C2.
This protocol uses port 443. But, not https. A simple mechanism is on tcp. Packet consists of multiple commands and data. The structure is as follows.
magic number is a fixed value. Packets start with this bytes. length is the length of command and data. In other words, strlen(command + data). command is 1 byte. There are various kinds of this.
Data has three structures.
The encryption key of RC4 seems to be stable. In my environment `fenquyidh` is the key.
Let's look at the data using actual traffic. If you have Ramnit traffic, use it. If you do not have it, look for Ramnit and move it, or look for pcap etc. For example, if you look at the #Ramnit tag on Twitter, you will find many Tweets. You will surely get Ramnit or its traffic.
Ramnit is banking trojan. It depends on the target country/region. For example, Ramnit used in attack campaign targeting Japan doesn't work with IP addresses of countries other than Japan. The configs and modules that Ramnit acquires from C2 also change. This time, let's see the traffic of Ramnit for Japan. If you are not able to get the traffic of Ramnit for Japan, please refer to this link. It seems that someone kindly released pcap ;)
Let's open pcap and look at the first packet.
When parsing this according to the protocol, it becomes as follows.
This data is encoded with RC4. So I decode it. RC 4 is a simple algorithm, write the code.
The results are as follows. Ramnit is sending two MD5 values to C2. Registration is done to bot by this.
This is what automates these processes.
This script uses tshark. If not installed, please install and set environment variables. Now, let's run the script.
Files are created in the output directory. Let's look at `064_21.bin`.
This file says "Antivirus Trusted Module v2.0 (AVG, Avast, Nod32, Norton, Bitdefender)". You can see that there is MZ header below 0x120 and it is a PE file. Cutting out 0x120 or later result in the following.
It is unpacked because packed by UPX.
Looking at this DLL with IDA, you can see that it is a program that interferes with Anti-Virus software.
Several DLL modules (067_21.bin, 070_21.bin, 073_21.bin) are downloaded like this.
Next, let's see 106_15.bin. This file seems to be zip. Looking inside it was IE's cookies. There was a DLL module that zipped the cookie, so it might be related.
Finally, look at 139_13.bin. This is the config of the injecting code for the web page.
Looking at this configuration, URLs of many credit card companies and related companies exist. It was localized for Japan.
Ramnit ModulesI analyzed the modules that Ramnit downloads. All modules had data added at the beginning of the PE format.
Also, its PE file is a DLL, packed with UPX.
At the beginning of the module there is a comment like a description of the role. Most of them are similar to the information already analyzed by analysts.
For Japan[module 1]
- Antivirus Trusted Module v2.0 (AVG, Avast, Nod32, Norton, Bitdefender)
Add to antivirus software exception list
- Cookie Grabber v0.2 (no mask)
Compress and send cookies of browsers (firefox, chorome, opera, IE) to zip.
- IE & Chrome & FF injector
Browser communication hook
- VNC IFSB
- VNC IFSB x64-x86
I think it is similar to this code.
- FF&Chrome reinstall x64-x86 [silent]
For USAmodule 1~4 is the same. module5 had the following functions instead.
- Ftp Grabber v2.0
And In US IP, AZORult has been downloaded.
FinallyThe Ramnit has not changed very much for a long time. It was consistent with Symantec's contents published in 2014.
The configuration changes depending on the IP address, but the same module was downloaded.
Ramnit traffic is interesting ;)