標籤:
Background:
linux作業系統 如果發現一個進程不明被殺掉 而且也不知道被哪一個進程殺掉的,如果我們不知道 可以通過
Configuration:
1). root登入並開啟audit.rules檔案,位於/etc/audit/檔案夾下。
添加以下內容:
-a always,exit -F arch=b64 -S kill -k *wg934*
Note: 如果壞境是32位請 改為 -F arch=b32
*wg934* 只是後面的標記, 方面查看用的 沒特別意思
2). 重啟aduitd 服務
service auditd restart
3). 查看一個進程的進程號並記錄下來, 當下次這個進程被殺掉後開啟linux audit 日誌查看在檔案夾/var/log/audit下。
Test and Result:
1). sleep 一個長時間進程 22303之後kill掉
[[email protected] audit]#
[[email protected] audit]# sleep 9999999&
[1] 22303
[[email protected] audit]# kill -9 22303
[1]+ Killed sleep 9999999
[[email protected] audit]#
linux裡面可以看到: opid = objective pid 被殺的目標PID
?其中syscall=62 為什麼是kill 還沒弄清楚
type=SYSCALL msg=audit(1420632793.383:1410163): arch=c000003e syscall=62 success=yes exit=0 a0=571f a1=9 a2=0 a3=0 items=0 ppid=23986 pid=24009 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts4 ses=77492 comm="bash" exe="/bin/bash" key="*wg934*"
type=OBJ_PID msg=audit(1420632793.383:1410163): opid=22303 oauid=0 ouid=0 oses=77492 obj=<NULL> ocomm="sleep"
使用指令碼去kill 一個進程同樣會被記錄下來:
[email protected] audit]# sleep 999999 &
[1] 714
[[email protected] audit]# python 1.py &
[2] 1390
[[email protected] audit]# vim audit.log
[1]- Killed sleep 999999
1.py
import os import timepid=‘714‘command=‘kill -9‘ + pidos.popen(command)time.sleep(100000000)
type=SYSCALL msg=audit(1420635463.926:1419473): arch=c000003e syscall=62 success=yes exit=0 a0=2ca a1=9 a2=0 a3=0 items=0 ppid=1390 pid=1391 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts4 ses=77492 comm="sh" exe="/bin/bash" key="*wg934*"
type=OBJ_PID msg=audit(1420635463.926:1419473): opid=714 oauid=0 ouid=0 oses=77492 obj=<NULL> ocomm="sleep"
Linux Audit log