系统日志:
/var/log/messages
- 通用系统活动日志/var/log/syslog
- 系统日志(基于Debian的系统)/var/log/auth.log
- 认证相关日志(登录、sudo等)服务日志:
/var/log/secure
- 安全相关日志(RHEL/CentOS)/var/log/apache2/
- Apache Web服务器日志/var/log/nginx/
- Nginx Web服务器日志/var/log/mysql.log
- MySQL数据库日志内核与启动日志:
/var/log/kern.log
- 内核日志/var/log/boot.log
- 系统启动日志/var/log/dmesg
- 内核环形缓冲区日志基础工具:
grep
- 文本搜索awk
- 文本处理sed
- 流编辑器tail
/head
- 查看日志首尾less
/more
- 分页查看高级工具:
journalctl
- systemd日志查看工具logwatch
- 日志摘要生成工具goaccess
- Web日志分析工具multitail
- 多日志文件监控SIEM解决方案:
# 检查失败的登录尝试
grep "Failed password" /var/log/auth.log
grep "authentication failure" /var/log/auth.log
# 检查成功登录
grep "Accepted password" /var/log/auth.log
grep "session opened" /var/log/auth.log
# 检查root用户登录
grep "root" /var/log/auth.log | grep "Accepted"
# 统计IP的失败登录次数
grep "Failed password" /var/log/auth.log | awk '{print $11}' | sort | uniq -c | sort -nr
# 检查异常进程
ps aux | grep -E "(nmap|nikto|sqlmap|hydra|john|medusa)"
# 检查隐藏进程
ps -ef | awk '{print $2}' | sort -n | uniq > /tmp/ps1
ls /proc | sort -n | uniq > /tmp/proc1
diff /tmp/ps1 /tmp/proc1
# 使用AIDE进行文件完整性检查
aide --check
# 快速检查关键文件修改
find /etc -type f -mtime -1 -ls
日志轮转配置:
/etc/logrotate.conf
和/etc/logrotate.d/
下的配置文件实时监控脚本示例:
#!/bin/bash
tail -f /var/log/auth.log | while read line
do
if echo "$line" | grep -q "Failed password"; then
echo "$(date) - 登录失败: $line" >> /var/log/auth_alert.log
# 可以添加邮件或短信通知
fi
done
网络流量分析:
漏洞扫描:
入侵检测:
通过合理配置和使用这些工具与技术,您可以有效监控Linux系统的安全状态,及时发现并响应潜在的安全威胁。