Ethereum Threat Actors Part 1 — DotNet Downloader using Ethereum Transactions for C&C updates.
As part of our research into how cybercrime actors using the Ethereum blockchain for fraudulent means, we analyzed a DotNet downloader that retrieves the malicious payload from URLs stored inside Ethereum transactions. We analyzed the sample provided by a German Security Researcher, Karsten Hahn @struppigel in this tweet.
This binary is a simple DotNet downloader, so we used ILSpy, an open-source .NET assembly decompiler in association of QuoLab, our collaborative and decentralized analysis platform to perform our research.
- SHA-256: 2ae7e6d0c8b9c8b86affaf5ee9752761a4cbff3f418a81fe74f9425b9387d4c0.
- Filename: mscheck32.exe.
- VirusTotal: 43/70 AV engines detected it as Trojan.
- Magic: PE32 executable for MS Windows (GUI) Intel 80386 Mono/.Net assembly.
The downloader is composed of four functions exhibiting different behaviors:
- ConvertHex: Convert a Hexadecimal string to plaintext string.
- GetAdditionalDataFromTransaction: Return JSON transaction ‘script’ field for a given TransactionID.
- GetLastTransactionHashFromAddress: Return last TransactionID for a given Ethereum Address.
- Main: Download, store and run the malicious payload retrieved from the URL stored on the Ethereum Blockchain.
The main function first reads the text content from “update.txt” if the file exist.
Then, the function GetLastTransactionHashFromAddress is called with the hardcoded value “41AFf7B3a85fD4248C7BC7bE989ce968494170de” that correspond to an Ethereum address.
If the last transaction of this address is considered as valid for the binary, the function GetAdditionalDataFromTransaction is called and the malicious URL is extracted from the transaction data.
The malware checks if it needs to be updated by comparing the URL to the “update.txt” file content. The binary verifies its persistence by checking that the file “msan32.exe” is still stored on the system.
If there is an update, or if the malware is not persistent anymore, the following operations are executed:
- Cleaning: Kill every process related to ‘msan32’.
- Persistence: Download the malicious payload and store it as ‘msan32.exe’.
- Persistence: Save the URL to this malicious payload inside ‘update.txt’.
- Infection: Execute the malicious ‘msan32.exe’ as a new process.
This function used the public Ethereum API of “blockcypher.com” in order to get the last Transaction ID related of the hardcoded Ethereum address (0x41AFf7B3a85fD4248C7BC7bE989ce968494170de).
A smart move from the author was to verify the value of the “tx_output_n” field in the API request response. The blockcypher API used this field to identify if the address is the sender or the receiver of the transaction. By checking this value, the author only cares about the transaction with 0x41AFf7B3a85fD4248C7BC7bE989ce968494170de as the sender because that prevents his botnet from being hijacked by someone else initiating a transaction to his address.
The “blockcypher.com” Ethereum API is used again to retrieve the transaction information and the malicious URL is extracted from the JSON “script” field.
Usually, the content of the ‘script’ field will be empty for a transaction between two EoA (Externally Owned Account i.e. controlled by a public/private keypair). However, Ethereum allows users to use this field to send arbitrary data to another account.
In case of a transaction between an Ethereum account (EoA or Smart Contract) that interacts with a Smart Contract, the ‘script’ field (input payload) will be composed with a four bytes function signature followed by the arguments of the function.
If you want to learn more about smart contract analysis, you will find our conference slides about this subject in our media center.
At time of analysis (01/08/2019), only one transaction is associated to the address 0x41AFf7B3a85fD4248C7BC7bE989ce968494170de.
This transaction on 21 August 2018 (05:27:42+UTC) is a transfer of USD 4.05 from one of the HitBTC exchange addresses to the malware address. We can assume that the malware author has a HitBTC account and that this cryptocurrency exchange knows his (potentially fake) identity. This transaction is surely a refill transaction allowing the malware author to have some funds to send his update URLS.
There is no transaction with 0x41AFf7B3a85fD4248C7BC7bE989ce968494170de as a sender, meaning that if someone is already infected by this downloader, no active malicious payload have been downloaded and executed on the affected system by this malware.
C&C Update Pricing
As an example, if we take this unrelated transaction to calculate the price per C2 command:
- ‘Script’ field content: 0x68747470733a2f2f7777772e6662692e676f76.
- URL string: ‘https://www.fbi.gov'.
- Length string: 19.
- Fee for this transaction: USD 0.003405.
This translates to around USD 0.00018 per character (i.e. USD 0.05 cents for a message at the length of tweet), which is a low price for changing persistent C2 URL.
Of course, it is interesting to monitor this address and download the malicious payload available at the URL, if future transactions occur.
If you want to analyze all the previous Ethereum transactions with values in the ‘script’ field, you will retrieve every call to a Smart Contracts (i.e. millions of results).
But, If you are only looking to view ‘script’ fields containing a specific pattern, you can use Google BigQuery and search, in our case, for every transaction starting with 0x68747470 (‘http’ in hexadecimal).
It is not the first time we saw the blockcypher API being used in malware. Some versions (>=4.1.0) of the Cerber ransomware have used it to retrieve transactions associated to bitcoin addresses (over HTTP request to http://api.blockcypher.com/v1/btc/main/addrs/BITCOIN_ADDRESS).
As this service does not require any API key, it is potentially why malware authors use it in the first place.
Future of Ethereum botnet
The usage of Ethereum for malware authors will surely be more common in the future, mainly because public blockchain provides a lot of security advantages for them:
- Ethereum blockchain is public and immutable, meaning that information (transactions or Smart Contracts) cannot be removed by law enforcement.
- Access to their C&C is secured due to the security behind Ethereum authentication (public/private key pair).
- Selling C&C control access can be achieved simply be changing the ownership of a Smart Contract.
To help combat this threat or monitor malicious transaction history, Threat Intel teams can obtain transaction history of actors. Additionally, law enforcement can potentially identify actors behind the botnet more easily if they request identity information to cryptocurrency exchanges (like HitBTC in this case) and shutdown botnets with access to the C&C account private key (Ethereum private key).
Other researchers also show that it is also possible to use Smart Contracts for botnet control. You can find more information using the following resources:
- ActiveBreach, powered by Ethereum Blockchain.
- BOTRACT — ABUSING SMART CONTRACTS AND BLOCKCHAIN FOR BOTNET COMMAND AND CONTROL.
- UNBLOCKABLE CHAINS — IS BLOCKCHAIN THE ULTIMATE MALICIOUS INFRASTRUCTURE?
Additionally, you can check out our open source tool Octopus to analyze Ethereum transaction and reverse Ethereum Smart Contracts. Moreover, please also find our conference presentations about this subject in our QuoScient media center.
We are grateful to Karsten Hahn (@struppigel) for highlight this binary, so that we could have a closer look at the mechanisms of malware authors using Ethereum transactions. Having outlined the most important findings above, we would like to take the chance to make some precisions regarding his original tweet:
- The downloader only uses Ethereum transaction to extract an URL.
- The downloader will download the malicious malware payload from this URL.
- The “script” field containing the URL is not custom, it’s standard in Ethereum but unusual for transaction between two EoA accounts.
We hope that our analysis has provided more insight and is helpful in spreading the word about this attack vector. We are happy if we have contributed to make the world more digitally secure as our Digital Active Defense vision guides us to do so.
Many thanks and I am happy to keep in touch on this subject.
Patrick Ventuzelo, Security Researcher at Quoscient
Indicators of Compromise