Auditing commands run by a user
With this PoC, you can create specific rules to alert about commands run by the user. To do this, you must first enable Audit logging to capture and log execve system calls so the Wazuh agent can read these logs.
Check our documentation to learn more about the Linux auditd system.
Configuration
Configure your environment as follows to test the PoC.
Run the following command to check that the Linux Auditing System is installed and running on your Ubuntu 20 endpoint.
# systemctl status auditd.service
If auditd is not installed, you can install it with the following command:
# apt-get install -y auditd
Check that
/var/ossec/etc/ossec.conf
in your Ubuntu 20 endpoint is configured for the agent to read theaudit.log
file.<localfile> <log_format>audit</log_format> <location>/var/log/audit/audit.log</location> </localfile>
Restart the Wazuh agent to apply the changes.
# systemctl restart wazuh-agent
Get your current euid in the Ubuntu 20 endpoint. This is needed to monitor the actions of your user. Root user monitoring is not recommended for this test, as it can be quite noisy.
# echo $EUID
Create the rules for your user at
/etc/audit/rules.d/wazuh.rules
. Make sure to replace<your_user_id>
with your currenteuid
.-a exit,always -F euid=<your_user_id> -F arch=b32 -S execve -k audit-wazuh-c -a exit,always -F euid=<your_user_id> -F arch=b64 -S execve -k audit-wazuh-c
Optionally, you can delete old rules.
# auditctl -D
Load rules from file.
# auditctl -R /etc/audit/rules.d/wazuh.rules