I've been looking into this family of malware recently, and since it has a very distinct method of operation, I thought I'd talk about it a bit, along with providing you some Snort rules to help find the malware on your network. I'm not going to go into the in depth binary analysis here, I'll keep it simple - since most people in the Snort world will read this blog wondering about the malware from a traffic perspective, that's what I'll focus on. Looking at what information you can glean just from watching the malware work is most of the battle.
Let's start by looking at the packet dump, as that's what we are most interested in - how it behaves on the network.
|A connectivity check|
It starts off with a simple connectivity check. There is nothing of value in the check, it's simply to see if the malware can reach the internet. Immediately following this check, it starts doing DNS lookups. This is a really noisy piece of malware, these requests are done very quickly, and there's a large amount of them.
|DNS lookups galore|
alert udp $HOME_NET any -> $EXTERNAL_NET 53 (msg:"BOTNET-CNC Possible host infection - excessive DNS queries for .eu"; flow:to_server; byte_test:1,!&,0xF8,2; content:"|02|eu|00|"; fast_pattern:only; detection_filter:track by_src, count 100, seconds 10; classtype:trojan-activity; sid:21544; rev:1;)
After searching around in DNS for a bit, outbound SYN packets start flying around with a destination port of 22292. (As I said, I'm keeping this simple.) Also easily sig-able using a similar methodology as the detection_filter above. But I'm not going to write this rule as it's very easy to evade just by changing the port. When writing Snort rules you want to focus on things that will be consistent, so you'll catch more than one variant.
I've pulled several samples of this and they all seem to exhibit the same activity.
Eventually after what seems like some switching back and forth between these types of outbound traffic, an HTTP request is made. I've blacked out portions of this just in case these numbers identify a system in some way:
Looking at this dump there are some excellent distinguishing characteristics that we may want to use in a rule.
2. The URI is rather unique.
3. Host is in China.
4. No Referer.
Here's our rule:
alert tcp $HOME_NET any -> $EXTERNAL_NET $HTTP_PORTS (msg:"BOTNET-CNC Win32.Trojan.Murofet variant outbound connection"; flow:established,to_server; content:".php?w="; nocase; http_uri; content:"&n="; distance:0; http_uri; pcre:"/\.php\x3fw\x3d\d+\x26n\x3d\d+/U"; content:"HTTP/1.0"; metadata:policy balanced-ips drop, policy security-ips drop, service http; reference:url,www.virustotal.com/file/aeab4913c8bb1f7f9e40258c323878969b439cf411bb2acab991bba975ada54e/analysis/; classtype:trojan-activity; sid:21440; rev:2;)
The above "Murofet" rule has been in the hands of customers since the 27th of February.
Content match number 1:
Content match number 2:
Both could seem rather common, so let's use our PCRE to get rid of false positives.
verifies that content match #1 has at least one digit after it until it hits:
Our second content match, also, verifying there is at least one digit in it. We restrict all of those to http_uri so we don't wind up looking at the URI in the Referer field, cookie, body, or whatever.
Our last content match is for "HTTP/1.0". While still common in today's "web 2.0" world, HTTP/1.1 is much more common.