Detecting suspicious binaries

Wazuh has anomaly and malware detection capabilities that detect suspicious binaries on an endpoint. Binaries are executable code written to perform automated tasks. Malicious actors use them mostly to carry out exploitation to avoid being detected.

In this use case, we demonstrate how the Wazuh rootcheck module can detect a trojan system binary on an Ubuntu endpoint. You perform the exploit by replacing the content of a legitimate binary with malicious code to trick the endpoint into running it as the legitimate binary.

The Wazuh rootcheck module also checks for hidden processes, ports, and files.




Ubuntu 22.04

The Wazuh rootcheck module detects the execution of a suspicious binary on this endpoint.


Take the following steps on the Ubuntu endpoint to enable the Wazuh rootcheck module and perform anomaly and malware detection.

By default, the Wazuh rootcheck module is enabled in the Wazuh agent configuration file. Check the <rootcheck> block in the /var/ossec/etc/ossec.conf configuration file of the monitored endpoint and make sure that it has the configuration below:


    <!-- Line for trojans detection -->


    <!-- Frequency that rootcheck is executed - every 12 hours -->

The rootcheck section explains the options in the rootcheck module.

Attack emulation

  1. Create a copy of the original system binary:

    $ sudo cp -p /usr/bin/w /usr/bin/w.copy
  2. Replace the original system binary /usr/bin/w with the following shell script:

    $ sudo tee /usr/bin/w << EOF
    echo "`date` this is evil" > /tmp/trojan_created_file
    echo 'test for /usr/bin/w trojaned file' >> /tmp/trojan_created_file
    #Now running original binary
  3. The rootcheck scan runs every 12 hours by default. Force a scan by restarting the Wazuh agent to see the relevant alert:

    $ sudo systemctl restart wazuh-agent

Visualize the alerts

You can visualize the alert data in the Wazuh dashboard. To do this, go to the Threat Hunting module and add the filters in the search bar to query the alerts.

  • location:rootcheck AND AND data.title:Trojaned version of file detected.

  • Additionally, using the Filter by type search field, apply the full_log filter.