A very interesting piece of malware that targets Point of Sale systems has recently surfaced in the malware community. As a guy who frequently reverses malware that targets card data (aka. Track data), this caused me to take notice. Before I jump into the really interesting bits of the malware, I'd like to offer a few links to those that have already taken a look at this stuff. Seculert specifically were the ones that originally discovered, and named, the Dexter malware.
http://blog.seculert.com/2012/12/dexter-draining-blood-out-of-point-of.html
http://volatility-labs.blogspot.com/2012/12/unpacking-dexter-pos-memory-dump.html
So if you either haven't gotten a chance to read the above articles, or simply would like a refresher, here's what the malware does in a nutshell.
That last bullet in particular really caught my eye. I can't remember the last time I saw a piece of malware that targeted Point of Sale systems that had a nice C&C structure to it. And that is where our story really begins…
So in looking at the underlying assembly of the malware, it becomes apparent that this sample is planning on talking to as many as seven different domains. It's also apparent that it's going to communicate over HTTP, via a POST request. Looking at the traffic that gets generated, we see something similar to the following:
Now you might be thinking to yourself, "Geez, that's a lot of …stuff". And you'd be right. So lets break down that nice blob of data that's being sent over the wire. In total, we see the following ten different variables:
I'm going to focus on the last variable ('val') first, mainly because it's the easies to decode, and because it's one of the most important. We see that 'val' has a value of 'ZnJ0a2o=', which I'm sure you've all guessed by now is Base64 encoded. Once decoded, we see this value change to 'frtkj'. You might be thinking that this is also garbage, but it is, in fact, a key that is used to encode the remaining text in the POST request. Specifically, we see the following occur when each variable's data is decoded:
"A".xor("f").xor("r").xor("t").xor("k").xor("j")
This results in the original content.
Know how this works, we can whip up a quick script to decode the entire string.
We can now easily determine when a number of the variable discovered actually contain.
So at this point we can see how the malware is communicating outbound to its master. However, that's only half of the puzzle. How is the malware receiving commands?
Well, the answer to that question comes in the form of the response Cookie. Specifically, the malware will set the 'response' cookie using the same technique (only in reverse) that we just witnessed. So basically, theserver takes the key from before, XORs each byte of the string against each character in the key, and Base64 encodes it. Dexter will then parse this data, and look for one of the following variables:
I should point out that each variable has to start with the character '$' in order for the malware to look at it. We can see how the sevariables are checked in the following decompiled code:
So at this point we can get a pretty clear picture of how this malware operates over the wire. The details of how this malware has gotten on these victim machines is still unclear, but please ensure that you are taking the necessary precautions to protect your system, with a special emphasis on Point of Sale boxes. Because really, nobody wants to become Dexter's next victim.