Viruses: Self-Replicating Code
What you'll learn: How computer viruses attach themselves to legitimate files and depend on human activity to spread through systems.
What Is a Virus?
A computer virus is malicious code that cannot spread on its own—it must attach itself to a host file or program, much like a biological virus needs a living cell. When you execute that infected file, the virus code runs, performs its malicious actions, and attempts to infect other files on the system.
The key characteristic: viruses require user action to spread. Someone must run the infected program, open the compromised document, or copy the file to another system.
How Viruses Attach to Hosts
File Infectors target executable files. The virus inserts its code into .exe, .dll, or script files. When you launch what appears to be a normal application, the virus code executes first, then (often) allows the legitimate program to run so you don't suspect anything.
Macro Viruses embed themselves in document files like Word or Excel documents. They exploit the scripting capabilities (macros) built into office software. When you open an infected document and macros are enabled, the virus runs—potentially infecting other documents or downloading additional malware.
Why User Action Matters
Unlike worms (which we haven't covered yet), viruses are passive until triggered. They spread when:
- You download and execute an infected program
- You share USB drives containing infected files
- You open an email attachment with a macro virus
- You copy files between systems manually
This dependency on human behavior is both a weakness (easier to prevent) and a strength (social engineering can trick users into triggering infections).
Key Takeaway: Viruses are self-replicating malware that attach to host files and require user action—like executing a program or opening a document—to activate and spread to other files.