CentOS Stream 8
Sponsored Link

Auditd : Search Logs with ausearch2021/03/04

 
Some Audit rules are set by default like System Login, Modification of User Accounts, Sudo Actions and so on, there logs are recorded in [/var/log/audit/audit.log].
[1] The logs are text format, so it's possible to see logs directly.
[root@dlp ~]#
tail -3 /var/log/audit/audit.log

type=CRED_ACQ msg=audit(1614840570.142:137): pid=1759 uid=1000 auid=1000 ses=3 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:setcred grantors=pam_unix acct="root" exe="/usr/bin/su" hostname=node01.srv.world addr=? terminal=ttyS0 res=success'
type=USER_START msg=audit(1614840570.146:138): pid=1759 uid=1000 auid=1000 ses=3 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:session_open grantors=pam_keyinit,pam_keyinit,pam_limits,pam_systemd,pam_unix,pam_umask,pam_xauth acct="root" exe="/usr/bin/su" hostname=node01.srv.world addr=? terminal=ttyS0 res=success'
type=SERVICE_STOP msg=audit(1614840591.332:139): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=fprintd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
[2] Many logs are recorded in [audit.log] and they are complicated, so [ausearch] command is provided by Audit package to search specific logs.
# search USER_LOGIN related logs

[root@dlp ~]#
ausearch --message USER_LOGIN --interpret

----
type=USER_LOGIN msg=audit(02/18/2021 15:52:50.274:71) : pid=1186 uid=root auid=root ses=1 subj=system_u:system_r:local_login_t:s0-s0:c0.c1023 msg='op=login id=root exe=/usr/bin/login hostname=localhost.localdomain addr=? terminal=ttyS0 res=success'
----
type=USER_LOGIN msg=audit(02/24/2021 14:21:48.796:65) : pid=1149 uid=root auid=root ses=1 subj=system_u:system_r:local_login_t:s0-s0:c0.c1023 msg='op=login id=root exe=/usr/bin/login hostname=localhost.localdomain addr=? terminal=ttyS0 res=success'
----
type=USER_LOGIN msg=audit(02/24/2021 14:33:50.176:91) : pid=1132 uid=root auid=root ses=1 subj=system_u:system_r:local_login_t:s0-s0:c0.c1023 msg='op=login id=root exe=/usr/bin/login hostname=localhost.localdomain addr=? terminal=ttyS0 res=success'
.....
.....

# search sudo actions by userID 1000

[root@dlp ~]#
ausearch -x sudo -ua 1000

----
time->Thu Mar  3 19:54:46 2021
type=USER_AUTH msg=audit(1614840886.112:133): pid=1939 uid=1000 auid=0 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:authentication grantors=pam_usertype,pam_localuser,pam_unix acct="cent" exe="/usr/bin/sudo" hostname=dlp.srv.world addr=? terminal=/dev/ttyS0 res=success'
----
time->Thu Mar  3 19:54:46 2021
type=USER_ACCT msg=audit(1614840886.115:134): pid=1939 uid=1000 auid=0 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:accounting grantors=pam_unix,pam_localuser acct="cent" exe="/usr/bin/sudo" hostname=dlp.srv.world addr=? terminal=/dev/ttyS0 res=success'
----
time->Thu Mar  3 19:54:46 2021
type=USER_CMD msg=audit(1614840886.116:135): pid=1939 uid=1000 auid=0 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='cwd="/home/cent" cmd="ls" exe="/usr/bin/sudo" terminal=ttyS0 res=success'
.....
.....

# search failure events on [dlp.srv.world]

[root@dlp ~]#
ausearch --host dlp.srv.world --success no

----
time->Thu Feb 25 16:33:00 2021
type=USER_END msg=audit(1614238380.105:215): pid=1152 uid=0 auid=0 ses=1 subj=system_u:system_r:local_login_t:s0-s0:c0.c1023 msg='op=PAM:session_close grantors=? acct="root" exe="/usr/bin/login" hostname=dlp.srv.world addr=? terminal=ttyS0 res=failed'
----
time->Tue Mar  2 15:29:14 2021
type=USER_END msg=audit(1614666554.196:114): pid=1186 uid=0 auid=0 ses=1 subj=system_u:system_r:local_login_t:s0-s0:c0.c1023 msg='op=PAM:session_close grantors=? acct="root" exe="/usr/bin/login" hostname=dlp.srv.world addr=? terminal=ttyS0 res=failed'
.....
.....

# search logs by a user who has login userID 1000 from 2021/3/3 to 2021/3/4

[root@dlp ~]#
ausearch --start 03/03/2021 --end 03/04/2021 -ul 1000

----
time->Thu Mar  4 15:54:46 2021
type=USER_AUTH msg=audit(1614840886.112:133): pid=1939 uid=1000 auid=0 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:authentication grantors=pam_usertype,pam_localuser,pam_unix acct="cent" exe="/usr/bin/sudo" hostname=dlp.srv.world addr=? terminal=/dev/ttyS0 res=success'
----
time->Thu Mar  4 15:54:46 2021
type=USER_ACCT msg=audit(1614840886.115:134): pid=1939 uid=1000 auid=0 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:accounting grantors=pam_unix,pam_localuser acct="cent" exe="/usr/bin/sudo" hostname=dlp.srv.world addr=? terminal=/dev/ttyS0 res=success'
.....
.....
Matched Content