audit可以监听kill事件,找到进程被杀掉的罪魁祸首

Linux 审计系统:audit

Audit does not provide additional security to your system; rather, it can be used to discover violations of security policies used on your system. These violations can further be prevented by additional security measures such as SELinux.

The Linux Audit system provides a way to track security-relevant information on your system. Based on pre-configured rules, Audit generates log entries to record as much information about the events that are happening on your system as possible. This information is crucial for mission-critical environments to determine the violator of the security policy and the actions they performed.

关于系统的更多内容,可参考 redhat 管理员手册。

安装很简单:sudo apt install auditd

启动服务并查看状态: systemctl enable auditd.service; systemctl restart auditd.service

然后通过auditctrl添加规则: auditctl -a exit,always -F arch=b64 -S kill -F a1=9

启动然后kill掉Python程序; 查看日志,即可发现kill发起的程序和用户;

sudo ausearch -sc kill

日志如下:

time->Thu Feb 24 04:00:08 2022

type=PROCTITLE msg=audit(1645675208.403:201): proctitle="htop"

type=OBJ_PID msg=audit(1645675208.403:201): opid=40099 oauid=1016 ouid=1016 oses=12951 obj==unconfined ocomm="nvtop"

type=SYSCALL msg=audit(1645675208.403:201): arch=c000003e syscall=62 success=yes exit=0 a0=9ca3 a1=9 a2=c1 a3=8 items=0 ppid=45939 pid=40129 auid=1016 uid=1016 gid=1016 euid=1016 suid=1016 fsuid=1016 egid=1016 sgid=1016 fsgid=1016 tty=pts4 ses=18035 comm="htop" exe="/usr/bin/htop" subj==unconfined key=(null)

type=OBJ_PID 那一列是杀进程的命令(ocomm="nvtop" )

type=SYSCALL 那一列是kill的调用者详情和系统命名码(syscall=62 )

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值