Aufgabe Security Audit für Kuno
1
Part 1: Security Audit Preparation
Create an audit directory structure
sudo mkdir -p /audit/{logs,reports,backups,scripts}
sudo mkdir -p /audit/logs/{user_activity,permission_changes,system_access}User Account Audit
grep -Po '^sudo.+:\K.*$' /etc/groupcat /etc/passwd | cut -d: -f1,3,6sudo cat /etc/shadow | cut -d: -f1,32
Part 2: Permission Security Scan
Dangerous Permission Detection
sudo find /home -type f -perm -002 -lssudo find /home -nouser -o -nogroupsudo find / -type f \( -perm -4000 -o -perm -2000 \) 2>/dev/nullsudo find /etc -type f -mtime -1Advanced Permission Analysis Tasks
find /home -type f -perm -002 | wc -lls -la /etc/ | grep "^d" | wc -l # Count directories3
Part 3: Automated User Management Script
Create a bash script: /audit/scripts/user_report.sh
/audit/scripts/user_report.sh#!/bin/bash
# User Report Generator
# Date: $(date)
echo "=== SYSTEM USER AUDIT REPORT ==="
echo "Generated on: $(date '+%Y-%m-%d %H:%M:%S')"
echo "================================"
echo ""
echo "Total number of users:"
cat /etc/passwd | wc -l
echo ""
echo "Users with login shells (excluding system users):"
grep -E "/bin/bash$|/bin/sh$" /etc/passwd | cut -d: -f1
echo ""
echo "Groups and their members:"
cat /etc/group | grep -E "developers|testers|management"
echo ""
echo "Recently modified files in /etc (last 7 days):"
sudo find /etc -type f -mtime -7 -printf "%T+ %p\n" | sort | head -10
echo ""
echo "Disk usage by home directories:"
sudo du -sh /home/* 2>/dev/null
echo ""Script Requirements
chmod +x /audit/scripts/user_report.sh./user_report.sh > /audit/reports/daily_report.txtREPORT_DIR="/audit/reports"
REPORT_FILE="$REPORT_DIR/report_$(date +%Y%m%d).txt"4
Part 4: Advanced Command Combinations
Practice complex pipe operations
sudo find /home -type f -exec du -h {} + | sort -rh | head -5find /home -type f | sed 's/.*\.//' | sort | uniq -c | sort -rncat /etc/passwd | sort -t: -k3 -n | cut -d: -f1,3sudo find /etc -name "*.conf" -exec ls -lh {} \; | head -20Challenges with grep and awk
Expandable: Suggested answers (for reference)
Assessment Criteria
Criterion
Weight
Description