Pages

Showing posts with label Zuponcic. Show all posts
Showing posts with label Zuponcic. Show all posts

Monday, 19 August 2013

Zuponcic: "Is it a bird?... Is it a plane?... No, it's another... wait, what!?" --- Part 2

Special thanks to Mike Strobel for help with decompiling the Java code and William Metcalf for sharing some Zuponcic samples.

NOTE: Information is based on Zuponcic samples captured on 2012-11-29 and 2013-06-10

"... there is no spoon ..."

There is no exploit code. The JAR file includes just 1 .class file with 2 methods that perform the following roles:
  • String decoder
  • Store path and filename builder
  • Initial Payload handler (downloader, decryptor, executor and cleaner)
Anti-forensic techniques used:
  • 'control flow obfuscation' - makes it incredibly difficult to decompile the code
  • 'encoded String values' - hides all the String values
  • 'use of StackTraceElement' - uses dynamic values on the Stack(see decoding strings section below)

NOTE: The screenshots in this section show the code after all the string values have been decoded. Prior to decoding, the values looked like in a sample below

encoded values sample

'SVwBIoycqCilt' is the name of the method that decodes the strings. The method wasn't fully reconstructed, but the decoding algorithm was successfully restored.

string decoding algorithm

The decoding key is built using dynamic values from the process stack.

reading stack elements

This trick works well when the class and the calling method names are static. In case of Zuponcic, it's been static since the first occurrence: class name - 'FlashPlayer' and calling method - 'init'. The resulting decoding key - 'FlashPlayerinit'. This value is later being assigned to a variable called 's2' and used to decode the strings(see decoding algorithm screenshot above). In a way, this is a 'protection' mechanism to prevent the decoding method returning valid results when called using Java 'Reflection' methods. Through some tinkering with the decoding method, the strings were decoded and any calls for the decoding routine have been manually replaced within the code, so it looks more readable.

decoded strings sample

The code above is also where the execution begins. It starts with identification of Java Temp folder and Initial Payload filename generation.

location and filename sample

The Initial Payload will be stored in Java Temp folder with a randomly generated filename using a number of digits and '.tmp' extension. It's then downloaded using 'URLConnection' methods with the following routine.

Initial Payload fetcher code

The download is implemented through an HTTP 'POST' request with 'Content-Type' set to 'application/x-www-form-urlencoded' and 'i' parameter containing a connection token. The token and the Initial Payload URL are retrieved from the landing page. The tokens appear to be different among the Zuponcic samples - possibly generated on per connection basis. The same goes for the RC4 decryption keys used to decrypt the Initial Payload.

RC4 cipher initialization

'SecretKey' value is also stored in plain text on the landing page and retrieved during the code execution. Once the payload is received, decrypted and stored on the disk it's executed through the following simple code.

execution and browser redirect

If 'writing' and 'running' operations are explicitly allowed for certificate signed applets in Java Security Policy or the process is run under a user with Administrator privileges - the Initial Payload will be successfully executed. After the Initial Payload execution(successful or not) the browser is redirected to the URL stored in 'g' parameter on the landing page. This URL is the name of the website the browser was originally trying to get to from the search results page(see part 1). If payload execution is unsuccessful the payload file is deleted and the browser is redirected to the URL stored in 'e' parameter on the landing page.

clean up routine

'e' parameter contains the last URL given by TDS(see part 1). It's pointing the browser back to the Zuponcic landing page. It's difficult to say what's going to happen at this stage, but I strongly believe the browser will be redirected to 'www.google.com' due to the request being sent directly to the website hosting Zuponcic. Any direct requests sent to it are being redirected.

'Trojan.Vundo'(Microsoft) has been delivered by the sample captured in November 2012. What makes it interesting that MD5 of the file was not known to VirusTotal at the time of writing this post. After the submission though, it shows 37/46 detection ratio - link.

Summary

What do you call an exploit kit that doesn't have any exploits? Kit? So, Zuponcic Kit is still a malware delivery method that is a part of a quite stealthy infrastructure. The use of 'protection/evasion' techniques like TDS, connection tokens, bytecode obfuscation, data encryption and encoding, code tricks with process stack, clean up routine and selective targeting is quite close bordering to an APT related threat. I personally don't like the use of these 3 letters, but some attributes of this kit are just unusual for an ordinary exploit kit and intend to make it more stealthier rather than successful. Some observations to support this theory.
  1. TDS - Traffic Distribution System. Dynamically created/added HTTP request content that follows the original request through 2 level redirect chain prevents replaying the connection sequence and get direct access to Zuponcic components. Domain names of the servers hosting it are never linked directly from the pages on compromised websites - making it difficult to trace them.
  2. Landing pages are dynamically generated using some of the content related to the original user request - to a certain extend, it's an attempt to put a disguise on. In all of the cases seen so far, the redirect chain starts with a user doing a Google search and clicking on one of the links from the result page that leads to a compromised website. The search criteria is being passed through all the TDS redirects in the 'Referer' value and later used when a landing page is generated. See part 1 for more details.
  3. Java applet parameters are also generated dynamically and more likely unique per individual browser session. None of the samples seen so far had the same values. TDS must be keeping track of all of the connections and will not allow to use the parameters assigned to a session twice. This again complicates the tracing and sample/evidence collection.
  4. The JAR file is signed with a certificate to make it look legit. It has only 1 Java class file. The class filename is rather misleading. It's is fairy obfuscated to make the analysis difficult. Uses dynamic content of the process stack to obscure the reverse engineering process. No exploits = no AV alerts = stealthy.
  5. Initial Payload is encrypted with RC4 during the transfer and when stored is disguised as a '.tmp' file. The encryption key varies from sample to sample. Payload sample seen in November 2012 was still unknown to VT in August 2013. Good indication of low distribution possibly due to campaign not being 'commercial'. 
  6. Clean up process to remove Initial Payload from a victim's disk if infection is not achieved. This is something you don't normally see when it comes to exploit kits. Someone really cares about the file being found, submitted to AV vendors and become detectable. 
  7. Intended for the machines that can be used as a platform for further attacks. This could be called a selective targeting where who ever is behind the Zuponcic is only interested in the machines that they can turn into a 'launch pad' and having Administrator rights helps a lot. 
Anyone having any additional information or would like to discuss the subject 'offline' please feel free to reach out using contact details under my Blogger profile.



Wednesday, 12 June 2013

Zuponcic: "Is it a bird?... Is it a plane?... No, it's another Exploit Kit" --- Part 1

Updated 2013-08-19: Number of changes to reflect the findings covered in Part 2.

Zuponcic is relatively rare malware delivery kit. The name was given after the website(zuponcic.com) the kit was detected on back in November 2012. Earliest mentioning of it on Emerging Sigs mailing list. I first encountered it in July 2012 hosted on 'za.ucypher.com' The kit has been slightly updated since.

NOTE: Information is based on a sample captured on 2013-06-10.

"In thrust we trust."

The journey starts with a couple of redirects before arriving at the website hosting the landing page and the malicious JAR file.

1st level redirect

GET request

After clicking on one of the links delivered by Google Search when looking for 'mansfield township nj', the browser was taken to 'www.mansfieldtwp-nj.com'.

first redirect

First redirect goes to a server hosting TDS(Traffic Distribution System) - 'vestica.defeatliberalmedia.com'. TDS is given a number of parameters and one of them is the website name the browser arrived from - 'www.mansfieldtwp-nj.com'. TDS more likely maintains a list of domain names allowed to use the service - protection mechanism in some way.

2nd level redirect

GET request

Referrer is still Google even though the browser was redirected to TDS host from 'www.mansfieldtwp-nj.com'

second redirect

Once TDS is satisfied with all of the parameters given and possibly other conditions(cookie, sessionID, etc), the browser is redirected to a website hosting the landing page and the malicious JAR file.

landing page GET

The browser arrived at the landing page and is still having Google as a referrer with the original search request details in the URL.

June 2013 sample has the following URL pattern:


The URL pattern for a sample seen in July 2012:


There are no GET requests for '.mt' and '/js/java.js'  files in June 2013 sample, but the landing page still has commented out code related to them.

'.mt' file request

Even though the code is commented out the '.mt' file URL has 'live' domain name in it - 'on the fly' generated I guess.

'java.js' file request

"Home! Sweet Home!"

Landing page requests the JAR file without performing any checks - <body> tag with 'onLoad' action calls a function that requests the file. There is only one '.class' file in the JAR - 'FlashPlayer.class' and it's 'doctored' with a bytecode obfuscation tool. JAR file is signed with 'Kurz Instruments, Inc.' certificate issued by 'GlobalSign' CA.

<applet> requesting the JAR file

 JAR signature

 Looks like the previous version of the kit used to check Java version. There is some 'leftover' code still on the page.


The landing page is armed with a couple more tricks. There is a hidden(0 by 0 pixels) <form> with an <img> tag that has an 'onClick' action.


The action will call a function that checks if Java is enabled in the browser. If not found it will 'submit' the <form> initiating a POST request.


POST request will be generated using two 'hidden' input values. One of the values contains an executable file name 'viewer_mansfield_township.exe'. In response, the server will send unprotected payload giving it this name. Note the name has two search keywords in it that were used in the original Google Search request(refer to 1st level redirect section). Looks like the landing page is being dynamically generated based on the details given to TDS during 2nd level redirect.

Another example. The search criteria in this case was 'perfume worldwide'.


'viewer', 'movie' and 'tool' seem to be 'padding' words for creating the filenames.

The second trick is 'onContextMenu' action. Right-clicking on the landing page will restart the redirect chain with a GET to the first website in it. This will also trigger 'onBeforeUnload' action that prompts user to confirm leaving the page while displaying a message. Which might be a bit embarrassing if you misspell it.


The landing page also has <title> tag that has the name of the website the redirects started from. Poor attempt to disguise I guess.

"Please wait! Zuponcic is lading.."

Quick summary:
  • has quite unique URL pattern
  • utilizes TDS to help prevent direct download of the exploit kit components
  • uses Java as a malware delivery method
  • JAR is signed with a valid certificate
  • attempts to trick user to download and execute the Initial Payload if no Java detected
See part 2 for JAR file analysis.


P.S. If you have any additional information on this exploit kit please share. Contact details can be found under Blogger profile.