VR - Mission 15: Cyber Storm
Storm
Students help protect an email server by using file operations to read, search, and filter suspicious emails.
Overview
In Cyber Storm, students step into the role of a cybersecurity analyst protecting an email server from malicious messages. Working entirely with file operations and string methods, they open and read email files, build a dictionary from each email's heading and body, search that body for suspicious keywords, and remove or flag the emails that pose a risk. By the end of the mission, students have written a working blocklist program that reads a file, checks its contents, and removes senders who don't belong.
π― Mission Goal: Students help protect an email server by using file operations.
Learning Targets
- I can open and read from a file.
- I can check for special characters.
- I can create a dictionary from an email file.
- I can search for a specific word and replace it with a different word.
- I can create a list of blocked users and remove their emails.
Key Concepts
- File operations include a variety of ways to open, read, write, and append to a file.
-
The
withstatement is a for loop for files that automatically closes the file. -
Use
inornot into search through a string. -
A string can be manipulated with methods such as
replace. - A new file can be created and data added to the file using append.
Assessment Opportunities
- Quiz after Objective 4
- Quiz after Objective 8
- Code Tracing Chart as a debugging tool
- Submit program code, or give students printed code and have them explain each line: Objective 3, Objective 5, Objective 7, Objective 8
- Give extra practice with file operations
- Give extra practice with string operations
- Submit final blocklist program
- Mission 15 Review Kahoot!
Success Criteria
- Open and read data from a file.
- Create a dictionary of an email's heading and body.
- Search the body of an email for suspicious keywords.
- Create a blocklist file and use it to remove suspicious emails.
Digital Resources
Classroom Materials
- βΈComputer or Chromebook with internet access
Real-World Applications
Extensions & Cross-Curricular
clean_line function can create a substring of a string using each letter's position (or index). Create an algorithm or equation that automates this process without needing "magic numbers."
π€
Vocabulary
βΎ
π
New Python Code
βΎ
π
Standards
βΎ
CSTA Standards - Grades 9-10
CSTA Standards - Grades 11-12
Certiport IT Specialist: Python Standards
PCEP: Certified Entry-Level Python Programmer
- This mission does not use the CodeBot - it uses the console for displaying information, so no hardware setup is needed.
- There are several CSTA standards specific to networks, privacy, and security in this mission - before or after Cyber Storm is a good time for additional lessons and discussions on these topics.
- Plan for students to do a "save as" at the beginning of each objective, so they can refer back to methods taught earlier.
- The name of the file used in the program changes frequently from one objective to another - make sure students are using the correct filename each time.
- This mission uses many file operations. It's a good time to do some extra practice and review of file and string methods.
Lesson Outline
Ask students if they've ever gotten a suspicious email, or heard of phishing or malware spreading through email. Introduce the mission: they'll write a program that reads an email server's messages, checks them for suspicious content, and removes emails from blocked senders - all using file operations.
- Open a file with a
withstatement, read its contents, and usestrip()to clean up whitespace and escape sequences from each line. - Reference Mission 15 Obj 2 as needed.
- Use
startswith()to identify each heading line and build a dictionary of the email's date, sender, and other header fields. - Submit program code for Objective 3, or have students explain each line.
- Reference Mission 15 Obj 4 as needed. Administer the Quiz after Objective 4.
- Find the blank line that separates the heading from the body, read the rest of the file into
email['body'], and useinto search it for a suspicious keyword. - Submit program code for Objective 5, or have students explain each line.
- Reference Mission 15 Obj 5 as needed.
- Use the
replace()method to swap a flagged word out of the email body. - Submit program code for Objective 7, or have students explain each line.
- Reference Mission 15 Obj 7 as needed.
- Import
os, check whether a blocklist file already exists, write new blocked senders to it withf.write(), and remove emails from any sender on the list withos.remove(). - Submit program code for Objective 8, or have students explain each line. Administer the Quiz after Objective 8.
- Have students give extra practice with file operations here if time allows, then submit their final blocklist program.
Close with the Level-1 Mission 15 Review Kahoot! to reinforce file operations, string searching, and the blocklist workflow before moving on to the Unit 6 Remix & Assessment.