Trustwave and Cybereason Merge to Form Global MDR Powerhouse for Unparalleled Cybersecurity Value. Learn More

Trustwave and Cybereason Merge to Form Global MDR Powerhouse for Unparalleled Cybersecurity Value. Learn More

Services
Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

Database Security

Prevent unauthorized access and exceed compliance requirements.

Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Solutions
BY TOPIC
Microsoft Security
Unlock the full power of Microsoft Security
Offensive Security
Solutions to maximize your security ROI
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Partners
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats

The Dexter Malware: Getting Your Hands Dirty

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.

  • Injects itself into iexplore.exe
  • Ensures the iexplore.exe process restarts in the event that it is manually stopped
  • Ensures persistence via writes to the 'Run 'registry key
  • Scrapes track data through a very common method
  • Has a command and control structure with a remote host

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:

10307_82c0a146-7a70-4983-afd2-4378b6160f5c

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:

  • page
  • ump
  • unm
  • cnm
  • query
  • spec
  • opt
  • view
  • var
  • val

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:

  1. The data is Base64 decoded
  2. Each character in the decoded string is xored sequentially against each character of the key we previously identified. In Ruby, it looks something like this:

"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.

BSL_10157_7bbbd6e9-b232-408d-8aaa-6cd1b2573627

We can now easily determine when a number of the variable discovered actually contain.

  • page: Mutex string
  • ump: Track data
  • unm: Username
  • cnm: Hostname
  • query: Victim OS
  • spec: Processor type
  • opt: Unknown
  • view: List of all running processes on the victim
  • var: Some unique string. Appears to be constant for this sample
  • val: Random key that changes every time the malware restarts

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:

  • update- (Updates the malware with the specified argument)
  • checkin: (alters the delay between times the malware attempts to make POST requests to the master host)
  • scanin: (alters the delay between times the malware scrapes memory for track data)
  • uninstall (completely removes the malware)
  • download- (downloads and execute the specified argument)

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:

8857_3dd124c8-2afd-484e-bfb9-27cee3bd1a5d

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.

ABOUT TRUSTWAVE

Trustwave is a globally recognized cybersecurity leader that reduces cyber risk and fortifies organizations against disruptive and damaging cyber threats. Our comprehensive offensive and defensive cybersecurity portfolio detects what others cannot, responds with greater speed and effectiveness, optimizes client investment, and improves security resilience. Learn more about us.

Latest Intelligence

Discover how our specialists can tailor a security program to fit the needs of
your organization.

Request a Demo