Hiring Partners
Segilola Resources Operating LimitedTaviatech TechnologiesFCMBMTN NigeriaAdvans La Fayette Microfinance BankAboki AfricaFirst Bank of NigeriaOPay
← Fundamentals Of Cyber Security Scripting · Lesson 2 of 9

Module One

📖 Every lesson in this course is free to read right here, no account needed. Create a free account to track your progress, take the exam, and earn your certificate.
2
📘 Module 1: Fundamentals of Cyber Security Scripting

🛡️ Module 1: Fundamentals of Cyber Security Scripting

Welcome, young cyber hero! This is the first module of our exciting journey.

📖 Module Introduction

Hello there! Have you ever wondered how computers protect themselves from bad people? How do they know when a virus is trying to sneak in? The answer is scripts! In this module, we will learn what scripts are, why they are important, and how they help keep our digital world safe. We will use very simple words, lots of pictures, and fun stories. By the end, you will be able to write your very first security script. Are you ready? Let’s go!

🎯 Learning Objectives

After reading this module, you will be able to:

  • Explain what a script is in your own words.
  • Tell why scripts are used in cyber security.
  • Identify the parts of a simple script.
  • Write a basic script that prints a message.
  • Understand how scripts can check for dangers.
  • Work with friends to create a simple security script.

📖 Warm‑up Story: The Guard Dog and the Robot

Once upon a time, in a small village in Nigeria, there lived a boy named Tunde. Tunde had a guard dog named Bingo. Bingo was very smart. Every night, Bingo would walk around the house and bark if he saw anything strange.

One day, Tunde’s father brought home a new robot. The robot could not bark, but it could follow instructions. Tunde’s father wrote a list of instructions for the robot: “Walk around the house. If you see a stranger, send a message to my phone.” The robot followed these instructions every night. That list of instructions was a script.

Tunde thought, “Wow! The robot does exactly what Bingo does, but it uses code!” From that day, Tunde wanted to learn how to write instructions for computers. And that is exactly what we are going to learn in this module!

📘 Lesson 1: What is a Script?

Definition: A script is a set of instructions that tells a computer what to do.

Why important: Scripts help computers do jobs automatically, so we don’t have to do them by hand.

Simple explanation: Think of a script like a recipe for baking a cake. The recipe tells you step by step what to do. A script tells the computer step by step what to do.

Real-life example: A morning alarm clock follows a script: “At 6am, make a loud noise.”

School example: Your teacher has a script for the day: “Morning prayer, maths, break, English, lunch, home time.”

Home example: “After dinner, wash the plates, then watch TV.”

Nigerian example: A security guard at a bank has a script: “Every hour, walk around the building. If you see anything suspicious, call the manager.”

  Script for Guardy (the robot):
  -------------------------------
  1. Wait until 10pm
  2. Check the front door
  3. Check the back door
  4. If any door is open → send a message
  5. End

Mini summary: A script is a list of steps for a computer to follow.


📘 Lesson 2: Why Do We Need Scripts in Cyber Security?

Definition: Cyber security scripts are special instructions that protect computers, networks, and data from attacks.

Why important: They work all day and night to catch dangers, so we don’t have to watch the screen all the time.

Simple explanation: Imagine you have a pet fish. You use a timer to feed it automatically. A security script is like a timer that checks for bad guys.

Real-life example: A script can scan all files on a computer and delete any that look like a virus.

School example: A script can lock all school computers at 4pm so nobody uses them after school.

Home example: A script can turn on the security camera when you leave home.

Nigerian example: In many Nigerian banks, scripts monitor every transaction. If someone tries to transfer money to a bad account, the script stops it immediately.

  Security Script Flow:
  Start → Check all files → Look for viruses → If virus found → Quarantine it → Alert admin

Mini summary: Cyber scripts watch over our digital world and act fast when something is wrong.


📘 Lesson 3: Scripting Languages – Python and Bash

Definition: A scripting language is a special language used to write scripts. We will focus on Python (very easy) and Bash (used in the terminal).

Why important: Knowing a scripting language lets you talk to the computer.

Simple explanation: Just like you speak English or Yoruba to talk to friends, you use Python or Bash to talk to a computer.

Real-life example: Python is used by companies like Google and Netflix to keep systems safe.

School example: You can write a Python script to check if your homework folder is safe.

Home example: Bash scripts are used to clean up old files on your family PC.

Nigerian example: Many Nigerian tech companies use Python to build security tools.

LanguageUseDifficulty for Kids
PythonGeneral scripting, security tools😊 Easy
BashCommand line, file management😐 Medium

Mini summary: We will learn Python because it is friendly and powerful.


📘 Lesson 4: Your First Script – “Hello, World!”

Definition: A Python script is a text file with instructions that ends with .py.

Why important: Writing your first script is like writing your first sentence – it opens a new world.

Simple explanation: Open a notepad, type a few lines, save as .py, and run it.

Real-life example: The classic first script prints “Hello, World!”.

School example: Print “Welcome to cyber class”.

Home example: Print “Don’t forget to lock the door”.

Nigerian example: Print “Aroko wa (our message) – stay safe online”.

  # my_first_script.py
  print("Hello, Cyber Heroes!")
  print("This script keeps us safe.")

Mini summary: We type instructions in a file and run them.


📘 Lesson 5: Variables – Storing Information

Definition: A variable is like a box where you store a value (number, text, or list).

Why important: Variables help us remember things in our script.

Simple explanation: Like a jar with a label. You put candies in it and can take them out later.

Real-life example: Let age = 10. Then you can use age later to check if someone is old enough.

School example: score = 100. Use it to reward a student.

Home example: door_locked = True. Use it to decide if the alarm should be on.

Nigerian example: balance = 5000 (in Naira). Use it to check if you can buy data.

  # variables example
  name = "Chidi"
  age = 10
  is_secure = True
  print(name, "is", age, "years old.")

Mini summary: Variables store data for later use.


📘 Lesson 6: Conditions – Making Decisions

Definition: Conditions are like questions that have True or False answers. They help scripts decide what to do.

Why important: They allow scripts to react differently in different situations.

Simple explanation: If it rains, take an umbrella. Else, wear sunglasses. The script checks the condition.

Real-life example: If a login password is wrong, deny access.

School example: If homework is done, you can play.

Home example: If the window is open, close it.

Nigerian example: If NEPA (electricity) is on, charge your phone; else, use a power bank.

  password = "secure123"
  if password == "secure123":
      print("Access granted!")
  else:
      print("Access denied.")

Mini summary: Conditions let scripts choose between actions.


📘 Lesson 7: Loops – Repeating Actions

Definition: A loop repeats a block of instructions several times.

Why important: They save us from writing the same instruction over and over.

Simple explanation: Like singing “Happy Birthday” three times. A loop does that for you.

Real-life example: A script that checks 1000 files one by one – it uses a loop.

School example: Count from 1 to 10 using a loop.

Home example: Repeat “check the door” 5 times.

Nigerian example: A loop can check all 50 students’ scores and find the highest.

  for i in range(5):
      print("Checking door", i+1)

Mini summary: Loops repeat tasks automatically.


📘 Lesson 8: Functions – Grouping Instructions

Definition: A function is a named group of instructions that you can call (run) whenever you want.

Why important: Functions keep your script neat and reusable.

Simple explanation: Like a “make_jollof” recipe – you can use it anytime you want to cook.

Real-life example: A function “scan_for_virus” that you can call many times.

School example: A function “calculate_average” for grades.

Home example: A function “lock_doors” that locks all doors.

Nigerian example: A function “send_alert” that sends a message to the security team.

  def lock_doors():
      print("Locking front door")
      print("Locking back door")
  # call the function
  lock_doors()

Mini summary: Functions are reusable blocks of code.


📘 Lesson 9: Reading and Writing Files

Definition: Scripts can read data from files and write data to files.

Why important: This helps scripts keep logs (records) of what they did.

Simple explanation: Like keeping a diary. The script writes what it checked.

Real-life example: A script reads a list of bad IP addresses and blocks them.

School example: Read a list of student names and print each one.

Home example: Write a shopping list to a file.

Nigerian example: A script reads a list of bank account numbers to monitor for fraud.

  # write to file
  with open("log.txt", "w") as f:
      f.write("All doors checked at 10pm")

Mini summary: Files help scripts store and retrieve data.


📘 Lesson 10: Modules – Using Ready-made Tools

Definition: Modules are like toolboxes full of extra functions that other people made.

Why important: They save time – we don’t have to invent everything ourselves.

Simple explanation: Like using a calculator instead of doing long addition by hand.

Real-life example: The “os” module helps interact with the computer’s operating system.

School example: The “math” module gives you sin, cos, and more.

Home example: The “datetime” module helps get the current time.

Nigerian example: Use the “requests” module to check if a website is up.

  import datetime
  now = datetime.datetime.now()
  print("Current time:", now)

Mini summary: Modules add superpowers to your scripts.


📘 Lesson 11: Error Handling – Being Safe

Definition: Error handling is a way to catch mistakes (errors) without crashing the script.

Why important: It makes scripts strong and reliable.

Simple explanation: Like wearing a helmet when riding a bike – if you fall, you are safe.

Real-life example: If a file is missing, the script tells you, instead of breaking.

School example: If a student’s name is not found, print “Not found”.

Home example: If the light bulb is broken, try another one.

Nigerian example: If the network is slow, the script waits and retries.

  try:
      file = open("missing.txt")
  except:
      print("File not found, but script continues.")

Mini summary: Error handling keeps scripts from crashing.


📘 Lesson 12: Simple Logging – Keeping Records

Definition: Logging means writing down what the script did, with timestamps.

Why important: Logs help us see what happened if something goes wrong.

Simple explanation: Like a diary for the script.

Real-life example: A script logs “2026-06-27 10:00: Door checked – OK”.

School example: Log when each student finishes a test.

Home example: Log when the alarm is turned on/off.

Nigerian example: A bank script logs every ATM withdrawal.

  import logging
  logging.basicConfig(filename='security.log', level=logging.INFO)
  logging.info('Security check completed.')

Mini summary: Logging keeps a history of actions.


📘 Lesson 13: Automating Security Checks

Definition: Automation means letting scripts do the repetitive work for us.

Why important: Humans get tired; scripts don’t.

Simple explanation: Like a robot vacuum that cleans the floor while you play.

Real-life example: A script that automatically updates antivirus definitions.

School example: A script that backs up all homework files every Friday.

Home example: A script that turns off lights at 11pm.

Nigerian example: A script that checks the weather every morning and sends a WhatsApp message.

  # pseudo-code for automation
  while True:
      check_for_updates()
      sleep(3600)  # wait 1 hour

Mini summary: Automation makes life easier and safer.


📘 Lesson 14: Keeping Scripts Secret – Passwords and Keys

Definition: We must protect our scripts so bad guys can’t change them. Use passwords and keep them hidden.

Why important: If an evil hacker changes your script, it may help them instead.

Simple explanation: Like keeping your diary in a locked drawer.

Real-life example: Never put passwords directly in a script; use secret files.

School example: The teacher keeps the answer key in a safe.

Home example: Keep your Wi-Fi password in a secret place.

Nigerian example: Bank scripts use special “API keys” that are never shown to anyone.

  # NEVER do this:
  password = "mysecret123"
  # INSTEAD, read from a secure file or environment variable.

Mini summary: Keep your scripts and secrets safe.


📘 Lesson 15: Testing Your Scripts

Definition: Testing means running your script to make sure it works as expected.

Why important: You don’t want a broken script when you need it most.

Simple explanation: Like checking your shoes before a race – make sure they are tied.

Real-life example: Run the script with test data to see if it catches a fake virus.

School example: Test a grading script with sample scores.

Home example: Test the “lock doors” script during the day.

Nigerian example: A fintech startup tests their fraud script with dummy transactions.

  # simple test
  assert(2 + 2 == 4)
  print("Test passed!")

Mini summary: Always test your scripts before using them for real.


📚 Key Vocabulary

  • Script: A list of instructions for a computer.
  • Variable: A container for storing data.
  • Condition: A true/false test that decides what to do.
  • Loop: Repeats a set of instructions.
  • Function: A named block of reusable code.
  • Module: A toolbox of pre‑written code.
  • Log: A record of events.
  • Automation: Letting scripts do tasks automatically.
  • Error handling: Catching mistakes without crashing.
  • Testing: Checking if a script works correctly.

🧠 Important Concepts

  • Scripts are like recipes for computers.
  • Cybersecurity scripts protect against attacks.
  • We use Python because it is easy.
  • Variables store information.
  • Conditions let scripts make decisions.
  • Loops repeat actions.
  • Functions organize code.
  • Logging keeps a history.
  • Always test and keep secrets safe.

🧩 Step‑by‑Step: Writing a Security Script

  1. Think – What do you want the script to do? (e.g., check if a password is strong)
  2. Plan – Write down the steps on paper.
  3. Code – Type the instructions in a .py file.
  4. Test – Run the script and see if it works.
  5. Fix – If it doesn’t work, find and correct mistakes.
  6. Use – Run it for real to protect something.
  Step 1: Define the problem
  Step 2: Write pseudo‑code
  Step 3: Write actual code
  Step 4: Run and debug
  Step 5: Deploy

🌍 Real‑life Examples

  • Google uses scripts to block billions of spam emails daily.
  • Banks use scripts to detect fraud.
  • Hospitals use scripts to keep patient data safe.

🇳🇬 Nigerian Examples

  • Nigerian fintech companies use scripts to monitor transactions.
  • Schools in Lagos use scripts to manage student records.
  • MTN Nigeria uses scripts to secure their networks.

🎉 Fun Examples Children Relate To

  • A script that counts how many candies you have.
  • A script that decides if you can watch TV based on homework done.
  • A script that gives you a compliment every day.

🏠 Everyday Examples

  • Your phone alarm is a script.
  • Automatic lights in the street.
  • Email filters that sort spam.

🧑‍🏫 Teacher Notes

Encourage students to think of scripts as “recipes”. Use pair programming for activities. Relate every concept to a daily routine. Use the Nigerian context to make it relatable. Emphasise that making mistakes is part of learning – debugging is a superpower!

👨‍👩‍👦 Parent Tips

Help your child by setting up a safe computer environment where they can practice. Ask them to explain their script to you. Celebrate small wins. Remind them that cyber security is about staying safe, not just about coding.

💡 Interesting Facts

  • The first computer virus was created in 1983.
  • Python was named after the comedy group Monty Python.
  • More than 70% of companies use Python for security tasks.

🤔 Did You Know?

Did you know that the first script ever written was for a computer called the “Z3” in 1941? It was used to calculate rocket trajectories!

🧾 Remember This

  • Scripts are instructions for computers.
  • Always test your scripts.
  • Keep your scripts and secrets safe.
  • Cyber scripts protect us every day.

❌ Common Mistakes

  • Forgetting to close a parenthesis ( ) or quote “ “.
  • Using a variable without defining it first.
  • Putting sensitive information like passwords directly in code.
  • Not testing before using.

✅ Best Practices

  • Use meaningful variable names (e.g., password_attempt).
  • Add comments to explain what your script does.
  • Keep scripts short and focused.
  • Store secrets in environment variables, not in code.
  • Test with different inputs.

📟 ASCII Diagrams

  Script Execution Flow
  ----------------------
  Start
    |
    V
  Read input  →  Process  →  Decision?
    |                         |
    |                         V
    |                     (If true) → Action A
    |                     (If false)→ Action B
    |
    V
  Output result
    |
    V
  End
  Loop Illustration (for 5 times)
  +---+   +---+   +---+   +---+   +---+
  | 1 | → | 2 | → | 3 | → | 4 | → | 5 |
  +---+   +---+   +---+   +---+   +---+

📊 Comparison: Python vs Bash

FeaturePythonBash
ReadabilityVery easyModerate
Best forGeneral automation, security toolsFile operations, system commands
Learning curveGentleSteeper

📝 End‑of‑Module Summary

Congratulations! You have completed Module 1. You now know what scripts are, why they are important in cyber security, and how to write a simple one. You have learned about variables, conditions, loops, functions, and modules. You also know how to keep your scripts safe and test them. Remember, every expert was once a beginner. Keep practicing and you will become a cyber hero!

❓ Frequently Asked Questions

  1. What is the easiest scripting language? Python is great for beginners.
  2. Can a script harm my computer? Only if you run a bad script. Always check before running.
  3. Do I need to know maths? Basic maths is enough.
  4. How long does it take to learn? You can write your first script today!
  5. Can I make a game with scripts? Yes, Python can make games too.
  6. What if my script doesn’t work? Don’t worry, every coder makes mistakes. Fix them step by step.
  7. Is cyber security scripting only for experts? No, anyone can learn.
  8. How do I run a Python script? Type python filename.py in the terminal.
  9. Can I use scripts on my phone? Yes, there are apps that run Python.
  10. What should I learn next? More advanced security concepts and network scripting.

📋 Review Questions

  1. What is a script?
  2. Why do we use scripts in cyber security?
  3. Name two scripting languages.
  4. What is a variable?
  5. What does a condition do?
  6. What is a loop?
  7. Why are functions useful?
  8. What is a module?
  9. What is error handling?
  10. Why is logging important?
  11. What does automation mean?
  12. How can you keep your script safe?
  13. Why do we test scripts?
  14. Give one Nigerian example of a security script.
  15. What is the first script you wrote in this module?

✏️ Fill‑in‑the‑Blank

  1. A __________ is a set of instructions for a computer. (script)
  2. __________ are used to store data. (Variables)
  3. If a condition is true, the script does one thing; else, it does another – this is called __________. (decision / conditional)
  4. A __________ repeats a block of code. (loop)
  5. __________ help organise code into reusable blocks. (Functions)

✔️ True or False

  1. Python is a scripting language. (True)
  2. Scripts cannot make decisions. (False)
  3. Loops are used to repeat actions. (True)
  4. You should always put passwords in your script. (False)
  5. Testing is not important. (False)

🔘 Multiple Choice Questions

  1. Which of these is a scripting language?
    A) HTML B) Python C) CSS D) XML
    Answer: B
  2. What does a condition check?
    A) True/False B) Colour C) Size D) Speed
    Answer: A
  3. Which statement repeats code?
    A) if B) for C) def D) import
    Answer: B
  4. What is a function?
    A) A variable B) A reusable block C) A loop D) A module
    Answer: B
  5. Which module helps with dates?
    A) os B) datetime C) sys D) math
    Answer: B
  6. What is the extension for Python files?
    A) .txt B) .py C) .java D) .c
    Answer: B
  7. Which of these is good practice?
    A) Storing passwords in code B) Testing scripts C) Ignoring errors D) Writing long unreadable code
    Answer: B
  8. What does a loop help with?
    A) Decision B) Repetition C) Storage D) Security
    Answer: B
  9. What is a module?
    A) A script B) A toolbox C) A variable D) A function
    Answer: B
  10. How do you write a comment in Python?
    A) // comment B) # comment C) /* comment */ D) -- comment
    Answer: B
  11. Which of these is a security script used for?
    A) Games B) Protecting data C) Drawing D) Music
    Answer: B
  12. What is the first step in writing a script?
    A) Code B) Test C) Plan D) Deploy
    Answer: C
  13. What does print() do?
    A) Reads input B) Shows output C) Stores data D) Loops
    Answer: B
  14. Which of these is NOT a good practice?
    A) Using meaningful names B) Adding comments C) Testing D) Hiding errors
    Answer: D
  15. What is a variable?
    A) A container B) A loop C) A condition D) A function
    Answer: A

🔗 Matching Exercises

Match the term with its description:

TermDescription
1. ScriptA. Repeats code
2. VariableB. Stores a value
3. LoopC. Group of instructions
4. FunctionD. True/False check
5. ConditionE. Named reusable block

Answers: 1-C, 2-B, 3-A, 4-E, 5-D

✍️ Short Answer Questions

  1. Explain in your own words what a script is.
  2. Why is automation important in cyber security?
  3. Give an example of a condition in everyday life.
  4. How do you keep a script safe from bad people?
  5. What is the difference between a variable and a function?

🎭 Scenario‑based Exercises

Scenario 1: You are a security guard at a school. You want a script that checks if the main gate is locked after 6pm. Write a simple Python script (pseudo-code) that does this.

Scenario 2: A bank wants a script that alerts the manager if a withdrawal is above ₦500,000. Write a condition that does this.

👥 Group Activity

In groups of 3, brainstorm five ways a script could help a small business in Nigeria. Then, write one small script (on paper) that solves one of those problems. Present it to the class.

🧑‍🎓 Individual Activity

Write a Python script that prints your name, your age, and a message like “I love cyber security”. Then, add a condition that prints “I am a kid” if age < 18, else “I am an adult”. Run it on your computer.

💬 Classroom Discussion Questions

  1. How can scripts help keep our online identity safe?
  2. What are some ethical issues with scripts? (e.g., using scripts to spy)
  3. How do you think scripts will change in the future?

🛠️ Mini Project

Build a simple password checker! Write a script that asks the user for a password. If the password is “cyber2026”, print “Access granted”. Otherwise, print “Access denied”. Add a loop that gives the user 3 tries.

📂 Practical Assignment

Download a text file with 10 common passwords. Write a script that reads the file and checks if any of them are “password123”. If yes, print “Weak password found!” Use a loop and a condition.

🏆 Challenge Exercise

Write a script that simulates a simple alarm system. If the door is open and the time is after 8pm, print “ALARM! Door open”. Otherwise, print “All safe”. Use variables for door status and time.

✅ Quiz Answers

All multiple-choice answers are indicated in the questions above (bold). Fill-in-the-blank answers: 1-script, 2-Variables, 3-decision/conditional, 4-loop, 5-Functions. True/False: 1-T, 2-F, 3-T, 4-F, 5-F.

🔑 Key Takeaways

  • Scripts are powerful tools for cyber security.
  • Python is a great language to start.
  • Always plan, code, test, and keep secrets safe.
  • Practice makes perfect – keep coding!

🚀 Preparation for Module 2

In the next module, we will learn about networks and how scripts can protect them. We will explore IP addresses, firewalls, and more fun stuff. See you there, cyber heroes!


End of Module 1 · Fundamentals of Cyber Security Scripting

🏆 Get Certified

🔒

Earn this certificate

Every lesson is already free to read. Sign up, finish the lessons, pass the exam (₦2,000 or 20,000 coins), and get a verified certificate with your name on it.

🎓 Sign Up to Get Certified
🛠️ Practice Tools
Hands-on simulators & labs - subscription required.
→
🎯 Internship Tasks
Real-world tasks to build your portfolio - unlock them with a subscription.
→