Magnitude Exploit Kit Backend Infrastructure Insight - Part I

In our recently released Trustwave Global Security Report Online and previous Magnitude blog post, A Peek Into the Lion's Den – The Magnitude [aka PopAds] Exploit Kit, we detailed our discovery of one of the more prevalent exploit kits seen these days, showed an inside look at the control panel and analyzed the kit's activity over one month.

The back-end infrastructure of Magnitude has revealed itself to be even more exciting than the front-end. With this post we'll provide more technical details about how the kit avoids detection.

Magnitude provides its customers with a good foundation for creating attacks with low detection rates. The most popular technique for making an attack undetectable is simply recreating everything from scratch and fast. The following scripts run in a cronjob and are responsible for different parts of the attack.

Exploit Obfuscation

The Magnitude author abuses the static analysis technology of Anti-Virus vendors by having a tool that re-creates its exploits periodically by randomizing every constant variable / function name.

Below is an example of the exploit outline, every part in the code surrounded by "%" will be replaced with a randomized string.

Magnitude

The PHP script uses a "preg_replace" function to replace the content, which is used almost in every part of the code.

Magnitude

After replacing the strings, the new content is written into a file and the exploit is ready for massive distribution.

Another script is responsible for re-generating the Java exploit, which is created on a different server and uploaded manually (for now) to the infection server. The process of creating the Java exploit is similar to other HTML based exploits - it loads an outline Java source file filled with patterns to be replaced.

image from http://s3.amazonaws.com/hires.aviary.com/k/mr6i2hifk4wxt1dp/14080521/c700c310-9366-481a-9ac2-45e3bf21b7e6.png

The PHP script loads the files and uses regular expression to replace those occurrences.

image from http://s3.amazonaws.com/hires.aviary.com/k/mr6i2hifk4wxt1dp/14080521/57f3d95e-724b-450f-8d30-768009c320e5.png

Finally, after creating the Java files with the randomized strings, the script compiles the source code and wraps it to a Jar file:

Magnitude

Since the commands are clearly written for Windows rather than Linux, the Java exploit creation process probably takes place on a different, Windows based machine.

Domain Detection Rate

Just like security products, the Magnitude exploit kit operates on several layers. Most security products use the domain/URL as part of their detection logic, and so Magnitude provides its customers with the ability to load a set of domains that are constantly checked. Magnitude uses the Scan4you anti-virus detection service to scan IP/domains as well as files to make sure commercial anti-virus products cannot detect it. Once security vendors mark a domain as malware, the system updates the information in the database and quickly replaces the domain with a new one that is not yet detected by security vendors, which makes URL Filtering less effective.

Magnitude

According to the code above, the script also manually checks the domain with Google by using "http://google.com/safebrowsing/diagnostic"

"Used" Domains Removal

Rotating domains every several minutes is effective but may be expensive. Making the website look legit and hosting the malicious content on a subdomain can keep the domain undetectable for a longer period of time. Knowing this, Magnitude creates a list of subdomains for every "main" domain and deletes it from the queue after a short period of time. This helps Magnitude overcome URL listing filtering engines.

Magnitude

Redirect Traffic

Apparently, the road to infection involves many obstacles. The Magnitude exploit kit checks several conditions before trying to exploit the target machine. An attacker that is using Magnitude can define a URL to which a target machine is redirected in case the infection conditions are not met. The URL is also controlled remotely and the system ensures it's up-to-date as shown below:

Magnitude

The system queries the pre-defined redirection URL, which provides the system the information where to redirect the victim, this way the URL can be generated dynamically.

Payload Detection Rate

Testing the detection of payloads by AV products is a very important practice for exploit kits and is commonly used because these products quickly add detection for these payloads. The Magnitude author also uses the Scan4you for testing the payload detection rate:

Magnitude

The second part of the script contains predefined payloads that may be owned by the author itself, these are also constantly updated from a remote server.

Magnitude

Backend Control Panel

On top of the exploit kit infrastructure the author created a control panel for administrators, which allows him to view and modify the configurations of their customers. The administrative control panel, unlike the customer control panel, is accessible only by specific IP addresses that are "hard coded" as part of the control panel. These IP addresses probably are ones used by the authors thus this restriction excludes access from anyone else.

Magnitude

As mentioned in the previous blog post, the customer's control panel is located on a different server. The infection server has to download the payloads from the customer's control panel server. A script was written specifically for this and can only be accessed from this server:

Magnitude

It is evident that the script communicates with the customer's control panel server, downloads the new payload and removes the old one.

The author has definitely learned from the mistakes of other exploit kit authors. The Magnitude exploit kit has been operating for more than a year in the shadows with no information on how it works behind the scenes. Most of the internal scripts can be accessed only from specific IP addresses and are password protected.

We will reveal additional technical information regarding the Magnitude exploit kit backend infrastructure in the next blog post.

Trustwave reserves the right to review all comments in the discussion below. Please note that for security and other reasons, we may not approve comments containing links.