一.audit簡介node
請參閱redhat說明文檔: https://people.redhat.com/sgrubb/audit/ubuntu
二.使用auditbash
1.確認系統安裝了audit服務,ubuntu執行如下命令安裝ui
~# sudo apt-get install auditd
2.啓動audit服務spa
systemctl restart auditd
實驗rest
監控/mnt目錄日誌
auditctl -w /mnt -p rwxa -k MNT //-w 制定監控的文件,-p制定屬性rwxa ,-k 指定標識符,隨意
當咱們操做/mnt是會產生審計日誌code
ls /mnt; touch /mnt/file
ausearch -i -k MNT //查看監控日誌
結果以下blog
root@localhost:~# ausearch -i -k MNT ---- type=CONFIG_CHANGE msg=audit(2019年08月21日 21:45:48.049:42) : auid=xiao ses=1 op="add_rule" key=MNT list=exit res=yes ---- type=PROCTITLE msg=audit(2019年08月21日 21:45:57.445:43) : proctitle=ls --color=auto /mnt/ type=PATH msg=audit(2019年08月21日 21:45:57.445:43) : item=0 name=/mnt/ inode=1569793 dev=fc:00 mode=dir,755 ouid=root ogid=root rdev=00:00 nametype=NORMAL type=CWD msg=audit(2019年08月21日 21:45:57.445:43) : cwd=/root type=SYSCALL msg=audit(2019年08月21日 21:45:57.445:43) : arch=x86_64 syscall=open success=yes exit=3 a0=0xcbf5e0 a1=O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC a2=0x0 a3=0x502 items=1 ppid=3544 pid=4611 auid=xiao uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=pts4 ses=1 comm=ls exe=/bin/ls key=MNT ---- type=PROCTITLE msg=audit(2019年08月21日 21:47:29.402:47) : proctitle=touch /mnt/file type=PATH msg=audit(2019年08月21日 21:47:29.402:47) : item=1 name=/mnt/file inode=1577707 dev=fc:00 mode=file,644 ouid=root ogid=root rdev=00:00 nametype=CREATE type=PATH msg=audit(2019年08月21日 21:47:29.402:47) : item=0 name=/mnt/ inode=1569793 dev=fc:00 mode=dir,755 ouid=root ogid=root rdev=00:00 nametype=PARENT type=CWD msg=audit(2019年08月21日 21:47:29.402:47) : cwd=/root type=SYSCALL msg=audit(2019年08月21日 21:47:29.402:47) : arch=x86_64 syscall=open success=yes exit=3 a0=0x7ffcfb32c8fa a1=O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK a2=0666 a3=0x69d items=2 ppid=3544 pid=4631 auid=xiao uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=pts4 ses=1 comm=touch exe=/bin/touch key=MNT root@localhost:~#
日誌保存在文檔
/var/log/audit/audit.log
注意點:
(1)這是臨時添加的,永久設置修改配置文件
/etc/audit/rules.d/audit.rules 子配置目錄 /etc/audit/audit.rules 主配置目錄
完成後重啓audit服務
(2)bash後臨時添加失敗或者寫到配置文件後,重啓audit服務失敗
須要解固,刪除修改配置文件中的-e 選項