Introduction
In today's digital world, protecting sensitive information like tax data is crucial. The recent Ernst & Young breach shows how important it is to understand security practices and how to safeguard your data. In this tutorial, you'll learn how to create a basic security monitoring system that can help detect unauthorized access to sensitive files. This is a fundamental skill that helps protect both personal and business data.
Prerequisites
Before starting this tutorial, you'll need:
- A computer with internet access
- Basic understanding of how computers work
- Python installed on your computer (any version 3.x works)
- A text editor like Notepad, VS Code, or similar
- Some sample text files to work with
Step-by-Step Instructions
Step 1: Create a Sample File Structure
Why this step is important
We need to set up a basic file system that mimics how real companies store sensitive data. This will help us understand how to monitor file access.
First, create a folder on your computer called security_demo. Inside this folder, create two subfolders: documents and logs. The documents folder will contain our sensitive files, and the logs folder will store access records.
Step 2: Create Sample Sensitive Files
Why this step is important
These files represent the type of sensitive data that was compromised in the Ernst & Young breach. By creating these files, we can practice monitoring access to them.
Inside the documents folder, create three text files:
client_tax_1.txtclient_tax_2.txtclient_tax_3.txt
Fill each file with sample content like:
Client Name: John Smith
Tax Year: 2023
Income: $75,000
SSN: 123-45-6789
Step 3: Create the Security Monitoring Script
Why this step is important
This script will monitor when files in our documents folder are accessed. It's a simplified version of what security systems do to detect unauthorized access.
Create a new file called security_monitor.py in your security_demo folder. Open it with your text editor and add the following code:
import os
import time
import datetime
def monitor_files(folder_path):
"""Monitor files in a folder for access"""
print(f"Starting security monitoring for folder: {folder_path}")
print("Monitoring for file access... Press Ctrl+C to stop")
# Get initial file states
file_states = {}
for filename in os.listdir(folder_path):
filepath = os.path.join(folder_path, filename)
if os.path.isfile(filepath):
file_states[filename] = os.path.getmtime(filepath)
try:
while True:
# Check each file
for filename in os.listdir(folder_path):
filepath = os.path.join(folder_path, filename)
if os.path.isfile(filepath):
current_time = os.path.getmtime(filepath)
# If file was accessed (modified time changed)
if filename in file_states:
if file_states[filename] != current_time:
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print(f"[ALERT] File accessed: {filename} at {timestamp}")
# Log the access
log_access(filename, timestamp)
# Update file state
file_states[filename] = current_time
else:
# New file detected
file_states[filename] = current_time
time.sleep(2) # Check every 2 seconds
except KeyboardInterrupt:
print("\nMonitoring stopped.")
def log_access(filename, timestamp):
"""Log file access to a log file"""
log_file = os.path.join("logs", "access_log.txt")
with open(log_file, "a") as f:
f.write(f"{timestamp} - {filename} accessed\n")
if __name__ == "__main__":
monitor_files("documents")
Step 4: Set Up the Logging System
Why this step is important
Logging is essential for tracking what happens in security systems. When someone accesses files, we need to record this information for review.
Run the script once to create the log file. You can do this by opening a terminal or command prompt, navigating to your security_demo folder, and typing:
python security_monitor.py
Then, in another terminal window, try accessing one of your tax files:
notepad documents/client_tax_1.txt
Or simply open it with any text editor. You'll see the monitoring script detect this access and log it to the access_log.txt file.
Step 5: Test Your Security System
Why this step is important
Testing helps you understand how your monitoring system works and what it can detect. This is crucial for real-world security implementation.
Try these actions to test your system:
- Open a tax file with a text editor
- Make a small change to the file and save it
- Close the file without saving
- Try to delete a file
Each time you perform these actions, the monitoring script should detect them and log the access in the logs/access_log.txt file.
Step 6: Analyze Your Security Logs
Why this step is important
Security monitoring is only useful if you can analyze the logs to detect suspicious activity. This step teaches you how to review your security data.
Open the logs/access_log.txt file to see all the file access records. You'll notice entries like:
2023-10-15 14:30:22 - client_tax_1.txt accessed
2023-10-15 14:31:15 - client_tax_2.txt accessed
Look for patterns in the access times. If you see files being accessed at unusual hours or by unknown users, this could indicate a security breach.
Step 7: Enhance Your Monitoring System
Why this step is important
Real security systems need more features than our basic example. This step introduces concepts for making your monitoring more robust.
Try adding these features to your script:
- Send email alerts when suspicious access is detected
- Track which user accessed files
- Set up automatic backup of sensitive files
- Add password protection to your monitoring system
These enhancements would make your system more suitable for real-world use.
Summary
In this tutorial, you've created a basic security monitoring system that can detect when sensitive files are accessed. This demonstrates how security systems work to protect data like the tax information that was exposed in the Ernst & Young breach. You learned how to set up a file monitoring system, create logs of file access, and analyze those logs for potential security issues.
While this is a simplified example, it shows the fundamental principles of file access monitoring that professional security systems use. Understanding these concepts helps you appreciate why data breaches like the one at Ernst & Young are so serious and why proper security measures are essential.
Remember, this system only monitors file access. Real security requires multiple layers of protection including encryption, access controls, network security, and regular audits.



