Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

centos7 部署audit安全审计[0]

Posted on 2023年11月14日 by
安全最重要的一步是内部安全,如何监控用户的行为是一个永恒不变的话题。
audit可以详细监控用户的行为,详细到查看或修改了某个文件。这些都可以在日志中查看到。
auditd内核模块主要用来获取审计信息,而用户的auditd守护进程主要是从内核模块获取审计信息然后记录。所以如果auditd内核模块没有起动,那么auditd守护进程启动了也没有任何用,用户定义的临时审计规则或永久审计规则都不会起效果,自然也不会记录任何信息
  • 安装
yum -y install auditd
  • 开启audit服务
service auditd start		#开启
service auditd stop		#关闭
service auditd restart		#重启
service auditd status

检查内核和守护程序

auditctl -s

  • 修改配置文件
nano /etc/audit/auditd.conf

完整的配置如下:

local_events = yes
write_logs = yes
log_file = /var/log/audit/audit.log  #日志文件位置
log_group = root
log_format = RAW
flush = INCREMENTAL_ASYNC
freq = 50 #每隔50条记录写入日志中(flush = INCREMENTAL时有效)
max_log_file = 8 #每个文件8M
num_logs = 5
priority_boost = 4
disp_qos = lossy
dispatcher = /sbin/audispd
name_format = NONE
##name = mydomain
max_log_file_action = ROTATE #日志文件达到最大空间的动作: ROTATE为将旧日志文件重命名,再新建日志文件继续写入
space_left = 7500   #限制剩余磁盘空间
space_left_action = SYSLOG
verify_email = yes
action_mail_acct = root
admin_space_left = 5000   #停止审计
admin_space_left_action = SUSPEND
disk_full_action = SUSPEND
disk_error_action = SUSPEND
use_libwrap = yes
##tcp_listen_port = 60
tcp_listen_queue = 5
##tcp_listen_port = 60
tcp_listen_queue = 5
tcp_max_per_addr = 1
##tcp_client_ports = 1024-65535
tcp_client_max_idle = 0
enable_krb5 = no
krb5_principal = auditd
##krb5_key_file = /etc/audit/audit.key
distribute_network = no

查看日志文件大小

cd /var/log/audit/
du -sh *
  • 添加规则
nano /etc/audit/rules.d/audit.rules

追加以下内容:

-w /bin/rm -p x -k removefile
-w /var/log/lastlog -p wa -k logins
-w /var/run/faillock/ -p wa -k logins
-w /var/run/utmp -p wa -k session
-w /var/log/wtmp -p wa -k logins
-w /var/log/btmp -p wa -k logins

需要重启服务,查看规则

auditctl -l
  • 审阅audit日志

三个工具aureport、ausearch、autrace有针对性地去统计分析以及跟踪log日志

aureport使用

aureport

aureport -l #用户登录信息
aureport --failed    #针对失败的event的统计
aureport -s
aureport -x
aureport -e -i --summary   #分类统计事件数量
aureport --failed

ausearch使用

ausearch -ui 1000 #特定用户UID
ausearch -i

 

参考资料:

  1. https://guoflight.github.io/posts/63889/
  2. https://blog.csdn.net/ezbuy/article/details/96101028
  3. https://www.cnblogs.com/zydev/p/13086818.html
  4. https://www.cnblogs.com/xingmuxin/p/8681227.html

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT