Courses / Computer Science XI (HSSC-I) – FBISE Complete SLO-Based Course

1.5 Cyber Security, Attacks and Encryption

Unit 1 – Computer Systems · 85 min read · 16 MCQs to check yourself

Asymmetric encryption – simply explained

1. What is cyber security and why do we need it?

Cyber security is the protection of computers, networks, programs and data from attack, damage and unauthorised access. It aims at the CIA triad:

Goal Meaning Example control
Confidentiality Only authorised people can read data Encryption, passwords
Integrity Data is not changed without permission Hashing, digital signatures
Availability Systems and data are usable when needed Backups, DDoS protection

We need it because banking, health records, exams, e-commerce and government services are all online. Attacks cause financial loss, identity theft, privacy breaches and loss of trust.

2. Ways a system can be attacked

Attack How it works Protection
Malware Malicious software: virus (attaches to files), worm (spreads by itself over networks), trojan (looks useful, hides harm), ransomware (encrypts files, demands payment), spyware/keylogger Antivirus, updates, do not install unknown apps
Phishing Fake emails/SMS/websites that trick users into giving passwords or card numbers ("Your account is blocked – click here") Check sender and URL, never share OTP, 2FA
Hacking Gaining unauthorised access by exploiting weak passwords or software flaws Strong passwords, patches, firewall
DDoS (Distributed Denial of Service) Thousands of infected computers (botnet) flood a server with requests so real users cannot reach it Traffic filtering, CDNs, extra capacity
XSS (Cross-Site Scripting) Attacker injects a malicious script into a web page (e.g. in a comment box); the script runs in other users' browsers and can steal cookies Validate and escape all user input
SQL injection SQL code typed into a form changes the database query Parameterised queries
Brute force Trying every possible password Long passwords, lock-out after failed tries
Social engineering Manipulating people (pretending to be IT staff) Awareness training
Man-in-the-middle Intercepting traffic on insecure Wi-Fi HTTPS, VPN

3. Authentication and authorization

4. Firewalls

A firewall is hardware or software that monitors network traffic and allows or blocks it according to security rules (e.g. block all incoming connections except web traffic on port 443). It sits between a trusted network and the Internet.

5. Cryptography and encryption

Cryptography is the science of protecting information by transforming it. Encryption turns readable plaintext into unreadable ciphertext using an algorithm and a key; decryption turns it back.

Caesar cipher (a simple substitution cipher)

Each letter is shifted by the key k: C = (P + k) bmod 26 and P = (C - k) bmod 26.

def caesar(text, k):
    out = ""
    for ch in text:
        if ch.isalpha():
            out += chr((ord(ch.upper()) - 65 + k) % 26 + 65)
        else:
            out += ch
    return out

secret = caesar("ATTACK AT DAWN", 3)
print(secret)
print(caesar(secret, -3))

Output:

DWWDFN DW GDZQ
ATTACK AT DAWN

The Caesar cipher is easy to break (only 25 possible keys – a brute-force attack). Modern algorithms use keys of 128 bits or more: 2¹²⁸ possible keys.

Symmetric vs asymmetric encryption

Basis Symmetric encryption Asymmetric (public-key) encryption
Keys One shared secret key for encryption and decryption Key pair: public key encrypts, private key decrypts
Efficiency / speed Very fast Much slower (heavy mathematics)
Security Weak point is sharing the key safely Private key is never shared – solves the key-distribution problem
Ease of implementation Simple More complex
Key length 128 or 256 bits (AES) 2048–4096 bits (RSA)
Large data handling Excellent – used for bulk data, disks, video Poor – used for small data: keys, signatures
Examples AES, DES, 3DES RSA, ECC, Diffie–Hellman

In practice HTTPS (TLS) uses both: asymmetric encryption to agree a session key safely, then fast symmetric AES for the actual data. Digital signatures use the private key to sign and the public key to verify, proving who sent a message.

6. Hashing

A hash function converts any data into a fixed-length "fingerprint". It is one-way (cannot be reversed) and a tiny change in input gives a completely different hash. Uses: storing passwords (sites store the hash, not the password), checking file integrity, blockchain.

import hashlib
print(len(hashlib.sha256(b"PrepOasis").hexdigest()))
print(hashlib.sha256(b"abc").hexdigest()[:16])

Output:

64
ba7816bf8f01cfea
Encryption Hashing
Two-way – can be decrypted with the key One-way – cannot be reversed
Output length depends on input Fixed-length output (SHA-256 → 64 hex characters)
Protects confidentiality Protects integrity / stores passwords

7. Security frameworks, policies and risk

Threat (school computer lab) Likelihood Impact Risk Priority action
Malware from USB drives 4 4 16 Antivirus, block auto-run
Weak teacher passwords 3 5 15 Password policy + 2FA
Phishing email to staff 3 4 12 Awareness training
Hardware theft 2 3 6 Locks, CCTV

8. Protect yourself – checklist

  1. Update the OS, browser and apps. 2. Use antivirus and keep the firewall on. 3. Strong, unique passwords + 2FA on email, banking and social media. 4. Never share an OTP or click unknown links. 5. Use HTTPS sites and avoid banking on public Wi-Fi. 6. Back up important files (3-2-1 rule). 7. Review app permissions and privacy settings.

What is asymmetric vs symmetric encryption?

Short and long questions

1. Define plaintext, ciphertext, encryption and decryption.

Model answer

Plaintext: original readable data. Ciphertext: scrambled unreadable data after encryption. Encryption: converting plaintext into ciphertext using an algorithm and key. Decryption: converting ciphertext back into plaintext using the key.

2. What is two-factor authentication? Why is it more secure than a password alone?

Model answer

2FA requires two different types of evidence to log in – e.g. something you know (password) and something you have (OTP on your phone) or something you are (fingerprint). It is more secure because a stolen or guessed password alone is not enough; the attacker would also need the user's phone or fingerprint.

3. Differentiate between authentication and authorization.

Model answer

Authentication verifies who the user is (password, OTP, biometrics). Authorization decides what an authenticated user may access or do (e.g. a student can view results but only the controller can edit them). Authentication always comes first.

4. What is phishing? How can you protect yourself from it?

Model answer

Phishing is a social-engineering attack in which fake emails, SMS or websites pretend to be a trusted organisation to steal passwords, card numbers or OTPs. Protection: check the sender address and the website URL (https and correct spelling); never click unexpected links or share OTPs; type the bank's address yourself; enable 2FA; report suspicious messages.

5. What is a firewall? Write two of its functions.

Model answer

A firewall is hardware or software placed between a trusted network and the Internet that monitors traffic and allows or blocks it according to security rules. Functions: (1) blocks unauthorised incoming connections (hackers, worms); (2) can block access to harmful websites/applications and log suspicious traffic.

6. Differentiate between encryption and hashing.

Model answer
Encryption Hashing
Two-way – ciphertext can be decrypted with the key One-way – the hash cannot be reversed
Output length depends on the input Fixed-length output (e.g. SHA-256 = 64 hex characters)
Used for confidentiality of data in transit/storage Used for password storage and integrity checks

7. Briefly explain DDoS and XSS attacks.

Model answer

DDoS (Distributed Denial of Service): attackers use a botnet of thousands of infected devices to flood a server with requests so that genuine users cannot access it. XSS (Cross-Site Scripting): an attacker injects malicious JavaScript into a web page (e.g. through a comment form); when other users open the page the script runs in their browser and can steal cookies or session data. Prevented by validating and escaping user input.

8. What is encryption? Compare symmetric and asymmetric encryption with respect to efficiency, security, ease of implementation, key length and large data handling. (1 + 5)

Model answer

Encryption is the process of converting readable plaintext into unreadable ciphertext using an algorithm and a key, so that only authorised parties with the correct key can read it.

Basis Symmetric Asymmetric
Keys One shared secret key Public key + private key pair
Efficiency Very fast, low processing Slow, heavy computation
Security Risk in sharing the key; secure if key kept secret Private key never shared – better key distribution and supports digital signatures
Ease of implementation Simple Complex
Key length 128–256 bits (AES) 2048–4096 bits (RSA)
Large data handling Excellent – used for files, disks, streaming Poor – used for small data such as keys and signatures
Examples AES, DES RSA, ECC
In HTTPS both are combined: asymmetric to exchange a session key, symmetric for the data.

9. What is cyber security? Explain any four types of cyber attacks and how to protect against each. Also describe a plan to analyse and prioritise cyber security risks.

Model answer

Cyber security protects computers, networks, programs and data from attacks, damage and unauthorised access, ensuring confidentiality, integrity and availability. Attacks: (1) Malware (virus, worm, trojan, ransomware) – antivirus, updates, avoid unknown downloads. (2) Phishing – check URLs and senders, never share OTPs, 2FA. (3) DDoS – traffic filtering, extra capacity, content delivery networks. (4) Hacking/brute force – strong unique passwords, account lock-out, patches, firewall. (Also XSS – input validation.) Risk plan: (1) identify assets (data, devices) and threats; (2) score each threat's likelihood and impact from 1 to 5; (3) risk = likelihood × impact; (4) handle highest risks first with controls (2FA, backups, training); (5) monitor, respond and review regularly (NIST: identify, protect, detect, respond, recover).

This lesson ends with a quiz of 16 MCQs. Open the lesson on PrepOasis to take it and save your progress.

Previous: 1.4 Networks: Topologies, Scalability and Reliability · Next: Unit 1 Review, SLO Checklist and Unit Test

All lessons in Computer Science XI (HSSC-I) – FBISE Complete SLO-Based Course