🎓 BookMCQ
← Back to 15. Security

📝 Computer viruses in operating system (25 MCQs)

Self Replicating Code Attached to Other Programs

A computer virus is malicious code that replicates by attaching itself to a host file, program, or other executable content. When an infected host runs or is processed, the virus may execute its payload and attempt further infection. Operating system security addresses viruses through execution controls, file protection, scanning, integrity monitoring, and recovery measures.

Why Host Based Replication Spreads Infection

Viruses depend on a host or carrier, unlike worms that can spread independently across networks. Users may distribute infected files through removable media, email attachments, downloads, or shared folders. Weak permissions and unrestricted execution allow infection to modify files or reach additional users and processes.

Infection, Activation and Payload Behaviour

A virus inserts or attaches its code to a host. When the infected host executes, the virus may run before, alongside, or after the original functionality. It can search for other files, infect eligible targets, and perform a payload such as data corruption. Exact behaviour depends on the virus design and execution environment.

Example of an Infected Executable File

A user receives an infected executable through removable media and launches it. The virus runs with the user's permissions and attempts to attach itself to other writable executable files. When those files are later shared and executed, additional systems may become infected. Restricted write access can limit the spread.

Detection, Containment and Recovery

Antivirus tools use signatures, heuristics, and behavioural analysis to identify known or suspicious code. Keeping software updated, scanning removable media, restricting execution, and maintaining offline backups reduce damage. Detection may miss new or modified malware, so infected systems may require isolation, trusted recovery media, and careful restoration.

Misconceptions About Computer Viruses

'Every virus spreads over a network automatically' is false because some rely on file sharing or user actions. 'A virus and a worm are identical' ignores the host requirement of a virus. 'Deleting one infected file always cleans the system' overlooks other infected files and persistence mechanisms.

Exam Focus: Virus Lifecycle and Malware Comparison

Explain the host attachment, execution, replication, and payload stages of a virus. Compare viruses with worms and Trojans by their propagation methods. Questions may ask how antivirus signatures, behavioural detection, access restrictions, and backups contribute to prevention, containment, and recovery.

Key Terms of Computer Viruses

  • Virus - Malware that replicates through a host.
  • Host file - File carrying the virus code.
  • Infection - Insertion of malicious code into a host.
  • Payload - Harmful action performed by malware.
  • Quarantine - Isolation of suspected infected files.
6
Easy
11
Medium
8
Hard

📝 All Computer viruses in operating system MCQs

Q1. What defines a computer virus?

A.Self‑replicating code that attaches to legitimate programs and spreads to other systems
B.A program that modifies the BIOS to cause hardware failure ✅
C.A network scanner that discovers open ports
D.An encryption tool used for data‑at‑rest protection
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: A computer virus is characterized by its ability to replicate itself and embed within legitimate software, allowing it to propagate to other machines. Option B describes a firmware attack, not a virus. Option C is a scanning tool, while option D is encryption software—both unrelated to viral behavior. Recognizing this definition helps students differentiate viruses from other malicious utilities in practical security contexts.

Q2. Why do Trojan horse programs often evade detection by traditional antivirus software?

A.They masquerade as trusted applications, blending with legitimate processes
B.They encrypt their payload using strong cryptography ✅
C.They only activate during system boot
D.They delete system logs after execution
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Trojan horses hide by appearing as trusted or useful software, which lets them run without raising suspicion from signature‑based scanners that focus on known malicious code. Option B describes ransomware techniques, not evasion. Option C is about boot‑time malware, while option D suggests log manipulation, which is a separate stealth method. Understanding this evasion tactic explains why behavior‑based detection is needed in real‑world defenses.

Q3. A user downloads a free PDF editor that unexpectedly copies edited documents to an external server. Which type of threat does this behavior illustrate?

A.Trojan horse ✅
B.Worm
C.Rootkit
D.Logic bomb
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The described behavior matches a Trojan horse: a seemingly benign program that surreptitiously performs malicious actions, such as exfiltrating files. A worm spreads autonomously, a rootkit hides its presence at the kernel level, and a logic bomb triggers under specific conditions. Identifying the Trojan horse pattern helps administrators implement application whitelisting and monitor outbound traffic for data leakage.

Q4. If a virus modifies a system's registry to run at startup, which mitigation strategy is most effective?

A.Implementing startup‑program monitoring and restricting registry edits ✅
B.Installing a firewall to block outbound traffic
C.Using disk encryption to protect files
D.Disabling USB ports on all workstations
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Monitoring startup entries and limiting registry modifications directly address the virus’s persistence mechanism, preventing it from auto‑executing after reboot. A firewall controls network traffic but does not stop a locally stored virus from launching. Disk encryption protects data at rest, not execution pathways. Disabling USB ports reduces removable media threats but does not affect registry‑based persistence.

Q5. Which of the following best describes a polymorphic virus?

A.A virus that changes its code each infection to avoid signature detection
B.A virus that spreads only through email attachments ✅
C.A virus that targets only mobile operating systems
D.A virus that self‑destructs after a single execution
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Polymorphic viruses encrypt or rewrite their own code with each replication, making static signatures ineffective. Option B describes a delivery vector, not the polymorphic nature. Option C limits the platform, while option D describes a logic bomb. Recognizing polymorphism is crucial for deploying heuristic or behavior‑based detection in environments where signatures quickly become obsolete.

Q6. An organization notices a sudden increase in network traffic to an unfamiliar IP address after employees open a seemingly harmless document. Which virus behavior does this indicate?

A.Data exfiltration via a back‑door Trojan ✅
B.Rapid replication like a worm
C.System shutdown triggered by a logic bomb
D.Privilege escalation using a rootkit
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: The spike in outbound traffic suggests a back‑door Trojan that silently sends data to a remote server, a classic exfiltration pattern. Worms cause rapid internal spread, not necessarily external traffic spikes. Logic bombs wait for a trigger, and rootkits hide malicious activity but do not inherently cause unusual outbound connections. Understanding this behavior guides incident responders to isolate the compromised host and block the malicious IP.

Q7. Why is it important for an operating system to enforce the principle of least privilege in the context of virus containment?

A.It limits the damage a virus can cause by restricting its access rights
B.It prevents viruses from being installed in the first place ✅
C.It ensures all processes run with administrator rights
D.It automatically updates antivirus definitions
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Least privilege ensures that even if a virus gains execution, it cannot modify critical system components or access sensitive data, thereby containing potential harm. Option B confuses prevention with containment; viruses can still be introduced despite safeguards. Option C would grant excessive rights, amplifying risk. Option D pertains to signature updates, not privilege management. This principle is foundational for reducing attack impact in real‑world deployments.

Q8. A programmer writes a script that, when executed, searches for files containing the keyword “confidential” and copies them to a hidden folder. Which security threat category does this script belong to?

A.Trojan horse
B.Worm
C.Back‑door
D.Spyware ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: The script covertly gathers information without user consent, fitting the definition of spyware, which monitors or extracts data. A Trojan horse disguises malicious intent as legitimate functionality, a worm spreads autonomously, and a back‑door provides persistent remote access. Recognizing the spyware nature helps security teams implement data‑loss‑prevention policies and monitor for unauthorized file‑access patterns.

Q9. If a virus uses the formula Rn=Rn−1×2R_n = R_{n-1} \times 2 to model its replication rate, how many copies will exist after three generations starting from a single instance?

A.8 ✅
B.6
C.4
D.16
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: Starting with R0=1R_0 = 1, after the first generation R1=1×2=2R_1 = 1 \times 2 = 2. The second generation gives R2=2×2=4R_2 = 2 \times 2 = 4. The third generation results in R3=4×2=8R_3 = 4 \times 2 = 8. Therefore, eight copies exist after three generations. Options B, C, and D miscalculate the exponential growth, which is a common mistake when students forget to multiply each step by the factor of two.

Q10. Which of the following is a primary reason that viruses often target executable files rather than data files?

A.Executable files can run code, allowing the virus to propagate
B.Data files are always read‑only and cannot be altered
C.Executable files are larger and store more information ✅
D.Data files are automatically backed up by most systems
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: Viruses need to execute code to replicate; targeting executables ensures their payload runs when the file is opened. Data files typically contain static information and do not trigger code execution, limiting viral spread. Option C is irrelevant to propagation, while option D assumes backup practices that do not affect the initial infection vector. Understanding this targeting helps in designing file‑type filtering rules.

Q11. A system administrator discovers that a recently installed driver is causing unexpected network scans. Which type of malicious code is most likely responsible?

A.Rootkit ✅
B.Worm
C.Trojan horse
D.Adware
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Rootkits embed themselves deep within the operating system, often modifying drivers to hide malicious activity such as covert network scanning. Worms spread independently, Trojan horses disguise malicious intent but usually rely on user interaction, and adware displays unwanted advertisements. Identifying a rootkit informs the admin that deeper system components must be examined and possibly reinstalled to eradicate hidden threats.

Q12. Why might a virus that encrypts files and demands payment be classified differently from a traditional virus?

A.It is a ransomware, a subtype that focuses on extortion rather than replication
B.It does not replicate at all, so it cannot be a virus ✅
C.It only targets mobile devices
D.It uses social engineering instead of code execution
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Ransomware encrypts data and extorts victims, distinguishing it from classic viruses whose primary goal is replication. While some ransomware can also replicate, its defining characteristic is the ransom demand, not spread. Option B misstates that replication is required for all viruses; many modern ransomware families incorporate spreading mechanisms. Options C and D describe platform or delivery aspects, not the core functional difference.

Q13. In a corporate network, a virus spreads via shared network drives without user interaction. Which propagation mechanism does this exemplify?

A.Worm ✅
B.Trojan horse
C.Logic bomb
D.Rootkit
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Worms autonomously propagate across network resources, such as shared drives, without needing user execution. Trojan horses require a user to run the malicious program, logic bombs await a trigger condition, and rootkits conceal their presence after installation. Recognizing worm behavior guides the implementation of network segmentation and access controls to limit automatic spread.

Q14. Which security control is most effective at preventing the execution of a virus that relies on macro scripts in office documents?

A.Disabling macros by default and allowing only signed macros ✅
B.Installing a hardware firewall at the network perimeter
C.Enabling full‑disk encryption on all workstations
D.Using a VPN for remote access
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: By disabling macros and permitting only digitally signed ones, organizations block the primary execution path used by macro‑based viruses, reducing the risk of infection. A hardware firewall filters network traffic but does not stop malicious macros from running locally. Full‑disk encryption protects data at rest, and VPNs secure remote connections; neither directly addresses macro execution.

Q15. A researcher observes that a virus modifies its code to appear different each time it infects a new host. Which detection technique is most likely to identify this virus?

A.Behavior‑based anomaly detection ✅
B.Signature‑based scanning
C.Static file hash comparison
D.Port scanning
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Behavior‑based anomaly detection monitors actions such as file writes, process creation, and network connections, allowing it to flag malicious activity even when the virus’s code changes. Signature‑based scanning fails because the code is constantly altered. Static hash comparison also relies on unchanged code, and port scanning assesses network services, not code behavior. Understanding detection methods helps in selecting appropriate security tools against polymorphic threats.

Q16. Why is it risky to grant a user administrative privileges on a workstation that frequently accesses the internet?

A.The user can inadvertently install or execute malicious software with full system rights ✅
B.Administrative privileges speed up internet browsing
C.It prevents the user from installing necessary updates
D.It forces the system to use a stronger encryption algorithm
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: Administrative rights allow a user to install or run any program, including malware downloaded from the internet, giving the virus unrestricted access to the system. Higher privileges do not affect browsing speed, nor do they block updates or enforce encryption. Recognizing this risk emphasizes the principle of least privilege as a key defensive measure in everyday computing environments.

Q17. A virus infects a system and then disables the antivirus service. Which type of malicious component does this behavior represent?

A.Rootkit ✅
B.Worm
C.Trojan horse
D.Spyware
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Rootkits specialize in hiding their presence and often disable security tools to avoid detection, matching the described behavior. Worms focus on spreading, Trojan horses disguise malicious intent, and spyware gathers information without necessarily interfering with security services. Identifying rootkit activity prompts deeper system integrity checks and possibly reinstalling compromised components.

Q18. If a virus uses the equation P(t)=P0ektP(t) = P_0 e^{kt} to model its spread over time, what does the variable kk represent?

A.The growth rate constant of the infection ✅
B.The initial number of infected hosts
C.The total number of hosts in the network
D.The time required for the virus to stop spreading
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: In the exponential growth model, kk is the constant that determines how quickly the infection expands; a larger kk means faster spread. P0P_0 is the initial infected count, not kk. The total network size and cessation time are separate parameters. Understanding the role of kk helps security planners predict outbreak speed and allocate resources accordingly.

Q19. Which of the following best explains why a virus might embed itself in a system's boot sector?

A.To ensure it loads before the operating system, granting early control
B.To increase the size of the infected file for better concealment ✅
C.To exploit a vulnerability in the BIOS firmware
D.To bypass user authentication mechanisms
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Boot‑sector infection allows the virus to execute before the OS loads, giving it control over system initialization and making removal harder. Option B misinterprets concealment tactics, while option C refers to BIOS attacks, not boot‑sector code. Option D suggests authentication bypass, which is unrelated to the timing advantage of boot‑sector persistence.

Q20. A company implements a whitelist that only allows approved executables to run. Which type of virus is most likely to be blocked by this measure?

A.Trojan horse that masquerades as a legitimate program ✅
B.Polymorphic virus that changes its signature
C.Worm that spreads via email attachments
D.Rootkit that hides kernel modifications
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: A whitelist permits only known, trusted executables; a Trojan horse that pretends to be a legitimate application will be blocked because its binary is not on the approved list. Polymorphic viruses may still execute if their code matches an allowed file, and worms or rootkits can operate through legitimate system utilities, bypassing the whitelist. This illustrates the strength of application control in preventing masqueraded threats.

Q21. Why does the use of code obfuscation techniques make static analysis of a virus more difficult?

A.It transforms readable code into complex, unintelligible forms, hindering pattern recognition
B.It encrypts the virus’s network traffic ✅
C.It reduces the virus’s ability to replicate
D.It disables the operating system’s logging facilities
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Obfuscation deliberately scrambles the code’s structure, preventing analysts from easily identifying signatures or malicious logic during static examination. Encrypting network traffic (option B) affects dynamic analysis, not static code review. Options C and D describe functional impacts that are unrelated to the difficulty of code inspection. Understanding obfuscation informs the need for dynamic or heuristic detection methods.

Q22. In a scenario where a virus modifies file timestamps to appear older, which security principle is being subverted?

A.Integrity of system logs and evidence ✅
B.Confidentiality of data
C.Availability of network services
D.Authentication of users
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Altering timestamps undermines the integrity of logs, making it harder to trace the infection timeline and detect anomalies. This does not affect confidentiality, availability, or authentication directly. Recognizing this subversion helps incident responders prioritize log preservation and employ tamper‑evident mechanisms to maintain trustworthy forensic data.

Q23. Which of the following best characterizes a logic bomb?

A.A piece of code that triggers a malicious action when a specific condition is met ✅
B.A self‑replicating program that spreads across networks
C.A hidden program that provides remote access to an attacker
D.A virus that encrypts files for ransom
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: A logic bomb lies dormant until a predefined condition—such as a date or specific user action—activates its payload. Worms replicate, back‑doors enable remote access, and ransomware encrypts data, none of which rely on a conditional trigger. Understanding the conditional nature of logic bombs aids in designing monitoring rules that detect unusual behavior when trigger conditions are approached.

Q24. If a virus's payload includes the command rm−rf/home/∗rm -rf /home/* on a Unix system, what is the primary impact?

A.Deletion of all user files in the home directory ✅
B.Creation of a hidden back‑door account
C.Encryption of the entire filesystem
D.Installation of a keylogger
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The command rm−rf/home/∗rm -rf /home/* recursively removes every file and directory under /home, effectively erasing all user data. It does not create back‑doors, encrypt files, or install keyloggers. Recognizing destructive commands enables administrators to implement command‑filtering policies and maintain regular backups to mitigate data loss.

Q25. A virus spreads by exploiting a vulnerability in a web server’s input validation routine. Which phase of the attack lifecycle does this represent?

A.Exploitation ✅
B.Delivery
C.Installation
D.Command and control
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Exploitation is the stage where an attacker leverages a specific vulnerability—in this case, inadequate input validation—to gain unauthorized execution. Delivery pertains to how the malicious code reaches the target, installation involves setting up persistence, and command and control refers to remote management. Understanding the exploitation phase helps prioritize patch management and input sanitization as critical defenses.

🔗 Related Topics (MCQs)