<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jerichokecilsekali on Medium]]></title>
        <description><![CDATA[Stories by Jerichokecilsekali on Medium]]></description>
        <link>https://medium.com/@jerichokecilsekali?source=rss-f8b4df02e0ea------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*JRbxaxBqTEhqag-N</url>
            <title>Stories by Jerichokecilsekali on Medium</title>
            <link>https://medium.com/@jerichokecilsekali?source=rss-f8b4df02e0ea------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 18:39:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jerichokecilsekali/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Exploring the Power of Wazuh for Endpoint Security]]></title>
            <link>https://medium.com/@jerichokecilsekali/exploring-the-power-of-wazuh-for-endpoint-security-88cca4bb6f4a?source=rss-f8b4df02e0ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/88cca4bb6f4a</guid>
            <category><![CDATA[wazuh-active-response]]></category>
            <category><![CDATA[wazuh-agent]]></category>
            <category><![CDATA[wazuh]]></category>
            <dc:creator><![CDATA[Jerichokecilsekali]]></dc:creator>
            <pubDate>Sat, 08 Jun 2024 09:10:28 GMT</pubDate>
            <atom:updated>2024-06-08T09:14:03.552Z</atom:updated>
            <content:encoded><![CDATA[<h3>Table of Contents</h3><p>– <a href="#d86c">What is Wazuh?</a><br>– <a href="#b398">Installing Wazuh Indexer, Server, and Dashboard</a><br>– <a href="#8572">Installing Wazuh Agents (Linux &amp; Windows)</a><br>– <a href="#bb83">Commons Errors Fix on Agents</a><br>– <a href="#a7e8">Detecting Bruteforce Attack</a><br>– <a href="#ed4a">Detecting Malware and Removing Malware (VirusTotal)</a><br>– <a href="#fec4">Detecting a SQL injection attack</a><br>– <a href="#978d">Vulnerability Detection</a><br>– <a href="#0b8a">Conclusion</a><br>– <a href="#f2f1">Reference</a></p><h3>What is Wazuh?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DUM04j0co5E0VMUt.png" /></figure><p>Wazuh is a comprehensive security platform designed to protect workloads across various environments, including on-premises, virtualized, containerized, and cloud-based setups. It is used by thousands of organizations worldwide to safeguard their data assets against a myriad of security threats. With its unified approach to XDR and SIEM, Wazuh offers advanced threat detection, incident response, and compliance management, making it an essential tool for modern cybersecurity operations.</p><h3>Installing Wazuh Indexer, Server, and Dashboard</h3><p>Before we dive into the installation process, let’s understand what each component — Wazuh Indexer, Server, and Dashboard — does in the Wazuh architecture:</p><ul><li><strong>Wazuh Indexer</strong>:<br>The Wazuh Indexer is responsible for indexing and storing data collected from various sources such as logs, events, and alerts. It acts as a repository for all the security-related information gathered by Wazuh agents deployed across your infrastructure. The Indexer efficiently organizes and makes this data searchable for further analysis and correlation.</li><li><strong>Wazuh Server:</strong><br>The Wazuh Server serves as the core component of the Wazuh architecture. It coordinates communication between agents and the central manager, manages configurations, and orchestrates tasks such as agent registration, rule distribution, and alert processing. The Server aggregates data from multiple agents, applies correlation rules, and generates alerts based on predefined criteria, helping to identify security incidents and potential threats.</li><li><strong>Wazuh Dashboard:</strong><br>The Wazuh Dashboard provides a graphical user interface (GUI) for monitoring and managing the security status of your environment. It offers visualizations, dashboards, and reporting capabilities to help security teams gain insights into the overall security posture, view real-time alerts, investigate incidents, and perform forensic analysis. The Dashboard simplifies the process of interpreting complex security data and enhances operational visibility across your infrastructure.</li></ul><p>Now, armed with this knowledge, you can proceed with the installation of Wazuh knowing the roles and functions of each component in the system.</p><p>To install Wazuh you only need to run the following script :</p><pre>curl -sO https://packages.wazuh.com/4.7/wazuh-install.sh &amp;&amp; sudo bash ./wazuh-install.sh -a</pre><p>After the installation assistant completes its tasks, it will display the access credentials and confirm the successful installation :</p><pre>INFO: You can access the web interface at https://&lt;wazuh-dashboard-ip&gt;<br>    User: admin<br>    Password: &lt;ADMIN_PASSWORD&gt;<br>INFO: Installation finished.</pre><p>Now, you have Wazuh installed and configured. To access the Wazuh web interface, navigate to https://&lt;wazuh-dashboard-ip&gt; and log in using the above credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eWQ5ZJtqm7iLwX3B9cNUlA.png" /><figcaption>Wazuh Dashboard</figcaption></figure><h3>Installing Wazuh Agent</h3><p>The Wazuh agent is multi-platform and runs on the endpoints that the user wants to monitor. It communicates with the Wazuh server, sending data in near real-time through an encrypted and authenticated channel.</p><p>You can add new agent through Wazuh Dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*UVnpAevfyDEb1kd4a9HH3g.png" /><figcaption>Deploying New Agent</figcaption></figure><h4>Linux Agent</h4><p>Run the following commands to download and install the agent:</p><pre>wget https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_4.7.5-1_amd64.deb &amp;&amp; sudo WAZUH_MANAGER=&#39;SERVER_ADDRESS&#39; WAZUH_AGENT_GROUP=&#39;GROUP_NAME&#39; WAZUH_AGENT_NAME=&#39;AGENT_NAME&#39; dpkg -i ./wazuh-agent_4.7.5-1_amd64.deb</pre><p>Customize the server address, group_name, and agent_name according to your needs. After succesfully installing the agent, you need to start the agent using this command:</p><pre>sudo systemctl daemon-reload<br>sudo systemctl enable wazuh-agent<br>sudo systemctl start wazuh-agent</pre><p>Note: If you use WSL as the agent, you must enable <strong><em>systemd </em></strong>on WSL boot by add the two line below</p><pre>[boot]<br>systemd=true</pre><p>on <strong><em>/etc/wsl.conf</em></strong>.</p><h4>Windows Agent</h4><p>Different from the previous one. To install Windows Agent, you need to run the following commands on <strong><em>PowerShell 3.0</em></strong> or above to download and install the agent:</p><pre>Invoke-WebRequest -Uri https://packages.wazuh.com/4.x/windows/wazuh-agent-4.7.5-1.msi -OutFile ${env.tmp}\wazuh-agent; msiexec.exe /i ${env.tmp}\wazuh-agent /q WAZUH_MANAGER=&#39;SERVER_ADDRESS&#39; WAZUH_AGENT_GROUP=&#39;default&#39; WAZUH_AGENT_NAME=&#39;AGENT_NAME&#39; WAZUH_REGISTRATION_SERVER=&#39;SERVER_ADDRESS&#39;</pre><p>Then start the agent with:</p><pre>NET START WazuhSvc</pre><p>After finished installing both agents, you can see both active agents on the Wazuh Dashboard in the <strong>Agents </strong>menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bv_apQ9188aBkBtR0f0wIg.png" /><figcaption>Both agents are active</figcaption></figure><h4>Commons Errors Fix on Agents</h4><p>In some cases, the service agent is already running but does not appear on the dashboard wazuh. This case can usually be solved by running the <strong>linux </strong>command on agent:</p><pre>ufw allow 1514 1515 55000</pre><p>The above command will allow traffic coming to ports 1514, 1515, and 55000 through your firewall. Port 1514 is for the agent connection service, 1515 is for the agent registration service, and 55000 is for the API server.</p><p>If your agents is an Windows. You can add <strong><em>inbound rules </em></strong>in your Windows Defender Firewall settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RIYCVhD3S7_ema00iG8DWw.png" /><figcaption>Add Inbound Rule in Windows</figcaption></figure><h3>Detecting a brute-force attack</h3><p>To detect a brute-force attack on the SSH Wazuh agent, you can employ various techniques and monitoring tools. In this example, we will use Hydra, a popular tool for performing brute-force attacks, to simulate the attack. Hydra is capable of testing a large number of password combinations against a target, making it an ideal tool for this demonstration.</p><p>First, ensure you have Hydra installed on your attacking machine. You can install it using the following command:</p><pre>sudo apt-get install hydra</pre><p>Next, configure Hydra to target the SSH service on the Wazuh agent. For instance, you might use a command like:</p><pre>hydra -l &lt;username&gt; -P &lt;password_list&gt; ssh://&lt;target_ip&gt;</pre><p>Replace &lt;username&gt; with the SSH username, &lt;password_list&gt; with the path to your password list file, and &lt;target_ip&gt; with the IP address of the Linux Wazuh agent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PK9t7QKYBKs-P8C4PyduVA.png" /></figure><p>Wazuh continuously monitors the authentication logs for failed login attempts. When it detects multiple failed attempts, it generates alerts. These alerts can be viewed in the Wazuh dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VpwNZdwK0KRpXY3HBz91lA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l_zJCnGLLbUOwc6B2rQwRw.png" /><figcaption>Wazuh Agent’s Security Events</figcaption></figure><p>When Wazuh detects the brute-force attack, you should see an alert similar to the following by clicking one of the security event.</p><pre>{<br>&quot;agent&quot;: {<br>    &quot;ip&quot;: &quot;172.23.114.31&quot;,<br>    &quot;name&quot;: &quot;LinuxAgent&quot;,<br>    &quot;id&quot;: &quot;002&quot;<br>  },<br>  &quot;data&quot;: {<br>    &quot;srcip&quot;: &quot;172.23.112.1&quot;,<br>    &quot;dstuser&quot;: &quot;jeri&quot;,<br>    &quot;srcport&quot;: &quot;56496&quot;<br>  },<br>  &quot;rule&quot;: {<br>    &quot;mail&quot;: false,<br>    &quot;level&quot;: 10,<br>    &quot;hipaa&quot;: [<br>      &quot;164.312.b&quot;<br>    ],<br>    &quot;pci_dss&quot;: [<br>      &quot;11.4&quot;,<br>      &quot;10.2.4&quot;,<br>      &quot;10.2.5&quot;<br>    ],<br>    &quot;tsc&quot;: [<br>      &quot;CC6.1&quot;,<br>      &quot;CC6.8&quot;,<br>      &quot;CC7.2&quot;,<br>      &quot;CC7.3&quot;<br>    ],<br>    &quot;description&quot;: &quot;sshd: brute force trying to get access to the system. Authentication failed.&quot;,<br>    &quot;groups&quot;: [<br>      &quot;syslog&quot;,<br>      &quot;sshd&quot;,<br>      &quot;authentication_failures&quot;<br>    ],<br>    &quot;nist_800_53&quot;: [<br>      &quot;SI.4&quot;,<br>      &quot;AU.14&quot;,<br>      &quot;AC.7&quot;<br>    ],<br>    &quot;frequency&quot;: 8,<br>    &quot;gdpr&quot;: [<br>      &quot;IV_35.7.d&quot;,<br>      &quot;IV_32.2&quot;<br>    ],<br>    &quot;firedtimes&quot;: 1,<br>    &quot;mitre&quot;: {<br>      &quot;technique&quot;: [<br>        &quot;Brute Force&quot;<br>      ],<br>      &quot;id&quot;: [<br>        &quot;T1110&quot;<br>      ],<br>      &quot;tactic&quot;: [<br>        &quot;Credential Access&quot;<br>      ]<br>    },<br>    &quot;id&quot;: &quot;5763&quot;<br>  },<br>  &quot;full_log&quot;: &quot;Jun  8 08:02:16 LAPTOP-T0B5R7HM sshd[73676]: Failed password for jeri from 172.23.112.1 port 56496 ssh2&quot;,<br>  &quot;id&quot;: &quot;1717808536.1686326&quot;,<br>  &quot;timestamp&quot;: &quot;2024-06-08T01:02:16.875+0000&quot;,<br>  &quot;predecoder&quot;: {<br>    &quot;hostname&quot;: &quot;LAPTOP-T0B5R7HM&quot;,<br>    &quot;program_name&quot;: &quot;sshd&quot;,<br>    &quot;timestamp&quot;: &quot;Jun  8 08:02:16&quot;<br>  },<br>  &quot;previous_output&quot;: &quot;Jun  8 08:02:16 LAPTOP-T0B5R7HM sshd[73680]: Failed password for jeri from 172.23.112.1 port 56500 ssh2\nJun  8 08:02:16 LAPTOP-T0B5R7HM sshd[73682]: Failed password for jeri from 172.23.112.1 port 56502 ssh2\nJun  8 08:02:16 LAPTOP-T0B5R7HM sshd[73679]: Failed password for jeri from 172.23.112.1 port 56499 ssh2\nJun  8 08:02:16 LAPTOP-T0B5R7HM sshd[73674]: Failed password for jeri from 172.23.112.1 port 56494 ssh2\nJun  8 08:02:16 LAPTOP-T0B5R7HM sshd[73686]: Failed password for jeri from 172.23.112.1 port 56507 ssh2\nJun  8 08:02:16 LAPTOP-T0B5R7HM sshd[73675]: Failed password for jeri from 172.23.112.1 port 56495 ssh2\nJun  8 08:02:16 LAPTOP-T0B5R7HM sshd[73673]: Failed password for jeri from 172.23.112.1 port 56493 ssh2&quot;,<br>  &quot;manager&quot;: {<br>    &quot;name&quot;: &quot;UbuntuServer&quot;<br>  },<br>  &quot;decoder&quot;: {<br>    &quot;parent&quot;: &quot;sshd&quot;,<br>    &quot;name&quot;: &quot;sshd&quot;<br>  },<br>  &quot;input&quot;: {<br>    &quot;type&quot;: &quot;log&quot;<br>  },<br>  &quot;@timestamp&quot;: &quot;2024-06-08T01:02:16.875Z&quot;,<br>  &quot;location&quot;: &quot;/var/log/auth.log&quot;,<br>  &quot;_id&quot;: &quot;Urde9Y8BPR-malTLIe-4&quot;<br>}</pre><p>From that information you can get some informations about the attack such as the:<br>- <strong>Timestamp</strong>: Jun 8 08:02:16<br>- <strong>Target IP</strong>: 172.23.114.31<br>- <strong>Attacker IP</strong>: 172.23.112.1<br>- <strong>Description: </strong>sshd: brute force trying to get access to the system.</p><p>If with a bruteforce attack the attacker can get the ssh password, wazuh will detect it as a threat with level 12.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m3GdFPjZHOtecHXUpBzL6Q.png" /></figure><p>Similar to the Linux agent, you can run a bruteforce attack on the Windows agent with the following hydra command:</p><pre>hydra -l &lt;username&gt; -P &lt;password_list&gt; rdp://&lt;target_ip&gt;</pre><p>Replace &lt;username&gt; with the SSH username, &lt;password_list&gt; with the path to your password list file, and &lt;target_ip&gt; with the IP address of the Windows Wazuh agent.</p><p>In this case, you need Windows Pro edition on your Windows agent to enable RDP (Remote Desktop Protocol) on your machine.</p><h3>Detecting Malware and Removing Malware (VirusTotal)</h3><p>To enhance your security posture and automatically handle malicious files, you can integrate VirusTotal with Wazuh. This guide will walk you through configuring Wazuh to utilize VirusTotal for identifying threats and setting up an automated response to remove them.</p><p>First, search for the &lt;syscheck&gt; block in the Wazuh agent configuration file /var/ossec/etc/ossec.conf. Make sure that &lt;disabled&gt; is set to no. This enables the Wazuh FIM to monitor for directory changes.</p><p>In this case, i want to do a realtime checking on Downloads directory /home/jeri/Downloads so within the &lt;syscheck&gt; block on /var/ossec/etc/ossec.conf , add the following entry to monitor the directory.</p><pre>&lt;directories realtime=&quot;yes&quot;&gt;/home/jeri/Downloads&lt;/directories&gt;</pre><p>Then Install jq, a utility that processes JSON input from the active response script.</p><pre>sudo apt install jq</pre><p>After that, you need to make a simple shellscript to remove detected malicious files. Save the scirpt as/var/ossec/active-response/bin/remove-threat.prg</p><pre>#!/bin/bash<br>OCAL=`dirname $0`;<br>cd $LOCAL<br>cd ../<br>PWD=`pwd`<br>read INPUT_JSON<br>FILENAME=$(echo $INPUT_JSON | jq -r .parameters.alert.data.virustotal.source.file)<br>COMMAND=$(echo $INPUT_JSON | jq -r .command)<br>LOG_FILE=&quot;${PWD}/../logs/active-responses.log&quot;<br>#------------------------ Analyze command -------------------------#<br>if [ ${COMMAND} = &quot;add&quot; ]<br>then<br> # Send control message to execd<br> printf &#39;{&quot;version&quot;:1,&quot;origin&quot;:{&quot;name&quot;:&quot;remove-threat&quot;,&quot;module&quot;:&quot;active-response&quot;},&quot;command&quot;:&quot;check_keys&quot;, &quot;parameters&quot;:{&quot;keys&quot;:[]}}\n&#39;<br> read RESPONSE<br> COMMAND2=$(echo $RESPONSE | jq -r .command)<br> if [ ${COMMAND2} != &quot;continue&quot; ]<br> then<br>  echo &quot;`date &#39;+%Y/%m/%d %H:%M:%S&#39;` $0: $INPUT_JSON Remove threat active response aborted&quot; &gt;&gt; ${LOG_FILE}<br>  exit 0;<br> fi<br>fi<br># Removing file<br>rm -f $FILENAME<br>if [ $? -eq 0 ]; then<br> echo &quot;`date &#39;+%Y/%m/%d %H:%M:%S&#39;` $0: $INPUT_JSON Successfully removed threat&quot; &gt;&gt; ${LOG_FILE}<br>else<br> echo &quot;`date &#39;+%Y/%m/%d %H:%M:%S&#39;` $0: $INPUT_JSON Error removing threat&quot; &gt;&gt; ${LOG_FILE}<br>fi<br>exit 0;</pre><p>The script handles an active response by reading a JSON object that specifies a command and a file to act upon. If the command is to “add” a response, it verifies whether it can proceed by sending a control message and reading a response. If allowed, it attempts to delete the specified file and logs the result. The script’s flow ensures that all actions are logged for later review.</p><p>After that, change the script’s ownership and permissions with the following commands:</p><pre>sudo chmod 750 /var/ossec/active-response/bin/remove-threat.prg<br>sudo chown root:wazuh /var/ossec/active-response/bin/remove-threat.prg</pre><p>Then restart the wazuh-agent service with:</p><pre>sudo systemctl restart wazuh-agent</pre><p>After configuring the Wazuh agent, you also need to configure your Wazuh server. Configuring the Wazuh Server involves several essential steps to ensure effective monitoring and response to security events.</p><p>One crucial aspect is the addition of File Integrity Monitoring (FIM) rules to detect changes within specified directories. For instance, to monitor the /home/jeri/Downloads directory, specific rules need to be added to the /var/ossec/etc/rules/local_rules.xml. These rules define actions to be taken upon file modifications or additions within the directory.</p><pre>&lt;group name=&quot;syscheck,pci_dss_11.5,nist_800_53_SI.7,&quot;&gt;<br>    &lt;!-- Rules for Linux systems --&gt;<br>    &lt;rule id=&quot;100200&quot; level=&quot;7&quot;&gt;<br>        &lt;if_sid&gt;550&lt;/if_sid&gt;<br>        &lt;field name=&quot;file&quot;&gt;/home/jeri/Downloads&lt;/field&gt;<br>        &lt;description&gt;File modified in /home/jeri/Downloads directory.&lt;/description&gt;<br>    &lt;/rule&gt;<br>    &lt;rule id=&quot;100201&quot; level=&quot;7&quot;&gt;<br>        &lt;if_sid&gt;554&lt;/if_sid&gt;<br>        &lt;field name=&quot;file&quot;&gt;/home/jeri/Downloads&lt;/field&gt;<br>        &lt;description&gt;File added to /home/jeri/Downloads directory.&lt;/description&gt;<br>    &lt;/rule&gt;<br>&lt;/group&gt;</pre><p>To enable the VirusTotal integration in the Wazuh server, you can add the following configuration to the /var/ossec/etc/ossec.conf file:</p><pre>&lt;integration&gt;<br>  &lt;name&gt;virustotal&lt;/name&gt;<br>  &lt;api_key&gt;&lt;YOUR_VIRUS_TOTAL_API_KEY&gt;&lt;/api_key&gt;<br>  &lt;timeout&gt;120&lt;/timeout&gt;<br>  &lt;retries&gt;3&lt;/retries&gt;<br>  &lt;interval&gt;1800&lt;/interval&gt;<br>  &lt;request_limit&gt;4&lt;/request_limit&gt;<br>  &lt;priority&gt;10&lt;/priority&gt;<br>  &lt;enabled&gt;yes&lt;/enabled&gt;<br>  &lt;flags&gt;extended&lt;/flags&gt;<br>&lt;/integration&gt;<br><br>&lt;group name=&quot;virustotal&quot;&gt;<br>  &lt;rule id=&quot;100200&quot;&gt;<br>    &lt;match&gt;VirusTotal: The file &#39;[^&#39;]+&#39; has a score of (\d+)/[45]&lt;/match&gt;<br>    &lt;description&gt;File has a VirusTotal score of 4 or 5&lt;/description&gt;<br>  &lt;/rule&gt;<br>  &lt;rule id=&quot;100201&quot;&gt;<br>    &lt;match&gt;VirusTotal: The file &#39;[^&#39;]+&#39; has a score of (\d+)/[234]&lt;/match&gt;<br>    &lt;description&gt;File has a VirusTotal score of 2, 3, or 4&lt;/description&gt;<br>  &lt;/rule&gt;<br>&lt;/group&gt;</pre><p>This configuration will enable the integration with VirusTotal and configure it to trigger a query whenever any of the rules 100200 and 100201 are triggered.</p><p>Make sure to replace &lt;YOUR_VIRUS_TOTAL_API_KEY&gt; with your actual VirusTotal API key. You can find the API key on <a href="https://www.virustotal.com/gui/user/jjchoNC/apikey">https://www.virustotal.com/gui/user/USERNAME/apikey</a>. Replace the USERNAME by your virustotal account username.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WxtcRB6eFSuPXKtexp02Sg.png" /><figcaption>VirusTotal API Key</figcaption></figure><p>After that, add the following code blocks to the ossec.conf file located at /var/ossec/etc/ossec.conf on the Wazuh server. This configuration facilitates active response functionality and executes the remove-threat.prg script when a file is identified as malicious by VirusTotal:</p><pre>&lt;ossec_config&gt;<br>  &lt;command&gt;<br>    &lt;name&gt;remove-threat&lt;/name&gt;<br>    &lt;executable&gt;remove-threat.prg&lt;/executable&gt;<br>    &lt;timeout_allowed&gt;no&lt;/timeout_allowed&gt;<br>  &lt;/command&gt;<br><br>  &lt;active-response&gt;<br>    &lt;disabled&gt;no&lt;/disabled&gt;<br>    &lt;command&gt;remove-threat&lt;/command&gt;<br>    &lt;location&gt;local&lt;/location&gt;<br>    &lt;rules_id&gt;87105&lt;/rules_id&gt;<br>  &lt;/active-response&gt;<br>&lt;/ossec_config&gt;</pre><p>The next step is to add rules to the Wazuh server /var/ossec/etc/rules/local_rules.xml file to alert about the active response results. Here’s an example of how you might add rules to monitor and alert on active response modifications:</p><pre>&lt;group name=&quot;virustotal,&quot;&gt;<br>  &lt;rule id=&quot;100092&quot; level=&quot;12&quot;&gt;<br>    &lt;if_sid&gt;657&lt;/if_sid&gt;<br>    &lt;match&gt;Successfully removed threat&lt;/match&gt;<br>    &lt;description&gt;$(parameters.program) removed threat located at $(parameters.alert.data.virustotal.source.file)&lt;/description&gt;<br>  &lt;/rule&gt;<br><br>  &lt;rule id=&quot;100093&quot; level=&quot;12&quot;&gt;<br>    &lt;if_sid&gt;657&lt;/if_sid&gt;<br>    &lt;match&gt;Error removing threat&lt;/match&gt;<br>    &lt;description&gt;Error removing threat located at $(parameters.alert.data.virustotal.source.file)&lt;/description&gt;<br>  &lt;/rule&gt;<br>&lt;/group&gt;</pre><p>Once everything is ready, restart the wazuh-manager service with following command:</p><pre>sudo systemctl restart wazuh-manager</pre><p>To test whether wazuh has integrated with VirusTotal, you can run the following command to download sample malware:</p><pre>sudo curl -Lo /home/jeri/Downloads/eicar.com https://secure.eicar.org/eicar.com &amp;&amp; sudo ls -lah /home/jeri/Downloads/eicar.com</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x4sJsletGfCqX7iI3_M8RQ.png" /></figure><p>We can see that the newly downloaded malware file has been deleted and if we visit security event in the Wazuh Dashboard you can find malware alerts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yg56SEHS1IxD2wPgVpZIWQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-wj4wL1EniRwwFUaaJWlsQ.png" /></figure><p>If we look further into event security, we will find the detail informations about the security event.</p><pre>{<br>  &quot;agent&quot;: {<br>    &quot;ip&quot;: &quot;172.23.114.31&quot;,<br>    &quot;name&quot;: &quot;LinuxAgent&quot;,<br>    &quot;id&quot;: &quot;002&quot;<br>  },<br>  &quot;manager&quot;: {<br>    &quot;name&quot;: &quot;UbuntuServer&quot;<br>  },<br>  &quot;data&quot;: {<br>    &quot;integration&quot;: &quot;virustotal&quot;,<br>    &quot;virustotal&quot;: {<br>      &quot;sha1&quot;: &quot;3395856ce81f2b7382dee72602f798b642f14140&quot;,<br>      &quot;malicious&quot;: &quot;1&quot;,<br>      &quot;total&quot;: &quot;69&quot;,<br>      &quot;found&quot;: &quot;1&quot;,<br>      &quot;positives&quot;: &quot;66&quot;,<br>      &quot;source&quot;: {<br>        &quot;sha1&quot;: &quot;3395856ce81f2b7382dee72602f798b642f14140&quot;,<br>        &quot;file&quot;: &quot;/home/jeri/Downloads/eicar.com&quot;,<br>        &quot;alert_id&quot;: &quot;1717815969.5336500&quot;,<br>        &quot;md5&quot;: &quot;44d88612fea8a8f36de82e1278abb02f&quot;<br>      },<br>      &quot;permalink&quot;: &quot;https://www.virustotal.com/gui/file/275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f/detection/f-275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f-1717815436&quot;,<br>      &quot;scan_date&quot;: &quot;2024-06-08 02:57:16&quot;<br>    }<br>  },<br>  &quot;rule&quot;: {<br>    &quot;firedtimes&quot;: 1,<br>    &quot;mail&quot;: true,<br>    &quot;level&quot;: 12,<br>    &quot;pci_dss&quot;: [<br>      &quot;10.6.1&quot;,<br>      &quot;11.4&quot;<br>    ],<br>    &quot;description&quot;: &quot;VirusTotal: Alert - /home/jeri/Downloads/eicar.com - 66 engines detected this file&quot;,<br>    &quot;groups&quot;: [<br>      &quot;virustotal&quot;<br>    ],<br>    &quot;mitre&quot;: {<br>      &quot;technique&quot;: [<br>        &quot;Exploitation for Client Execution&quot;<br>      ],<br>      &quot;id&quot;: [<br>        &quot;T1203&quot;<br>      ],<br>      &quot;tactic&quot;: [<br>        &quot;Execution&quot;<br>      ]<br>    },<br>    &quot;id&quot;: &quot;87105&quot;,<br>    &quot;gdpr&quot;: [<br>      &quot;IV_35.7.d&quot;<br>    ]<br>  },<br>  &quot;decoder&quot;: {<br>    &quot;name&quot;: &quot;json&quot;<br>  },<br>  &quot;input&quot;: {<br>    &quot;type&quot;: &quot;log&quot;<br>  },<br>  &quot;@timestamp&quot;: &quot;2024-06-08T03:06:13.000Z&quot;,<br>  &quot;location&quot;: &quot;virustotal&quot;,<br>  &quot;id&quot;: &quot;1717815973.5340514&quot;,<br>  &quot;timestamp&quot;: &quot;2024-06-08T03:06:13.000+0000&quot;,<br>  &quot;_id&quot;: &quot;prfP9Y8BPR-malTLnPWR&quot;<br>}</pre><p>From that information you can get some informations about the malware such as the:<br>- <strong>Scan Date</strong>: 2024–06–08 02:57:16 GMT<br>- <strong>Positives: </strong>66 (Number of antivirus engines that flagged the file as malicious)<br>- <strong>Malicious</strong>: 1 (Indicates whether the file is flagged as malicious. In this case, it’s marked as “1”, meaning it is flagged as malicious)<br>- <strong>Malware File: </strong>/home/jeri/Downloads/eicar.com</p><p>Not only on Linux agents, you can also use it on Windows agents. the steps are almost the same, you need to enable Wazuh FIM on C:\Program Files (x86)\ossec-agent\ossec.conf by adding this following lines:</p><pre>&lt;directories realtime=&quot;yes&quot;&gt;C:\Users\ACER\Downloads&lt;/directories&gt;</pre><p>If you face permission error, you can fix it by giving your user full control access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*NI2Y-Sq4JJKiRWWTemhCiQ.png" /><figcaption>Give User Full Control Permission</figcaption></figure><p>Replace ACER with your Windows user. The directory C:\Users\ACER\Downloads will be monitored in near real-time.</p><p>Instead of using shellscript, on windows we can use python which is later compiled to an executable file.</p><pre>#!/usr/bin/python3<br># Copyright (C) 2015-2022, Wazuh Inc.<br># All rights reserved.<br><br>import os<br>import sys<br>import json<br>import datetime<br><br>if os.name == &#39;nt&#39;:<br>    LOG_FILE = &quot;C:\\Program Files (x86)\\ossec-agent\\active-response\\active-responses.log&quot;<br>else:<br>    LOG_FILE = &quot;/var/ossec/logs/active-responses.log&quot;<br><br>ADD_COMMAND = 0<br>DELETE_COMMAND = 1<br>CONTINUE_COMMAND = 2<br>ABORT_COMMAND = 3<br><br>OS_SUCCESS = 0<br>OS_INVALID = -1<br><br>class message:<br>    def __init__(self):<br>        self.alert = &quot;&quot;<br>        self.command = 0<br><br>def write_debug_file(ar_name, msg):<br>    with open(LOG_FILE, mode=&quot;a&quot;) as log_file:<br>        log_file.write(str(datetime.datetime.now().strftime(&#39;%Y/%m/%d %H:%M:%S&#39;)) + &quot; &quot; + ar_name + &quot;: &quot; + msg +&quot;\n&quot;)<br><br>def setup_and_check_message(argv):<br><br>    # get alert from stdin<br>    input_str = &quot;&quot;<br>    for line in sys.stdin:<br>        input_str = line<br>        break<br><br><br>    try:<br>        data = json.loads(input_str)<br>    except ValueError:<br>        write_debug_file(argv[0], &#39;Decoding JSON has failed, invalid input format&#39;)<br>        message.command = OS_INVALID<br>        return message<br><br>    message.alert = data<br><br>    command = data.get(&quot;command&quot;)<br><br>    if command == &quot;add&quot;:<br>        message.command = ADD_COMMAND<br>    elif command == &quot;delete&quot;:<br>        message.command = DELETE_COMMAND<br>    else:<br>        message.command = OS_INVALID<br>        write_debug_file(argv[0], &#39;Not valid command: &#39; + command)<br><br>    return message<br><br><br>def send_keys_and_check_message(argv, keys):<br><br>    # build and send message with keys<br>    keys_msg = json.dumps({&quot;version&quot;: 1,&quot;origin&quot;:{&quot;name&quot;: argv[0],&quot;module&quot;:&quot;active-response&quot;},&quot;command&quot;:&quot;check_keys&quot;,&quot;parameters&quot;:{&quot;keys&quot;:keys}})<br><br>    write_debug_file(argv[0], keys_msg)<br><br>    print(keys_msg)<br>    sys.stdout.flush()<br><br>    # read the response of previous message<br>    input_str = &quot;&quot;<br>    while True:<br>        line = sys.stdin.readline()<br>        if line:<br>            input_str = line<br>            break<br><br>    # write_debug_file(argv[0], input_str)<br><br>    try:<br>        data = json.loads(input_str)<br>    except ValueError:<br>        write_debug_file(argv[0], &#39;Decoding JSON has failed, invalid input format&#39;)<br>        return message<br><br>    action = data.get(&quot;command&quot;)<br><br>    if &quot;continue&quot; == action:<br>        ret = CONTINUE_COMMAND<br>    elif &quot;abort&quot; == action:<br>        ret = ABORT_COMMAND<br>    else:<br>        ret = OS_INVALID<br>        write_debug_file(argv[0], &quot;Invalid value of &#39;command&#39;&quot;)<br><br>    return ret<br><br>def main(argv):<br><br>    write_debug_file(argv[0], &quot;Started&quot;)<br><br>    # validate json and get command<br>    msg = setup_and_check_message(argv)<br><br>    if msg.command &lt; 0:<br>        sys.exit(OS_INVALID)<br><br>    if msg.command == ADD_COMMAND:<br>        alert = msg.alert[&quot;parameters&quot;][&quot;alert&quot;]<br>        keys = [alert[&quot;rule&quot;][&quot;id&quot;]]<br>        action = send_keys_and_check_message(argv, keys)<br><br>        # if necessary, abort execution<br>        if action != CONTINUE_COMMAND:<br><br>            if action == ABORT_COMMAND:<br>                write_debug_file(argv[0], &quot;Aborted&quot;)<br>                sys.exit(OS_SUCCESS)<br>            else:<br>                write_debug_file(argv[0], &quot;Invalid command&quot;)<br>                sys.exit(OS_INVALID)<br><br>        try:<br>            file_path = msg.alert[&quot;parameters&quot;][&quot;alert&quot;][&quot;data&quot;][&quot;virustotal&quot;][&quot;source&quot;][&quot;file&quot;]<br>            if os.path.exists(file_path):<br>                os.remove(file_path)<br>            write_debug_file(argv[0], json.dumps(msg.alert) + &quot; Successfully removed threat&quot;)<br>        except OSError as error:<br>            write_debug_file(argv[0], json.dumps(msg.alert) + &quot;Error removing threat&quot;)<br><br><br>    else:<br>        write_debug_file(argv[0], &quot;Invalid command&quot;)<br><br>    write_debug_file(argv[0], &quot;Ended&quot;)<br><br>    sys.exit(OS_SUCCESS)<br><br>if __name__ == &quot;__main__&quot;:<br>    main(sys.argv)</pre><p>Then make the executeable file using pyinstaller .</p><pre>pyinstaller -F remove-threat.py --distpath &quot;C:\Program Files (x86)\ossec-agent\active-response\bin&quot;</pre><p>After succefuly convert the python code into an executeable file. Change the file extension from remove-threat.exe to remove-threat.prg .</p><p>Sometimes, Windows Defender detects it as a malware. The solution is adding ossec-aggent folder into Windows Security Exclusions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2k5q9q0yI3F26pG2NIGwbQ.png" /></figure><p>Then restart the Wazuh service by running this block on PowerShell.</p><pre>Restart-Service -Name wazuh</pre><p>For the wazuh-server , you can use the previous Linux agent configuration.</p><p>Now, try to download sample malware on your Windows agent.</p><pre>Invoke-WebRequest -Uri https://secure.eicar.org/eicar.com.txt -OutFile eicar.txt<br>cp .\eicar.txt C:\Users\ACER\Downloads</pre><p>In the Wazuh Dashboard, check the security event on the Windows agent and you will see something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iGfvJWtZ-he2Ge44DwEaZA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rBBlYpt7MsTrYQh6vJxE9Q.png" /><figcaption>Windows Agent Security Event</figcaption></figure><p>Now the server can detect and remove malware from the Linux agent and Windows agent. Briefly, when getting a malware alert from the integrated VirusTotal, Wazuh Server will run the remove-threat.prg program to remove the malware.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*XuTyGi0f2I5XOxTyd7X_Wg.png" /><figcaption>Active Response Remove Threat</figcaption></figure><p>Linux Agent: /var/ossec/active-response/bin/remove-threat.prg (Shellscript)</p><p>Windows Agent: C:\Program Files (x86)\ossec-agent\active-response\bin\remove-threat.prg (PE32+ Executeable)</p><p>That’s why i use same program exentension for Linux agent and Windows agent. So it can be run on different OS agents.</p><h3>Detecting a SQL injection attack</h3><p>In this use case, we simulate an SQL injection attack against an Linux agent (Ubuntu) endpoint running an Apache web server and detect it using Wazuh.</p><p>The first step, you need to download and startthe apache web server service on your Linux agent by running the following commands:</p><pre>sudo apt install apache2<br>sudo ufw allow &#39;Apache&#39;<br>sudo systemctl status apache2</pre><p>Add the following lines to the Wazuh agent’s /var/ossec/etc/ossec.conf file. This configuration enables the Wazuh agent to monitor the access logs of your Apache server:</p><pre>&lt;ossec_config&gt;<br>  &lt;localfile&gt;<br>    &lt;log_format&gt;apache-access&lt;/log_format&gt;<br>    &lt;location&gt;/var/log/apache2/access.log&lt;/location&gt;<br>  &lt;/localfile&gt;<br>&lt;/ossec_config&gt;</pre><p>Make sure to place these lines within the &lt;ossec_config&gt; tags of your existing ossec.conf file. This setup specifies the format of the logs as apache-access and indicates the location of the Apache access log file.</p><p>Then restart the Wazuh agent to apply the configuration changes:</p><pre>sudo systemctl restart wazuh-agent</pre><p>To perform the SQLi attack, try to run this command:</p><p>Replace &lt;UBUNTU_IP&gt; with the appropriate IP address and execute the following command from the attacker endpoint:</p><pre>curl -X GET &quot;http://&lt;UBUNTU_IP&gt;/tag/?id=SELECT+*+FROM+users&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7waH3BP3fW0Qmdr4VKxoMQ.png" /><figcaption>Perform SQL Injection Attack</figcaption></figure><p>The expected result here is an alert with rule ID 31103. You can check it on security event on wazuh dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XmvUfbT8h_dduD9y4tcj4g.png" /><figcaption>SQL Injection Attack Event</figcaption></figure><p>If you look in more detail, you will find some information about SQL injection attacks.</p><pre>{<br>  &quot;agent&quot;: {<br>    &quot;ip&quot;: &quot;172.23.114.31&quot;,<br>    &quot;name&quot;: &quot;LinuxAgent&quot;,<br>    &quot;id&quot;: &quot;002&quot;<br>  },<br>  &quot;manager&quot;: {<br>    &quot;name&quot;: &quot;UbuntuServer&quot;<br>  },<br>  &quot;data&quot;: {<br>    &quot;protocol&quot;: &quot;GET&quot;,<br>    &quot;srcip&quot;: &quot;172.23.112.1&quot;,<br>    &quot;id&quot;: &quot;404&quot;,<br>    &quot;url&quot;: &quot;/tag/?id=SELECT+*+FROM+users&quot;<br>  },<br>  &quot;rule&quot;: {<br>    &quot;firedtimes&quot;: 3,<br>    &quot;mail&quot;: false,<br>    &quot;level&quot;: 7,<br>    &quot;pci_dss&quot;: [<br>      &quot;6.5&quot;,<br>      &quot;11.4&quot;,<br>      &quot;6.5.1&quot;<br>    ],<br>    &quot;tsc&quot;: [<br>      &quot;CC6.6&quot;,<br>      &quot;CC7.1&quot;,<br>      &quot;CC8.1&quot;,<br>      &quot;CC6.1&quot;,<br>      &quot;CC6.8&quot;,<br>      &quot;CC7.2&quot;,<br>      &quot;CC7.3&quot;<br>    ],<br>    &quot;description&quot;: &quot;SQL injection attempt.&quot;,<br>    &quot;groups&quot;: [<br>      &quot;web&quot;,<br>      &quot;accesslog&quot;,<br>      &quot;attack&quot;,<br>      &quot;sql_injection&quot;<br>    ],<br>    &quot;mitre&quot;: {<br>      &quot;technique&quot;: [<br>        &quot;Exploit Public-Facing Application&quot;<br>      ],<br>      &quot;id&quot;: [<br>        &quot;T1190&quot;<br>      ],<br>      &quot;tactic&quot;: [<br>        &quot;Initial Access&quot;<br>      ]<br>    },<br>    &quot;id&quot;: &quot;31103&quot;,<br>    &quot;nist_800_53&quot;: [<br>      &quot;SA.11&quot;,<br>      &quot;SI.4&quot;<br>    ],<br>    &quot;gdpr&quot;: [<br>      &quot;IV_35.7.d&quot;<br>    ]<br>  },<br>  &quot;decoder&quot;: {<br>    &quot;name&quot;: &quot;web-accesslog&quot;<br>  },<br>  &quot;full_log&quot;: &quot;172.23.112.1 - - [08/Jun/2024:15:49:56 +0700] \&quot;GET /tag/?id=SELECT+*+FROM+users HTTP/1.1\&quot; 404 436 \&quot;-\&quot; \&quot;curl/7.81.0\&quot;&quot;,<br>  &quot;input&quot;: {<br>    &quot;type&quot;: &quot;log&quot;<br>  },<br>  &quot;@timestamp&quot;: &quot;2024-06-08T08:49:56.151Z&quot;,<br>  &quot;location&quot;: &quot;/var/log/apache2/access.log&quot;,<br>  &quot;id&quot;: &quot;1717836596.51836116&quot;,<br>  &quot;timestamp&quot;: &quot;2024-06-08T08:49:56.151+0000&quot;,<br>  &quot;_id&quot;: &quot;hbkK948BPR-malTLYC5Q&quot;<br>}</pre><p>SQL Injection Attack Information:<strong><br>- (Attacker IP) srcip: </strong>172.23.112.1<strong><br>- Timestamp: </strong>2024–06–08 08:49:56.151+0000 GMT<br>- <strong>Payload URL: </strong>/tag/?id=SELECT+*+FROM+users<br>- <strong>Status Code: </strong>404</p><h3>Vulnerability Detection</h3><p>The Wazuh Vulnerability Detector module aids users in identifying vulnerabilities within the operating system and applications installed on monitored endpoints. It operates through Wazuh’s native integration with external vulnerability feeds, which are indexed by Canonical, Debian, Red Hat, Arch Linux, Amazon Linux Advisories Security (ALAS), Microsoft, and the National Vulnerability Database (NVD).</p><p>In wazuh version 4.7 the vulnerability detection module on the wazuh server is automatically configured. You can check it in /var/ossec/etc/ossec.conf in the &lt;vulnerability-detector&gt; block. You just need to change block value of &lt;enabled&gt; from noto yes .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Yb6rgkT-JHbtCKmvfaN0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*scWJNeY926-imHDAqn3V4g.png" /></figure><p>In this case, i use Ubuntu Linux agent and Windows agent. So i just need to enable that two blocks.</p><p>In my situation, many vulnerabilities have been detected on Windows Agent and Linux Agent, as shown below. However, this might not be the case for everyone, as some systems may have vulnerable software or services running, which would trigger alerts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_osPmz24lqT2JG-gWMpOXw.png" /><figcaption>Linux Agent Vulnerability</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KKS2MensBAw-n1pA_SC2pw.png" /><figcaption>Windows Agent Vulnerability</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-lvkzyWzt7yJRmi7lNC-fw.png" /><figcaption>Example of Python 3.10 Vulnerability</figcaption></figure><p>From the image above, we know that my Python 3.10.150.0 (64 Bit) is vulnerable to CVE-2023–40217. We can also see the dates when the CVE was published and updated.</p><h3>Conclusion</h3><p>In conclusion, Wazuh offers a comprehensive security monitoring solution, covering log analysis, intrusion detection, vulnerability assessment, and compliance management. By installing its components and agents, organizations can strengthen their cybersecurity posture, detect various threats such as brute force attacks, malware, and SQL injection, and take proactive measures to mitigate risks. Utilizing Wazuh’s capabilities not only improves threat detection and incident response, but also helps maintain regulatory compliance and protect sensitive data. There are actually many more examples of using Wazuh, you can find them in the Wazuh documentation or on the Wazuh blog.</p><h3>Reference</h3><p><a href="https://documentation.wazuh.com/current/index.html">Wazuh documentation</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88cca4bb6f4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>