Skip to content

auditd useful commands

  1. #Adding/Modifying Rules
  2. #    Watch for files
  3. auditctl –w /etc/yum.conf -p wa  -k yum_watch
  4. auditctl –w /usr/bin/nmap -p x   -k nmap_watch
  5. auditctl –w /etc/shadow   -p rwa -k shadow_watch
  6. #    Remove a rule using auditctl
  7. auditctl -W /etc/shadow -p rwa -k shadow_watch
  8. #    Watching for ptrace system call
  9. auditctl -a entry,always -F arch=b64 -S ptrace -k info_scan
  10. #    Suppress 32bit clock_gettime & fstat64 system calls
  11. -a entry,never -F arch=b32 -S clock_gettime -k clock_gettime
  12. -a entry,never -F arch=b32 -S fstat64 -k fstat64
  13. #    Audit files opened by a specific user
  14. auditctl -a exit,always -S open -F auid=2010
  15. auditctl -a exit,always -F arch=b64 -F auid=2010  -F uid=2010 -F path=/etc/hosts -S open
  16. #    Audit unsuccessful attempts for multiple system calls where user id is greater than or equal to 500
  17. auditctl -a always,exit -F arch=b32 -S creat -S open -S openat -S truncate -S ftruncate -F exit=-EACCES -F auid>=500
  18. auditctl -a always,exit -F arch=b32 -S creat -S open -S openat -S truncate -S ftruncate -F exit=-EPERM -F auid>=500
  19. #Reporting/Searching
  20. #    List all rules
  21. auditctl -l
  22. #    List status
  23. auditctl -s
  24. #    Report on watched files. Date format is local to the server’s date format.
  25. aureport -f
  26. aureport -f –start 02/18/10 17:42:00
  27. aureport -f –start 02/18/10 17:00:00 –end 02/18/10 17:10:00
  28. aureport -f -ts this-week
  29. aureport -f -ts today
  30. #    Search by system call
  31. ausearch -sc ptrace -i
  32. #    Search for user id or effective user id
  33. ausearch -ui 2010
  34. ausearch -ue 2010
  35. #    Lists all auth attempts and their result
  36. aureport -au
  37. #    List just logins
  38. aureport -l
  39. #    List account modification attempts.
  40. aureport -m
  41. #    Search events where success value is no, User id is 500 and key is nmap_watch
  42. ausearch -sv no -ua 500 -k nmap_watch
  43. #    Search by executable
  44. ausearch -x /usr/bin/nmap
  45. #    Search by terminal
  46. ausearch -tm pts/0
  47. #    Search by daemon. Stuff like cron log terminal as the daemon name
  48. ausearch -tm cron