How Hackers Hide Their Malware: The Basics
Malware depends on these four basic techniques to avoid detection.
First of a two-part series.
Antivirus (AV) and anti-malware products are among the oldest and most mature defenses against cyber attacks we have, yet new malware samples seem to make it past legacy AV solutions every day. If you monitored the top AV engines the day WannaCry surfaced, you'd have seen that most of them missed the first samples early on but slowly updated signatures over the following hours, days, and weeks. This is a perfect example of the delayed, reactive nature of signature-based detection solutions.
Signature-based AV software can also miss well-known threats. The industry sees anywhere from 300,000 to 1 million new malware variants each day. However, criminals aren't making millions of new worms, Trojans, or viruses. There are probably thousands, not hundreds of thousands, of truly unique malware families. So, where do these millions of variants come from?
The answer is malware evasion techniques. Over time, malware authors have developed hundreds of techniques to make their malware look "new again" to evade security controls. In the second of a two-part post, I'll cover seven high-level evasion techniques cybercriminals use to hide malware from you and your security software, and explain some of the ways we can still detect them. Here, in part 1, I'll outline four basic malware obfuscation methods.
1. Packers
A packer is a program that compresses an executable to make it smaller. It wraps the compressed executable in the code necessary to decompress itself at runtime. The act of compression changes the way the executable file looks. Signature-based detection relies on malware researchers or automated systems finding a pattern in a known malware file, such as a hash or the number of binary patterns, to create a unique identifier for that malware. Packing changes this identifier, so the AV may not detect the packed file.
Though there are legitimate uses for packers, including making your executables smaller or making it harder for pirates to reverse engineer your code, malware regularly uses packed executables to try to hide from your AV. AV can often detect packing, but since you can legitimately pack executables, AV products can't use this alone to decide something is malware.
2. Crypters
A crypter is similar to a packer but adds additional obfuscation or encryption to the mix. Like a packer, its goal is to change the binary fingerprint of a file to avoid detection. In a nutshell, the crypter encrypts the original executable using an encryption algorithm — often something as simple as a XOR cipher with a unique key. The crypter then creates a stub, which is the initial program that has everything it needs to decrypt and run the real embedded payload.
By using different keys with a XOR cipher to encode the original program, you can create almost endless altered copies of the same program. Nowadays, other criminals sell many different crypters on the underground market. You can also find many free ones, like the well-known Veil-Evasion framework.
There are some issues with both packers and crypters. For instance, both techniques mostly protect malware from static analysis but not necessarily dynamic analysis. Static analysis means malware detection techniques you perform on a file that has not executed yet. Because you want to stop malware before it gets onto systems, many AV products scan files as they pass through networks or get copied onto a computer's file system. However, static analysis limits what AV can learn about the particular file since those files could be packed or crypted.
Dynamic analysis, on the other hand, means detection techniques applied when a file executes. Dynamic analysis allows you to see the malware code in memory, or pay attention to other things it does. A packed or crypted program eventually has to unpack or decrypt itself to run. Thus, products using dynamic analysis can often recognize the obfuscated malware once it does run. Furthermore, once AV companies figure out how to detect particular packers or the stubs for crypters, they can sometimes recognize those malicious files without needing to see the decoded binary.
I'm simplifying, of course. Packers and crypters continue to evolve in an arms race against AV software and now use techniques such as only decrypting small portions of the real payload in memory at a time, which can make it harder for AV products.
3. Polymorphic Malware
At the highest level, polymorphic malware is malware that repeatedly uses packing and crypting methods to change the way it looks. However, rather than using static keys as most crypters do, polymorphic malware uses more complex encrypting algorithms with random keys, variables, and decoders. The malware itself can mutate itself every time it copies itself to a new location, or criminals can set up servers that automatically morph their malware variant every time it's sent to a new victim. Server-side polymorphic malware is very popular and likely accounts for a large majority of daily malware variants.
4. Downloaders, Droppers, and Staged Loading
Many kinds of malware use staging programs called droppers or downloaders to learn about a system before installing the real malware. Some of these droppers scope out a system first to avoid triggering security alerts when they download and install the real payload. They may seek out and kill security processes or check to see if they're running on a virtual system. They may also download their secondary payloads using encrypted back channels to avoid network detection or inject malware directly into known Windows processes to avoid detection. On the downside, AV vendors can design signatures to recognize these droppers and downloaders, and modern AV programs are good at defending themselves from dropper tricks.
These four techniques hackers use to hide malware are relatively basic but quite effective. In the second part of this series, I describe several more advanced obfuscation methods, and explain ways companies can still detect malware even if it's hidden.
Related Content:
How Hackers Hide Their Malware: Advanced Obfuscation (Part 2 of series)
Learn from the industry’s most knowledgeable CISOs and IT security experts in a setting that is conducive to interaction and conversation. Click for more info and to register.
About the Author
You May Also Like