Computer Security and Malware: Viruses, Encryption and MCQs

Computer security is the protection of computers, networks and data from theft, damage and unauthorised access. With mobile banking, online admissions and e-challans now routine in Pakistan and India, test papers regularly ask how a worm differs from a virus, what ransomware does, which key encrypts a message in public-key cryptography, and what counts as two-factor authentication. Learn each threat by how it spreads and what it does, and each defence by what it can and cannot stop.

Asked in: PPSC, FPSC, NTS, ETEA, KPPSC, SSC, IBPS and ICS/ECAT computer

Goals of security and the people involved

Security is usually described by the CIA triad. Confidentiality means only authorised people can read the data; integrity means data is not altered without permission; availability means systems and data are there when legitimate users need them. Encryption protects confidentiality, hashing helps detect changes to integrity, and backups and protection against flooding attacks support availability.

A vulnerability is a weakness in software, hardware or procedure; a threat is anything that could exploit it; an attack is an actual attempt to do so. A patch is an update that fixes a known vulnerability, and a zero-day vulnerability is one that attackers exploit before the vendor has released a fix.

A hacker is someone who breaks into systems. White-hat (ethical) hackers test systems with permission to find and fix weaknesses; black-hat hackers break in for personal gain or damage; grey-hat hackers fall in between, often probing without permission but without clear malicious intent.

Types of malware

Malware (malicious software) is any program written to cause harm. A virus attaches itself to a host file or program and spreads when that file is run or shared; it needs a host and usually some user action. A boot sector virus infects the startup area of a disk, a macro virus hides in the macros of documents such as Word or Excel files, and a polymorphic virus changes its code each time it copies itself to avoid detection.

A worm is a standalone program that copies itself from computer to computer across a network without needing a host file. A Trojan horse looks like a useful or harmless program but carries a hidden harmful function; it does not copy itself. Ransomware encrypts the victim's files or locks the system and demands payment, usually in cryptocurrency, for the key.

Spyware secretly gathers information about the user; a keylogger is spyware that records every keystroke to steal passwords. Adware shows unwanted advertisements. A rootkit hides deep in the operating system to conceal itself and keep privileged (administrator) access. A logic bomb lies dormant until a condition is met, such as a certain date. A backdoor is a secret way into a system that bypasses normal login, and a botnet is a network of infected computers (zombies) controlled remotely by an attacker.

Social engineering and network attacks

Social engineering tricks people rather than machines. Phishing uses fake emails or websites that imitate a trusted body to steal passwords, card numbers or OTP codes. Spear phishing targets a particular person or organisation using personal details; smishing does the same through SMS text messages; vishing (voice phishing) uses phone calls, such as a caller pretending to be from a bank's helpline. Pharming redirects users from a genuine website to a fake one, for example by tampering with DNS.

A denial-of-service (DoS) attack floods a server with traffic or requests so that genuine users cannot reach it; a distributed DoS (DDoS) uses many machines, often a botnet, at once. Both attack availability. In a man-in-the-middle attack the attacker secretly sits between two parties and reads or alters their messages. Spoofing means faking an identity such as an email sender, IP address or caller number.

Password attacks include brute force (trying every possible combination) and dictionary attacks (trying common words and leaked passwords). SQL injection inserts database commands into a website's input field to read or change data the site never meant to reveal.

Well-known malware cases

Brain, released in 1986, is widely cited as the first virus for IBM PC compatible computers running MS-DOS. It was written by two brothers, Basit and Amjad Farooq Alvi, in Lahore, Pakistan, and infected the boot sector of floppy disks. Earlier self-copying programs such as Creeper existed on research networks in the early 1970s, so the claim is specifically about IBM PCs.

The Morris worm of 1988, written by Robert Tappan Morris, was one of the first worms to spread widely over the Internet and slowed thousands of machines. ILOVEYOU (2000) spread through email as an attachment disguised as a love letter and overwrote files on infected computers.

Stuxnet, discovered in 2010, targeted industrial control systems and is known for damaging centrifuges in Iran's nuclear programme. WannaCry, which struck in May 2017, was ransomware that spread automatically through a flaw in Windows file sharing (SMB) and hit hospitals, companies and government offices in many countries.

Encryption, hashing and digital signatures

Encryption turns readable plaintext into unreadable ciphertext using an algorithm and a key; decryption turns it back. The study of these methods is cryptography. A simple historical example is the Caesar cipher, which shifts each letter a fixed number of places: with a shift of 3, A becomes D and C becomes F.

Symmetric (secret-key) encryption uses the same key to encrypt and decrypt; it is fast, and examples are AES and the older DES. Its problem is sharing the key safely. Asymmetric (public-key) encryption uses a key pair: a public key that anyone may know and a private key kept secret by its owner. To send Priya a secret message, Hamza encrypts with Priya's public key, and only Priya's private key can decrypt it. RSA is the best-known asymmetric algorithm.

A hash function such as SHA-256 turns any input into a fixed-length value; it is one-way (the input cannot be recovered) and the same input always gives the same hash, so it is used to store passwords and check that files are unchanged. A digital signature is created with the sender's private key and checked with the sender's public key; it proves who sent a message and that it was not altered. A digital certificate, issued by a certificate authority (CA), binds a public key to an identity, and HTTPS uses TLS (the successor of SSL) to encrypt web traffic.

Authentication, authorisation and protection

Authentication checks who you are; authorisation decides what you are allowed to do after that. Authentication factors fall into three groups: something you know (password, PIN), something you have (ATM card, phone receiving an OTP, hardware token) and something you are (fingerprint, face or iris, called biometrics). Two-factor authentication (2FA) combines two different groups, such as an ATM card plus PIN; a password plus a security question is still one factor because both are things you know.

Strong passwords are long and mix upper and lower case letters, numbers and symbols, are not reused, and are never shared. A CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) is a challenge that is easy for people but hard for automated bots.

Antivirus software detects malware by known signatures and by suspicious behaviour (heuristics) and can quarantine infected files. A firewall, in hardware or software, filters network traffic according to rules; it does not clean a virus already on the computer. Other defences include regular updates and patches, intrusion detection systems (IDS), a VPN for an encrypted tunnel over public networks, and regular backups kept offline, which are the best protection against losing data to ransomware.

Solved examples

  1. A program arrives on Ali's office PC by itself through the network, copies itself to every other PC on the LAN and slows the whole network, though no one opened any file. What kind of malware is it, and how does it differ from a virus?
    1. It spread across the network without a host file and without any user opening anything.
    2. Self-spreading standalone malware is a worm.
    3. A virus, by contrast, attaches to a host file and spreads when that infected file is run or shared.
    Answer: A worm; unlike a virus it needs no host file or user action to spread
  2. Neha receives an SMS: 'Your bank account is blocked. Click this link and enter your card PIN to unlock it.' Name the attack and the correct response.
    1. The message pretends to come from a trusted bank to steal a secret, which is phishing.
    2. Because it arrives by SMS, the specific name is smishing (SMS phishing). A phone call doing the same would be vishing.
    3. The right response is not to click the link, never to share a PIN or OTP, and to contact the bank through its official number.
    Answer: Smishing; ignore the link and verify with the bank directly
  3. Using a Caesar cipher with a shift of 3, encrypt the word CAT.
    1. Shift each letter 3 places forward in the alphabet.
    2. C β†’ D, E, F gives F; A β†’ B, C, D gives D; T β†’ U, V, W gives W.
    3. To decrypt, shift each letter 3 places back.
    Answer: FDW
  4. Hamza wants to send Priya a message that only she can read, using public-key (asymmetric) encryption. Which key does he use to encrypt, and which key decrypts it?
    1. In asymmetric encryption each person has a public key (shared openly) and a private key (kept secret).
    2. Hamza encrypts with Priya's public key, which anyone can obtain.
    3. Only the matching private key, which Priya alone holds, can decrypt it. If Hamza wanted to prove the message came from him, he would sign it with his own private key instead.
    Answer: Encrypt with Priya's public key; decrypt with Priya's private key
  5. Which of these are two-factor authentication? (i) ATM card plus PIN (ii) password plus security question (iii) password plus fingerprint.
    1. Two-factor authentication needs two different types of factor: know, have or are.
    2. (i) card (have) plus PIN (know): two factors. (iii) password (know) plus fingerprint (are): two factors.
    3. (ii) password and security question are both things you know, so it is still single-factor.
    Answer: (i) and (iii) are two-factor; (ii) is not
  6. A clinic in Karachi finds all its patient files renamed and unreadable, with a note demanding payment in cryptocurrency for the key. Identify the malware and the defence that would have let the clinic recover without paying.
    1. Malware that encrypts files and demands payment for the decryption key is ransomware.
    2. Paying does not guarantee that the files will be returned, and an antivirus cannot normally decrypt files that are already encrypted.
    3. Recent backups kept offline (not connected to the infected network) let the clinic wipe the systems and restore the data.
    Answer: Ransomware; regular offline backups

Exam shortcuts

Common mistakes

Practice MCQs

  1. Malware that looks like a useful program but carries a hidden harmful function and does not copy itself is a:
    A) Worm
    B) Logic bomb
    C) Trojan horse
    D) Boot sector virus
    Answer: C) Trojan horse β€” A Trojan horse disguises itself as genuine software and depends on the user installing it; it does not replicate. A worm and a boot sector virus both copy themselves, and a logic bomb is code that waits for a trigger condition rather than posing as a useful program.
  2. A virus that hides inside the macros of Word or Excel documents is called a:
    A) Macro virus
    B) Boot sector virus
    C) Rootkit
    D) Keylogger
    Answer: A) Macro virus β€” A macro virus is written in the macro language of office applications and spreads through documents. A boot sector virus infects a disk's startup area, a rootkit hides inside the operating system, and a keylogger records keystrokes; none of them live in document macros.
  3. A fraudulent SMS asks the receiver to click a link and enter an OTP to claim a prize. This attack is called:
    A) Pharming
    B) Vishing
    C) Spoofing
    D) Smishing
    Answer: D) Smishing β€” Smishing is phishing carried out through SMS text messages. Vishing uses voice calls, pharming silently redirects a user to a fake website, and spoofing is the general faking of an identity rather than the name for an SMS phishing attack.
  4. The Brain virus of 1986, widely cited as the first virus for IBM PC compatible computers, was written in:
    A) Bengaluru
    B) Lahore
    C) Manila
    D) Cambridge
    Answer: B) Lahore β€” Brain was written by the brothers Basit and Amjad Farooq Alvi in Lahore, Pakistan, and spread through infected floppy disk boot sectors. Manila is linked to the ILOVEYOU worm of 2000, and Bengaluru and Cambridge have no connection with Brain.
  5. Which type of malware encrypts a victim's files and demands payment for the decryption key?
    A) Ransomware
    B) Adware
    C) Spyware
    D) Worm
    Answer: A) Ransomware β€” Ransomware locks data by encrypting it and asks for a ransom, often in cryptocurrency. Adware shows unwanted advertisements, spyware secretly collects information, and a worm is defined by how it spreads, not by demanding money.
  6. Malware that hides deep inside the operating system to conceal its presence and keep administrator-level access is a:
    A) Macro virus
    B) Botnet
    C) Rootkit
    D) Adware
    Answer: C) Rootkit β€” A rootkit modifies the operating system to hide itself and other malware while keeping privileged control. A macro virus lives in document macros, a botnet is a group of infected machines under remote control, and adware simply displays advertisements.
  7. Which of these is an asymmetric (public-key) encryption algorithm?
    A) AES
    B) DES
    C) Caesar cipher
    D) RSA
    Answer: D) RSA β€” RSA uses a pair of keys, one public and one private, so it is asymmetric. AES and DES are symmetric algorithms that use one shared secret key, and the Caesar cipher is a simple letter-shift method that also uses a single shared shift value.
  8. Spyware that secretly records every key pressed by the user, often to steal passwords, is called a:
    A) Firewall
    B) Keylogger
    C) Rootkit
    D) Logic bomb
    Answer: B) Keylogger β€” A keylogger captures keystrokes and sends them to the attacker. A firewall is a defence that filters traffic, a rootkit hides and keeps privileged access, and a logic bomb triggers its payload when a condition is met; none of them is defined by recording keystrokes.
  9. A DDoS attack that floods a bank's website so customers cannot open it mainly harms which goal of the CIA triad?
    A) Confidentiality
    B) Integrity
    C) Availability
    D) Authentication
    Answer: C) Availability β€” Flooding a service keeps genuine users out, which attacks availability. Confidentiality is about data being read by unauthorised people and integrity about data being changed; a flood need not do either. Authentication is not one of the three CIA goals.
  10. A digital signature on an email is created using the:
    A) Sender's private key
    B) Sender's public key
    C) Receiver's public key
    D) Receiver's private key
    Answer: A) Sender's private key β€” The sender signs with a private key that only the sender holds, and anyone can verify it with the sender's public key, proving origin and integrity. A public key cannot prove identity because everyone has it, and the receiver's keys are used for keeping a message secret, not for signing.
  11. Logging in with a password and then a fingerprint scan is an example of:
    A) Single-factor authentication
    B) Authorisation
    C) Encryption
    D) Two-factor authentication
    Answer: D) Two-factor authentication β€” A password is something you know and a fingerprint is something you are, so two different factor types are used: two-factor authentication. Single-factor would use only one type, authorisation decides permissions after login, and encryption scrambles data rather than verifying a user.
  12. Using a Caesar cipher with a shift of 2, the word DOG becomes:
    A) EPH
    B) FQI
    C) FQH
    D) BME
    Answer: B) FQI β€” Each letter moves 2 places forward: D to F, O to Q and G to I, giving FQI. EPH uses a shift of 1, BME shifts backwards by 2, and FQH shifts the last letter by only 1.
  13. Which statement about a cryptographic hash function such as SHA-256 is correct?
    A) It can be reversed with the right key
    B) It needs a public and private key pair
    C) Its output gets longer as the input grows
    D) The same input always gives the same fixed-length output
    Answer: D) The same input always gives the same fixed-length output β€” A hash is deterministic and always produces the same fixed-length digest for the same input, which is why it can check passwords and files. It is one-way, so no key reverses it; it uses no key pair; and its output length stays the same however large the input is.
  14. WannaCry, which hit computers in many countries in May 2017, is best classified as:
    A) Adware
    B) Keylogger
    C) Ransomware
    D) Spyware
    Answer: C) Ransomware β€” WannaCry encrypted files and demanded a ransom, so it is ransomware; it spread by exploiting a flaw in Windows file sharing. It did not display advertisements like adware, record keystrokes like a keylogger, or quietly collect personal information like spyware.
  15. After Neha logs in, the office system lets her view the payroll file but not edit it. Deciding what she is allowed to do is called:
    A) Authorisation
    B) Authentication
    C) Encryption
    D) Spoofing
    Answer: A) Authorisation β€” Granting or limiting permissions after identity is confirmed is authorisation. Authentication was the earlier step of proving she is Neha, encryption protects data by scrambling it, and spoofing is faking an identity.

Questions

What is the difference between a virus and a worm?

A virus attaches itself to a host file and spreads when that file is run or shared. A worm is a standalone program that copies itself across networks on its own, without a host file or user action.

Who created the Brain virus?

Brain (1986) was written by the brothers Basit and Amjad Farooq Alvi in Lahore, Pakistan. It is widely cited as the first virus for IBM PC compatible computers and infected the boot sector of floppy disks.

Does a firewall protect against viruses?

A firewall blocks unwanted network traffic according to rules, which can stop some attacks from reaching a computer, but it does not scan or clean files. Antivirus software is needed to detect and remove malware.

What is the difference between symmetric and asymmetric encryption?

Symmetric encryption uses one shared secret key for both encryption and decryption (for example AES). Asymmetric encryption uses a public key and a private key pair (for example RSA), so no secret key has to be shared in advance.