I'd like to use the auditd daemon to log whatever is run as or by root on our servers. To that effect, I added the following lines to /etc/audit/audit.rules
:
# Log all commands run as (or by) root
-a exit,always -F arch=b64 -F euid=0 -S execve -k exec_root
-a exit,always -F arch=b32 -F euid=0 -S execve -k exec_root
Works well. Now I'd like to ausearch
(8) to return only the actual commands, that have been run. It returns too much for me…
# ausearch -k exec_root -c ausearch -m execve
…
----
time->Fri Jun 17 13:43:08 2016
type=PROCTITLE msg=audit(1466163788.236:26612): proctitle=6175736561726368002D6B00657865635F726F6F74002D63006175736561726368002D6D00657865637665
type=PATH msg=audit(1466163788.236:26612): item=1 name="/lib64/ld-linux-x86-64.so.2" inode=687763 dev=fc:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL
type=PATH msg=audit(1466163788.236:26612): item=0 name="/sbin/ausearch" inode=407310 dev=fc:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL
type=CWD msg=audit(1466163788.236:26612): cwd="/home/ask"
type=EXECVE msg=audit(1466163788.236:26612): argc=7 a0="ausearch" a1="-k" a2="exec_root" a3="-c" a4="ausearch" a5="-m" a6="execve"
type=SYSCALL msg=audit(1466163788.236:26612): arch=c000003e syscall=59 success=yes exit=0 a0=559e5b5c5198 a1=559e5b5cb3f8 a2=559e5b5bfba0 a3=559e5b5db000 items=2 ppid=5651 pid=5652 auid=1000 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts3 ses=1 comm="ausearch" exe="/sbin/ausearch" key="exec_root"
----
time->Fri Jun 17 13:50:29 2016
type=PROCTITLE msg=audit(1466164229.888:31811): proctitle=6175736561726368002D6B00657865635F726F6F74002D63006175736561726368002D6D00657865637665
type=PATH msg=audit(1466164229.888:31811): item=1 name="/lib64/ld-linux-x86-64.so.2" inode=687763 dev=fc:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL
type=PATH msg=audit(1466164229.888:31811): item=0 name="/sbin/ausearch" inode=407310 dev=fc:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL
type=CWD msg=audit(1466164229.888:31811): cwd="/home/ask"
type=EXECVE msg=audit(1466164229.888:31811): argc=7 a0="ausearch" a1="-k" a2="exec_root" a3="-c" a4="ausearch" a5="-m" a6="execve"
type=SYSCALL msg=audit(1466164229.888:31811): arch=c000003e syscall=59 success=yes exit=0 a0=55cc1c3a0198 a1=55cc1c3a63f8 a2=55cc1c39aba0 a3=55cc1c3b6000 items=2 ppid=6163 pid=6164 auid=1000 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts3 ses=1 comm="ausearch" exe="/sbin/ausearch" key="exec_root"
I would like to ONLY get the type=EXECVE
lines, WITHOUT having to use grep
… ☺
But as you can see in the example above, adding -m execve
to the ausearch(8)
command didn' work. It also returned type=PROCTITLE
, type=PATH
etc.pp. lines.
What's the right way to go?
I'm on Ubuntu 16.04.
Thanks, Alexander