深圳宝安区网站建设公司,做物流网站的公司,网站开发建设需要多少钱,做网站的公司吉林标题利用Audit审计系统行为
Linux Audit守护进程是一个可以审计Linux系统事件的框架
这个框架本身有数个组件#xff0c;包括内核、二进制文件及其他文件。
1.内核audit#xff1a;钩在内核中来捕获事件并将它们发送到auditd。
2.二进制文件 auditd#xff1a;捕捉事件并…标题利用Audit审计系统行为
Linux Audit守护进程是一个可以审计Linux系统事件的框架
这个框架本身有数个组件包括内核、二进制文件及其他文件。
1.内核·audit钩在内核中来捕获事件并将它们发送到auditd。
2.二进制文件 ·auditd捕捉事件并记录它们记录在日志文件中的守护进程。·auditctl配置auditd的客户端工具。 ·audispd多路复用事件的守护进程。 ·aureport从日志文件auditd.log中读取内容的报告工具。·ausearch事件查看器查看的内容是auditd.log。 ·autrace使用内核中的审计组件来追踪二进制文件。 ·aulast和上一个类似但是使用的是审计框架。 ·aulastlog和lastlog类似但是使用的也是审计框架 ·ausyscall映射系统调用ID和名字。 ·auvirt展示和审计有关虚拟机的信息。
3.文件 ·audit.rules由auditctl使用它读取该文件来决定需要使用什么规则。·auditd.confauditd的配置文件。
在Debian/Ubuntu中使用以下命令安装
apt-get install auditd audispd-pluginsCentos中使用以下命令安装
yum -y install audit两个文件管理审计守护进程的配置一个用于守护进程本身auditd.conf另一个是用于auditctl工具的规则audit.rules。
1.auditd.conf文件auditd.conf对Linux audit守护进程的配置聚焦在它应该在哪里以及如何记录事件。它也定义了如何应对磁盘满的情况、如何处理日志轮转和要保留的日志文件数量。通常对大多数系统来说默认配置是足够的。
2.audit.rules为了配置应该审计什么日志审计框架使用了一个名为audit.rules的文件。和大多数情况一样从零开始而不加载任何规则。通过用-l参数来运行auditctl我们可以确定使用中的规则。 万一加载了任何规则的话可用-D参数运行auditctl来删除已加载规则。
管理审计服务
配置 auditd 后启动服务来收集审计信息
# service auditd start使用 service 命令而不是 systemctl 的唯一原因是正确记录用户 ID (UID) 值。
设置开机启动
# systemctl enable auditd定义审计规则
使用 auditctl 工具可以在你想要的任何系统调用上添加审计规则。规则会按顺序执行。
下一步定义监视规则。此规则跟踪文件或目录是否由某些类型的访问触发包括读取、写入、执行和属性更改。
定义规则的语法是
auditctl -w path_to_file -p permissions -k key_name-w #指定所要监控的文件或命令 -p #监控属性(如x执行) ·r读取·w写入·x执行·a属性改变-k #指定关键词(方便在日志中查询) -D #清除规则(临时,不会清除配置文件规则)
如要审核用户创建操作首先向 /etc/passwd 文件添加监视以跟踪写入和属性更改访问并添加自定义键以记录所有消息此自定义键可用于过滤日志消息
[rootlocalhost ~]# auditctl -w /etc/passwd -p wa -k user-modify接下来添加一个新用户。这样做会更改 /etc/passwd 文件
[rootlocalhost ~]# useradd user01最后检查 auditd 是否记录了更改。默认情况下auditd 将日志存储在 /var/log/audit/audit.log 文件中
[rootlocalhost yy]# cat /var/log/audit/audit.log | grep modify 定义持久审计规则
要使audit规则在重新启动后保持不变请将它们添加到/etc/audit/rules.d/audit.rules文件中。
下面在 audit.rules 文件中定义持久性规则以监视 /etc/passwd 文件的更改。
-w /etc/passwd -p wa -k user-modify保存文件然后重新加载 auditd 守护程序以实现对规则文件中配置的更改
[rootlocalhost ~]# service auditd reload可以运行auditctl -l列出规则
[rootlocalhost ~]# auditctl -l最后添加新用户或更改 /etc/passwd 文件会出发审计。更改记录在 /var/log/audit/audit.log 中即使系统重新启动规则仍然存在。
搜索审计日志
使用ausearch工具搜索审计日志。默认情况下它搜索 /var/log/audit/audit.log 文件。
例如要根据 key_name 搜索日志条目搜索有关user-modify相关的
[rootlocalhost yy]# ausearch -i -k user-modify-i #显示信息更清晰,比如显示日期而不是时间戳-k #指定关键词(auditctl -k指定的关键词)-c commond #只显示与指令相关日志(如-c rm)
创建审计报告
使用 aureport 工具根据审计日志查询和创建审计报告。
[rootlocalhost ~]# aureport [rootlocalhost yy]# aureport Summary ReportRange of time in logs: 2023年09月12日 15:46:48.403 - 2023年09月20日 02:58:23.161
Selected time for report: 2023年09月12日 15:46:48 - 2023年09月20日 02:58:23.161
Number of changes in configuration: 175
Number of changes to accounts, groups, or roles: 9
Number of logins: 5
Number of failed logins: 2
Number of authentications: 24
Number of failed authentications: 4
Number of users: 5
Number of terminals: 11
Number of host names: 3
Number of executables: 14
Number of commands: 16
Number of files: 3
Number of AVCs: 0
Number of MAC events: 12
Number of failed syscalls: 2
Number of anomaly events: 0
Number of responses to anomaly events: 0
Number of crypto events: 94
Number of integrity events: 0
Number of virt events: 0
Number of keys: 1
Number of process IDs: 215
Number of events: 994
查看关于尝试身份验证的报告
[rootlocalhost yy]# aureport -auAuthentication Report# date time acct host term exe success event1. 2023年09月12日 15:47:38 gnome-initial-setup localhost.localdomain /dev/tty1 /usr/libexec/gdm-session-worker yes 145
2. 2023年09月12日 15:48:53 yy localhost.localdomain /dev/tty1 /usr/libexec/gdm-session-worker yes 177
3. 2023年09月12日 08:43:01 yy ? /dev/pts/0 /usr/bin/sudo yes 205
4. 2023年09月12日 21:42:08 yy localhost.localdomain /dev/tty1 /usr/libexec/gdm-session-worker yes 282
5. 2023年09月12日 21:44:15 root 192.168.171.1 ssh /usr/sbin/sshd no 296
6. 2023年09月12日 21:44:23 root 192.168.171.1 ssh /usr/sbin/sshd no 297
7. 2023年09月12日 21:44:33 root 192.168.171.1 ssh /usr/sbin/sshd yes 298
8. 2023年09月12日 21:44:49 yy 192.168.171.1 ssh /usr/sbin/sshd yes 332
9. 2023年09月12日 21:45:26 yy 192.168.171.1 ssh /usr/sbin/sshd yes 353
10. 2023年09月13日 04:54:31 yy localhost.localdomain /dev/tty1 /usr/libexec/gdm-session-worker yes 398
11. 2023年09月13日 04:57:58 gdm localhost.localdomain /dev/tty1 /usr/libexec/gdm-session-worker yes 54
12. 2023年09月13日 04:58:13 yy localhost.localdomain /dev/tty1 /usr/libexec/gdm-session-worker yes 150
13. 2023年09月15日 05:00:30 yy localhost.localdomain /dev/tty1 /usr/libexec/gdm-session-worker no 192
14. 2023年09月15日 05:00:35 yy localhost.localdomain /dev/tty1 /usr/libexec/gdm-session-worker yes 193
15. 2023年09月15日 05:01:17 yy ? /dev/pts/0 /usr/bin/sudo yes 198
16. 2023年09月15日 05:25:28 yy localhost.localdomain /dev/tty1 /usr/libexec/gdm-session-worker yes 219
17. 2023年09月15日 05:26:02 yy ? /dev/pts/0 /usr/bin/sudo no 224
18. 2023年09月15日 05:26:05 yy ? /dev/pts/0 /usr/bin/sudo yes 225
19. 2023年09月17日 22:51:08 yy ? ? /usr/lib/polkit-1/polkit-agent-helper-1 yes 266
20. 2023年09月17日 22:52:34 yy 192.168.171.1 ssh /usr/sbin/sshd yes 299
21. 2023年09月17日 23:16:01 yy ? /dev/pts/1 /usr/bin/sudo yes 313
22. 2023年09月17日 23:26:06 yy localhost.localdomain pts/1 /usr/lib/polkit-1/polkit-agent-helper-1 yes 332
23. 2023年09月20日 02:45:51 yy localhost.localdomain /dev/tty1 /usr/libexec/gdm-session-worker yes 380
24. 2023年09月20日 02:46:17 yy 192.168.171.1 ssh /usr/sbin/sshd yes 400
25. 2023年09月20日 02:48:57 yy ? /dev/pts/1 /usr/bin/sudo yes 415
26. 2023年09月20日 02:52:12 yy localhost.localdomain pts/1 /usr/lib/polkit-1/polkit-agent-helper-1 yes 434
27. 2023年09月20日 02:52:15 yy localhost.localdomain pts/1 /usr/lib/polkit-1/polkit-agent-helper-1 yes 436
28. 2023年09月20日 02:58:23 root localhost.localdomain pts/1 /usr/bin/su yes 470
其中no代表验证失败。yes代表验证成功。
在 CentOS8 系统上配置审计功能可以极大地提高系统的安全性和可靠性帮助我们更好地监控系统的操作记录并追踪系统日志及时发现可能的安全问题。
转换系统调用
系统调用是以数字类型的值来记录的。因为在不同的服务器架构之间这些值会有重叠。通过使用uname-m我们可以确定服务器架构并使用ausyscall来确定数字为188的系统调用代表了什么。
[rootlocalhost yy]# ausyscall x86_64 54
setsockopt
[rootlocalhost yy]# ausyscall x86_64 150
munlock
[rootlocalhost yy]# ausyscall x86_64 188
setxattr
[rootlocalhost yy]#审计Linux的进程
审计框架有一个名为autrace的工具。它使用了审计框架并增加了合适的规则来捕获信息并记录它们。收集到的信息可以使用ausearch来展示。
[rootlocalhost yy]# auditctl -D
No rules
[rootlocalhost yy]# autrace /bin/ls
Waiting to execute: /bin/ls
公共 视频 文档 音乐 iscsi-initiator-utils-6.2.1.4-8.git095f59c.el8.x86_64.rpm
模板 图片 下载 桌面 iscsi-initiator-utils-iscsiuio-6.2.1.4-8.git095f59c.el8.x86_64.rpm
Cleaning up...
Trace complete. You can locate the records with ausearch -i -p 13141
[rootlocalhost yy]# ausearch -i -p 13141
按照用户来审计文件访问
审计框架可以用于监控系统调用包括对文件的访问。如果你希望知道一个特定的用户ID访问了什么文件可使用如下规则
[rootlocalhost yy]# auditctl -a exit,always -F archx86_64 -S open -F auid1001其中-F archx86_64定义了使用什么架构uname-m来监控正确的系统调用一些系统调用在不同的架构之间是不同的-S open定义选择“open”系统调用-F auid80定义相关的用户ID。
扩展知识
unhide使用如下的6种技术来审计隐藏进程 ·对比/proc和/bin/ps命令的输出。 ·对比来自/bin/ps命令输出的信息和遍历procfs获得信息。 ·对比来自/bin/ps命令输出的信息和系统调用syscall获得的信息系统调用扫描。 ·全部PID空间的占用PID暴力破解。 ·逆向搜索以验证ps命令看到的所有线程也是被内核所见到的。 ·快速对比/bin/ps命令的输出、/proc分析的结果、遍历procfs的结果这三者。使用如下的命令安装unhide 需要下载编译安装
使用如下的命令进行暴力PID检测以发现隐藏进程
./unhide-linux brute使用如下的命令进行proc分析以发现隐藏进程
./unhide-linux procall、lsoflist open files是Linux系统中强大的工具它用于列出系统中打开的文件包括普通文件、网络套接字等。因此它也常常被用于审计。