Skip to content
Roman Gascoin RG-003
All articles

Technical note TN-03 Spec sheet

White Comet

Low-level polymetamorphic malware

Issued
Reading
3 min read
Class
Association
Keywords
  • Association
  • Cybersecurity
Format
Raw Markdown
On this page

All the source code can be found here.


Disclaimer

This project was carried out for research and educational purposes only. The PoC organization and its developers are not responsible for what you do with this project.


Introduction

Whitecomet-Research is a project about malware made by PoC Innovation. The goal of this project is to study various techniques used to bypass antivirus (AV) software, such as polymorphic and metamorphic programs.


Polymorphism / Metamorphism

Polymorphic programs can modify themselves at each execution in order to remain undetectable by antivirus analysis. Each file on your machine has a unique signature (a hash) that changes according to the content of the file (for example, two files with the exact same content will have the same MD5 hash; you can check this on Linux with md5sum [file]).

Metamorphism follows the same idea, but while the only thing that changes in the binary with polymorphism is the encryption, with metamorphism it is the ASM instructions themselves that are modified (without altering the original behavior).

Some basics

Polymorphism

On the first execution, the payload is not encrypted, so the program simply writes a new binary on top of itself with its encrypted payload (along with a key stored in clear text in an accessible area) and then executes the payload that is still in memory (not encrypted, since this is the first execution).

On each new execution, it does the same thing, except that it first grabs the XOR key and decrypts itself before doing any of the above. A new random key is generated at each execution. The encryption process we chose is a one-time pad XOR.

For more detailed explanations, we invite you to check our dedicated READMEs for Linux and Windows, stored in the Polymorphic directory.

Metamorphism

We are working with ASM instructions. There are many possible architectures, but for the sake of the repo we are going with x86-64 only. It is technically possible to code something that would adapt to the architecture. To understand where and how we change instructions, we invite you to check the dedicated README stored in the Metamorphic directory.

Why are the Linux and Windows directories separate?

To create polymorphic malware, we have to use the segments of binary files. These segments represent the different parts of the binary where code is stored. Linux and Windows do not use the same binary file format (ELF for Linux and PE for Windows), so these segments are used differently. That is why we can build the same malware for both operating systems, but not with the exact same code.

The compilation and the code (e.g. the libraries) are also different for the two programs, which is another reason why they are kept separate.

What does the payload/malware do?

It is a basic reverse shell: when the victim launches it, it opens a hidden command interpreter on their computer and links it to yours. You can then do whatever you want, within the limits of what a shell allows, of course.

Polymorphism and antivirus software

For many AVs, polymorphic viruses can be difficult to analyze: first because the malicious code is encrypted, and second because the signature changes at every launch, so the AV cannot simply compare the program’s hash with databases of malicious hashes.

We used VirusTotal for our tests.

Linux – Polymorphism

(The scan-result screenshots that illustrated this section are no longer available.)

Linux – Polymetamorphism

(The scan-result screenshots that illustrated this section are no longer available.)

These results show that polymorphic behavior (metamorphism is a polymorphic behavior as well) is not checked at all by most AVs. A program should almost never be polymorphic (even when updating itself), and AVs should check for this in order to flag it as malicious behavior.


How AVs can counter polymorphism

Some antivirus products use AI (machine learning), which allows them to recognize more malware over time based on similarities and behaviors. Dynamic analysis can counter some of these types of AV bypass.

What’s next

We are looking for more FUD (fully undetectable) techniques and for ways to bypass antivirus software that uses AI. We are also interested in building our own antivirus to counter these threats (we have a tiny polymorphic checker in ./WC-AV).