As more of our lives move online, protecting data and computer systems has become as important as building them. Cyber security is the practice of defending computers, servers, networks and data from malicious attacks, unauthorised access and damage. A single stolen password, a breached bank account or a ransomware-encrypted hard disk can cause enormous financial and personal harm, which is why every computer science student must understand the threats and the defences.
The threats come from many directions. Malware such as viruses, worms and trojans can infect systems; hackers use techniques like phishing and social engineering to trick people into revealing secrets; and attackers can intercept or tamper with data as it travels across networks. Defending against these threats requires a layered approach: antivirus software, strong passwords, encryption, authentication, firewalls and good user habits.
This chapter explains the common threats to computer systems, the ethical issues raised by security, and the techniques used to protect data. It covers malware types, hacking and crackers, cyber crimes, protection tools, and the concept of IT Act and cyber law. Security questions in the board examination ask for definitions of terms like phishing, firewall, firewall's purpose, encryption vs decryption, and identifying the appropriate security measure for a scenario.
A threat is any circumstance or event that can cause harm to a computer system or data. Threats may come from inside the organisation or from outside, and they may be accidental or deliberate. Common threats include malware infection, unauthorised access to data, data theft, denial of service, hardware or network failure, and human error such as losing a USB drive or revealing a password.
Malware (malicious software) is software designed to damage, disrupt or gain unauthorised access to a computer system. The main categories are:
def classify_malware(name):
if name == "virus":
return "self-replicates with host file, needs user action"
elif name == "worm":
return "self-replicates across network automatically"
elif name == "trojan":
return "disguised program creating a backdoor"
elif name == "ransomware":
return "encrypts files and demands payment"
else:
return "unknown malware"
A hacker is a person skilled in computers who explores systems; the term is often used for those who break into systems for ethical or malicious reasons. White hat hackers work ethically, finding vulnerabilities with permission to improve security. Black hat hackers (crackers) break into systems illegally for personal gain. Grey hat hackers act between the two, sometimes finding flaws without authorisation but without malicious intent.
Cyber crime refers to illegal activities committed using computers or networks. Examples include hacking (unauthorised access), phishing (fraudulent emails that trick users into revealing passwords), identity theft (stealing someone's personal information), cyber stalking, data theft, and spreading malware. The Information Technology (IT) Act, 2000 of India and its amendments provide the legal framework to prosecute such offences.
Social engineering is the manipulation of people into performing actions or divulging confidential information. Attackers exploit human trust rather than technical flaws. Phishing is the most common form: fake emails or websites that impersonate trusted organisations (banks, government portals) and lure victims into entering usernames, passwords or card numbers on fraudulent pages.
Pharming redirects a user from a legitimate website to a fake one, often by poisoning DNS records, so even typing the correct address leads to a malicious site. Defence against social engineering lies mostly in awareness: never click suspicious links, verify senders, and never share passwords.
A Denial of Service (DoS) attack floods a server with huge volumes of traffic so that it becomes too slow or crashes, denying service to legitimate users. A Distributed DoS (DDoS) attack uses many compromised machines (a botnet) to launch the flood simultaneously, making it harder to block. Other attacks include spoofing (faking an IP or email identity), man-in-the-middle attacks that intercept communication, and SQL injection, where attackers inject malicious SQL into input fields to manipulate databases.
-- A naive query vulnerable to SQL injection
SELECT * FROM users WHERE user_id = '101 OR 1=1';
Protection is layered across people, processes and technology.
def simple_caesar(text, shift):
result = ""
for ch in text:
if ch.isalpha():
base = ord('a') if ch.islower() else ord('A')
result += chr((ord(ch) - base + shift) % 26 + base)
else:
result += ch
return result
plain = "HELLO"
cipher = simple_caesar(plain, 3)
print("Encrypted:", cipher) # KHOOR
print("Decrypted:", simple_caesar(cipher, -3)) # HELLO
Authentication verifies that a user is who they claim to be, using something you know (password), something you have (smart card, OTP) or something you are (biometrics). A digital signature is an electronic equivalent of a handwritten signature, created by encrypting a hash of the message with the sender's private key. It provides authenticity, integrity (message not altered) and non-repudiation (sender cannot deny sending). Digital signatures and encryption together use the concept of public and private keys (asymmetric cryptography).
Ethical behaviour online matters as much as technical protection. Cyber ethics covers responsible use of computers: respecting privacy, not copying others' work illegally, not spreading false information, and not hacking systems. The IT Act, 2000 is India's primary law dealing with cyber crime and electronic commerce, later amended in 2008 to strengthen provisions against cyber offences.
| Malware | How It Spreads | Key Characteristic |
|---|---|---|
| Virus | Attaches to files, needs execution | Self-replicates with a host |
| Worm | Network, no host needed | Spreads automatically |
| Trojan | Disguised as useful software | Creates a backdoor |
| Spyware | Installed secretly | Monitors user activity |
| Ransomware | Via infected downloads | Encrypts data, demands payment |
| Measure | Purpose |
|---|---|
| Firewall | Filters network traffic, blocks unauthorised access |
| Antivirus | Detects and removes malware |
| Encryption | Converts data to unreadable ciphertext |
| Strong password + MFA | Verifies identity |
| Backups | Restore data after loss or attack |
Security is the discipline that protects the connected world from harm. Understanding threats is the first line of defence: viruses, worms, trojans, spyware and ransomware each spread differently, and attackers use phishing, social engineering and denial-of-service to compromise systems. Defence combines technology and behaviour: firewalls filter traffic, antivirus removes malware, encryption guards data, strong passwords and multi-factor authentication verify identity, and backups guarantee recovery. The IT Act and cyber ethics frame these practices within the law. With networks and their threats understood, the remaining chapters return to programming, beginning with a comprehensive revision of Python fundamentals.