Unauthorized Changes Detection
Monitoring Passwd File Modifications
Real-Time File Tracking Techniques
1. Inotify-Based Monitoring
## Install inotify-tools
sudo apt-get install inotify-tools
## Real-time passwd file monitoring
inotifywait -m /etc/passwd -e modify,create,delete
2. Auditd System Monitoring
## Install auditd
sudo apt-get install auditd
## Configure audit rule for passwd file
sudo auditctl -w /etc/passwd -p wa -k passwd_changes
Detection Strategies
graph TD
A[Modification Detection] --> B[File Integrity Checks]
A --> C[Log Analysis]
A --> D[Real-Time Monitoring]
Integrity Verification Methods
Method |
Description |
Command |
MD5 Checksum |
Compare file hash |
md5sum /etc/passwd |
Tripwire |
Advanced integrity checker |
tripwire --check |
AIDE |
Filesystem monitoring tool |
aide --check |
Scripted Detection Approach
#!/bin/bash
## Passwd Modification Detection Script
CURRENT_HASH=$(md5sum /etc/passwd | awk '{print $1}')
STORED_HASH=$(cat /root/.passwd_baseline_hash)
if [ "$CURRENT_HASH" != "$STORED_HASH" ]; then
echo "ALERT: Unauthorized passwd modification detected!"
## Send notification or trigger security response
fi
Advanced Detection Techniques
1. Comprehensive Logging
## Enable detailed system logging
sudo auditd -l detailed
2. Periodic Integrity Checks
## Cron job for regular checks
0 * * * * /usr/local/bin/passwd_integrity_check.sh
LabEx Security Practice
Leverage LabEx environments to simulate and practice unauthorized modification detection techniques safely.
Key Detection Indicators
- Unexpected user additions
- UID/GID modifications
- Shell configuration changes
- Timestamp alterations
Notification and Response
graph TD
A[Modification Detected] --> B[Log Generation]
B --> C[Notification Trigger]
C --> D[Security Response]
D --> E[System Lockdown/Investigation]