📝 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.
📝 All Computer viruses in operating system MCQs
Q1. What defines a computer virus?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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 to model its replication rate, how many copies will exist after three generations starting from a single instance?
📖 Explanation: Starting with , after the first generation . The second generation gives . The third generation results in . 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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 to model its spread over time, what does the variable represent?
📖 Explanation: In the exponential growth model, is the constant that determines how quickly the infection expands; a larger means faster spread. is the initial infected count, not . The total network size and cessation time are separate parameters. Understanding the role of 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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 on a Unix system, what is the primary impact?
📖 Explanation: The command 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?
📖 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.