Skip to content
Visual explainer 2h 30m to learn 4 steps

Malware families & how they spread

Classify malware by behaviour and name the defences for each family.

By Invicly Tech, , in Cyber Security Fundamentals. About 11 minutes to read.

Topic 28 of 49

In short

Malware is classified by how it behaves: viruses attach to files, worms spread by themselves, trojans hide in useful programs, ransomware encrypts for extortion, and infostealers harvest data. Many modern attacks are fileless, abusing legitimate tools.

Explained simply

Malware means malicious software: any program built to harm you, spy on you or take control of your computer. Security people sort malware into families by what it does, not by its name. Knowing the family tells you how it got in, what it wants and which defence stops it.

Some malware spreads. A virus hides inside another file and runs when a person opens that file. A worm needs no help: it scans the network, finds machines with the same weakness and copies itself to them. Worms can infect thousands of machines in hours.

Some malware hides. A trojan pretends to be something useful, like a free game or a cracked app. A RAT (remote access trojan) quietly gives the attacker remote control. An infostealer grabs saved passwords, browser cookies and crypto wallets, then sends them away within minutes.

Ransomware locks your files with encryption and demands payment. Today most gangs also copy your data first and threaten to publish it, which is called double extortion. Fileless attacks avoid dropping a new program at all. They misuse tools already on the machine, such as PowerShell, so there is no strange file to scan.

Press Play on a diagram to walk through it one step at a time.

MapMalware families
Malware
  • Self-spreading
    • Virus
    • Worm
  • Disguised
    • Trojan
    • RAT
  • Extortion
    • Ransomware
  • Theft
    • Infostealer
    • Keylogger
CompareWhich defence fits which family
Worms and ransomware
  • Patch exposed services fast
  • Segment the network
  • Offline or immutable backups
  • Alert on shadow copy deletion
Trojans and infostealers
  • Application control
  • Block macros from the internet
  • Phishing-resistant MFA
  • Revoke sessions after infection
RATs and fileless
  • EDR behaviour detection
  • Script block logging
  • Watch parent and child processes
  • Alert on beaconing to new domains

In depth

Viruses, worms and trojans: how each one spreads

The key question is: what does the malware need to move? A virus needs a host file and a person to run it, so it spreads at human speed through shared files and USB sticks. Classic file-infecting viruses are rare today; macro malware inside Office documents is the modern cousin.

A worm needs only a reachable, vulnerable service. WannaCry in 2017 used the EternalBlue exploit against SMBv1 (Windows file sharing, TCP port 445) and hit hundreds of thousands of machines in a few days, even though Microsoft had released the fix (MS17-010) two months earlier. A trojan needs trust: the user installs it on purpose because it looks legitimate.

So the defences differ. Patching and network segmentation slow worms. Application control and blocking macros from the internet stop many trojans and macro droppers. User awareness helps against all three.

  • Virus: host file plus user action
  • Worm: vulnerable network service, no user needed
  • Trojan: user trust, installed willingly
  • Loader or dropper: small first stage that downloads the real payload

Modern ransomware is a business process

Big ransomware attacks are not a single click. Operators buy or steal access (often from an initial access broker), spend days exploring the network, steal domain admin credentials, copy data out, delete backups and shadow copies, and only then start encryption, often at night or on a weekend. Many groups run as ransomware-as-a-service: developers write the malware and affiliates carry out the attacks for a share of the ransom.

This long middle phase is the defender's best chance. Signs include new admin accounts, remote tools like AnyDesk appearing, mass file access over SMB, large uploads to cloud storage, and commands like vssadmin delete shadows. Stopping the attack before encryption is far cheaper than recovering after it.

Backups are the last line. Keep at least one copy offline or immutable (cannot be changed or deleted for a set time), and test restores regularly.

FlowTypical ransomware intrusion timeline
  1. 1
    Initial access

    Phishing, stolen VPN login or exposed service

  2. 2
    Discovery

    Map hosts, shares and admins

  3. 3
    Credential theft

    Reach domain admin

  4. 4
    Exfiltration

    Copy data out for leverage

  5. 5
    Sabotage recovery

    Delete backups and shadow copies

  6. 6
    Encrypt

    Often at night, many hosts at once

Infostealers and RATs: the access economy

Infostealers such as RedLine and Lumma are cheap, sold as a monthly service, and usually spread through fake software downloads, cracked games, malicious ads and fake browser updates. They run once, collect saved browser passwords, session cookies, crypto wallets and VPN or chat tokens, upload a small archive called a log, and often delete themselves. Those logs are sold on criminal markets.

Stolen session cookies are especially dangerous because they can let an attacker reuse a logged-in session and skip MFA. Many big breaches started with one infected personal laptop that held work logins.

RATs are different: they stay. They give the attacker a remote shell, screen capture, keylogging and file transfer, and they phone home to a command and control (C2) server on a schedule. Look for regular outbound connections (beaconing) and unknown programs that start at boot.

  • After an infostealer: reset passwords and revoke all sessions, not just passwords
  • Phishing-resistant MFA (passkeys, FIDO2 keys) blocks password replay
  • Short session lifetimes limit the value of stolen cookies

Fileless and living off the land

Living off the land (LotL) means using tools the operating system already trusts: PowerShell, WMI, rundll32, mshta, certutil, regsvr32 on Windows, or bash, curl and cron on Linux. The LOLBAS project documents which Windows binaries can be abused and how. Because these tools are signed by Microsoft, antivirus that only scans new files sees nothing wrong.

Fileless often means the payload lives in memory or in the registry instead of a file on disk. For example, a script downloads code and runs it directly in memory, and a registry Run key starts it again after reboot.

Detection moves from files to behaviour. Turn on PowerShell Script Block Logging (event 4104), collect process creation with full command lines (Sysmon event 1 or Windows 4688), and alert on odd parent and child pairs, such as Word starting PowerShell. AMSI (Antimalware Scan Interface) lets security tools inspect scripts after they are decoded.

Learn it in 4 short steps

About 40m each. Track them with a timer in your plan.

  1. 1
    Compare viruses, worms and trojans~40m
  2. 2
    Explain ransomware and double extortion~40m
  3. 3
    Explain infostealers and RATs~40m
  4. 4
    Explain fileless and living-off-the-land~40m

Key points

  • Worms spread on their own; viruses need a host file.
  • Ransomware often adds data theft for double extortion.
  • Infostealers and RATs focus on access and data.
  • Fileless malware abuses built-in tools to avoid detection.

Key terms

Tap a card to flip it. 0/4 known

Examples

Classify a sample from its behaviour report

A sandbox report says the file arrived as setup.exe from a cracked software site. When run, it reads the Chrome and Edge password databases, zips them, sends one HTTPS upload to an unknown domain and deletes itself. It never scans the network and adds no startup entry. Step 1: no spreading, so it is not a worm or virus. Step 2: disguised as useful software, so it was delivered as a trojan. Step 3: one-time theft of credentials, so the family is infostealer. Step 4: the response is not just cleaning the laptop: reset every saved password, revoke active sessions and check sign-in logs for logins from new places.

Spot a living-off-the-land chain in process logs

A user opened an invoice document. Sysmon event 1 logs show WINWORD.EXE as the parent of powershell.exe, with an encoded command. Step 1: Word has no normal reason to start PowerShell, which is the first red flag. Step 2: decode the Base64 command (it is UTF-16LE text) in an isolated analysis VM to see what it downloads. Step 3: check event 4104 for the decoded script block. Step 4: look for persistence, such as a new Run key in Sysmon event 13. The query below finds the suspicious parent and child pair in a Splunk-style SIEM.

spl
index=sysmon EventCode=1
  (ParentImage="*\\WINWORD.EXE" OR ParentImage="*\\EXCEL.EXE")
  (Image="*\\powershell.exe" OR Image="*\\cmd.exe" OR Image="*\\mshta.exe")
| table _time host User ParentImage Image CommandLine

Quick reference

  • Worm = spreads by itself over the network; virus = needs a host file and a user
  • WannaCry (2017) spread through SMBv1 on TCP 445; the fix MS17-010 was already out
  • Ransomware warning sign: vssadmin delete shadows or wbadmin delete catalog
  • After an infostealer, revoke sessions and tokens as well as resetting passwords
  • PowerShell Script Block Logging writes event 4104 with the decoded script
  • Office app starting powershell.exe, cmd.exe or mshta.exe is a classic alert
  • LOLBAS lists Windows binaries attackers abuse; GTFOBins does the same for Unix
  • Keep one backup copy offline or immutable and test that it restores

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1Malware infects a server and, with no user action, starts scanning other hosts on port 445 and copying itself. What is it?

Question 2

2Why do modern ransomware groups copy data out before encrypting it?

Question 3

3An infostealer took a user's browser cookies. Which response matters most beyond a password reset?

Question 4

4Why is fileless or living-off-the-land activity hard for traditional antivirus to catch?

Question 5

5Which log source best helps detect fileless PowerShell attacks?

0/5 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Sort these five into families: (a) spreads through an unpatched VPN service, (b) fake PDF reader that opens a remote shell, (c) encrypts shares and demands bitcoin, (d) uploads saved passwords once and deletes itself, (e) macro inside a Word file that runs when opened.

  2. Exercise 2medium

    Pick three living-off-the-land binaries from the LOLBAS project and, for each, write what attackers use it for and one detection idea.

  3. Exercise 3hard

    Write a one-page ransomware readiness checklist for a small company that covers the stages before encryption, not just backups. Give at least two controls and one detection per stage.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Is a trojan the same as a virus?
No. A virus copies itself into other files. A trojan does not copy itself; it tricks you into installing it by pretending to be useful software.
Should a company pay the ransom?
Law enforcement agencies such as the FBI and CISA advise against paying, because payment does not guarantee working decryption or deleted data, and it funds more attacks. Some payments can also break sanctions law, so the decision involves legal counsel.
Can Macs and Linux machines get malware?
Yes. There are infostealers for macOS, and Linux servers are common targets for cryptominers, botnets and ransomware aimed at virtualisation hosts. They are less often targeted than Windows desktops, but not immune.
Does antivirus still matter if attacks are fileless?
Yes, it still blocks a lot of commodity malware. But you also need behaviour-based detection, such as EDR and good process and script logging, to catch attacks that use built-in tools.

Go deeper

ShareXLinkedInWhatsApp