AUTOMATION WITH PYTHON
Lesson 4 of 5WARMUP: Repetitive Tasks Brainstorm
Think about tasks you do every day on a computer — checking email, scanning files, backing up data. What if a script could do them automatically while you sleep?
Brainstorm: List 3 security tasks that could be automated. (Examples: log scanning, password rotation, backup verification)
CORE CONCEPTS
Automation saves time, reduces human error, and lets you respond to threats 24/7. A SOC (Security Operations Center) relies heavily on automated alerts.
Python can interact with files, send emails, make network requests — everything you need for security automation.
On a real server, scripts are scheduled using cron (Linux) or Task Scheduler (Windows). You can also use a simple while loop with time.sleep() to simulate scheduling.
This pattern runs forever — perfect for a background monitoring service!
MINI CHALLENGE: File Monitoring Script
Write a Python script that monitors a directory and prints a warning whenever a new file is created or an existing file is modified.
config.json changes.
MAIN PROJECT: Automated Security Alert System
Design and write a Python script that monitors server logs, detects repeated failed login attempts, and sends a simulated alert.
Function to read the latest log entries
Detect >5 failed attempts from same IP
Print or write an alert to a file
Run the check every 10 seconds
QUIZ: Automation
Test your automation knowledge.
1. What Python function pauses execution for a given number of seconds?
2. Why is automation important in cybersecurity?
3. What is a common tool used to schedule Python scripts on Linux?