Skip to main content
Be Bitwise

Common Malware Techniques

Malware Analysis Fundamentals · Advanced Reverse Engineering track

6 min read

In this module

How Malware Operates

Malware authors have spent decades refining a shared playbook for getting code running, keeping it there, and dodging detection. Whether you're tearing samples apart or trying to stop them, you need to recognise the moves.

Process Injection

Process injection runs malicious code inside a legitimate process. The malicious activity now wears the badge of a trusted program, and your detection problem just got a lot harder.

DLL Injection: The most common technique. The malware:

  1. Opens a handle to the target process (e.g., explorer.exe)
  2. Allocates memory in the target using VirtualAllocEx
  3. Writes the path of a malicious DLL into that memory using WriteProcessMemory
  4. Creates a remote thread in the target that calls LoadLibrary with the DLL path

The target process now loads and executes the malicious DLL as if it were a legitimate library.

Every arrow below crosses from one process into another, which is exactly what makes this pattern stand out in an API trace. OpenProcess asks for a handle with rights to the target; the next three calls use that handle to reach into it:

The trick in the last call is that LoadLibraryA takes exactly one pointer argument, the same shape as a thread start routine, so a new thread can be pointed straight at it.

Process Hollowing: The malware:

  1. Creates a legitimate process in a suspended state (e.g., svchost.exe)
  2. Unmaps the legitimate code from the process
  3. Maps its own code into the process's address space
  4. Resumes the process, which now executes the malicious code

The process appears to be a legitimate svchost.exe in task managers and process lists.

Key Concept

Process injection hides malicious code inside trusted processes. DLL injection loads a malicious library into another process. Process hollowing replaces a legitimate process's code entirely. Both techniques make the malware harder to detect because the malicious activity appears to originate from a trusted program.

Persistence Mechanisms

Persistence ensures the malware survives reboots. Common mechanisms on Windows:

Registry Run Keys: Drop an entry under HKLM\Software\Microsoft\Windows\CurrentVersion\Run and the malware fires at every login. Crude, easy, still works.

Scheduled Tasks: A task that runs the binary on intervals or triggers (login, startup, idle). Good for blending into normal admin activity.

Services: Register the malware as a Windows service set to auto-start. SYSTEM privileges out of the gate, no user needed.

DLL Hijacking: Drop a malicious DLL where a legitimate program will load it before the real one. Now the malware runs whenever that program starts.

Bootkits: Tamper with the MBR or UEFI so the implant loads before the OS. Survives an OS reinstall, which is precisely the point.

Command and Control (C2)

C2 is the communication channel between the malware and the attacker. It allows the attacker to:

  • Send commands (download files, execute programs, spread to other machines)
  • Receive stolen data (credentials, documents, screenshots)
  • Update the malware's behaviour

HTTP/HTTPS C2: The default. Periodic HTTP requests dressed up as ordinary web browsing. With HTTPS the payload is encrypted, so deep packet inspection is largely blind.

DNS C2: Commands and data ride inside DNS queries and replies. DNS is rarely blocked or even logged, so it sails through firewalls that would shred anything else. The malware queries encoded-data.evil-domain.com and gets commands back inside TXT records.

Domain Generation Algorithms (DGAs): Hardcoded domains get blacklisted fast. A DGA generates thousands of pseudo-random domains per day from the date. The attacker registers a handful in advance. Defenders are left chasing a moving target.

Here's a toy DGA (it only emits names under the reserved .example domain). The implant and the operator run the same function on the same date, so they agree on the list without ever talking. Before you run it, predict how many of tomorrow's names are on a blocklist built from today's.

Try itRun it, then change SEED and see every name change: an analyst who recovers the algorithm and the seed from a sample can generate next month's list and register or sinkhole the names first.
C (GCC 9.2.0)

Social media and cloud services: Some malware fetches its instructions from Twitter posts, GitHub gists, or Google Docs. Traffic to those domains looks completely normal — because, well, it is.

Credential Theft

Keylogging: Recording every keystroke to scoop up passwords, card numbers, and anything else typed.

Credential dumping: Pulling stored passwords out of LSASS, browsers, email clients, and the like. Mimikatz is the household name here, infamous for yanking plaintext passwords and NTLM hashes straight out of Windows memory.

Man-in-the-browser: Inject into the browser, sit between the user and the web app, then quietly rewrite traffic on the fly. Classic example: the user submits a transfer to one account; the malware swaps the destination on the way out.

Evasion Techniques

Beyond anti-debug and anti-VM measures:

Fileless malware: Lives entirely in memory, riding on PowerShell, WMI, or .NET. Nothing malicious touches disk, which is bad news for AV scanners that only know how to read files.

Living off the land: Use what's already there. PowerShell, certutil, bitsadmin — every single command is a normal admin tool, and detection has to reason about behaviour rather than binaries.

Code signing: A stolen or fraudulently issued code-signing cert makes the binary look trustworthy. Some defenders trust signatures more than they should.

Ransomware Specifics

Ransomware has its own set of techniques:

  • Enumerate and encrypt files using strong cryptography (AES for file content, RSA for the AES key)
  • Delete shadow copies (backup snapshots) to prevent recovery
  • Display ransom notes demanding payment
  • Communicate with C2 to report encryption status and receive decryption keys upon payment

Recognizing the Patterns

Nothing here belongs to one family. They're Lego bricks. A banking trojan glues process injection onto keylogging and credential theft. A backdoor stacks persistence, C2, and evasion. Once you can name the bricks, every new sample stops looking unique and starts looking like a particular combination — which is exactly how MITRE ATT&CK teaches you to read them. The work goes from "decode this incomprehensible thing" to "tag the pieces and understand the assembly".