📖 Scenario: You are a cybersecurity analyst investigating a suspicious activity on a company server. You have access to a log file that records user actions with timestamps and IP addresses.Your task is to analyze the log entries to identify any unusual login attempts based on a threshold of failed attempts.
🎯 Goal: Build a simple log analysis setup that stores log entries, sets a threshold for failed login attempts, counts failed attempts per IP, and identifies IPs exceeding the threshold.
📋 What You'll Learn
Create a dictionary called log_entries with exact entries for user login attempts
Add a variable called failed_attempt_threshold set to 3
Use a for loop with variables ip and status to iterate over log_entries.items() and count failed attempts per IP
Create a list called blocked_ips that contains IPs with failed attempts greater than the threshold
💡 Why This Matters
🌍 Real World
Cybersecurity analysts use log forensics to detect unauthorized access attempts and protect systems from attacks.
💼 Career
Understanding how to analyze logs and identify suspicious patterns is essential for roles like security analyst, incident responder, and network administrator.
Progress0 / 4 steps
1
Create the log entries dictionary
Create a dictionary called log_entries with these exact entries: '192.168.1.10': 'success', '192.168.1.11': 'failed', '192.168.1.12': 'failed', '192.168.1.11': 'failed', '192.168.1.13': 'success', '192.168.1.11': 'failed'
Cybersecurity
Hint
Use a dictionary with IP addresses as keys and login status as values. Duplicate keys will overwrite previous entries, so consider this in your approach.
2
Set the failed attempt threshold
Add a variable called failed_attempt_threshold and set it to 3
Cybersecurity
Hint
This variable will help decide when to flag an IP for too many failed attempts.
3
Count failed login attempts per IP
Create a dictionary called failed_attempts to count failed logins. Use a for loop with variables ip and status to iterate over log_entries.items(). For each status equal to 'failed', increase the count for that ip in failed_attempts
Cybersecurity
Hint
Use a dictionary to keep counts and the get method to handle new IPs.
4
Identify IPs exceeding the failed attempt threshold
Create a list called blocked_ips that contains IPs from failed_attempts with counts greater than failed_attempt_threshold
Cybersecurity
Hint
Use a list comprehension to filter IPs with too many failed attempts.
Practice
(1/5)
1. What is the main purpose of log forensics in cybersecurity?
easy
A. To create new logs for system monitoring
B. To delete unnecessary log files
C. To analyze recorded events to understand system activity
D. To encrypt user data for privacy
Solution
Step 1: Understand the role of logs
Logs record events and activities happening in a system.
Step 2: Identify the goal of log forensics
Log forensics uses these records to analyze and understand what happened in the system, especially for security investigations.
Final Answer:
To analyze recorded events to understand system activity -> Option C
Quick Check:
Log forensics = analyze events [OK]
Hint: Log forensics means studying logs to find what happened [OK]
Common Mistakes:
Confusing log creation with log analysis
Thinking log forensics deletes logs
Assuming log forensics encrypts data
2. Which of the following is a correct example of a log entry timestamp format?
easy
A. 2024-06-01T14:23:45Z
B. 14/23/2024 06:01
C. June 31, 2024 25:61
D. 2024-13-01 14:23:45
Solution
Step 1: Recognize standard timestamp formats
ISO 8601 format like YYYY-MM-DDTHH:MM:SSZ is widely used in logs.
Step 2: Check each option for validity
2024-06-01T14:23:45Z matches ISO 8601 correctly. Options A, B, and D have invalid dates or times.
Final Answer:
2024-06-01T14:23:45Z -> Option A
Quick Check:
Valid ISO 8601 timestamp = 2024-06-01T14:23:45Z [OK]