One Yara to Rule Them All

Cythereal MAGIC generated Yara rules for VPNFilter also catch other botnet families

Malware authors share and reuse tried and tested code. Such sharing of code can be exploited, as we demonstrate here with the VPN Filter malware.

We used Cythereal MAGIC to generate Yara rules for VPN Filter malware. These rules, when applied on a large malware collection, flagged VPN Filter variants, as expected. In addition, the rules also triggered on variants of PNScan, Mirai (Gafgyt), Filecoder, and Tsunami, while producing ZERO false positives.

This is important and exciting as it provides evidences that sharing of code between malware can be weaponized. That is, you can use code from one malware family to catch not-yet-seen variants of not just the same family, but also of other malware families.

Related reading: Weaponizing Malware Code Sharing with Cythereal MAGIC

Early in May Cisco Talos reported finding a new Linux botnet, that they named VPN Filter. The Talos report described that the VPN Filter attack to consists of three stages. The report published hashes of 12 malware binaries for three architectures: ARM, MIPS, and x86. Of these eight files were for Stage 2 of the attack, two for ARM, three for MIPS, and two for x86. The remaining four files were Stage 1 and Stage 3 of for MIPS and x86. There was no file reported for Stages 1 and 3 of ARM.

We uploaded the 12 malware binaries into Cythereal MAGIC. MAGIC returned clusters of malware containing the VPN Filter malware, generating Yara rules for each cluster. MAGIC’s Yara rules are based on the code shared between malware in a cluster.

Here are our findings:

1. MAGIC re-discovered clusters identified by Talos

MAGIC correctly rediscovered the groups of Stage 2 binaries reported by Talos, the only stage with multiple binaries in Talos reports. It automatically found that the two ARM binaries, three MIPS binaries, and three x86 binaries had shared code. The other four files remained singletons, as they were in the Talos report.

The following table provides the number of distinct shared procedures between binaries in each cluster.

Architecture Talos count Num of Distinct Procedures Distribution type # Shared Procedures % Procedures Shared
ARM 2 472 In both files 465 98.51%
In 1 file 7 1.49%
MIPS 3 780 In all 3 files 567 72.69%
In 2 files 100 12.82%
In 1 file 113 14.49%
X86 3 791 In all 3 files 628 79.40%
In 2 files 62 7.83%
In 1 file 101 12.76%

MAGIC groups two or more “semantically similar” procedures as a single distinct procedure. MAGIC found that the three Stage 2 MIPS files of the malware collection identified by Talos have 780 distinct procedures between them. Of these 567 (72.67%) are in all three of the files, 100 (12.82%) are in two of the three files, and only 113 are in only one of the three files. The two Stage 2 MIPS malware have 472 distinct procedures, of which 465 (98.51%) are in both the files. Similarly, the three Stage 2 x86 files have 791 procedures, with 628 (79.40%) in all three files, 62 (7.83%) in two files, and 101 (12.76%) in only one of the files.

Well, Talos had already found this grouping. So what’s new?

The new part here is automation. We threw the 12 VPN Filter binaries into MAGIC’s collection of around 1 million malware. Each was uploaded individually, without any information about their known association. MAGIC came back with clusters that matched those published byTalos. Which means instead of reverse engineering each malware manually and using Bindiff to find shared code, MAGIC do this entire work automatically.

For a full list of shared procedures, see: Bindiff of x86 stage2 malware

2. MAGIC generated Yara rules found variants of other malware families

So, how do the MAGIC generated Yara rules perform in the field. To answer this question we shared our VPN Filter Yara rules with three companies: a very large security company based in US, a European AV company, and a European AV testing company.

The three companies independently scanned their benign and malware collection with our rules, and reported the following:

1) Each reported that the rules did NOT trigger any False Positives.

2) Each reported that the rules caught all the VPN Filter variants.

3) Each reported that the rules detected not just VPN Filter malware, but other malware variants, as well.

That all the companies reported that the rules did not generate any False Positive is significant because the companies serve different market segments and are likely to have very different set of benign files.

We further investigated the malware variants caught by our rules on Virustotal. Turns out that the malware caught by our rules span several known router malware, including PNScan, Mirai, Filecoder, and Tsunami.

This is the power of leveraging the shared code between malware families: The shared code can be used to detect not just known malware, but also unknown ones (since, MAGIC didn’t know of the malware variants that the three companies found).

Want more details?

The table at the end of this note presents hashes of the malware found using our Yara rules.

Visit https://bitbucket.org/cythereal/threat-intelligence for our analysis and Yara rules.

The bitbucket repository provides a lot of details that will whet the appetite of a reverser. It gives the actual RVAs of the matching procedures across a large number of malware and, when available, the names of the functions.

Want to Access MAGIC?

Please contact arun@cythereal.com

Hashes of malware detected by our rules

The following table gives hashes of malware detected by our Yara rules (as reported by one of the companies). Since our Yara rules are based on code, this list indicates malware that shares code with VPNFilter.

Arch/Stage Sha1 Family
ARM Stage 2
f16c48ead435d2574abd2e18836681ba2ce788e7 VPNFilter
12fcf1e988139160f3c8d6b07e05417e32defee5 PNScan
5a0416cffd5aa8273b2daf18b6eece0ee2d65724 PNScan
8c9fd0c2f8795a25392d03f00766691c9f209ddd PNScan
a3b36e0af923edc0939a38ac4a1a7fea52766984 PNScan
0e169f77716c32c8e8de0032f1c66d57775c3638 PNScan
X86 Stage 1
4ac8d962c6072b77f157c5d6459b887a658d66d5 VPNFilter
6304f74e76bd404b9324a54296bf6cef82d7dca6 VPNFilter
4abb20f92c04e1118e356936f36359620e998de7 VPNFilter
8a189f0c6a69efeaed1916860a0ff74e424563f6 VPNFilter
60a5b825c197a8788b8934c31e7453bd9a87e452 VPNFilter
1e35991d2df112caca1655b3da67f5fca3ad96e9 Mirai
1c115556696f0629848e1eb93c74f5cae2a3c8f3 Mirai
10345d0612e3fce42ef62aaf3ded248bcd5fe85a Mirai
069928d79f238c584935ecd1f3c4129dc3b32a19 Tsunami
5bd6b41aa29bd5ea1424a31dadd7c1cfb3e09616 Filecoder
5bd9369f8cd958bbd1c55072206bdd8f7f075a6a Mirai
b1cf342d9af676e1e3f1b2e7256bba961ecfd500 Filecoder
78aafe02c892614b240b01556e9ce93f22e04416 Tsunami
01e265e319a0d32acfeb075cd1562afaea608fef
9e933493f70f1a009d9026d320d7bf05f3242cf6 PNScan
22fccce549dcccf18c6aacb95adf0ed988bc39d6 Tsunami
X86 Stage 2
4abb20f92c04e1118e356936f36359620e998de7 VPNFilter
8a189f0c6a69efeaed1916860a0ff74e424563f6 VPNFilter
60a5b825c197a8788b8934c31e7453bd9a87e452 VPNFilter
4ac8d962c6072b77f157c5d6459b887a658d66d5 VPNFilter
6304f74e76bd404b9324a54296bf6cef82d7dca6 VPNFilter
1e35991d2df112caca1655b3da67f5fca3ad96e9 Mirai
10345d0612e3fce42ef62aaf3ded248bcd5fe85a Mirai
1c115556696f0629848e1eb93c74f5cae2a3c8f3 Mirai
069928d79f238c584935ecd1f3c4129dc3b32a19 Tsunami
5bd9369f8cd958bbd1c55072206bdd8f7f075a6a Mirai
78aafe02c892614b240b01556e9ce93f22e04416 Tsunami
b1cf342d9af676e1e3f1b2e7256bba961ecfd500 Filecoder
5bd6b41aa29bd5ea1424a31dadd7c1cfb3e09616 Filecoder
01e265e319a0d32acfeb075cd1562afaea608fef
9e933493f70f1a009d9026d320d7bf05f3242cf6 PNScan
X86 Stage 3
4fcb3f9cdf5a6150cc111ac8f6ae0b273c0f740e VPNFilter
4abb20f92c04e1118e356936f36359620e998de7 VPNFilter
60a5b825c197a8788b8934c31e7453bd9a87e452 VPNFilter
8a189f0c6a69efeaed1916860a0ff74e424563f6 VPNFilter
4ac8d962c6072b77f157c5d6459b887a658d66d5 VPNFilter
6304f74e76bd404b9324a54296bf6cef82d7dca6 VPNFilter
1e35991d2df112caca1655b3da67f5fca3ad96e9 Mirai
1c115556696f0629848e1eb93c74f5cae2a3c8f3 Mirai
10345d0612e3fce42ef62aaf3ded248bcd5fe85a Mirai
069928d79f238c584935ecd1f3c4129dc3b32a19 Tsunami
5bd9369f8cd958bbd1c55072206bdd8f7f075a6a Filecoder
78aafe02c892614b240b01556e9ce93f22e04416 Tsunami
9e933493f70f1a009d9026d320d7bf05f3242cf6 PNScan
fe8ef614c7bfd1d0611dc8ad3f51692e72409d97 WisdomEye
22fccce549dcccf18c6aacb95adf0ed988bc39d6 Tsunami
ff288e9082f1c70a6404b3dbda43736fa2ff8838 Coinminer