Auditd : Search Logs with ausearch2022/03/11 |
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 -5 /var/log/audit/audit.log type=SERVICE_STOP msg=audit(1646976126.110:375): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=user@1000 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'UID="root" AUID="unset" type=SERVICE_STOP msg=audit(1646976126.124:376): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=user-runtime-dir@1000 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'UID="root" AUID="unset" type=SERVICE_STOP msg=audit(1646976150.679:377): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-hostnamed comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'UID="root" AUID="unset" type=BPF msg=audit(1646976150.712:378): prog-id=79 op=UNLOAD type=BPF msg=audit(1646976150.712:379): prog-id=78 op=UNLOAD |
[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(11/25/2021 18:26:50.936:87) : pid=884 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(11/26/2021 01:22:54.878:79) : pid=854 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(12/07/2021 22:31:29.947:82) : pid=861 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(12/07/2021 22:36:31.962:68) : pid=849 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 10 23:21:54 2022 type=USER_AUTH msg=audit(1646976114.048:341): pid=3246 uid=1000 auid=1000 ses=8 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 10 23:21:54 2022 type=USER_ACCT msg=audit(1646976114.081:342): pid=3246 uid=1000 auid=1000 ses=8 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 10 23:21:54 2022 type=USER_CMD msg=audit(1646976114.081:343): pid=3246 uid=1000 auid=1000 ses=8 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='cwd="/home/cent" cmd=636174202F6574632F736861646F77 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 Mar 10 23:25:15 2022 type=USER_AUTH msg=audit(1646976315.473:406): pid=3329 uid=1000 auid=1000 ses=12 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:authentication grantors=? acct="root" exe="/usr/bin/su" hostname=dlp.srv.world addr=? terminal=/dev/ttyS0 res=failed' ---- time->Thu Mar 10 23:25:26 2022 type=USER_AUTH msg=audit(1646976326.418:410): pid=3333 uid=1000 auid=1000 ses=12 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:authentication grantors=? acct="cent" exe="/usr/bin/sudo" hostname=dlp.srv.world addr=? terminal=/dev/ttyS0 res=failed' ---- time->Thu Mar 10 23:25:30 2022 type=USER_AUTH msg=audit(1646976330.290:411): pid=3333 uid=1000 auid=1000 ses=12 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:authentication grantors=? acct="cent" exe="/usr/bin/sudo" hostname=dlp.srv.world addr=? terminal=/dev/ttyS0 res=failed' ..... ..... # search logs by a user who has login userID 1000 from 2022/3/10 to 2022/3/11 [root@dlp ~]# ausearch --start 03/10/2022 --end 03/11/2022 -ul 1000 ---- time->Thu Mar 10 23:25:36 2022 type=CRED_DISP msg=audit(1646976336.981:414): pid=3293 uid=0 auid=1000 ses=12 subj=system_u:system_r:local_login_t:s0-s0:c0.c1023 msg='op=PAM:setcred grantors=pam_localuser,pam_unix acct="cent" exe="/usr/bin/login" hostname=dlp.srv.world addr=? terminal=/dev/ttyS0 res=success' ---- time->Thu Mar 10 23:25:36 2022 type=USER_END msg=audit(1646976336.983:415): pid=3293 uid=0 auid=1000 ses=12 subj=system_u:system_r:local_login_t:s0-s0:c0.c1023 msg='op=PAM:session_close grantors=pam_selinux,pam_loginuid,pam_selinux,pam_namespace,pam_keyinit,pam_keyinit,pam_limits,pam_systemd,pam_unix,pam_umask,pam_lastlog acct="cent" exe="/usr/bin/login" hostname=dlp.srv.world addr=? terminal=/dev/ttyS0 res=success' ..... ..... |
Sponsored Link |
|