<?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 Faizanhaider on Medium]]></title>
        <description><![CDATA[Stories by Faizanhaider on Medium]]></description>
        <link>https://medium.com/@faizanhaider1916?source=rss-e745c7560101------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ZdDgZ550gkepONAs</url>
            <title>Stories by Faizanhaider on Medium</title>
            <link>https://medium.com/@faizanhaider1916?source=rss-e745c7560101------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 13:39:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@faizanhaider1916/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[Custom Wazuh Detection Rules]]></title>
            <link>https://medium.com/@faizanhaider1916/custom-wazuh-detection-rules-8d799be84d2d?source=rss-e745c7560101------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d799be84d2d</guid>
            <category><![CDATA[detection-rules]]></category>
            <category><![CDATA[essential-wazuh-rules]]></category>
            <category><![CDATA[wazuh-custom-rules]]></category>
            <category><![CDATA[mitre-attack]]></category>
            <category><![CDATA[wazuh]]></category>
            <dc:creator><![CDATA[Faizanhaider]]></dc:creator>
            <pubDate>Thu, 23 Apr 2026 05:39:16 GMT</pubDate>
            <atom:updated>2026-04-23T05:39:16.810Z</atom:updated>
            <content:encoded><![CDATA[<p>A complete reference guide covering prerequisites, rule syntax, working mechanisms, and deployment notes for core Wazuh SIEM detection rules.</p><h3><strong>Introduction</strong></h3><p>In this Writeup I would like to introduce some of basic Wazuh custom detection rules that are necessary inside your environment. These are introduction level rules and could be helpful if you are creating your own home SOC lab with Wazuh.</p><h3><strong>Pre-requisites</strong></h3><p><strong>Wazuh Manager Installed</strong></p><p>Wazuh Manager (v4.x recommended) must be fully installed and operational. It processes all rules and generates alerts.</p><p><strong>Agents Enrolled</strong></p><p>Wazuh agents must be installed and enrolled on monitored endpoints (Linux, Windows, macOS) and sending heartbeat logs.</p><p><strong>Log Sources Configured</strong></p><p>Relevant log sources must be defined in ossec.conf: syslog, auth.log, Windows Event Log, application logs, etc.</p><p><strong>Audit &amp; Sysmon Setup</strong></p><p>For file integrity, process, and registry rules — Linux Auditd or Windows Sysmon must be configured and forwarding events.</p><p><strong>Decoders in place</strong></p><p>Wazuh decoders parse raw logs into structured fields. Confirm default decoders load and that custom decoders are validated before adding rules that rely on them.</p><p><strong>Rule File Location Known</strong></p><p>Custom rules go in /var/ossec/etc/rules/local_rules.xml. Never edit default rule files directly — override using custom rule IDs (100000+).</p><h3><strong>Rule File Structure</strong></h3><p>/var/ossec/etc/rules/<br> ├── local_rules.xml ← your custom rules go here<br> ├── rules_config.xml<br>/var/ossec/etc/decoders/<br> ├── local_decoder.xml ← custom decoders<br>/var/ossec/etc/<br> ├── ossec.conf ← main config</p><h3><strong>Essential Detection Rules</strong></h3><p><strong>Multiple Failed SSH Login Attempts (Brute Force) — Level 12</strong></p><pre>&lt;!-- Step 1: Detect a single SSH failure (parent rule) --&gt;<br>&lt;rule id=&quot;100010&quot; level=&quot;5&quot;&gt;<br>  &lt;if_sid&gt;5760&lt;/if_sid&gt;<br>  &lt;match&gt;Failed password&lt;/match&gt;<br>  &lt;description&gt;SSH authentication failure&lt;/description&gt;<br>  &lt;group&gt;authentication_failure,pci_dss_10.2.4,gdpr_IV_35.7.d&lt;/group&gt;<br>&lt;/rule&gt;<br><br>&lt;!-- Step 2: Escalate when 5 failures occur in 60 seconds --&gt;<br>&lt;rule id=&quot;100011&quot; level=&quot;12&quot; frequency=&quot;5&quot; timeframe=&quot;60&quot;&gt;<br>  &lt;if_matched_sid&gt;100010&lt;/if_matched_sid&gt;<br>  &lt;same_source_ip/&gt;<br>  &lt;description&gt;Brute force SSH: $(frequency) failures from $(srcip) in $(timeframe)s&lt;/description&gt;<br>  &lt;group&gt;authentication_failures,brute_force,pci_dss_11.4&lt;/group&gt;<br>  &lt;mitre&gt;<br>    &lt;id&gt;T1110.001&lt;/id&gt;<br>  &lt;/mitre&gt;<br>&lt;/rule&gt;</pre><p><strong>How it works:</strong></p><p><em>Agent on Linux host ships </em><em>/var/log/auth.log or </em><em>/var/log/secure to Wazuh Manager.</em></p><p><em>Wazuh’s built-in SSH decoder extracts fields: </em><em>srcip, </em><em>user, </em><em>program=sshd.</em></p><p><em>Parent rule 100010 fires on each “Failed password” log entry at level 5 (informational).</em></p><p><em>Rule 100011 uses a </em><strong><em>frequency counter</em></strong><em> — if rule 100010 fires 5+ times within 60 seconds from the same source IP, a level-12 alert is generated.</em></p><p><em>Alert is forwarded to Wazuh Dashboard / SIEM / email based on active-response thresholds.</em></p><p><strong>Privilege Escalation via sudo — Level 10</strong></p><pre>&lt;!-- Alert when sudo is used with a sensitive command --&gt;<br>&lt;rule id=&quot;100020&quot; level=&quot;10&quot;&gt;<br>  &lt;if_sid&gt;5402&lt;/if_sid&gt;<br>  &lt;match&gt;COMMAND=/bin/bash|COMMAND=/bin/sh|COMMAND=/usr/bin/passwd&lt;/match&gt;<br>  &lt;description&gt;Privilege escalation: sensitive sudo command executed by $(dstuser)&lt;/description&gt;<br>  &lt;group&gt;sudo,privilege_escalation,pci_dss_10.2.5&lt;/group&gt;<br>  &lt;mitre&gt;<br>    &lt;id&gt;T1548.003&lt;/id&gt;<br>  &lt;/mitre&gt;<br>&lt;/rule&gt;<br><br>&lt;!-- Also alert on sudo authentication failure --&gt;<br>&lt;rule id=&quot;100021&quot; level=&quot;8&quot;&gt;<br>  &lt;if_sid&gt;5402&lt;/if_sid&gt;<br>  &lt;match&gt;authentication failure&lt;/match&gt;<br>  &lt;description&gt;Failed sudo attempt - possible unauthorized escalation&lt;/description&gt;<br>  &lt;group&gt;sudo,authentication_failure&lt;/group&gt;<br>&lt;/rule&gt;</pre><p><strong>How it works:</strong></p><p>When a user runs sudo &lt;command&gt;, Linux logs the event to /var/log/auth.log including the username, effective user, and full command.</p><p>Wazuh’s sudo decoder (SID 5402 block) extracts srcuser, dstuser, and COMMAND fields.</p><p>Rule 100020 matches if the command includes a shell binary or password utility — common for privilege abuse — and fires a level-10 alert.</p><p>Add more dangerous commands to the regex pipe list as your environment requires (e.g., /usr/bin/python3, /usr/bin/vi).</p><p><strong>File Integrity Monitoring (FIM) — Critical File Modified — Level 13</strong></p><pre>&lt;!-- FIM config in ossec.conf (prerequisite) --&gt;<br>&lt;!--<br>  &lt;syscheck&gt;<br>    &lt;directories check_all=&quot;yes&quot; realtime=&quot;yes&quot;&gt;/etc&lt;/directories&gt;<br>  &lt;/syscheck&gt;<br>--&gt;<br><br>&lt;!-- Rule: alert on modification of /etc/passwd or /etc/shadow --&gt;<br>&lt;rule id=&quot;100030&quot; level=&quot;13&quot;&gt;<br>  &lt;if_sid&gt;550&lt;/if_sid&gt;<br>  &lt;field name=&quot;file&quot;&gt;/etc/passwd|/etc/shadow|/etc/sudoers&lt;/field&gt;<br>  &lt;description&gt;Critical file modified: $(file) — possible privilege manipulation&lt;/description&gt;<br>  &lt;group&gt;syscheck,fim_alert,pci_dss_11.5,hipaa_164.312.b&lt;/group&gt;<br>  &lt;mitre&gt;<br>    &lt;id&gt;T1565.001&lt;/id&gt;<br>  &lt;/mitre&gt;<br>&lt;/rule&gt;</pre><p><strong>How it works:</strong></p><p>Windows Security Event Log (channel) is forwarded by the Wazuh agent using the &lt;localfile&gt; block set to eventchannel.</p><p>Wazuh’s Windows event decoder parses the XML event and populates fields like win.system.eventID, win.eventdata.targetUserName, and win.eventdata.ipAddress.</p><p>Rule 100040 matches Event ID 4625 (logon failure). Rule 100041 counts 8 such events within 120s from the same IP and fires a brute-force alert.</p><p><strong>Malware / Known Bad Process Execution — Level 14</strong></p><pre>&lt;!-- Detect suspicious process names from auditd/sysmon --&gt;<br>&lt;rule id=&quot;100050&quot; level=&quot;14&quot;&gt;<br>  &lt;if_group&gt;audit_command&lt;/if_group&gt;<br>  &lt;field name=&quot;audit.command&quot;&gt;mimikatz|meterpreter|cobalt|netcat|ncat|empire|psexec&lt;/field&gt;<br>  &lt;description&gt;CRITICAL: Known attack tool executed: $(audit.command) by $(audit.auid)&lt;/description&gt;<br>  &lt;group&gt;audit,attack_tool,malware,pci_dss_6.6&lt;/group&gt;<br>  &lt;mitre&gt;<br>    &lt;id&gt;T1059&lt;/id&gt;<br>    &lt;id&gt;T1003&lt;/id&gt;<br>  &lt;/mitre&gt;<br>&lt;/rule&gt;<br><br>&lt;!-- Windows variant using Sysmon Event ID 1 (Process Create) --&gt;<br>&lt;rule id=&quot;100051&quot; level=&quot;14&quot;&gt;<br>  &lt;if_sid&gt;61603&lt;/if_sid&gt;<br>  &lt;field name=&quot;win.eventdata.image&quot;&gt;(?i)mimikatz|psexec|wce\.exe|procdump&lt;/field&gt;<br>  &lt;description&gt;CRITICAL: Credential theft tool detected via Sysmon: $(win.eventdata.image)&lt;/description&gt;<br>  &lt;group&gt;sysmon,credential_access,attack_tool&lt;/group&gt;<br>  &lt;mitre&gt;<br>    &lt;id&gt;T1003.001&lt;/id&gt;<br>  &lt;/mitre&gt;<br>&lt;/rule&gt;</pre><p><strong>How it works:</strong></p><p>On Linux: auditd must be configured with -a always,exit -F arch=b64 -S execve rules. On Windows: Sysmon must be installed with a ruleset that captures Event ID 1 (Process Create).</p><p>When any process executes, auditd/Sysmon logs the binary name, path, and user. Wazuh ingests these as structured fields.</p><p>Rules 100050/100051 perform regex matching on the process name or image path field against a curated list of known attack tools.</p><p>Level-14 critical alert fires immediately. This should be connected to an active-response playbook.</p><p><strong>New User Account Created — Level 8</strong></p><pre>&lt;!-- Linux: new user created via useradd --&gt;<br>&lt;rule id=&quot;100060&quot; level=&quot;8&quot;&gt;<br>  &lt;if_sid&gt;5901&lt;/if_sid&gt;<br>  &lt;description&gt;New user account created: $(dstuser) — verify if authorized&lt;/description&gt;<br>  &lt;group&gt;account_creation,persistence,pci_dss_8.1&lt;/group&gt;<br>  &lt;mitre&gt;<br>    &lt;id&gt;T1136.001&lt;/id&gt;<br>  &lt;/mitre&gt;<br>&lt;/rule&gt;<br><br>&lt;!-- Windows: Event ID 4720 - User Account Created --&gt;<br>&lt;rule id=&quot;100061&quot; level=&quot;8&quot;&gt;<br>  &lt;if_sid&gt;60106&lt;/if_sid&gt;<br>  &lt;field name=&quot;win.system.eventID&quot;&gt;4720&lt;/field&gt;<br>  &lt;description&gt;Windows: New user created - $(win.eventdata.targetUserName) by $(win.eventdata.subjectUserName)&lt;/description&gt;<br>  &lt;group&gt;account_creation,windows,persistence&lt;/group&gt;<br>  &lt;mitre&gt;<br>    &lt;id&gt;T1136.001&lt;/id&gt;<br>  &lt;/mitre&gt;<br>&lt;/rule&gt;</pre><p>How it works:</p><p>On Linux, useradd or adduser commands log to auth.log. Wazuh&#39;s built-in SID 5901 rule family covers this.</p><p>On Windows, Event ID 4720 is generated in the Security log whenever a local account is created.</p><p>Rule fires with level 8 — medium severity. An analyst should verify whether this was an authorized IT action or unauthorized persistence by an attacker.</p><p><strong>Suspicious Crontab / Scheduled Task Modification — Level 11</strong></p><pre>&lt;!-- FIM must watch /etc/cron.d/, /var/spool/cron/ --&gt;<br>&lt;rule id=&quot;100070&quot; level=&quot;11&quot;&gt;<br>  &lt;if_sid&gt;550&lt;/if_sid&gt;<br>  &lt;field name=&quot;file&quot;&gt;/etc/cron|/var/spool/cron|/etc/anacrontab&lt;/field&gt;<br>  &lt;description&gt;Crontab modified: $(file) — possible persistence installation&lt;/description&gt;<br>  &lt;group&gt;syscheck,cron,persistence,fim_alert&lt;/group&gt;<br>  &lt;mitre&gt;<br>    &lt;id&gt;T1053.003&lt;/id&gt;<br>  &lt;/mitre&gt;<br>&lt;/rule&gt;<br><br>&lt;!-- Windows: Scheduled Task created (Event ID 4698) --&gt;<br>&lt;rule id=&quot;100071&quot; level=&quot;10&quot;&gt;<br>  &lt;if_sid&gt;60106&lt;/if_sid&gt;<br>  &lt;field name=&quot;win.system.eventID&quot;&gt;4698&lt;/field&gt;<br>  &lt;description&gt;Windows scheduled task created: $(win.eventdata.taskName)&lt;/description&gt;<br>  &lt;group&gt;windows,scheduled_task,persistence&lt;/group&gt;<br>  &lt;mitre&gt;<br>    &lt;id&gt;T1053.005&lt;/id&gt;<br>  &lt;/mitre&gt;<br>&lt;/rule&gt;</pre><p><strong>How it works:</strong></p><p>FIM must watch cron directories. When a crontab file changes, syscheck generates SID-550 with the file path.</p><p>Rule 100070 matches on the file field matching cron-related paths — fires at level 11.</p><p>On Windows, enabling “Audit Other Object Access Events” via GPO causes Event ID 4698 to fire when a scheduled task is created — rule 100071 catches this.</p><p><strong>Port Scanning / Reconnaissance Detection — Level 10</strong></p><pre>&lt;!-- Detect multiple firewall-dropped connections from one source --&gt;<br>&lt;rule id=&quot;100080&quot; level=&quot;6&quot;&gt;<br>  &lt;if_sid&gt;4151&lt;/if_sid&gt;<br>  &lt;description&gt;Firewall blocked connection from $(srcip)&lt;/description&gt;<br>  &lt;group&gt;firewall,dropped&lt;/group&gt;<br>&lt;/rule&gt;<br><br>&lt;!-- Escalate: 20 blocked connections in 10 seconds = port scan --&gt;<br>&lt;rule id=&quot;100081&quot; level=&quot;10&quot; frequency=&quot;20&quot; timeframe=&quot;10&quot;&gt;<br>  &lt;if_matched_sid&gt;100080&lt;/if_matched_sid&gt;<br>  &lt;same_source_ip/&gt;<br>  &lt;description&gt;Port scan detected from $(srcip) — $(frequency) blocked in $(timeframe)s&lt;/description&gt;<br>  &lt;group&gt;firewall,recon,port_scan&lt;/group&gt;<br>  &lt;mitre&gt;<br>    &lt;id&gt;T1046&lt;/id&gt;<br>  &lt;/mitre&gt;<br>&lt;/rule&gt;</pre><p><strong>How it works:</strong></p><p>Firewall (iptables, pfSense, Cisco ASA) must be configured to log dropped/rejected connections and those logs shipped to Wazuh.</p><p>Each blocked connection fires rule 100080 at level 6 (below alert threshold if desired).</p><p>Rule 100081 uses a tight timeframe (10 seconds, 20 events) from the same IP. This pattern uniquely fingerprints port scanners like nmap.</p><p><strong>Rootkit / Kernel Module Detection — Level 15</strong></p><pre>&lt;!-- Rootcheck generates SID 510/511 events; extend with this rule --&gt;<br>&lt;rule id=&quot;100090&quot; level=&quot;15&quot;&gt;<br>  &lt;if_sid&gt;510&lt;/if_sid&gt;<br>  &lt;description&gt;ROOTKIT ALERT: Hidden process or file detected — immediate investigation required&lt;/description&gt;<br>  &lt;group&gt;rootcheck,rootkit,pci_dss_11.4&lt;/group&gt;<br>  &lt;mitre&gt;<br>    &lt;id&gt;T1014&lt;/id&gt;<br>  &lt;/mitre&gt;<br>&lt;/rule&gt;<br><br>&lt;!-- Suspicious kernel module loaded --&gt;<br>&lt;rule id=&quot;100091&quot; level=&quot;14&quot;&gt;<br>  &lt;if_group&gt;audit_command&lt;/if_group&gt;<br>  &lt;field name=&quot;audit.command&quot;&gt;insmod|modprobe|rmmod&lt;/field&gt;<br>  &lt;description&gt;Kernel module operation detected: $(audit.command) by UID $(audit.auid)&lt;/description&gt;<br>  &lt;group&gt;audit,kernel_module,rootkit_attempt&lt;/group&gt;<br>  &lt;mitre&gt;<br>    &lt;id&gt;T1547.006&lt;/id&gt;<br>  &lt;/mitre&gt;<br>&lt;/rule&gt;</pre><p><strong>How it works:</strong></p><p>Wazuh’s built-in <strong>rootcheck</strong> module scans periodically: it compares PID lists from /proc vs running processes, checks for hidden files, and inspects kernel module list.</p><p>Any anomaly (hidden PID, suspicious file in /dev, writable startup script) generates a SID-510 event with a description of the finding.</p><p>Level-15 is Wazuh’s maximum severity. These alerts should trigger automatic host isolation via active-response.</p><p><strong>Web Application Attack — SQL Injection / XSS Attempt — Level 11</strong></p><pre>&lt;!-- Detect SQL injection patterns in web server logs --&gt;<br>&lt;rule id=&quot;100100&quot; level=&quot;11&quot;&gt;<br>  &lt;if_sid&gt;31101&lt;/if_sid&gt;<br>  &lt;url&gt;select%20|union%20|insert%20into|drop%20table|1=1|&#39;%20OR%20&#39;|;--|SLEEP\(|BENCHMARK\(&lt;/url&gt;<br>  &lt;description&gt;SQL Injection attempt detected from $(srcip) to $(url)&lt;/description&gt;<br>  &lt;group&gt;web,attack,sql_injection,pci_dss_6.6&lt;/group&gt;<br>  &lt;mitre&gt;<br>    &lt;id&gt;T1190&lt;/id&gt;<br>  &lt;/mitre&gt;<br>&lt;/rule&gt;<br><br>&lt;!-- Detect XSS patterns --&gt;<br>&lt;rule id=&quot;100101&quot; level=&quot;10&quot;&gt;<br>  &lt;if_sid&gt;31101&lt;/if_sid&gt;<br>  &lt;url&gt;&lt;script|javascript:|onerror=|onload=|eval\(|alert\(|document\.cookie&lt;/url&gt;<br>  &lt;description&gt;XSS attempt detected from $(srcip)&lt;/description&gt;<br>  &lt;group&gt;web,attack,xss&lt;/group&gt;<br>  &lt;mitre&gt;<br>    &lt;id&gt;T1059.007&lt;/id&gt;<br>  &lt;/mitre&gt;<br>&lt;/rule&gt;</pre><p><strong>How it works:</strong></p><p>Apache/Nginx/IIS access logs must be shipped by the agent. Wazuh’s web decoder (SID 31100 family) parses the URL, HTTP method, status code, and source IP.</p><p>The &lt;url&gt; field tag in Wazuh rules matches against the decoded URL/query string — making it easy to catch encoded payloads.</p><p>Rule 100100 matches URL-encoded SQL keywords. Rule 100101 catches XSS-typical JavaScript injection strings.</p><p>Consider chaining these with a frequency rule to detect automated scanners (Sqlmap, Nikto) making hundreds of attempts per minute.</p><h3><strong>Deployment Checklist</strong></h3><p>1. All custom rules have IDs starting at <strong>100000+</strong> (Wazuh reserves 0–99999 for built-in rules).<br>2. Test rules using wazuh-logtest tool before deploying to production.<br>3. Set &lt;logall&gt;yes&lt;/logall&gt; in ossec.conf temporarily during testing to confirm events are being received.<br>4. Validate rule syntax: /var/ossec/bin/wazuh-logtest -U &quot;rule:100010&quot;<br>5. Reload (not restart) after changes: systemctl reload wazuh-manager</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d799be84d2d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>