An extensive analysis of the hybrid Trojan dubbed GozNym has allowed Cisco researchers to reverse engineer its domain generation algorithm (DGA) and start sinkholing botnets that rely on the malware.
The existence of GozNym, which is a combination between the Nymaim dropper and the Gozi ISFB banking Trojan, was brought to light in April by IBM Security researchers. The malware has been seen targeting the customers of numerous banks in North America and Europe.
Experts from Cisco’s Talos team have analyzed the malware and identified a total of four variants, each using a slightly different version of a DGA.
In the attacks observed by Cisco, cybercriminals delivered GozNym using spear phishing emails containing specially crafted Word documents designed to download and execute a malicious binary via VBA macros. Once it has been successfully deployed on a system, the Trojan hijacks the victim’s browsing session in an effort to redirect them to a phishing website.
GozNym first checks Internet connectivity through a DNS query for google.com and microsoft.com records. It then queries the command and control (C&C) domains generated by its DGA either via a simple gethostbyname API call or via a complex DNS protocol implementation leveraging Google’s DNS servers.
Researchers identified several DGA variants. One of the more interesting DGAs relies on the XORShift pseudorandom number generator (PRNG) to create a list of 15 domain names with a length ranging between 5 and 12 characters and a suffix randomly selected between .net, .com, .in or .pw. The PRNG is seeded using two hardcoded DWORD values and a bit-shifted value of the current day.
Once the 15 domain names are generated, the malware queries each of them to determine if the IP responses are publicly routable. When two different IPs are resolved, they are used in the second stage of the DGA.
The second stage is similar, but it replaces the hardcoded DWORD seeds with the IP addresses obtained in the first stage. In this stage, the malware creates a list of 128 domain names.
The GozNym DGA is complex, but Cisco researchers have identified flaws that allowed them to predict domain names using brute force.
The company has started sinkholing GozNym domains and it wants to do so for every botnet it finds. Cisco’s sinkhole server was contacted more than 23,000 times within the first 24 hours, and since the Trojan is designed to only beacon a domain once, experts believe this represents the approximate number of infected devices.
The connections came from 1,854 unique IP addresses. A majority of them were traced to Germany (47%) and the United States (37%). Some infections were also spotted in Poland, Canada and the United Kingdom.
Cisco has made available several scripts that other researchers can use to analyze GozNym samples, including the DGA and C&C communications.