Welcome, young cyber hero! This is Module 4, the next step in our exciting journey.
In Modules 1, 2, and 3, we learned the basics of scripting, networks, and security tools. Now, in Module 4, we will go even further. We will learn about web security (how to protect websites), database security (how to keep data safe), and mobile security (how to protect phones). We will also learn about social engineering (how hackers trick people) and how to defend against it. By the end of this module, you will be able to write scripts that can protect websites, apps, and even your friends from cyber attacks. Letβs become the ultimate cyber heroes!
After reading this module, you will be able to:
There was a small online store in Lagos called βBisiβs Bakeryβ. Bisi sold cakes and pastries online. One day, a hacker tried to break into her website. The hacker used a trick called SQL injection to try and steal Bisiβs customer list.
But Bisi had a clever friend, Chidi, who had learned about web security. Chidi wrote a script that checked every visitorβs input. If the input looked dangerous, the script blocked it. The hacker was stopped, and Bisiβs bakery was safe. Chidi became a local hero!
In this module, you will learn how to write scripts like Chidiβs to protect websites and apps from bad people.
Definition: Web security is the practice of protecting websites and web applications from attacks.
Why important: Websites contain lots of personal information. Web security keeps that information safe.
Simple explanation: Imagine your website is a house. Web security is like locking the doors and windows to keep burglars out.
Real-life example: Banks use web security to protect customer accounts.
School example: Your schoolβs website uses security to protect student records.
Home example: Your familyβs online shopping accounts need web security.
Nigerian example: Nigerian banks and online stores use web security to protect customers.
Web Security Layers
-------------------
[User] β [Firewall] β [Web Server] β [Database]
| | | |
| | | V
| | | [Encryption]
| | V
| | [Input Validation]
| V
| [SSL/HTTPS]
V
[Secure Website]
Mini summary: Web security protects websites from attacks.
Definition: SQL injection is an attack where a hacker sends bad SQL code to a websiteβs database to steal or change data.
Why important: It is one of the most common and dangerous attacks.
Simple explanation: Imagine you are at a restaurant. The waiter asks, βWhat would you like?β You say, βI want the menu AND I want to see the kitchenβs secret recipes!β That is like SQL injection.
Real-life example: In 2009, hackers used SQL injection to steal millions of credit card numbers from a major company.
School example: A hacker could use SQL injection to change their grades in the school database.
Home example: A hacker could use SQL injection to steal your familyβs online shopping data.
Nigerian example: Nigerian banks have been targets of SQL injection attacks.
SQL Injection Example --------------------- Normal input: "John" Malicious input: "John' OR '1'='1' -- " This could trick the database into showing all records.
Mini summary: SQL injection is a dangerous attack that sends bad code to a database.
Definition: Defending against SQL injection means using secure coding techniques to stop bad SQL code from reaching the database.
Why important: It prevents hackers from stealing data.
Simple explanation: Like having a bouncer at a club who checks IDs before letting anyone in.
Real-life example: Using prepared statements (a secure way to talk to databases).
School example: A school website can validate all user input to prevent attacks.
Home example: A home router can block suspicious queries.
Nigerian example: A Nigerian fintech company uses input validation to protect customer data.
Input Validation Example
------------------------
user_input = "John"
if "OR" in user_input or "--" in user_input:
print("Suspicious input blocked!")
else:
print("Input is safe.")
Mini summary: Input validation and prepared statements stop SQL injection.
Definition: Cross-Site Scripting (XSS) is an attack where a hacker injects malicious scripts into a website.
Why important: XSS can steal cookies, session tokens, and other sensitive data.
Simple explanation: Imagine you post a comment on a website. The hacker writes a comment that contains a hidden script. When someone views the comment, the script runs and steals their info.
Real-life example: In 2018, British Airways suffered an XSS attack that stole customer data.
School example: A hacker could use XSS to steal studentsβ login cookies.
Home example: A hacker could use XSS to take over your social media account.
Nigerian example: Nigerian e-commerce sites must protect against XSS.
XSS Attack Example ------------------ User input: If the website doesn't escape this, the script will run in the browser.
Mini summary: XSS injects malicious scripts into websites.
Definition: Defending against XSS means escaping or filtering user input so that scripts don't run.
Why important: It protects users from having their data stolen.
Simple explanation: Like turning off the microphone so no one can secretly record you.
Real-life example: Using libraries that automatically escape user input.
School example: A school forum can filter out HTML tags.
Home example: A blog can escape comments before displaying them.
Nigerian example: Nigerian news websites escape comments to prevent XSS.
Escaping Example
----------------
user_input = ""
safe_input = user_input.replace("<", "<").replace(">", ">")
print(safe_input) # Output: <script>alert('Hacked!');</script>
Mini summary: Escaping user input prevents XSS attacks.
Definition: Database security is the practice of protecting the database (where data is stored) from attacks.
Why important: Databases contain valuable information like passwords, credit card numbers, and personal details.
Simple explanation: Imagine a bank vault. The vault has locks, cameras, and alarms. Database security is like that for your data.
Real-life example: Banks encrypt database backups and limit access to only authorised users.
School example: A school database stores student records and must be protected.
Home example: Your familyβs password manager stores passwords in a secure database.
Nigerian example: A Nigerian hospitalβs database contains patient records and must be secure.
Database Security Measures -------------------------- [Encryption] β [Access Control] β [Monitoring] β [Backups]
Mini summary: Database security protects stored data from unauthorised access.
Definition: Mobile security is the practice of protecting smartphones and tablets from attacks.
Why important: Phones contain a lot of personal information, and they are often less secure than computers.
Simple explanation: Like putting a case on your phone to protect it from drops, but for digital threats.
Real-life example: Banks use mobile apps with security features like biometric authentication.
School example: A school can use mobile security to prevent students from installing unauthorised apps.
Home example: Using a screen lock and not installing unknown apps.
Nigerian example: Many Nigerians use mobile banking, so mobile security is very important.
Mobile Security Checklist ------------------------- β Use a strong screen lock β Only install apps from official stores β Keep your phone updated β Be careful with app permissions
Mini summary: Mobile security protects phones and the data on them.
Definition: Social engineering is when hackers trick people into giving away sensitive information.
Why important: It is often easier to trick a person than to hack a computer.
Simple explanation: Imagine a stranger calls you and pretends to be your friend to get your password. That is social engineering.
Real-life example: Phishing emails that look like they are from your bank asking for your password.
School example: A hacker might call a school and pretend to be a parent to get a studentβs grades.
Home example: A hacker might send a text message saying, βI need your password for security reasons.β
Nigerian example: Nigerians receive many phishing emails and SMS scams.
Social Engineering Flow ----------------------- Hacker β Tricks Person β Gets Information β Uses Information
Mini summary: Social engineering is tricking people to get their secrets.
Definition: Defending against social engineering means being aware of tricks and verifying identities.
Why important: It stops hackers from getting your information through lies.
Simple explanation: Like never giving your house keys to a stranger, no matter what they say.
Real-life example: Always verify the identity of someone asking for sensitive information.
School example: Teach students not to share passwords with anyone.
Home example: Talk to your family about not giving personal information over the phone.
Nigerian example: Nigerian banks educate customers about phishing and social engineering.
Social Engineering Defense Checklist ------------------------------------ β Be suspicious of unsolicited requests β Verify identities through official channels β Never share passwords or OTPs β Educate yourself and others
Mini summary: Awareness and verification defeat social engineering.
Definition: A web security scanner is a script that automatically checks a website for vulnerabilities.
Why important: It helps find weaknesses before hackers do.
Simple explanation: Like a health check-up for your website.
Real-life example: Tools like OWASP ZAP and Burp Suite are used to scan websites.
School example: A school can scan its website for vulnerabilities before launching it.
Home example: A blogger can scan their blog for security issues.
Nigerian example: Nigerian companies use scanners to test their e-commerce sites.
Scanner Flow ------------ Start β Check for SQL Injection β Check for XSS β Check for open ports β Report findings
Mini summary: Web security scanners find vulnerabilities automatically.
Definition: We can build a simple scanner that checks for common vulnerabilities like SQL injection and XSS.
Why important: It helps us understand how scanners work and how to defend against attacks.
Simple explanation: Like building a robot that checks every door in a building to see if itβs locked.
Real-life example: Security researchers build custom scanners for their specific needs.
School example: Students can build a scanner for their schoolβs website as a project.
Home example: You can build a scanner to test your own website.
Nigerian example: A Nigerian startup can build a custom scanner to test their app.
Simple Scanner Pseudo-code
--------------------------
function check_sql_injection(url):
send request with "' OR '1'='1"
if response shows error or all data:
return "Vulnerable to SQL injection"
else:
return "Safe"
Mini summary: Building a scanner helps understand web security.
Definition: Secure coding for web apps means writing code that is resistant to attacks.
Why important: It is the first line of defence against hackers.
Simple explanation: Like building a house with strong walls so burglars canβt break in.
Real-life example: Using frameworks like Django or Flask that have built-in security features.
School example: A school web project must follow secure coding practices.
Home example: A personal website should validate all user input.
Nigerian example: Nigerian developers must follow secure coding to protect user data.
Secure Coding Checklist for Web Apps ------------------------------------ β Validate all user input β Use prepared statements for databases β Escape output to prevent XSS β Use HTTPS for all pages β Keep libraries and frameworks updated
Mini summary: Secure coding prevents many web vulnerabilities.
Definition: Password security is the practice of creating and managing strong passwords.
Why important: Weak passwords are the easiest way for hackers to break into accounts.
Simple explanation: Like having a strong lock on your front door.
Real-life example: Using a password manager to generate and store strong passwords.
School example: Students should use strong passwords for their school accounts.
Home example: Using a different password for each online service.
Nigerian example: Nigerian banks encourage customers to use strong passwords and OTPs.
Password Strength Checklist --------------------------- β At least 12 characters long β Mix of uppercase, lowercase, numbers, and symbols β Not based on personal information β Different for every service
Mini summary: Strong passwords protect your accounts from being hacked.
Definition: Two-factor authentication (2FA) adds a second step to log in, like a code sent to your phone.
Why important: Even if someone steals your password, they canβt log in without the second factor.
Simple explanation: Like needing both a key and a fingerprint to open a safe.
Real-life example: Many websites offer 2FA via SMS or authenticator apps.
School example: A school can use 2FA for teacher accounts.
Home example: You can enable 2FA on your email and social media accounts.
Nigerian example: Nigerian banks use 2FA for online banking.
2FA Process ----------- 1. User enters password 2. User receives a code on their phone 3. User enters the code 4. Access granted
Mini summary: 2FA adds an extra layer of security to your accounts.
Definition: A web security system combines multiple tools and scripts to protect a website.
Why important: A single tool is not enough; you need layers of defence.
Simple explanation: Like having locks, alarms, and security cameras all working together.
Real-life example: A company uses a firewall, a scanner, a monitor, and a response team.
School example: A school uses a firewall, antivirus, and security training.
Home example: You can use a firewall, a password manager, and 2FA.
Nigerian example: A Nigerian bank uses all these layers to protect customer data.
Web Security System
-------------------
[Firewall] β [Scanner] β [Monitor] β [Alert] β [Response]
| | | | |
| | | | V
| | | | [Fix Vulnerability]
| | | V
| | | [Notify Admin]
| | V
| | [Log Event]
| V
| [Generate Report]
V
[Block Bad Traffic]
Mini summary: A web security system uses multiple layers to protect a website.
Step 1: Goal β Check for SQL injection Step 2: Python Step 3: Plan β Send test payloads, check responses Step 4: Code β Write the script Step 5: Test β Use on a safe test site Step 6: Improve β Add XSS checks Step 7: Deploy β Run on your site
Encourage students to think about how they use websites and apps every day. Discuss real-world security incidents. Use the warm-up story to introduce concepts. Emphasise the importance of ethical behaviour β using security skills to protect, not harm. Use group projects to build teamwork.
Help your child by discussing online safety at home. Encourage them to use strong passwords and 2FA. Talk about social engineering and how to recognise phishing attempts. Celebrate their learning by helping them test their scripts on safe websites.
Did you know that the world's largest data breach happened in 2019, exposing 4 billion records? It was caused by a combination of SQL injection and social engineering. That's why learning web security is so important!
SQL Injection Defense --------------------- User Input β Validate β Escape β Safe Query β Database
XSS Defense ----------- User Input β Escape β Safe Output β Browser
Web Security Layers
-------------------
[Internet] β [Firewall] β [Web App] β [Database]
| | | |
| | | V
| | | [Encryption]
| | V
| | [Input Validation]
| V
| [HTTPS]
V
[Secure Website]
| Feature | SQL Injection | XSS |
|---|---|---|
| Target | Database | Browser |
| Impact | Data theft, data loss | Session hijacking, data theft |
| Defense | Input validation, prepared statements | Input escaping, output encoding |
| Feature | Password Only | Password + 2FA |
|---|---|---|
| Security Level | Low | High |
| Ease of Use | Easy | Moderate |
| Risk of Compromise | High (if weak or stolen) | Low (needs both factors) |
Congratulations! You have completed Module 4. You now have a deep understanding of web security, including:
You are now equipped to protect websites and apps from many common attacks. Keep learning, keep coding, and always use your skills for good. The digital world needs more heroes like you!
Match the term with its description:
| Term | Description |
|---|---|
| 1. SQL Injection | A. Adds a second login step |
| 2. XSS | B. An attack on the database |
| 3. 2FA | C. Tricking people to get secrets |
| 4. Social Engineering | D. An attack on the browser |
| 5. Web Scanner | E. A script that finds vulnerabilities |
Answers: 1-B, 2-D, 3-A, 4-C, 5-E
Scenario 1: You have built a website for your school. A student tells you they saw a strange pop-up on the site. You suspect XSS. Write a script (pseudo-code) that checks for XSS vulnerabilities on your site.
Scenario 2: You are working for a Nigerian bank. The bank wants to protect its customers from social engineering attacks. Write a script (pseudo-code) that sends an educational message to customers about phishing.
In groups of 3, create a presentation about a real-world cyber security incident. Discuss how the attack happened and what could have been done to prevent it. Include a demonstration of a security script that could have helped.
Write a Python script that checks if a website has HTTPS enabled. The script should connect to the website and check if it uses port 443. Print a message indicating whether the connection is secure.
Build a simple web vulnerability scanner. Write a script that checks for SQL injection and XSS vulnerabilities on a given URL. Use the requests library in Python. Test it on a safe test site like "https://testphp.vulnweb.com".
Write a script that scans a given website for common security headers (like Content-Security-Policy, X-Frame-Options, etc.). Print a report of which headers are present and which are missing. Include recommendations for improvement.
Write a script that simulates a social engineering defense system. The script should prompt the user for a secret code. If the user tries to give the code to an unauthorised person (simulated by input), the script should reject it and alert the user about social engineering.
All multiple-choice answers are indicated in the questions above (bold). Fill-in-the-blank answers: 1-Web security, 2-SQL injection, 3-XSS, 4-Database security, 5-Mobile security, 6-Social engineering, 7-web security scanner, 8-Secure coding, 9-Two-factor authentication, 10-Password security. True/False: 1-T, 2-F, 3-T, 4-F, 5-T, 6-F, 7-T, 8-T, 9-F, 10-F.
Congratulations on completing Module 4! You now have a solid understanding of web, database, and mobile security. In the next course, we will dive into advanced topics like network penetration testing, cloud security, and incident response. You will learn how to think like a hacker to better defend against them. Keep learning, keep coding, and always stay curious! See you in the next adventure.
End of Module 4 Β· Fundamentals of Cyber Security Scripting
This concludes the four-module foundation course. Well done, cyber hero!