Linux Audit log

來源:互聯網
上載者:User

標籤:

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.