Types of Computer Viruses: How Each Infects and How to Prevent It
Computer viruses are grouped by what they infect and by how they hide. By target, the main types are file infectors (executables), boot sector viruses (startup code), macro viruses (Office documents) and script viruses (files run by interpreters such as PowerShell or JavaScript). By behaviour, they can be resident in memory, stealth, polymorphic, metamorphic or multipartite.
Topic: Cyber Threats, Scams & Online Safety in Cybersecurity & Ethical Hacking · Tutorial
Also covers: Cybersecurity Foundations
Quick answer: Computer viruses are grouped by what they infect and by how they hide. By target, the main types are file infectors (executables), boot sector viruses (startup code), macro viruses (Office documents) and script viruses (files run by interpreters such as PowerShell or JavaScript). By behaviour, they can be resident in memory, stealth, polymorphic, metamorphic or multipartite. Boot sector and multipartite viruses are largely historic thanks to UEFI Secure Boot, while macro, script and polymorphic techniques are still seen. Each type has a matching control: patching, Secure Boot, macro blocking, script restrictions and behaviour-based endpoint protection.
Key takeaways
- A virus needs a host file or code area to live in.
- Classify by target first, then by hiding behaviour.
- Secure Boot made classic boot sector viruses rare.
- Office now blocks internet macros by default.
- Script-based infections are the most current concern.
Table of Contents
- What Makes Something a Virus?
- Which Virus Types Are Defined by What They Infect?
- Which Types Are Defined by How They Hide?
- Which Types Still Matter Today?
- How Do You Prevent Each Type?
- References
What Makes Something a Virus?
NIST defines a virus as a program that replicates by infecting other programs or files, usually needing the host to run. That host requirement separates it from worms, which spread on their own, and Trojans, which disguise themselves but do not replicate. NIST SP 800-83 describes compiled viruses and interpreted viruses (macro and script) as the two broad families.
Which Virus Types Are Defined by What They Infect?
| Type | Host | How it runs | Status |
|---|---|---|---|
| File infector | Executables such as .exe | When the infected program starts | Less common, still seen |
| Boot sector | Master boot record or boot code | Before the operating system loads | Mostly historic |
| Macro | Word or Excel documents | When macros are enabled | Reduced by default blocking |
| Script | PowerShell, VBScript, JavaScript files | Through an interpreter | Current |
Modern pre-boot threats are tracked as bootkits under MITRE T1542.003. Script abuse falls under T1059, and opening a malicious file is T1204.002.
Which Types Are Defined by How They Hide?
- Resident: loads into memory and infects files as they are opened.
- Non-resident: searches for files to infect only when it runs.
- Stealth: intercepts system calls so infected files look clean.
- Polymorphic: encrypts itself with a changing decryptor.
- Metamorphic: rewrites its whole body on each copy.
- Multipartite: infects both files and boot areas.
A single virus can combine several, for example a resident, polymorphic file infector. For the mutation techniques in detail, read what a polymorphic virus is.
Which Types Still Matter Today?
Most real infections today are Trojans, ransomware and infostealers rather than self-replicating viruses. Viral techniques survive inside them: scripts that chain to other scripts, documents that drop code, and packers that change every file. Boot sector viruses faded because UEFI firmware with Secure Boot only loads signed boot code. Macro viruses dropped after Microsoft began blocking macros in files from the internet by default.
Script viruses are the type to watch. A shortcut or script file can launch PowerShell, fetch more code and copy itself to shared folders or USB drives, which is why script logging and blocking script attachments in email are worth the effort.
How Do You Prevent Each Type?
| Type | Main control |
|---|---|
| File infector | Application control, updated endpoint protection |
| Boot sector and bootkit | UEFI Secure Boot, firmware updates |
| Macro | Keep internet macro blocking, allow only signed macros |
| Script | PowerShell logging, constrained language mode, block script file types in email |
| Polymorphic and stealth | Behaviour and memory scanning, cloud protection |
On Windows, a read-only check confirms Secure Boot is on:
Confirm-SecureBootUEFI
Back up data offline and teach staff not to enable content in unexpected documents. Indian organisations should report notable incidents to CERT-In within 6 hours. New to the subject? Start with what a virus is in cyber security. WebAsha runs cybersecurity fundamentals training.
References
Frequently Asked Questions
What's Your Reaction?
Like
1
Dislike
0
Love
0
Funny
0
Wow
0
Sad
0
Angry
0