# From Zero to SOC: Deploying a Production-Ready Security Operations Center on Real Infrastructure

## Table of Contents

**Part 1 — Architecture**

1. Introduction
2. High-Level Design (HLD)
3. Low-Level Design (LLD)
4. Lab Inventory and Deployment Architecture

**Part 2 — Deployment**

5. Deploying and configuring the pfSense firewall
6. Installing the server that hosts the SOC components
7. Installing the SOC components
8. Configuring and using TheHive (ticketing system)
9. Integrations and automation
10. Installing the Shuffle SOAR

**Part 3 — Use Cases in Action**

11. SOC use case demonstrations
12. Conclusion

---

# Part 1 — Architecture

## 1\. Introduction

This guide walks you through building a complete, operational SOC (Security Operations Center) on real infrastructure, end to end: from the architecture design, to the deployment of every component, to real attack scenarios that prove the SOC actually detects and responds.

The SOC is built entirely on open-source tools:

- **pfSense**: firewall, router and DHCP server
- **Proxmox**: hypervisor hosting all the virtual machines
- **Wazuh**: SIEM, the core of the SOC
- **TheHive**: incident and case management (ticketing)
- **Cortex**: automated analysis of observables
- **MISP**: threat intelligence sharing platform
- **Shuffle**: SOAR, for automated response playbooks

The goal is proactive monitoring, automation of critical tasks, and fast incident handling. Every step comes with a screenshot so you can follow along in your own lab.

## 2\. High-Level Design (HLD)

This architecture describes how threats are detected, analyzed and answered in our external SOC.

![High-level architecture of the external SOC](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/hld-01-v2.jpg align="center")

### 2.1. Components and their roles

**1\. Windows 10 client with the Wazuh agent**

*Role:* the Windows 10 endpoint runs the Wazuh agent, which collects security events (logs, system alerts). The agent watches system activity, detects anomalies and sends the data to the Wazuh server.

*Capabilities:*

- Real-time monitoring of local events
- Attack detection (intrusions, changes to sensitive files)
- Forwarding of collected data to the central server for analysis

**2\. Wazuh server**

*Role:* the Wazuh server centralizes the data sent by the agents installed on the endpoints, and analyzes it to spot suspicious or malicious behavior.

*Capabilities:*

- Agent management (endpoint monitoring)
- Log analysis and alert generation
- Forwarding of critical alerts to the orchestrator (Shuffle)

**3\. Shuffle (automation orchestrator)**

*Role:* Shuffle automates security workflows and orchestrates the different stages of incident handling.

*Capabilities:*

- Receives and processes alerts from the Wazuh server
- Enriches alerts with IOCs (indicators of compromise) using tools such as MISP or Cortex
- Sends enriched alerts to TheHive for centralized management
- Sends email notifications to the SOC team for critical alerts

**4\. TheHive (incident management)**

*Role:* TheHive is the platform used to centralize, track and resolve security alerts.

*Capabilities:*

- Ingests enriched alerts coming from Shuffle
- Assigns tasks to SOC analysts
- Enables collaboration between SOC team members for a fast response
- Communicates both ways with Cortex for additional analysis

**5\. MISP (threat intelligence sharing)**

*Role:* MISP is a threat intelligence sharing platform. It enriches alerts with a collaborative database of indicators of compromise (malicious IPs, file hashes, suspicious domains).

*Capabilities:*

- Provides relevant IOCs to enrich alerts
- Improves detection with global threat intelligence

**6\. Cortex (automated analysis)**

*Role:* Cortex runs analysis tools (analyzers) on IOCs to produce actionable information.

*Capabilities:*

- In-depth lookups on suspicious domains, IP addresses or files
- Sends results straight back to TheHive to support decision-making

**7\. SOC analyst**

*Role:* the SOC analyst interprets alerts, manages incidents and applies remediation.

*Responsibilities:*

- Monitor the alerts generated by Wazuh and enriched in TheHive
- Respond to incidents, through automated or manual response actions
- Work with the analysis and management tools to keep the network secure

**8\. Router / firewall (active response)**

*Role:* the network infrastructure used to apply incident responses, for example blocking a malicious IP or isolating an endpoint.

*Capabilities:*

- Connects all the components of the architecture
- Allows corrective actions to be executed directly on the endpoints

### 2.2. How it all works together

1. **Event collection:** Wazuh agents on the endpoints collect logs and send them to the Wazuh server for centralized analysis.
2. **Detection and alerting:** the Wazuh server analyzes the data, detects suspicious behavior and raises alerts when a threat is found.
3. **Orchestration and enrichment:** alerts are sent to Shuffle, which enriches them with IOCs from MISP and Cortex, notifies the SOC team by email, and forwards the enriched alerts to TheHive.
4. **Incident management and analysis:** enriched alerts are centralized in TheHive and assigned to an analyst, who uses Cortex for further analysis and takes corrective action.
5. **Incident response:** responses can include blocking a malicious IP, isolating an endpoint, or other actions executed through the router, the firewall, an EDR or Wazuh itself.

![SOC workflow: from the Wazuh agent to TheHive and email notifications](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/hld-02.png align="center")

In short, this architecture relies on smooth integration between collection, analysis, management and orchestration tools. Automation with Shuffle and enrichment with MISP and Cortex cut response times, while collaboration between the tools and the analysts keeps threat handling effective.

## 3\. Low-Level Design (LLD)

The LLD describes how the components talk to each other: which protocols, which ports, and in which direction the data flows.

![Low-level design: communication between the SOC components](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/lld-01.jpg align="center")

> **Note:** the reference design below uses **OPNsense with Zenarmor** as the next-generation firewall and **Suricata** as the IDS/IPS. In the lab deployed in Part 2, the firewall role is played by **pfSense** (with Snort/Suricata as IDS/IPS). The communication flows are the same: firewall and IDS logs go to Wazuh over Syslog.

### 3.1. Communication details

**1\. Wazuh (SIEM)**

*Log collection:*

- **Agents:** installed on endpoints, servers and network devices; they send their logs to the Wazuh manager.
- **API integration:** Wazuh exchanges data with TheHive and MISP through their APIs.
- **Syslog:** Wazuh collects firewall and Suricata logs over Syslog (UDP/TCP 514 by default).
- **Filebeat (optional):** can be used to ship logs from network tools to Wazuh, for better scalability.

*Threat detection:*

- Wazuh stores and queries the indexed data in the **Wazuh indexer**, and detects threats using rules and threat feeds coming from MISP.

**2\. MISP (threat intelligence platform)**

*Communication:*

- **REST API:** MISP provides IOCs (malicious IP addresses, file hashes…) to Wazuh. Wazuh queries MISP at scheduled intervals for updates.
- **Data feeds:** MISP pulls data from external threat intelligence providers over secure HTTPS/TLS connections.

*System-level interaction:*

- IOCs are formatted and sent to Wazuh to be correlated with the collected logs.
- MISP can share threats with other SOCs over HTTPS/TLS.

**3\. TheHive (incident management)**

*Communication:*

- **Webhook / API:** Wazuh sends high-priority alerts to TheHive, which creates cases through its API. TheHive calls Cortex to enrich incidents (API over HTTPS/TLS).

*System-level interaction:*

- Alerts are automatically parsed and turned into structured cases.
- Analysts use TheHive's web interface to manage cases and take further action.

**4\. Cortex (automation and enrichment)**

*Communication:*

- **API calls:** Cortex receives analysis requests from TheHive (for example, file hash checks or IP reputation). Cortex analyzers connect to external services (VirusTotal, WHOIS, etc.) over HTTPS/TLS.

*System-level interaction:*

- Analysis results are sent back to TheHive to enrich incidents with actionable information.

**5\. Firewall / NGFW (OPNsense with Zenarmor in the reference design)**

*Communication:*

- **Syslog:** the firewall sends its firewall and VPN logs to Wazuh over Syslog (UDP/TCP).
- **Zenarmor:** records network activity (blocked connections, suspicious flows) and sends it to Wazuh.

*System-level interaction:*

- The firewall enforces network policies based on threat intelligence (for example, blocking malicious IPs).
- Automated workflows can push firewall rules dynamically through the firewall's API.

**6\. Suricata (IDS/IPS)**

*Communication:*

- **Syslog / JSON output:** Suricata writes its alerts in JSON and sends them to Wazuh via Syslog or over an encrypted (TLS) connection.
- **SPAN / TAP ports:** Suricata listens to network traffic on a mirror port or a network TAP to detect threats.

*System-level interaction:*

- Suricata alerts (matched signatures) are processed by Wazuh and correlated with endpoint data and threat intelligence.
- Suricata rules can be updated based on IOCs from MISP or on Wazuh alerts.

### 3.2. Workflow summary

1. **Log and alert collection:** Wazuh collects logs from the endpoints, the firewall and Suricata, and receives threat intelligence from MISP.
2. **Alert correlation:** Wazuh correlates the logs and raises alerts when events match predefined rules or IOCs.
3. **Incident management:** alerts are sent to TheHive for case management; Cortex enriches the cases with extra context from external tools.
4. **Automated actions:** critical incidents can trigger API calls to the firewall to block IPs or update rules.
5. **Network security hardening:** the firewall and Suricata actively monitor traffic and raise alerts on malicious activity.

### 3.3. Protocols and ports

| Component | Protocol | Port | Purpose |
| --- | --- | --- | --- |
| Wazuh agents | TCP/UDP | 1514 / 514 | Send logs to Wazuh |
| Wazuh manager | HTTPS | 443 | API communication (e.g. with TheHive) |
| MISP | HTTPS | 443 | Share IOCs with Wazuh |
| TheHive | HTTPS | 443 | Case management via API |
| Cortex | HTTPS | 443 | Automated analysis via analyzers |
| Firewall (OPNsense / pfSense) | Syslog (UDP/TCP) | 514 | Firewall logs sent to Wazuh |
| Suricata | Syslog / JSON | 514 / custom | Alerts sent to Wazuh |

> In the lab deployed in Part 2, the web interfaces listen on these ports: Wazuh dashboard `9443`, TheHive `9000`, Cortex `9001`, MISP `443`, Portainer `9111`, Shuffle `3001`/`3443`.

### 3.4. Network communication map

1. **Endpoints → Wazuh manager:** logs are sent securely by the Wazuh agents (encrypted channel).
2. **Wazuh → MISP:** queries MISP IOCs via API (HTTPS).
3. **Wazuh → TheHive:** alerts are sent to TheHive to create cases (HTTPS API).
4. **TheHive → Cortex:** sends enrichment requests (HTTPS API).
5. **Firewall and Suricata → Wazuh:** Syslog/JSON logs are forwarded to Wazuh over encrypted connections.

## 4\. Lab Inventory and Deployment Architecture

Here is the architecture we actually deployed on Proxmox:

![Deployment architecture of the SOC lab](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-001.jpg align="center")

And here are the virtual machines that make up the lab:

| VM name on Proxmox | Type | Role | IP address | Software |
| --- | --- | --- | --- | --- |
| VIZUALIZER-DASHBOARDS | Jump host | Used to connect to and view the web interfaces of all deployed tools | 20.0.0.20 | Windows 10 + PuTTY (SSH administration of the Linux servers) |
| PROD-FIREWALL | Firewall | Firewall, DHCP server for the LAN, and IDS/IPS with Snort | WAN: 10.0.0.10/32 — LAN: 20.0.0.10/24 | pfSense + Snort |
| SECURITY-OPERATION-CENTER | External SOC | Detects, analyzes and responds to security incidents in the environment it protects | 20.0.0.21 | Portainer, TheHive, Cortex, MISP, Wazuh |
| REDTEAM | Pentest machine | Runs penetration tests to simulate real attacks, from detection to incident response | 20.0.0.22 | Kali Linux |
| PLAYBOOK-AUTOMATION-SOAR | SOAR | Automates the playbooks defined for incident handling | 20.0.0.25 | Ubuntu Server 24.04.1 + Docker + Shuffle |
| Windows-Agent | Windows agent | Test endpoint for the SIEM use cases | 20.0.0.23 | Windows 10 + Wazuh agent |
| Linux-Agent | Linux agent | Test endpoint for the SIEM use cases | 20.0.0.24 | Ubuntu Desktop + Wazuh agent |

---

# Part 2 — Deployment

## 5\. Deploying and Configuring the pfSense Firewall

### 5.1. What is pfSense?

**pfSense is an open-source operating system, based on FreeBSD, used to build a router/firewall. This guide uses version 2.7.2 (the latest release as of February 2024).**

### 5.2. Installing pfSense on Proxmox 8.1

In this section, we install pfSense on a hosted Proxmox 8.1 hypervisor, using the following architecture:

- 1 pfSense virtual machine with 2 interfaces, "WAN" and "LAN"

In our setup:

- WAN --> `vmbr1` --> 10.0.0.1/24
- LAN --> `vmbr2` --> 20.0.0.1/24

![Screenshot 2](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-002.jpg align="center")

- 1 Windows 10 machine, connected to the pfSense "LAN" interface, used to administer the firewall

#### 5.2.1. Prerequisites

- A Proxmox 8.1 hypervisor
- The pfSense ISO image
- A Windows 10 machine for administration

#### 5.2.2. Downloading and preparing the ISO image

**1.** Download the pfSense ISO image from the official website: <https://www.pfsense.org/download/>

**2.** Select the "AMD64" architecture and the "DVD Image (ISO)" installer.

**3.** Click the "Download" button:

![Screenshot 3](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-003.jpg align="center")

Note: the image is downloaded as an `.iso.gz` archive. Extract it with a tool such as 7-Zip to get the `.iso` file.

#### 5.2.3. Uploading the ISO to Proxmox

**1.** Log in to the Proxmox web interface.

**2.** In the server view, click the "local" storage, then "ISO Images" in the right-hand panel.

**3.** Click "Upload" to transfer the image from your PC to the Proxmox server.

Tip: you can also download the ISO directly from a URL if you have a valid link to the `.iso` file.

#### 5.2.4. Creating the network bridges (vmbr) on Proxmox

Before creating the virtual machine, we need to create the "vmbr" bridges that pfSense will connect to.

**1.** Click the name of your Proxmox node, then click "Network" in the right-hand panel.

**2.** Click "Create" > "Linux Bridge":

![Screenshot 4](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-004.jpg align="center")

A new bridge, "vmbr1", now appears in the Proxmox network list:

![Screenshot 5](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-005.jpg align="center")

**3.** Click "Apply Configuration" to activate the bridge.

pfSense needs 2 virtual network cards, each connected to its own bridge. In our case, `vmbr0` is already bound to the server's public IP address, so we use `vmbr1` **for the WAN** and `vmbr2` **for the LAN**.

#### 5.2.5. Creating and configuring the pfSense VM

**1.** Click "Create VM".

**2.** Name your VM and, in the next step, select the installation ISO image.

**3.** Keep the default settings in the "System" tab.

**4.** In the "Disks" tab, set the disk size to 20 GB.

**5.** Keep the default settings in the "CPU" tab.

**6.** Set the memory to 2048 MB.

**7.** In the "Network" tab, select "vmbr1".

![Screenshot 6](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-006.jpg align="center")

![Screenshot 7](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-007.png align="center")

**8.** Confirm the creation of the VM, but do not start it yet!

**9.** Add a second network card to the pfSense VM:

**10.** Click your VM, then "Hardware" > "Add" in the right-hand panel.

**11.** Click "Network Device".

**12.** Select "vmbr2" for this card (leave the MAC address on "auto").

**13.** Click "Add".

The network hardware of your pfSense VM should now look like this:

![Screenshot 8](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-008.jpg align="center")

The pfSense VM is ready to start.

### 5.3. Installing pfSense

**1.** Start the VM to launch the installer, wait a moment, then accept the license agreement by pressing "Enter":

![Screenshot 9](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-009.jpg align="center")

**2.** Select **"Install pfSense"**:

![Screenshot 10](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-010.jpg align="center")

**3.** This version of the installer asks you to configure the network before continuing:

![Screenshot 11](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-011.jpg align="center")

**4.** First, select the WAN interface, which corresponds to `vmbr1`:

![Screenshot 12](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-012.jpg align="center")

**5.** Configure the WAN interface with a static IP address matching your setup. It should look like this:

![Screenshot 13](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-013.jpg align="center")

**6.** Next, select the LAN interface, which corresponds to `vmbr2`:

![Screenshot 14](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-014.jpg align="center")

**7.** Configure its IP address according to your setup and, most importantly, enable it as a DHCP server:

![Screenshot 15](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-015.jpg align="center")

**8.** Confirm the interface assignment to continue the installation:

![Screenshot 16](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-016.jpg align="center")

**9.** Click "Continue". If everything is correct, a message says that no valid subscription was found. Choose the **CE (Community Edition)** version:

![Screenshot 17](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-017.jpg align="center")

**10.** Choose the file system. We use **ZFS** (the recommended default):

![Screenshot 18](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-018.jpg align="center")

**11.** Select the storage disk:

![Screenshot 19](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-019.jpg align="center")

**12.** Confirm your choice. The disk will be formatted for the installation:

![Screenshot 20](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-020.jpg align="center")

**13.** Choose the version to install. We use **2.7.2**, the most stable release at the time:

![Screenshot 21](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-021.jpg align="center")

**14.** The installation starts:

![Screenshot 22](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-022.jpg align="center")

**15.** When the installation is complete, you get the following screen:

![Screenshot 23](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-023.jpg align="center")

**16.** Select **"Reboot"** to restart:

![Screenshot 24](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-024.jpg align="center")

**17.** Wait for the machine to restart. On boot, pfSense detects the network interfaces and asks you to assign them as "WAN" and "LAN". Here, pfSense detected our 2 network cards as "vtnet0" and "vtnet1":

![Screenshot 25](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-025.jpg align="center")

**18.** Assign the detected network cards to the "WAN" and "LAN" interfaces (important!):

- Type "vtnet0" and press "Enter" to assign it as the "WAN" interface
- Type "vtnet1" to assign the other card as the "LAN" interface:

![Screenshot 26](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-026.jpg align="center")

**19.** Type **"y"** to confirm and wait while pfSense applies the assignment (this can take a few minutes):

![Screenshot 27](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-027.jpg align="center")

![Screenshot 28](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-028.jpg align="center")

### 5.4. Assigning IP Addresses to the WAN and LAN Interfaces

Once the interfaces are assigned, pfSense displays the following screen:

![Screenshot 29](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-029.png align="center")

The "WAN" interface has no IP address yet, because it must be configured statically. With a hosting provider, this is often a failover IP in the form `xxx.xxx.xxx.xxx/32`; in our case, it is the address of the `vmbr1` network. The "LAN" interface, on the other hand, received pfSense's default address, `192.168.1.1/24`.

We therefore assign a static IP address to the "WAN" interface from the pfSense console:

![Screenshot 30](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-030.jpg align="center")

**1.** Type "2" ("Set interface(s) IP address"), then "1" to select the "WAN" interface:

![Screenshot 31](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-031.png align="center")

**2.** Answer "n" when asked whether to configure the WAN via DHCP (our WAN IP is static):

![Screenshot 32](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-032.jpg align="center")

**3.** Enter the WAN IP address (in our case, an address on the `vmbr1` network):

![Screenshot 33](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-033.jpg align="center")

**4.** Enter the subnet mask (/32):

![Screenshot 34](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-034.jpg align="center")

**5.** Enter the gateway IP address:

![Screenshot 35](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-035.jpg align="center")

**6.** Answer "n" when asked whether to configure a WAN IPv6 address via DHCP6:

![Screenshot 36](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-036.jpg align="center")

**7.** Press "Enter" without typing anything (no WAN IPv6 address):

![Screenshot 37](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-037.jpg align="center")

**8.** Answer "n" here as well, since the WAN address is static:

![Screenshot 38](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-038.jpg align="center")

**9.** Answer "n" to keep HTTPS access to the pfSense web interface:

![Screenshot 39](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-039.jpg align="center")

**10.** Press "Enter" to confirm:

![Screenshot 40](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-040.jpg align="center")

Now we configure the LAN interface so that it matches the `vmbr2` network.

**11.** As before, choose option 2:

![Screenshot 41](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-041.jpg align="center")

**12.** This time, select the LAN interface (option 2):

![Screenshot 42](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-042.jpg align="center")

**13.** Answer "n" so the interface is not configured as a DHCP client:

![Screenshot 43](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-043.jpg align="center")

**14.** Enter the LAN interface IP address:

![Screenshot 44](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-044.jpg align="center")

**15.** Enter the subnet mask:

![Screenshot 45](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-045.jpg align="center")

**16.** Enter the gateway IP address:

![Screenshot 46](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-046.jpg align="center")

**17.** Confirm this address as the default gateway, then answer "n" to skip IPv6 configuration:

![Screenshot 47](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-047.jpg align="center")

**18.** Press "Enter" to skip the IPv6 address for the LAN interface:

![Screenshot 48](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-048.jpg align="center")

**19.** Next, we enable the DHCP server on the LAN so it can assign IP addresses to the SOC components. Answer "y":

![Screenshot 49](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-049.jpg align="center")

**20.** Enter the range of IP addresses the DHCP server can assign, as shown below:

![Screenshot 50](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-050.jpg align="center")

**21.** Finally, keep "HTTPS" as the web interface protocol:

![Screenshot 51](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-051.jpg align="center")

**22.** The LAN interface is now configured, as shown below. Press "Enter" to continue:

![Screenshot 52](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-052.jpg align="center")

**23.** Both interfaces are now correctly configured:

![Screenshot 53](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-053.jpg align="center")

### 5.5. Accessing the pfSense Web Interface from a VM on vmbr2 (LAN)

**1.** Create a virtual machine with a graphical interface (in our case, a Windows machine).

**2.** Connect it to "vmbr2" so that it sits on the LAN, then start it. Here, we created a Windows 10 VM with a network card connected to "vmbr2".

We named this VM **VIZUALIZER-DASHBOARDS**. It acts as a jump host to access the SOC components and, above all, to administer the firewall.

![Screenshot 54](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-054.jpg align="center")

Make sure the Windows VM's network card is connected to "vmbr2"; otherwise, it will not be able to reach the pfSense LAN!

Once the VM is running, you can confirm it is on the LAN: it received a `20.0.0.xxx/24` address from the pfSense DHCP server and has Internet access:

![Screenshot 55](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-055.jpg align="center")

**3.** Open a browser on the VM and go to `https://20.0.0.10` (the pfSense LAN address). Accept the browser warning to trust pfSense's self-signed certificate:

![Screenshot 56](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-056.jpg align="center")

**4.** Log in with the default credentials: username "admin", password "pfsense":

![Screenshot 57](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-057.jpg align="center")

**5.** The pfSense setup wizard opens automatically. Click "Next":

![Screenshot 58](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-058.jpg align="center")

**6.** The wizard has 9 steps. In the first screen, you can set your "Domain".

Also enter your DNS servers (here, Quad9), then click "Next":

![Screenshot 59](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-059.jpg align="center")

**7.** In step 3, set the "Timezone" to "Europe/Paris" and click "Next":

![Screenshot 60](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-060.jpg align="center")

**8.** In step 4, make sure the WAN IP type is set to "Static" and click "Next":

![Screenshot 61](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-061.jpg align="center")

![Screenshot 62](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-062.jpg align="center")

**9.** In step 5, you will see the LAN IP settings you configured during installation. Click "Next":

![Screenshot 63](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-063.jpg align="center")

**10.** Change the default admin password for the web interface (never keep the default password, everyone knows it!) and click **"Next"**:

![Screenshot 64](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-064.jpg align="center")

**11.** The configuration is complete! Click "Reload" to apply your settings:

![Screenshot 65](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-065.jpg align="center")

**12.** pfSense reloads and confirms that the setup was successful:

- Click "Finish":

![Screenshot 66](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-066.jpg align="center")

**13.** Accept the license agreement by clicking "Accept":

![Screenshot 67](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-067.jpg align="center")

**14.** Click "Close" to finish:

![Screenshot 68](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-068.jpg align="center")

**15.** The pfSense dashboard is displayed:

![Screenshot 69](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-069.jpg align="center")

The pfSense firewall is now configured and ready to use!

### 5.6. Configuring NAT on the Firewall

Next, we configure NAT so that machines on the LAN can reach the Internet through the single WAN interface.

**1.** Enable NAT (address translation)

pfSense must translate the private LAN addresses into the WAN address.

**2.** Go to: `Firewall` → `NAT` → `Outbound`

**3.** Select the `Hybrid Outbound NAT` mode.

**4.** This mode lets pfSense create automatic rules while still allowing you to add your own.

![Screenshot 70](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-070.jpg align="center")

**5.** Add a manual NAT rule:

- `Interface`: `WAN`
- `Source`: `LAN subnets` (your LAN network, here `20.0.0.0/24`)
- `Destination`: `any`
- `Translation`: `Interface Address`
- Save and apply the changes.

![Screenshot 71](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-071.jpg align="center")

**6.** Create a firewall rule on the LAN interface

Now we allow traffic from the LAN to the Internet.

**6.1.** Go to: `Firewall` → `Rules` → `LAN`

**6.2.** Add a new rule:

- Action: `Pass`
- Interface: `LAN`
- Address Family: `IPv4`
- Protocol: `Any` (allows TCP/UDP/ICMP)
- Source: `20.0.0.0/24`
- Destination: `Any`
- Gateway: `Default`
- Description: `Allow Internet access from LAN`

**7.** Save and apply the rules (`Apply Changes`).

You can confirm it works by pinging [google.com](http://google.com) from the Windows host:

![Screenshot 72](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-072.jpg align="center")

## 6\. Installing the Server that Hosts the SOC Components

### 6.1. Server specifications

- OS --> Ubuntu Server 24.04.1
- RAM --> 32 GB
- Storage --> 400 GB
- 4 cores
- 2 CPU sockets

### 6.2. Installing and configuring Ubuntu Server

**1.** In the Proxmox web interface, click **"Create VM"**:

![Screenshot 73](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-073.png align="center")

**2.** Name the machine. We called it **"SECURITY-OPERATION-CENTER"**:

![Screenshot 74](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-074.jpg align="center")

**3.** Select the Ubuntu Server ISO image:

![Screenshot 75](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-075.jpg align="center")

**4.** In the **"System"** section, keep the defaults and click **"Next"**:

![Screenshot 76](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-076.png align="center")

**5.** In the disk section, increase the size according to your available storage, then click **"Next"**. We set it to 400 GB:

![Screenshot 77](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-077.png align="center")

**6.** Set the number of cores and CPU sockets the VM needs, then click **"Next"**:

![Screenshot 78](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-078.png align="center")

**7.** Due to limited resources, we later came back and adjusted this section as follows:

![Screenshot 79](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-079.jpg align="center")

**8.** Set the amount of RAM:

![Screenshot 80](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-080.png align="center")

**9.** Select the network card. Here it is the LAN bridge, `vmbr2`. Since the pfSense LAN interface acts as a DHCP server, the VM will receive its IP address automatically:

![Screenshot 81](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-081.png align="center")

**10.** Here is what the final VM configuration should look like:

![Screenshot 82](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-082.jpg align="center")

**11.** Start the machine by clicking **"Start"**:

![Screenshot 83](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-083.jpg align="center")

**12.** Once the VM has booted, select **"Try or Install Ubuntu Server"**:

![Screenshot 84](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-084.jpg align="center")

**13.** We kept English as the installation language:

![Screenshot 85](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-085.jpg align="center")

**14.** Continue without updating the installer for now (updates will be applied after installation):

![Screenshot 86](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-086.png align="center")

**15.** Choose your keyboard layout (in our case, **"French"**):

![Screenshot 87](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-087.jpg align="center")

**16.** Select the standard Ubuntu Server installation:

![Screenshot 88](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-088.jpg align="center")

**17.** The server automatically receives an IP address from pfSense, here **20.0.0.21/24**:

![Screenshot 89](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-089.jpg align="center")

**18.** The installer tests connectivity by reaching the Ubuntu download mirror:

![Screenshot 90](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-090.jpg align="center")

**19.** Select the storage disk. This is the 400 GB disk we defined when creating the VM:

![Screenshot 91](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-091.jpg align="center")

**20.** Review the partition layout, then confirm:

![Screenshot 92](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-092.jpg align="center")

**21.** Confirm again: the disk will be formatted so the OS can be installed:

![Screenshot 93](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-093.jpg align="center")

**22.** Create your user account and set the server name and password:

**Username --> manager**

**Password -->** `********`

![Screenshot 94](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-094.jpg align="center")

**23.** Enable **"Install OpenSSH server"**. We will use it to connect to the server over SSH:

![Screenshot 95](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-095.jpg align="center")

**24.** You can also select optional software packages. We skipped this step and continued without selecting anything:

![Screenshot 96](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-096.jpg align="center")

**25.** The installation starts:

![Screenshot 97](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-097.jpg align="center")

**26.** When the installation completes successfully, you will see **"SUCCESS"** on the last line:

![Screenshot 98](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-098.png align="center")

**27.** Restart the machine by selecting **"Reboot Now"**:

![Screenshot 99](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-099.png align="center")

**28.** Log in to the server with your username and password:

![Screenshot 100](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-100.jpg align="center")

**29.** First, set a password for the **"root"** user with this command:

```bash
sudo passwd
```

![Screenshot 101](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-101.jpg align="center")

**30.** Then switch to the root user and update the system packages:

```bash
sudo apt update && apt upgrade -y
```

![Screenshot 102](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-102.jpg align="center")

Wait for the updates to finish.

Once they are done, the server is ready:

![Screenshot 103](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-103.jpg align="center")

We can now start deploying the SOC components!

## 7\. Installing the SOC Components

In this section, we install the core components of the SOC:

- **Portainer**: to manage the Docker containers
- **TheHive**: our ticketing / case management system
- **Cortex**: our SOAR, used to analyze observables
- **MISP**: our threat intelligence sharing platform, used to collect threat information and enrich indicators of compromise (IOCs)
- **Wazuh**: our SIEM, which centralizes the SOC's security events

The diagram below summarizes how these components work together:

![Screenshot 104](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-104.jpg align="center")

### 7.1. Automated Deployment

The first step is to connect to the deployment server over SSH and clone the GitHub repository that contains our installation script.

**1.** Log in to the Windows 10 host where our SSH client (PuTTY) is installed:

![Screenshot 105](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-105.jpg align="center")

**2.** Sign in to GitHub to access our private repository:

*(private repository link hidden)*

![Screenshot 106](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-106.jpg align="center")

**3.** Connect to the deployment server over SSH with PuTTY:

![Screenshot 107](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-107.jpg align="center")

![Screenshot 108](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-108.jpg align="center")

**4.** Log in to the server with our user account (manager):

![Screenshot 109](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-109.jpg align="center")

**5.** Switch to **root** and clone the private repository, using:

**Username -->** `********`

**Password --> the Personal Access Token generated on GitHub**

![Screenshot 110](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-110.jpg align="center")

**6.** Once cloned, go into the **SOC-AS-A-SERVICE** folder and make **"Script_De_Déploiement.sh"** executable:

```bash
chmod +x Script_De_Déploiement.sh
```

![Screenshot 111](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-111.jpg align="center")

**7.** Run the script:

```bash
./Script_De_Déploiement.sh
```

The script displays a menu that lets you choose which tool to install:

![Screenshot 112](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-112.jpg align="center")

**8.** Start with **option 1**, which installs the updates and prerequisites needed by the other components:

![Screenshot 113](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-113.jpg align="center")

**9.** When it finishes, the script shows the Portainer address. Portainer hosts and monitors the containers used in our environment. You will set the password for the **"admin"** user the first time you log in:

![Screenshot 114](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-114.jpg align="center")

**10.** The console then tells you to open Portainer at **http://YOUR_IP:9111**, in our case [**http://20.0.0.21:9111**](http://20.0.0.21:9111):

![Screenshot 115](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-115.jpg align="center")

**11.** You now have access to the Portainer interface:

![Screenshot 116](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-116.jpg align="center")

Notice that 2 containers are already running. They are required by TheHive.

**12.** Next, install the ticketing system by choosing **option 2** in the script:

![Screenshot 117](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-117.jpg align="center")

**13.** Once installed, the console tells you to open TheHive at

**http://YOUR_IP:9000**, in our case [**http://20.0.0.21:9000**](http://20.0.0.21:9000)

![Screenshot 118](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-118.jpg align="center")

**14.** Open the TheHive interface at that address and log in with the following credentials (you can change them later):

**Username --> admin**

**Password -->** `********`

![Screenshot 119](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-119.jpg align="center")

**15.** You are now logged in to TheHive:

![Screenshot 120](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-120.jpg align="center")

**16.** Next, install the **Cortex** SOAR by choosing **option 3** in the script:

![Screenshot 121](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-121.jpg align="center")

**17.** When it finishes, the console tells you to open Cortex at **http://YOUR_IP:9001**, in our case [**http://20.0.0.21:9001**](http://20.0.0.21:9001):

![Screenshot 122](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-122.jpg align="center")

**18.** Open the Cortex interface:

![Screenshot 123](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-123.jpg align="center")

**19.** On first access, Cortex asks you to update its database and create an administrator account:

![Screenshot 124](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-124.jpg align="center")

In our case:

**Username --> admin**

**Password -->** `********`

**20.** You can now log in to Cortex with the credentials you just created:

![Screenshot 125](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-125.jpg align="center")

![Screenshot 126](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-126.jpg align="center")

**21.** Next, install the **Wazuh** SIEM by choosing **option 4** in the script:

![Screenshot 127](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-127.jpg align="center")

**22.** When the installation finishes, the console tells you to open Wazuh at **https://YOUR_IP:9443**, in our case [**https://20.0.0.21:9443**](https://20.0.0.21:9443):

![Screenshot 128](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-128.jpg align="center")

**23.** Log in to Wazuh with the following credentials:

**Username --> admin**

**Password -->** `********`

![Screenshot 129](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-129.jpg align="center")

![Screenshot 130](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-130.jpg align="center")

**24.** Next, install **MISP** by choosing **option 5** in the script:

![Screenshot 131](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-131.jpg align="center")

**25.** The script asks for the server's IP address before starting the installation.

Enter your server's IP address, in our case **20.0.0.21**:

![Screenshot 132](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-132.jpg align="center")

**26.** When the installation finishes, the console tells you to open MISP at **https://YOUR_IP**, in our case [**https://20.0.0.21**](https://20.0.0.21):

![Screenshot 133](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-133.jpg align="center")

**27.** Log in to MISP with the following credentials:

**Username --> admin@admin.test**

**Password --> the one generated during the MISP installation**

![Screenshot 134](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-134.jpg align="center")

**28.** After logging in, MISP asks you to change the password. Our new credentials:

**Username --> admin@admin.test**

**Password -->** `********`

![Screenshot 135](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-135.jpg align="center")

## 8\. Configuring and Using TheHive (Ticketing System)

In this section, we log in to TheHive and walk through how to use it in a production environment.

**1.** Log in to the TheHive web interface and start by creating an organization.

In TheHive, an "Organization" represents a separate entity, such as a department or a business unit, that uses TheHive independently. Here is why organizations matter:

#### What an organization does in TheHive

**Data isolation**: by default, organizations are isolated from each other and cannot see or share data. This keeps information confidential and secure.

**User management**: you can assign users to one or more organizations. The suggested permission profiles depend on the organization type (Admin or non-Admin).

**Case and task management**: non-admin organizations handle the day-to-day work on cases, alerts and tasks.

#### Why create an organization?

**Separation of duties**: organizations let you separate responsibilities and data between teams or departments.

**Effective collaboration**: organizations make it easier for the security team to work together, and with other organizations, so incidents are handled faster.

**Automation and orchestration**: TheHive is designed to automate and orchestrate incident response, which reduces response times and improves your security posture.

In short, organizations give you a structured and secure way to manage security incidents, while making collaboration and automation easier.

![Screenshot 136](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-136.jpg align="center")

**2.** Give your organization a name and a description:

**Name --> CYBERETHIK**

**Description --> SOC-EXTERNE-CYBERETHIK**

![Screenshot 137](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-137.jpg align="center")

**3.** Open the organization you just created and create a user inside it:

![Screenshot 138](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-138.jpg align="center")

**4.** Fill in the new user's details:

![Screenshot 139](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-139.jpg align="center")

**5.** Set a password for this user by clicking **New password**:

![Screenshot 140](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-140.jpg align="center")

**6.** Log out, then log back in with the new user, in our case [**analyst1@cyberethik.co**](mailto:analyst1@cyberethik.co):

![Screenshot 141](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-141.jpg align="center")

**7.** Once logged in, you see this screen:

![Screenshot 142](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-142.jpg align="center")

It shows 0 cases, 0 alerts and 0 tasks. This is normal: no incident has been reported yet. Let's create a few for the demo.

**8.** Click **"New Case"** in the top-right corner:

![Screenshot 143](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-143.jpg align="center")

We created a case called **"Demo Case"**:

![Screenshot 144](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-144.jpg align="center")

**9.** Once the case is created, you see its details:

the assigned analyst, the severity, the creation date, the description and other information, as shown below:

![Screenshot 145](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-145.jpg align="center")

**10.** Now that the case exists, what can we do with it?

We can assign tasks related to this case to one or more analysts.

For example, let's assign an IP address investigation task to an analyst:

![Screenshot 146](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-146.jpg align="center")

**11.** The case **"Demo Case"** now has a task called **"Investigate IP"**:

![Screenshot 147](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-147.jpg align="center")

**12.** Several analysts can work on different tasks within the same case. Let's add a second task, **"Investigate Domain"**, to **"Demo Case"**:

![Screenshot 148](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-148.jpg align="center")

**13.** An analyst can now log in and choose which task to work on in **"Demo Case"**.

For example, the analyst can start investigating the IP address by starting the task:

![Screenshot 149](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-149.jpg align="center")

**14.** Click **Start** to get the screen below:

![Screenshot 150](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-150.jpg align="center")

**15.** During or after the investigation, the analyst can click **"Add new task log"** to document their work:

![Screenshot 151](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-151.jpg align="center")

**16.** You can also attach files, for example as evidence from an analysis:

![Screenshot 152](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-152.jpg align="center")

**17.** If you have several organizations, you can share tasks with them by clicking **"Add Share"** and selecting the organization to share with:

![Screenshot 153](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-153.png align="center")

![Screenshot 154](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-154.jpg align="center")

**18.** Because we started the task, it is automatically assigned to our analyst account, as shown below:

![Screenshot 155](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-155.jpg align="center")

Likewise, if another analyst logs in and starts the **"Investigate Domain"** task, it will be assigned to them.

**19.** Now let's say the analysis is complete and we want to take an action, for example blocking the IP address.

To do this, open the case by clicking **"Demo Case"**:

![Screenshot 156](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-156.jpg align="center")

**20.** Click **"Require action"**, then **"Add log"**:

![Screenshot 157](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-157.jpg align="center")

![Screenshot 158](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-158.jpg align="center")

**21.** Once confirmed, a **pop-up** indicates that an action is required:

![Screenshot 159](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-159.jpg align="center")

**22.** Back on the task list, you can see that the **"Investigate IP"** task requires an action:

![Screenshot 160](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-160.jpg align="center")

You can now share this task with the operational team in charge, for example the network or system team. These teams would be represented by the organizations you share with, as described above.

**23.** Once the required action has been completed, click **"Mark as done"** in the **pop-up**, describe the action taken, and confirm:

![Screenshot 161](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-161.jpg align="center")

**24.** Here, for example, we added the comment **"IP address blocked by the network team"**:

![Screenshot 162](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-162.jpg align="center")

**25.** Now close the task:

![Screenshot 163](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-163.jpg align="center")

**26.** The task is now closed:

![Screenshot 164](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-164.jpg align="center")

Repeat the same process for the second task.

**27.** You can also add observables (artifacts) during the analysis. Open the **"Observables"** tab, click **"Add observables"**, and choose a type, for example a domain or an IP:

![Screenshot 165](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-165.jpg align="center")

![Screenshot 166](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-166.jpg align="center")

**28.** Here we add the IP **8.8.8.8** with a medium severity. You can flag it as an indicator of compromise by clicking the star next to **IoC**, and add a tag; here we used the tag **"attacking IP"**:

![Screenshot 167](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-167.jpg align="center")

**29.** The observable now appears in the list:

![Screenshot 168](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-168.jpg align="center")

**30.** Now suppose this IP address is linked to the domain **"**[**hacker.com**](http://hacker.com)**"**. Add it as another observable:

![Screenshot 169](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-169.jpg align="center")

**31.** If you try to close the case now, TheHive warns you that it cannot be closed yet, because the **"Investigate Domain"** task is still in progress:

![Screenshot 170](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-170.jpg align="center")

**32.** To close the case properly, go back to the tasks and close the **"Investigate Domain"** task first:

![Screenshot 171](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-171.png align="center")

Both tasks of the case are now handled and closed:

![Screenshot 172](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-172.jpg align="center")

**33.** You can now close **"Demo Case"** without any issue:

![Screenshot 173](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-173.jpg align="center")

**34.** When closing a case, you must classify the incident, as shown below, and add a comment if needed:

![Screenshot 174](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-174.jpg align="center")

**35.** Since this was a demo, we classified it as a false positive:

![Screenshot 175](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-175.jpg align="center")

**36.** The case is now closed:

![Screenshot 176](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-176.jpg align="center")

You can also speed up incident handling by checking whether an observable has already been seen in a previous case, so you don't waste time investigating it again. To show this, create a new case called **demo2**:

![Screenshot 177](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-177.jpg align="center")

**37.** In this new case, add the same observable that we added for the **"Investigate IP"** task earlier:

![Screenshot 178](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-178.jpg align="center")

**38.** Click the observable to see whether it is linked to a previously handled case:

![Screenshot 179](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-179.jpg align="center")

**39.** TheHive shows that it is linked to a recent case, **"Demo Case"**:

![Screenshot 180](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-180.jpg align="center")

This lets you correlate observables and quickly see whether they have already been identified and handled, which makes the analysis faster and easier.

You can then simply close the case, with a comment saying it had already been seen.

Both cases are now closed:

![Screenshot 181](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-181.png align="center")

**40.** You can also follow activity in TheHive in real time by clicking **"Open in new window"** in the top-right corner:

![Screenshot 182](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-182.jpg align="center")

![Screenshot 183](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-183.jpg align="center")

In the next section, we will see how to run analyses on observables.

For example, instead of manually checking an IP's reputation on AbuseIPDB or VirusTotal, we will do it directly from TheHive.

To do this, we make API calls to threat intelligence databases and services, through our Cortex SOAR.

## 9\. Integrations and Automation

In this section, we run analyses on observables using services such as VirusTotal and AbuseIPDB.

When an analyst clicks an observable attached to a case in TheHive, they can instantly enrich it with useful information for the investigation.

This helps the team quickly deal with both urgent and non-urgent threats.

The overall goal is to automate observable analysis directly from the ticketing system.

Cortex makes API calls to various data and threat intelligence sources and displays the results, which makes analysts' work faster and more productive.

### 9.1. Configuring Cortex

As with TheHive, the first step is to log in to Cortex, create an organization, and add a user to it.

**1.** Create an organization and add a user

Click **"Add organization"** in the top-left corner:

![Screenshot 184](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-184.png align="center")

**2.** Give the organization a name and a description:

![Screenshot 185](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-185.jpg align="center")

**3.** Select the organization you just created to add a user to it:

![Screenshot 186](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-186.jpg align="center")

**4.** Click **"Add user"** in the top-left corner:

![Screenshot 187](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-187.jpg align="center")

**5.** Fill in the user's details and confirm. The new user now appears in the list:

![Screenshot 188](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-188.jpg align="center")

**6.** Next, we need to add **analyzers**. Analyzers are the modules that make the **API** calls.

The TheHive Project's GitHub repository has a Cortex Analyzers section with a full list of analyzers built by the community:

[Cortex-Analyzers/analyzers at master · TheHive-Project/Cortex-Analyzers](https://github.com/TheHive-Project/Cortex-Analyzers/tree/master/analyzers)

![Screenshot 189](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-189.png align="center")

**7.** Install the prerequisites described on this page: [Analyzers & Responders - TheHive 5 Documentation](https://docs.strangebee.com/cortex/installation-and-configuration/analyzers-responders/)

Once they are installed, you can enable an analyzer. For example, to check an IP address's reputation with VirusTotal, first enable the VirusTotal analyzer in Cortex: click the **"Organization"** section in the top-right corner:

![Screenshot 190](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-190.jpg align="center")

**8.** Then open the **"Analyzers"** tab:

![Screenshot 191](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-191.jpg align="center")

**9.** Since we want to enable **VirusTotal**, search for it in the search bar:

![Screenshot 192](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-192.png align="center")

**10.** Here, it is already enabled. If it were not, you would click **"Enable"** (see the arrow at the bottom, on **VirusTotal_Rescan_3_1**). A form like the one below opens, where you enter your VirusTotal API key:

![Screenshot 193](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-193.jpg align="center")

Then enable it.

**11.** To test the analyzer, click **"New Analysis"** in the top-left corner:

![Screenshot 194](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-194.jpg align="center")

**12.** Fill in the required information as follows:

![Screenshot 195](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-195.jpg align="center")

Here, we run the test on Google's public DNS IP address, **8.8.8.8**.

**13.** Click **"Start"** to run the analyzer on the IP. If everything works, the status shows **"Success"** once the job is complete:

![Screenshot 196](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-196.jpg align="center")

**14.** Click **"View"** to see the results. You get a detailed report like this:

![Screenshot 197](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-197.jpg align="center")

You can follow the same process to add any other analyzers you need and run analyses with them.

You can also analyze other data types, such as **IPs, hashes, domains, etc.**, to confirm potential indicators of compromise.

Next, we will integrate Cortex with TheHive so that analyses can be launched directly from TheHive when handling an alert or a case with observables.

### 9.2. Integrating Cortex with TheHive

**Goals:**

- Run analyses on observables that already exist in TheHive
- Use a single web interface
- Work faster

**1.** Connect TheHive to the Cortex API

First, create another user in Cortex with read and analyze permissions (`read`, `analyze`):

![Screenshot 198](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-198.jpg align="center")

**2.** Create an API key for this user:

![Screenshot 199](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-199.jpg align="center")

**3.** Once the API key is created, click **"Reveal"**:

![Screenshot 200](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-200.jpg align="center")

**4.** You can now see and copy the API key:

![Screenshot 201](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-201.jpg align="center")

**5.** Connect to the server where TheHive is installed and open the following file: `/etc/thehive/application.conf`

![Screenshot 202](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-202.jpg align="center")

**6.** Go to the **"Cortex configuration"** section and make the following changes:

set the name (we used `CORTEX1`), enter the Cortex server address in the `url` field, and add the API key of the user you just created. The configuration should look like this:

![Screenshot 203](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-203.png align="center")

**7.** Save the file and restart TheHive:

![Screenshot 204](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-204.jpg align="center")

**8.** Refresh the TheHive web interface and click **"About"** in the top-right corner. You can see that Cortex is now connected to TheHive:

![Screenshot 205](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-205.jpg align="center")

**9.** You can now run an analyzer on an observable directly from TheHive, without opening Cortex. Tick the box next to the observable and click **"Run analyzers"**:

![Screenshot 206](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-206.jpg align="center")

**10.** Choose the analyzer you want to run:

![Screenshot 207](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-207.jpg align="center")

**11.** For example, select VirusTotal. New information is added to the observable:

![Screenshot 208](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-208.jpg align="center")

**12.** Click the results to see more details for your analysis:

![Screenshot 209](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-209.jpg align="center")

**13.** Every analyzer launched from TheHive actually runs in Cortex. You can find it in the **"Jobs History"** section of Cortex:

![Screenshot 210](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-210.jpg align="center")

**14.** Most analyzer results are displayed as raw JSON. You can make them much more readable with report templates. To do this, log back in to TheHive as an admin:

![Screenshot 211](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-211.jpg align="center")

**15.** Go to the **"Analyzer templates"** section:

![Screenshot 212](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-212.jpg align="center")

**16.** Download the templates using the link provided in this section:

![Screenshot 213](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-213.jpg align="center")

**17.** Download the **template** archive, **without unzipping it**:

![Screenshot 214](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-214.jpg align="center")

**18.** Go back, click **"Import templates"**, and import the file you downloaded:

![Screenshot 215](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-215.jpg align="center")

**19.** Now, when you log in as an analyst and view an analyzer's results, they are displayed in a much clearer format than raw JSON:

![Screenshot 216](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-216.jpg align="center")

From now on, every analyzer report will be displayed this way!

### 9.3. Configuring MISP (Threat Intelligence Sharing Platform)

In this section, we configure MISP, our platform for sharing indicators of compromise (IOCs). MISP is valuable because it gathers many threat feeds in one central place, so you don't have to jump between sources during an investigation.

Log in to MISP and start by enabling some feeds.

**1.** In the **"Sync Actions"** menu, select **"Feeds"**:

![Screenshot 217](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-217.jpg align="center")

**2.** You now see the list of available feeds:

![Screenshot 218](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-218.jpg align="center")

**3.** There are 2 default feeds. Select both and click **"Enable selected"**:

![Screenshot 219](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-219.jpg align="center")

**4.** Confirm by clicking **"Yes"**:

![Screenshot 220](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-220.jpg align="center")

**5.** To check the progress, go to **"Administration"** > **"Jobs"**:

![Screenshot 221](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-221.jpg align="center")

![Screenshot 222](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-222.jpg align="center")

**6.** When it is done, the progress bar shows **"Completed"**. While the feeds are loading, you can already view the downloaded events by clicking "Home" > **"List Events"**:

![Screenshot 223](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-223.png align="center")

These feeds provide many indicators of compromise: known malware and their hashes, malicious IPs, malicious domains, and more.

**7.** To see more details or metadata about an event or IOC, click the eye icon in the last column of the **"List Events"** page:

![Screenshot 224](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-224.jpg align="center")

You get a lot of useful information:

![Screenshot 225](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-225.jpg align="center")

**8.** You can also do threat modeling in MISP by opening the **"Event Graph"** tab while viewing an event:

![Screenshot 226](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-226.jpg align="center")

### 9.4. Integrating MISP with Cortex

In this section, we connect MISP to Cortex so that Cortex can query the MISP IOC database through its API.

**1.** First, we need to enable the MISP analyzer in Cortex:

![Screenshot 227](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-227.png align="center")

**2.** To enable it, we need a MISP API key. Log in to MISP, go to **"Administration"**, and select **"List Auth Keys"**:

![Screenshot 228](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-228.jpg align="center")

**3.** Click **"Add authentication key"**:

![Screenshot 229](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-229.jpg align="center")

**4.** Fill in the details for your environment, including the IP address allowed to use the key (the Cortex server, in our case **20.0.0.21**). Once you confirm, MISP displays the new API key:

![Screenshot 230](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-230.jpg align="center")

**5.** Make sure you copy this key before leaving the page; it is only shown once:

![Screenshot 231](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-231.jpg align="center")

When creating the key, we added the comment **"Rest API Integration MISP-CORTEX"**.

**6.** Copy the key and paste it into the **"key"** field of the MISP analyzer in Cortex:

![Screenshot 232](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-232.jpg align="center")

![Screenshot 233](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-233.jpg align="center")

**7.** Click **"Save"** to enable the analyzer.

Let's run a quick test to confirm that MISP is properly connected to Cortex.

In Cortex, click **"New Analysis"** in the top-left corner:

![Screenshot 234](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-234.jpg align="center")

**8.** Run a test on the IP **8.8.8.8**. MISP now appears in the list of available analyzers:

![Screenshot 235](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-235.jpg align="center")

**9.** Select it and click **"Start"**:

![Screenshot 236](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-236.jpg align="center")

**10.** The analyzer runs successfully, which confirms the integration works:

![Screenshot 237](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-237.jpg align="center")

**11.** Here are the analyzer's results:

![Screenshot 238](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-238.jpg align="center")

**12.** Now let's run the MISP analyzer from TheHive. We will test it with a malicious domain as the observable.

Start by adding an observable to the **"demo2"** case created earlier:

![Screenshot 239](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-239.jpg align="center")

**13.** Fill in the required information:

![Screenshot 240](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-240.jpg align="center")

**14.** Select the observable you just added and click **"Run analyzers"**:

![Screenshot 241](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-241.png align="center")

**15.** Select MISP from the available analyzers:

![Screenshot 242](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-242.jpg align="center")

**16.** The analysis completes successfully and MISP returns information about the observable:

![Screenshot 243](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-243.jpg align="center")

**17.** Click the result to view the detailed report:

![Screenshot 244](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-244.jpg align="center")

Next, we integrate the Wazuh SIEM with TheHive.

### 9.5. Integrating Wazuh with TheHive

#### Step 1: Install the TheHive Python module with pip

This Python module is used by the custom integration script we will create in the next step.

Run the following command on the deployment server:

```bash
sudo /var/ossec/framework/python/bin/pip3 install thehive4py
```

![Screenshot 245](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-245.jpg align="center")

#### Step 2: Create the custom integration script

Create the script below in **/var/ossec/integrations/** and name it [**custom-w2thive.py**](http://custom-w2thive.py). We used nano, but any text editor will do.

In this script, the `lvl_threshold` variable is set to `0`, which means **every** alert created by Wazuh is forwarded to TheHive. If you monitor a large number of agents, this can generate a lot of noise; consider raising the threshold so that only more severe alerts are forwarded.

```python
#!/var/ossec/framework/python/bin/python3
import json
import sys
import os
import re
import logging
import uuid
from thehive4py.api import TheHiveApi
from thehive4py.models import Alert, AlertArtifact
#start user config
# Global vars
#threshold for wazuh rules level
lvl_threshold=0
#threshold for suricata rules level
suricata_lvl_threshold=3
debug_enabled = False
#info about created alert
info_enabled = True
#end user config
# Set paths
pwd = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
log_file = '{0}/logs/integrations.log'.format(pwd)
logger = logging.getLogger(__name__)
#set logging level
logger.setLevel(logging.WARNING)
if info_enabled:
    logger.setLevel(logging.INFO)
if debug_enabled:
    logger.setLevel(logging.DEBUG)
# create the logging file handler
fh = logging.FileHandler(log_file)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
logger.addHandler(fh)
def main(args):
    logger.debug('#start main')
    logger.debug('#get alert file location')
    alert_file_location = args[1]
    logger.debug('#get TheHive url')
    thive = args[3]
    logger.debug('#get TheHive api key')
    thive_api_key = args[2]
    thive_api = TheHiveApi(thive, thive_api_key )
    logger.debug('#open alert file')
    w_alert = json.load(open(alert_file_location))
    logger.debug('#alert data')
    logger.debug(str(w_alert))
    logger.debug('#gen json to dot-key-text')
    alt = pr(w_alert,'',[])
    logger.debug('#formatting description')
    format_alt = md_format(alt)
    logger.debug('#search artifacts')
    artifacts_dict = artifact_detect(format_alt)
    alert = generate_alert(format_alt, artifacts_dict, w_alert)
    logger.debug('#threshold filtering')
    if w_alert['rule']['groups']==['ids','suricata']:
        #checking the existence of the data.alert.severity field
        if 'data' in w_alert.keys():
            if 'alert' in w_alert['data']:
                #checking the level of the source event
                if int(w_alert['data']['alert']['severity'])<=suricata_lvl_threshold:
                    send_alert(alert, thive_api)
    elif int(w_alert['rule']['level'])>=lvl_threshold:
        #if the event is different from suricata AND suricata-event-type: alert check lvl_threshold
        send_alert(alert, thive_api)
def pr(data,prefix, alt):
    for key,value in data.items():
        if hasattr(value,'keys'):
            pr(value,prefix+'.'+str(key),alt=alt)
        else:
            alt.append((prefix+'.'+str(key)+'|||'+str(value)))
    return alt
def md_format(alt,format_alt=''):
    md_title_dict = {}
    #sorted with first key
    for now in alt:
        now = now[1:]
        #fix first key last symbol
        dot = now.split('|||')[0].find('.')
        if dot==-1:
            md_title_dict[now.split('|||')[0]] =[now]
        else:
            if now[0:dot] in md_title_dict.keys():
                (md_title_dict[now[0:dot]]).append(now)
            else:
                md_title_dict[now[0:dot]]=[now]
    for now in md_title_dict.keys():
        format_alt+='### '+now.capitalize()+'\n'+'| key | val |\n| ------ | ------ |\n'
        for let in md_title_dict[now]:
            key,val = let.split('|||')[0],let.split('|||')[1]
            format_alt+='| **' + key + '** | ' + val + ' |\n'
    return format_alt
def artifact_detect(format_alt):
    artifacts_dict = {}
    artifacts_dict['ip'] = re.findall(r'\d+\.\d+\.\d+\.\d+',format_alt)
    artifacts_dict['url'] = re.findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',format_alt)
    artifacts_dict['domain'] = []
    for now in artifacts_dict['url']:
        artifacts_dict['domain'].append(now.split('//')[1].split('/')[0])
    return artifacts_dict
def generate_alert(format_alt, artifacts_dict,w_alert):
    #generate alert sourceRef
    sourceRef = str(uuid.uuid4())[0:6]
    artifacts = []
    if 'agent' in w_alert.keys():
        if 'ip' not in w_alert['agent'].keys():
            w_alert['agent']['ip']='no agent ip'
    else:
        w_alert['agent'] = {'id':'no agent id', 'name':'no agent name'}
    for key,value in artifacts_dict.items():
        for val in value:
            artifacts.append(AlertArtifact(dataType=key, data=val))
    alert = Alert(title=w_alert['rule']['description'],
            tlp=2,
            tags=['wazuh',
            'rule='+w_alert['rule']['id'],
            'agent_name='+w_alert['agent']['name'],
            'agent_id='+w_alert['agent']['id'],
            'agent_ip='+w_alert['agent']['ip'],],
            description=format_alt ,
            type='wazuh_alert',
            source='wazuh',
            sourceRef=sourceRef,
            artifacts=artifacts,)
    return alert
def send_alert(alert, thive_api):
    response = thive_api.create_alert(alert)
    if response.status_code == 201:
        logger.info('Create TheHive alert: '+ str(response.json()['id']))
    else:
        logger.error('Error create TheHive alert: {}/{}'.format(response.status_code, response.text))
if __name__ == "__main__":
    try:
        logger.debug('debug mode') # if debug enabled
        # Main function
        main(sys.argv)
    except Exception:
        logger.exception('EGOR')
```

Create the script in the right location:

![Screenshot 246](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-246.jpg align="center")

Next, create a bash script called `custom-w2thive` in the same **/var/ossec/integrations/** folder. Wazuh uses it to run the Python script above:

Here is the bash script:

```bash
#!/bin/sh
# Copyright (C) 2015-2020, Wazuh Inc.
# Created by Wazuh, Inc. <info@wazuh.com>.
# This program is free software; you can redistribute it and/or modify it under the terms of GP>
WPYTHON_BIN="framework/python/bin/python3"
SCRIPT_PATH_NAME="$0"
DIR_NAME="$(cd $(dirname ${SCRIPT_PATH_NAME}); pwd -P)"
SCRIPT_NAME="$(basename ${SCRIPT_PATH_NAME})"
case ${DIR_NAME} in
    */active-response/bin | */wodles*)
        if [ -z "${WAZUH_PATH}" ]; then
            WAZUH_PATH="$(cd ${DIR_NAME}/../..; pwd)"
        fi
        PYTHON_SCRIPT="${DIR_NAME}/${SCRIPT_NAME}.py"
        ;;
    */bin)
        if [ -z "${WAZUH_PATH}" ]; then
            WAZUH_PATH="$(cd ${DIR_NAME}/..; pwd)"
        fi
        PYTHON_SCRIPT="${WAZUH_PATH}/framework/scripts/${SCRIPT_NAME}.py"
        ;;
    */integrations)
        if [ -z "${WAZUH_PATH}" ]; then
            WAZUH_PATH="$(cd ${DIR_NAME}/..; pwd)"
        fi
        PYTHON_SCRIPT="${DIR_NAME}/${SCRIPT_NAME}.py"
        ;;
esac
${WAZUH_PATH}/${WPYTHON_BIN} ${PYTHON_SCRIPT} $@
```

![Screenshot 247](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-247.jpg align="center")

#### Step 3: Set permissions and ownership

Make sure Wazuh has the right permissions to run both scripts by running the following commands:

```bash
sudo chmod 755 /var/ossec/integrations/custom-w2thive.py
sudo chmod 755 /var/ossec/integrations/custom-w2thive
sudo chown root:wazuh /var/ossec/integrations/custom-w2thive.py
sudo chown root:wazuh /var/ossec/integrations/custom-w2thive
```

![Screenshot 248](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-248.jpg align="center")

#### Step 4: Enable the integration in the Wazuh manager configuration

Open the Wazuh manager configuration file (`/var/ossec/etc/ossec.conf`) and add the block below. Put your TheHive server address in the `<hook_url>` tag and your TheHive API key in the `<api_key>` tag. The block goes inside the `<ossec_config>` section. Make sure the indentation matches the rest of the file to avoid errors.

```xml
<ossec_config>
…
  <integration>
    <name>custom-w2thive</name>
    <hook_url>http://TheHive_Server_IP:9000</hook_url>
    <api_key>YOUR_THEHIVE_API_KEY</api_key>
    <alert_format>json</alert_format>
  </integration>
…
</ossec_config>
```

To get the API key, log in to TheHive as an admin, select your organization, and create an API key for the user linked to that organization:

![Screenshot 249](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-249.jpg align="center")

**1.** Click **"Reveal"** after creating the key, then copy and save it. We will use it in the Wazuh–TheHive integration:

![Screenshot 250](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-250.png align="center")

**2.** Here is what the final Wazuh configuration looks like:

![Screenshot 251](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-251.png align="center")

**3.** Once done, restart the Wazuh manager:

```bash
sudo systemctl restart wazuh-manager
```

![Screenshot 252](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-252.jpg align="center")

**4.** If everything went well, you will soon see Wazuh alerts appear in the **Alerts** tab of TheHive:

![Screenshot 253](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-253.png align="center")

The integration is complete!

In the next section, we connect TheHive to MISP.

### 9.6. Integrating TheHive with MISP

The goal is to be able to push alerts and cases from TheHive directly to MISP, so nothing gets lost.

**1.** On the deployment server, open the file:

`/etc/thehive/application.conf`

![Screenshot 254](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-254.jpg align="center")

**2.** As with the Cortex integration, go to the MISP configuration section of the file:

![Screenshot 255](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-255.png align="center")

**3.** Fill in the required information. The configuration should look like this:

![Screenshot 256](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-256.png align="center")

**4.** Save your changes and restart TheHive:

```bash
systemctl restart thehive
```

![Screenshot 257](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-257.jpg align="center")

**5.** Refresh TheHive and open the **"About"** section, as we did for Cortex. MISP is now connected, but an error is displayed next to it:

![Screenshot 258](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-258.jpg align="center")

**6.** To fix this error, TheHive must accept MISP's self-signed certificate. In the same file, `/etc/thehive/application.conf`, add the following line to the MISP section:

```plaintext
wsConfig.ssl.loose.acceptAnyCertificate: true
```

![Screenshot 259](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-259.png align="center")

**7.** Restart TheHive again and refresh the page to confirm that the certificate is accepted and the error is gone:

![Screenshot 260](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-260.jpg align="center")

**8.** Next, let's see how to turn important alerts into cases, so analysts can track and handle them properly.

Go to the alerts page in TheHive:

![Screenshot 261](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-261.jpg align="center")

**9.** Select an alert to turn into a case. Here, we use the alert **"Successful sudo to ROOT executed"** and click the **"Import and preview"** icon next to it:

![Screenshot 262](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-262.png align="center")

**10.** The following screen appears:

![Screenshot 263](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-263.jpg align="center")

**11.** Click **"Merge into case"** at the bottom:

![Screenshot 264](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-264.jpg align="center")

**12.** Type the title of an existing case. Here, we choose **"Demo Case"**, created earlier. Select it from the list, then click **"Merge"**:

![Screenshot 265](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-265.jpg align="center")

**13.** The alert has been merged into the case, along with its key information:

![Screenshot 266](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-266.jpg align="center")

**14.** The alert is now part of the case, as shown below after clicking **"Merge"**:

![Screenshot 267](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-267.jpg align="center")

You can also export a case to MISP, for example to enrich specific alerts further.

To do this, open a case and click **"Export"** in the top-right corner:

![Screenshot 268](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-268.jpg align="center")

![Screenshot 269](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-269.jpg align="center")

**15.** The case has been exported to MISP:

![Screenshot 270](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-270.jpg align="center")

**16.** If, during an investigation, you find a critical IOC that could help others facing the same threat, you can publish it on MISP to share it with the community. Just make sure it does not contain any confidential information:

![Screenshot 271](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-271.png align="center")

![Screenshot 272](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-272.jpg align="center")

**17.** With the SOC environment in place, the next step is onboarding the assets to monitor, by installing Wazuh agents on them.

For this demo, we use one Windows agent and one Linux agent:

![Screenshot 273](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-273.jpg align="center")

**18.** Let's start with the Windows 10 host. Log in to Wazuh and generate the agent deployment script:

![Screenshot 274](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-274.jpg align="center")

**19.** Click **"Deploy new agent"**, then choose the operating system for the agent, in our case Windows:

![Screenshot 275](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-275.jpg align="center")

**20.** Fill in the required information. The screen should look like this:

![Screenshot 276](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-276.jpg align="center")

**21.** Wazuh generates a PowerShell command:

![Screenshot 277](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-277.jpg align="center")

**22.** To enroll the Windows 10 host, log in to it, open PowerShell as Administrator, and run the command:

![Screenshot 278](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-278.jpg align="center")

![Screenshot 279](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-279.jpg align="center")

**23.** The command ran successfully. To start the agent, run:

```powershell
NET START WazuhSvc
```

![Screenshot 280](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-280.png align="center")

The Wazuh agent is now running.

**24.** Now let's do the same for the Linux host. In Wazuh, change the operating system to generate the Linux deployment command:

![Screenshot 281](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-281.jpg align="center")

**25.** After filling in the required information, the screen looks like this:

![Screenshot 282](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-282.png align="center")

**26.** Copy the generated command and run it on the Linux host as root:

![Screenshot 283](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-283.jpg align="center")

**27.** To start the agent, run the following commands:

```bash
sudo systemctl daemon-reload
sudo systemctl enable wazuh-agent
sudo systemctl start wazuh-agent
```

![Screenshot 284](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-284.jpg align="center")

**28.** The agent is now running. Let's check Wazuh to confirm that both agents are connected:

![Screenshot 285](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-285.jpg align="center")

**29.** Both agents are listed and active, since both hosts are currently running.

Click **"Inventory"** to see all the system information collected from an agent:

![Screenshot 286](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-286.jpg align="center")

## 10\. Installing the Shuffle SOAR

Shuffle lets us automate the playbooks we define.

For this installation, we deployed a dedicated Ubuntu host on our Proxmox hypervisor to run Shuffle:

![Screenshot 287](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-287.jpg align="center")

**1.** Install the Docker prerequisites. Log in to the Ubuntu host and run the following commands:

```bash
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
```

![Screenshot 288](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-288.jpg align="center")

**2.** Download the Docker installation script:

```bash
curl -fsSL https://get.docker.com -o get-docker.sh
```

**3.** Install Docker:

```bash
sh get-docker.sh
```

**4.** Download docker-compose:

```bash
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
```

![Screenshot 289](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-289.jpg align="center")

**5.** Make it executable:

```bash
sudo chmod +x /usr/local/bin/docker-compose
```

**6.** Enable the Docker service:

```bash
sudo systemctl enable docker
```

![Screenshot 290](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-290.jpg align="center")

**7.** Start the Docker service:

```bash
systemctl start docker
```

**8.** Clone the Shuffle GitHub repository:

```bash
git clone https://github.com/frikky/shuffle
```

![Screenshot 291](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-291.jpg align="center")

**9.** Go into the Shuffle folder:

```bash
cd shuffle/
```

**10.** Start Shuffle with docker-compose:

```bash
sudo docker-compose up -d
```

![Screenshot 292](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-292.jpg align="center")

**11.** Apply the following changes so that the OpenSearch database works properly:

```bash
sudo sysctl -w vm.max_map_count=262144
sudo chown 1000:1000 -R shuffle-database
```

![Screenshot 293](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-293.jpg align="center")

**12.** Restart Shuffle:

```bash
sudo docker-compose restart
```

![Screenshot 294](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-294.jpg align="center")

Once the installation is complete, open the web interface to create the administrator account: <http://20.0.0.25:3001> or <https://20.0.0.25:3443>

![Screenshot 295](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-295.jpg align="center")

**13.** You now have access to the Shuffle interface:

![Screenshot 296](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-296.jpg align="center")

**14.** Log in with the administrator account you created on first access:

![Screenshot 297](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/etape-297.jpg align="center")

Shuffle is installed and ready to use!

---

# Part 3 — Use Cases in Action

## 11\. SOC Use Case Demonstrations

The SOC is deployed. Now let's prove it works. This part walks through a set of real-world scenarios that show how Wazuh, the core of our SOC, can be configured to **prevent, detect and respond** to threats. Each use case is a realistic scenario you can reproduce in your own lab with a few specific configuration changes.

### 11.1. Preparing the lab environment

Wazuh is made of **agents**, deployed on the monitored endpoints, and **central components**, which collect and analyze the data sent by the agents.

We recommend using virtual machines and taking **snapshots** right after setting up the infrastructure. This way, you can go back to a clean environment before testing each new use case, so tests don't interfere with each other.

The diagram below shows the lab architecture needed to run the use cases in this part:

![Wazuh lab architecture for the use cases](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-001.jpg align="center")

#### Wazuh central components

In these use cases, the Wazuh central components (server, indexer and dashboard) run on a single system. A distributed architecture isn't needed to monitor a small environment like this one. Here, we simply use the Wazuh SIEM deployed in Part 2.

#### Monitored endpoints

The Wazuh agent monitors the following endpoints. Depending on the use case, an endpoint plays the role of the **victim** or of the **attacker**.

| Endpoint | Operating system (64-bit) | CPU | RAM | Disk |
| --- | --- | --- | --- | --- |
| Ubuntu | Ubuntu 22.04 LTS | 1 vCPU | 2 GB | 10 GB |
| RHEL | Red Hat Enterprise Linux 9.0 / 8.0 | 1 vCPU | 2 GB | 10 GB |
| Windows | Windows 11 / 10 | 2 vCPU | 4 GB | 25 GB |
| Kali Linux | Kali Linux (attacker) | — | — | — |

See section 9.6 (steps 17 to 29) for how to install the Wazuh agent on these endpoints. You need Internet access for some integrations and to download the software used in the use cases.

> **Note:** the use cases were run in a dedicated test network (`192.168.20.0/24`), so the IP addresses in the screenshots differ from those of Part 2. In the commands, replace placeholders such as `<UBUNTU_IP>` with your own values.

#### The 12 use cases

1. Blocking a known malicious actor
2. File integrity monitoring
3. Detecting a brute-force attack
4. Monitoring Docker events
5. Monitoring AWS infrastructure
6. Detecting unauthorized processes
7. Network IDS integration
8. Detecting a SQL injection attack
9. Detecting suspicious binaries
10. Detecting and removing malware with VirusTotal
11. Vulnerability detection
12. Detecting hidden processes

---

### 11.2. Use case 1 — Blocking a known malicious actor

In this use case, we prevent malicious IP addresses from accessing a web server. We set up an Apache web server on an Ubuntu endpoint and try to reach it from an attacker endpoint.

We use a public **IP reputation database**: a list of IP addresses that have been reported as malicious. The attacker endpoint plays the malicious actor, so we add its IP address to that database.

We then configure Wazuh to **block the attacker from reaching the web server for 60 seconds**, a simple way to discourage attackers from continuing.

This use case relies on two Wazuh features: **CDB lists** and **Active Response**.

**Infrastructure**

| Endpoint | Description |
| --- | --- |
| Attacker (RHEL 9.0) | Connects to the victim's web server. Its IP address is flagged as malicious using a Wazuh CDB list. |
| Ubuntu 22.04 (victim) | Runs an Apache 2.4.54 web server. Wazuh Active Response automatically blocks connections from the attacker. |
| Windows 11 (victim) | Runs an Apache 2.4.54 web server. Wazuh Active Response automatically blocks connections from the attacker. |

#### Configuration — Ubuntu endpoint

Install an Apache web server and monitor its logs with the Wazuh agent.

**1.1.** Update the local packages and install Apache:

```bash
sudo apt update
sudo apt install apache2
```

![Use case screenshot 2](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-002.jpg align="center")

**1.2.** If the firewall is enabled, allow external access to the web ports (skip this step if the firewall is disabled):

```bash
sudo ufw status
sudo ufw app list
sudo ufw allow 'Apache'
```

![Use case screenshot 3](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-003.png align="center")

**1.3.** Check that the Apache service is running:

```bash
sudo systemctl status apache2
```

![Use case screenshot 4](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-004.jpg align="center")

**1.4.** Use `curl` (or open the URL in a browser) to display the Apache default page and confirm the installation:

```bash
curl http://<UBUNTU_IP>
```

You should get a result like this:

![Use case screenshot 5](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-005.jpg align="center")

**1.5.** Add the following to `/var/ossec/etc/ossec.conf` so the Wazuh agent monitors the Apache access logs:

```xml
<localfile>
  <log_format>syslog</log_format>
  <location>/var/log/apache2/access.log</location>
</localfile>
```

![Use case screenshot 6](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-006.png align="center")

**1.6.** Restart the Wazuh agent to apply the changes:

```bash
sudo systemctl restart wazuh-agent
```

![Use case screenshot 7](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-007.jpg align="center")

#### Configuration — Wazuh server

On the Wazuh server, we add the attacker's IP address to a CDB list, then configure the rules and Active Response.

**Download the utilities and set up the CDB list**

**1.7.** Install `wget` to download the required files:

```bash
sudo apt update && sudo apt install -y wget
```

![Use case screenshot 8](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-008.jpg align="center")

**1.8.** Download the AlienVault IP reputation database:

```bash
sudo wget https://raw.githubusercontent.com/firehol/blocklist-ipsets/master/alienvault_reputation.ipset -O /var/ossec/etc/lists/alienvault_reputation.ipset
```

![Use case screenshot 9](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-009.jpg align="center")

**1.9.** Add the attacker's IP address to the reputation database (replace `<ATTACKER_IP>` with the attacker's IP):

```bash
echo "<ATTACKER_IP>" | sudo tee -a /var/ossec/etc/lists/alienvault_reputation.ipset
```

![Use case screenshot 10](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-010.jpg align="center")

**1.10.** Download a script that converts the `.ipset` format to the CDB list format:

```bash
sudo wget https://wazuh.com/resources/iplist-to-cdblist.py -O /tmp/iplist-to-cdblist.py
```

![Use case screenshot 11](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-011.jpg align="center")

**1.11.** Convert `alienvault_reputation.ipset` to a CDB list with the script:

```bash
sudo python3 /tmp/iplist-to-cdblist.py /var/ossec/etc/lists/alienvault_reputation.ipset /var/ossec/etc/lists/blacklist-alienvault
```

![Use case screenshot 12](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-012.jpg align="center")

**1.12.** Optional: remove the `.ipset` file and the script, which are no longer needed:

```bash
sudo rm -rf /var/ossec/etc/lists/alienvault_reputation.ipset
sudo rm -rf /tmp/iplist-to-cdblist.py
```

**1.13.** Set the right ownership on the generated file:

```bash
sudo chown wazuh:wazuh /var/ossec/etc/lists/blacklist-alienvault
```

**Configure Active Response to block the malicious IP**

Add a custom rule that triggers a Wazuh Active Response script. Add it to the custom ruleset file on the Wazuh server, `/var/ossec/etc/rules/local_rules.xml`:

```xml
<group name="attack,">
  <rule id="100100" level="10">
    <if_group>web|attack|attacks</if_group>
    <list field="srcip" lookup="address_match_key">etc/lists/blacklist-alienvault</list>
    <description>IP address found in AlienVault reputation database.</description>
  </rule>
</group>
```

![Use case screenshot 13](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-013.png align="center")

**1.14.** Edit the Wazuh server configuration file, `/var/ossec/etc/ossec.conf`, and add the list to the `<ruleset>` section:

```xml
<ossec_config>
  <ruleset>
    <!-- Default ruleset -->
    <decoder_dir>ruleset/decoders</decoder_dir>
    <rule_dir>ruleset/rules</rule_dir>
    <rule_exclude>0215-policy_rules.xml</rule_exclude>
    <list>etc/lists/audit-keys</list>
    <list>etc/lists/amazon/aws-eventnames</list>
    <list>etc/lists/security-eventchannel</list>
    <list>etc/lists/blacklist-alienvault</list>

    <!-- User-defined ruleset -->
    <decoder_dir>etc/decoders</decoder_dir>
    <rule_dir>etc/rules</rule_dir>
  </ruleset>
</ossec_config>
```

![Use case screenshot 14](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-014.png align="center")

**1.15.** Add the Active Response block to the same file, `/var/ossec/etc/ossec.conf`.

*For the Ubuntu endpoint:* the `firewall-drop` command works with the local iptables firewall and drops incoming connections from the attacker for 60 seconds:

```xml
<ossec_config>
  <active-response>
    <command>firewall-drop</command>
    <location>local</location>
    <rules_id>100100</rules_id>
    <timeout>60</timeout>
  </active-response>
</ossec_config>
```

![Use case screenshot 15](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-015.jpg align="center")

**1.16.** Restart the Wazuh manager to apply the changes:

```bash
sudo systemctl restart wazuh-manager
```

#### Attack emulation

From the attacker endpoint, access the web server (replace `<WEBSERVER_IP>` with the right value):

```bash
curl http://<WEBSERVER_IP>
```

The first connection goes through. After that, Wazuh Active Response temporarily blocks every new connection from the attacker for 60 seconds.

#### Viewing the alerts

You can view the alert data in the Wazuh dashboard: open the **Threat Hunting** module and add filters in the search bar to query the alerts.

![Use case screenshot 16](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-016.jpg align="center")

---

### 11.3. Use case 2 — File integrity monitoring (FIM)

File Integrity Monitoring (FIM) helps you audit sensitive files and meet regulatory compliance requirements. Wazuh has a built-in FIM module that watches the file system for file **creation, modification and deletion**.

In this use case, the Wazuh FIM module detects changes in monitored directories on an Ubuntu endpoint. It also enriches the alerts with information about the user and process behind each change, using **who-data** auditing.

**Infrastructure**

| Endpoint | Description |
| --- | --- |
| Ubuntu 22.04 | The Wazuh FIM module monitors a directory on this endpoint to detect file creation, changes and deletion. |
| Windows 11 | The Wazuh FIM module monitors a directory on this endpoint to detect file creation, changes and deletion. |

#### Configuration — Ubuntu endpoint

Configure the Wazuh agent to monitor file system changes in the `/root` directory.

**2.1.** Edit the Wazuh agent configuration file, `/var/ossec/etc/ossec.conf`, and add the directory to monitor inside the `<syscheck>` block. `report_changes` and `realtime` give you details on what changed, as soon as it changes:

```xml
<directories check_all="yes" report_changes="yes" realtime="yes">/root</directories>
```

> You can monitor any path you like in this block.

![Use case screenshot 17](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-017.jpg align="center")

**2.2.** Restart the Wazuh agent to apply the changes:

```bash
sudo systemctl restart wazuh-agent
```

![Use case screenshot 18](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-018.jpg align="center")

#### Testing the configuration

- Create a text file in the monitored directory, then wait 5 seconds.
- Add some content to the file and save it. Wait 5 seconds.
- Delete the file from the monitored directory.

#### Viewing the alerts

Open the **File Integrity Monitoring** module in the Wazuh dashboard and add filters in the search bar to query the alerts:

![Use case screenshot 19](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-019.jpg align="center")

![Use case screenshot 20](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-020.jpg align="center")

You can see the file being created, then modified, then deleted!

---

### 11.4. Use case 3 — Detecting a brute-force attack

Brute-forcing is a common way for attackers to gain unauthorized access to endpoints and services. Services such as **SSH** on Linux and **RDP** on Windows are frequent targets. Wazuh detects brute-force attacks by **correlating multiple failed authentication events**.

Use case 1 showed how to block an attacker's IP with Active Response. Here, we show how Wazuh detects brute-force attacks against our endpoints.

**Infrastructure**

| Endpoint | Description |
| --- | --- |
| Kali Linux (attacker) | Runs the brute-force attacks. Needs an SSH client. |
| Ubuntu 22.04 (victim) | Target of SSH brute-force attacks. Needs an SSH server installed and enabled. |
| Windows 10 (victim) | Target of RDP brute-force attacks. Needs RDP enabled. |

#### Configuration

On the attacker endpoint (Kali), install **Hydra**, which we will use to run the brute-force attack:

**3.1.** Install Hydra:

```bash
sudo apt update
sudo apt install -y hydra
```

#### Attack emulation — SSH (Ubuntu)

- Create a text file containing 10 random passwords.
- Run Hydra against the Ubuntu endpoint (replace `<UBUNTU_IP>` with its IP address):

```bash
sudo hydra -l badguy -P <PASSWD_LIST.txt> <UBUNTU_IP> ssh
```

![Use case screenshot 21](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-021.jpg align="center")

Wazuh detects the attack, and the alerts include information about the attacker:

![Use case screenshot 22](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-022.png align="center")

#### Attack emulation — RDP (Windows)

Now let's try an RDP brute-force against the Windows endpoint. Run Hydra from the attacker, replacing `<WINDOWS_IP>` with the Windows endpoint's IP:

```bash
sudo hydra -l badguy -P <PASSWD_LIST.txt> rdp://<WINDOWS_IP>
```

![Use case screenshot 23](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-023.jpg align="center")

Here is what Wazuh detects:

![Use case screenshot 24](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-024.jpg align="center")

The RDP brute-force attack is detected by the SIEM as well.

---

### 11.5. Use case 4 — Monitoring Docker events

Docker automates the deployment of applications inside software containers. The Wazuh Docker module detects security incidents in containers and alerts in real time. Here, we configure Wazuh to monitor Docker events on an Ubuntu endpoint that hosts containers.

**Infrastructure**

| Endpoint | Description |
| --- | --- |
| Ubuntu 22.04 | The Docker host where you create and delete containers. |

#### Configuration

**4.1.** Install Python and pip:

```bash
sudo apt install python3 python3-pip
```

**4.2.** Upgrade pip:

```bash
pip3 install --upgrade pip
```

**4.3.** Install Docker and the Docker Python library:

```bash
curl -sSL https://get.docker.com/ | sh
sudo pip3 install docker==7.1.0 urllib3==2.2.2 requests==2.32.2 --break-system-packages
```

![Use case screenshot 25](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-025.jpg align="center")

**4.4.** Edit the Wazuh agent configuration file, `/var/ossec/etc/ossec.conf`, and add this block to enable the `docker-listener` module:

```xml
<ossec_config>
  <wodle name="docker-listener">
    <interval>10m</interval>
    <attempts>5</attempts>
    <run_on_start>yes</run_on_start>
    <disabled>no</disabled>
  </wodle>
</ossec_config>
```

![Use case screenshot 26](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-026.jpg align="center")

**4.5.** Restart the Wazuh agent to apply the changes:

```bash
sudo systemctl restart wazuh-agent
```

#### Testing the configuration

Perform several Docker actions: pull an image, start a container, run some commands inside it, then remove it.

- Pull an image, such as NGINX, and run a container:

```bash
sudo docker pull nginx
sudo docker run -d -P --name nginx_container nginx
sudo docker exec -it nginx_container cat /etc/passwd
sudo docker exec -it nginx_container /bin/bash
exit
```

![Use case screenshot 27](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-027.jpg align="center")

- Stop and remove the container:

```bash
sudo docker stop nginx_container
sudo docker rm nginx_container
```

![Use case screenshot 28](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-028.jpg align="center")

#### Viewing the alerts

Open the **Docker** module in the Wazuh dashboard:

![Use case screenshot 29](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-029.jpg align="center")

![Use case screenshot 30](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-030.jpg align="center")

Wazuh tracks the container in real time, from its creation to its removal!

---

### 11.6. Use case 5 — Monitoring AWS infrastructure

This use case shows how the Wazuh AWS module (`aws-s3`) collects log data from AWS services, here **Amazon CloudTrail**.

**Infrastructure**

| Cloud service | Description |
| --- | --- |
| Amazon CloudTrail | Like the other supported AWS services, CloudTrail requires the right policies for user permissions and a valid authentication method. In this PoC, we use **profile** authentication. |

#### Configuration — CloudTrail

**5.1.** Open the CloudTrail service from the AWS console:

![Use case screenshot 31](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-031.jpg align="center")

**5.2.** Create a new trail:

![Use case screenshot 32](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-032.jpg align="center")

**5.3.** Either create a new S3 bucket or choose an existing one to store the CloudTrail logs. **Write down the bucket name**: you will need it in the Wazuh configuration.

![Use case screenshot 33](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-033.png align="center")

![Use case screenshot 34](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-034.jpg align="center")

**5.4.** On the Wazuh server, add the `aws-s3` module to `/var/ossec/etc/ossec.conf`, with your bucket name and AWS profile:

```xml
<ossec_config>
  <wodle name="aws-s3">
    <disabled>no</disabled>
    <interval>10m</interval>
    <run_on_start>yes</run_on_start>
    <skip_on_error>yes</skip_on_error>
    <bucket type="cloudtrail">
      <name><AWS_BUCKET_NAME></name>
      <aws_profile><AWS_PROFILE_NAME></aws_profile>
    </bucket>
  </wodle>
</ossec_config>
```

**5.5.** Restart the Wazuh manager. AWS monitoring alerts now appear in the dashboard:

```bash
sudo systemctl restart wazuh-manager
```

![Use case screenshot 35](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-035.jpg align="center")

---

### 11.7. Use case 6 — Detecting unauthorized processes

The Wazuh **command monitoring** feature runs commands on an endpoint and monitors their output.

In this use case, we use it to detect when **Netcat** is running on an Ubuntu endpoint. Netcat is a networking utility often used for port scanning and listening, and a classic tool for attackers.

**Infrastructure**

| Endpoint | Description |
| --- | --- |
| Ubuntu 22.04 | We configure Wazuh command monitoring on this endpoint to detect a running Netcat process. |

#### Configuration — Ubuntu endpoint

Configure command monitoring to periodically list all running processes on the Ubuntu endpoint.

**6.1.** Add the following block to the Wazuh agent configuration file, `/var/ossec/etc/ossec.conf`. It collects the list of running processes every 30 seconds:

```xml
<ossec_config>
  <localfile>
    <log_format>full_command</log_format>
    <alias>process list</alias>
    <command>ps -e -o pid,uname,command</command>
    <frequency>30</frequency>
  </localfile>
</ossec_config>
```

![Use case screenshot 36](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-036.png align="center")

**6.2.** Restart the Wazuh agent to apply the changes:

```bash
sudo systemctl restart wazuh-agent
```

**6.3.** Install Netcat and its dependencies:

```bash
sudo apt install ncat nmap -y
```

![Use case screenshot 37](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-037.jpg align="center")

#### Configuration — Wazuh server

Create a rule that fires every time Netcat is launched.

**6.4.** Add the following rules to `/var/ossec/etc/rules/local_rules.xml` on the Wazuh server:

```xml
<group name="ossec,">
  <rule id="100050" level="0">
    <if_sid>530</if_sid>
    <match>^ossec: output: 'process list'</match>
    <description>List of running processes.</description>
    <group>process_monitor,</group>
  </rule>

  <rule id="100051" level="7" ignore="900">
    <if_sid>100050</if_sid>
    <match>nc -l</match>
    <description>netcat listening for incoming connections.</description>
    <group>process_monitor,</group>
  </rule>
</group>
```

**6.5.** Restart the Wazuh manager to apply the changes:

```bash
sudo systemctl restart wazuh-manager
```

![Use case screenshot 38](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-038.jpg align="center")

![Use case screenshot 39](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-039.jpg align="center")

#### Attack emulation

On the monitored Ubuntu endpoint, run Netcat for 30 seconds:

```bash
nc -l 8000
```

#### Viewing the alerts

Open the **Threat Hunting** module in the Wazuh dashboard and filter the alerts (for example `rule.id:100051`):

![Use case screenshot 40](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-040.jpg align="center")

![Use case screenshot 41](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-041.jpg align="center")

---

### 11.8. Use case 7 — Network IDS integration

Wazuh integrates with a network-based intrusion detection system (NIDS) to improve threat detection by monitoring and analyzing network traffic.

In this use case, we integrate **Suricata** with Wazuh. Suricata's network traffic inspection gives extra visibility into what's happening on your network.

**Infrastructure**

| Endpoint | Description |
| --- | --- |
| Ubuntu 22.04 | The endpoint where we install Suricata. Wazuh monitors and analyzes the network traffic it sees. |

#### Configuration

Set up Suricata on the Ubuntu endpoint and send its logs to the Wazuh server.

**7.1.** Install Suricata on the Ubuntu endpoint (we tested this with version 6.0.8; it may take a while):

```bash
sudo add-apt-repository ppa:oisf/suricata-stable
sudo apt-get update
sudo apt-get install suricata -y
```

![Use case screenshot 42](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-042.jpg align="center")

**7.2.** Download and extract the Emerging Threats ruleset for Suricata:

```bash
cd /tmp/ && curl -LO https://rules.emergingthreats.net/open/suricata-6.0.8/emerging.rules.tar.gz
sudo tar -xvzf emerging.rules.tar.gz && sudo mkdir /etc/suricata/rules && sudo mv rules/*.rules /etc/suricata/rules/
sudo chmod 640 /etc/suricata/rules/*.rules
```

![Use case screenshot 43](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-043.jpg align="center")

**7.3.** Edit the Suricata settings in `/etc/suricata/suricata.yaml` and set the following variables (use your own network interface name for `af-packet`):

```yaml
HOME_NET: "<UBUNTU_IP>"
EXTERNAL_NET: "any"

default-rule-path: /etc/suricata/rules
rule-files:
  - "*.rules"

# Global stats configuration
stats:
  enabled: yes

# Linux high speed capture support
af-packet:
  - interface: enp0s3
```

**7.4.** Restart Suricata:

```bash
sudo systemctl restart suricata
```

**7.5.** Add the following to the Wazuh agent configuration file, `/var/ossec/etc/ossec.conf`, so the agent reads Suricata's log file:

```xml
<ossec_config>
  <localfile>
    <log_format>json</log_format>
    <location>/var/log/suricata/eve.json</location>
  </localfile>
</ossec_config>
```

![Use case screenshot 44](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-044.png align="center")

**7.6.** Restart the Wazuh agent to apply the changes:

```bash
sudo systemctl restart wazuh-agent
```

#### Attack emulation

Wazuh automatically parses `/var/log/suricata/eve.json` and generates the related alerts in the dashboard.

Ping the Ubuntu endpoint from the Wazuh server:

```bash
ping -c 20 "<UBUNTU_IP>"
```

#### Viewing the alerts

Open the **Threat Hunting** module and filter the alerts:

![Use case screenshot 45](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-045.jpg align="center")

The SIEM now sees and detects network flows!

---

### 11.9. Use case 8 — Detecting a SQL injection attack

Wazuh can detect SQL injection attacks from web server logs that contain patterns such as `select`, `union` and other common SQL injection patterns.

SQL injection is an attack where a malicious actor inserts malicious code into strings that are passed to a database server for parsing and execution. A successful SQL injection gives unauthorized access to the confidential data stored in the database.

In this use case, we simulate a SQL injection attack against the Ubuntu endpoint and detect it with Wazuh.

**Infrastructure**

| Endpoint | Description |
| --- | --- |
| Ubuntu 22.04 (victim) | Runs an Apache 2.4.54 web server. |
| RHEL 8.0 (attacker) | Launches the SQL injection attack. |

#### Configuration — Ubuntu endpoint

Install Apache and configure the Wazuh agent to monitor the Apache logs.

**8.1.** Update the local packages and install Apache:

```bash
sudo apt update
sudo apt install apache2
```

**8.2.** If the firewall is enabled, allow external access to the web ports (skip this step if it is disabled):

```bash
sudo ufw app list
sudo ufw allow 'Apache'
sudo ufw status
```

**8.3.** Check that the Apache service is running:

```bash
sudo systemctl status apache2
```

**8.4.** Use `curl` (or open the URL in a browser) to display the Apache default page:

```bash
curl http://<UBUNTU_IP>
```

**8.5.** Add the following to the Wazuh agent configuration file, `/var/ossec/etc/ossec.conf`, so the agent monitors the Apache access logs:

```xml
<ossec_config>
  <localfile>
    <log_format>apache</log_format>
    <location>/var/log/apache2/access.log</location>
  </localfile>
</ossec_config>
```

**8.6.** Restart the Wazuh agent to apply the changes:

```bash
sudo systemctl restart wazuh-agent
```

#### Attack emulation

From the attacker endpoint, run the following command (replace `<UBUNTU_IP>` with the right IP):

```bash
curl -XGET "http://<UBUNTU_IP>/users/?id=SELECT+*+FROM+users";
```

The expected result is an alert with rule ID **31103**; a *successful* SQL injection attempt generates an alert with rule ID **31106**.

![Use case screenshot 46](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-046.jpg align="center")

In our case, since we had already added the attacker's IP to the CDB list in use case 1, the request was also flagged as coming from an IP with a bad reputation!

---

### 11.10. Use case 9 — Detecting suspicious binaries

Wazuh has anomaly and malware detection capabilities that spot suspicious binaries on an endpoint. Binaries are executable code; attackers often tamper with them to run malicious code while avoiding detection.

In this use case, the Wazuh **rootcheck** module detects a **trojaned system binary** on an Ubuntu endpoint. We perform the exploit by replacing the content of a legitimate binary with malicious code, so the endpoint runs it as if it were the original.

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

**Infrastructure**

| Endpoint | Description |
| --- | --- |
| Ubuntu 22.04 | The Wazuh rootcheck module detects a suspicious binary on this endpoint. |

#### Configuration

The rootcheck module is enabled by default in the Wazuh agent configuration. Check the `<rootcheck>` block in `/var/ossec/etc/ossec.conf` on the monitored endpoint and make sure it looks like this:

```xml
<rootcheck>
  <disabled>no</disabled>
  <check_files>yes</check_files>

  <!-- Line for trojans detection -->
  <check_trojans>yes</check_trojans>

  <check_dev>yes</check_dev>
  <check_sys>yes</check_sys>
  <check_pids>yes</check_pids>
  <check_ports>yes</check_ports>
  <check_if>yes</check_if>

  <!-- Frequency that rootcheck is executed - every 12 hours -->
  <frequency>43200</frequency>
  <rootkit_files>/var/ossec/etc/shared/rootkit_files.txt</rootkit_files>
  <rootkit_trojans>/var/ossec/etc/shared/rootkit_trojans.txt</rootkit_trojans>
  <skip_nfs>yes</skip_nfs>
</rootcheck>
```

![Use case screenshot 47](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-047.png align="center")

#### Attack emulation

- Make a copy of the original system binary:

```bash
sudo cp -p /usr/bin/w /usr/bin/w.copy
```

- Replace the original `/usr/bin/w` binary with the following shell script:

```bash
sudo tee /usr/bin/w << EOF
#!/bin/bash
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
/usr/bin/w.copy
EOF
```

![Use case screenshot 48](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-048.jpg align="center")

- By default, the rootcheck scan runs every 12 hours. Force a scan by restarting the Wazuh agent:

```bash
sudo systemctl restart wazuh-agent
```

#### Viewing the alerts

Open the **Threat Hunting** module and filter the alerts with:

```plaintext
location:rootcheck AND rule.id:510 AND data.title:Trojaned version of file detected.
```

![Use case screenshot 49](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-049.jpg align="center")

---

### 11.11. Use case 10 — Detecting and removing malware with VirusTotal

Wazuh uses its integration module to connect to external APIs and alerting tools such as **VirusTotal**.

In this use case, the Wazuh FIM module monitors a directory for changes, and the VirusTotal API scans the files in that directory. We then configure Wazuh to trigger an **Active Response** script that **deletes any file VirusTotal flags as malicious**.

You need a VirusTotal API key so Wazuh can authenticate with the VirusTotal API.

**Infrastructure**

| Endpoint | Description |
| --- | --- |
| Ubuntu 22.04 | The Linux endpoint where you download a malicious file. Wazuh triggers an Active Response script to delete it once VirusTotal flags it as malicious. |
| Windows 11 | The Windows endpoint where you download a malicious file. Wazuh triggers an Active Response script to delete it once VirusTotal flags it as malicious. |

#### Configuration — Ubuntu endpoint

These steps configure Wazuh to monitor the `/root` directory in near real time, install the required packages, and create the Active Response script that removes malicious files. They also work on other Linux distributions.

**10.1.** In the Wazuh agent configuration file, `/var/ossec/etc/ossec.conf`, find the `<syscheck>` block and make sure `<disabled>` is set to `no`. This enables Wazuh FIM.

**10.2.** Inside the `<syscheck>` block, add an entry to monitor the `/root` directory in near real time:

```xml
<directories realtime="yes">/root</directories>
```

![Use case screenshot 50](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-050.jpg align="center")

**10.3.** Install `jq`, which the Active Response script uses to parse JSON input:

```bash
sudo apt update
sudo apt -y install jq
```

![Use case screenshot 51](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-051.jpg align="center")

**10.4.** Create the Active Response script `/var/ossec/active-response/bin/remove-threat.sh`, which removes malicious files from the endpoint:

```bash
#!/bin/bash

LOCAL=`dirname $0`;
cd $LOCAL
cd ../

PWD=`pwd`

read INPUT_JSON
FILENAME=$(echo $INPUT_JSON | jq -r .parameters.alert.data.virustotal.source.file)
COMMAND=$(echo $INPUT_JSON | jq -r .command)
LOG_FILE="${PWD}/../logs/active-responses.log"

#------------------------ Analyze command -------------------------#
if [ ${COMMAND} = "add" ]
then
 # Send control message to execd
 printf '{"version":1,"origin":{"name":"remove-threat","module":"active-response"},"command":"check_keys", "parameters":{"keys":[]}}\n'

 read RESPONSE
 COMMAND2=$(echo $RESPONSE | jq -r .command)
 if [ ${COMMAND2} != "continue" ]
 then
  echo "`date '+%Y/%m/%d %H:%M:%S'` $0: $INPUT_JSON Remove threat active response aborted" >> ${LOG_FILE}
  exit 0;
 fi
fi

# Removing file
rm -f $FILENAME
if [ $? -eq 0 ]; then
 echo "`date '+%Y/%m/%d %H:%M:%S'` $0: $INPUT_JSON Successfully removed threat" >> ${LOG_FILE}
else
 echo "`date '+%Y/%m/%d %H:%M:%S'` $0: $INPUT_JSON Error removing threat" >> ${LOG_FILE}
fi

exit 0;
```

**10.5.** Set the script's ownership and permissions:

```bash
sudo chmod 750 /var/ossec/active-response/bin/remove-threat.sh
sudo chown root:wazuh /var/ossec/active-response/bin/remove-threat.sh
```

![Use case screenshot 52](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-052.jpg align="center")

**10.6.** Restart the Wazuh agent to apply the changes:

```bash
sudo systemctl restart wazuh-agent
```

#### Configuration — Wazuh server

On the Wazuh server, we raise alerts for changes in the endpoint's directory, enable the VirusTotal integration, and trigger the Active Response script whenever a suspicious file is detected.

**10.7.** Add the following rules to `/var/ossec/etc/rules/local_rules.xml`. They raise alerts for changes in `/root` detected by FIM scans:

```xml
<group name="syscheck,pci_dss_11.5,nist_800_53_SI.7,">
    <!-- Rules for Linux systems -->
    <rule id="100200" level="7">
        <if_sid>550</if_sid>
        <field name="file">/root</field>
        <description>File modified in /root directory.</description>
    </rule>
    <rule id="100201" level="7">
        <if_sid>554</if_sid>
        <field name="file">/root</field>
        <description>File added to /root directory.</description>
    </rule>
</group>
```

![Use case screenshot 53](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-053.png align="center")

**10.8.** Add the following to the Wazuh server's `/var/ossec/etc/ossec.conf` to enable the VirusTotal integration. Replace `<YOUR_VIRUS_TOTAL_API_KEY>` with your own key. A VirusTotal query is triggered every time rule `100200` or `100201` fires:

```xml
<ossec_config>
  <integration>
    <name>virustotal</name>
    <api_key><YOUR_VIRUS_TOTAL_API_KEY></api_key> <!-- Replace with your VirusTotal API key -->
    <rule_id>100200,100201</rule_id>
    <alert_format>json</alert_format>
  </integration>
</ossec_config>
```

![Use case screenshot 54](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-054.jpg align="center")

**10.9.** Add the following blocks to the Wazuh server's `/var/ossec/etc/ossec.conf`. They enable Active Response and run the `remove-threat.sh` script when VirusTotal flags a file as malicious:

```xml
<ossec_config>
  <command>
    <name>remove-threat</name>
    <executable>remove-threat.sh</executable>
    <timeout_allowed>no</timeout_allowed>
  </command>

  <active-response>
    <disabled>no</disabled>
    <command>remove-threat</command>
    <location>local</location>
    <rules_id>87105</rules_id>
  </active-response>
</ossec_config>
```

**10.10.** Add the following rules to `/var/ossec/etc/rules/local_rules.xml` to alert on the Active Response results:

```xml
<group name="virustotal,">
  <rule id="100092" level="12">
    <if_sid>657</if_sid>
    <match>Successfully removed threat</match>
    <description>$(parameters.program) removed threat located at $(parameters.alert.data.virustotal.source.file)</description>
  </rule>

  <rule id="100093" level="12">
    <if_sid>657</if_sid>
    <match>Error removing threat</match>
    <description>Error removing threat located at $(parameters.alert.data.virustotal.source.file)</description>
  </rule>
</group>
```

**10.11.** Restart the Wazuh manager to apply the configuration changes:

```bash
sudo systemctl restart wazuh-manager
```

#### Attack emulation

Download an **EICAR** test file (a harmless file that every antivirus detects as malware) into the monitored `/root` directory on the Ubuntu endpoint:

```bash
sudo curl -Lo /root/eicar.com https://secure.eicar.org/eicar.com && sudo ls -lah /root/eicar.com
```

#### Viewing the alerts

Open the **Threat Hunting** module and filter the alerts:

![Use case screenshot 55](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-055.jpg align="center")

As soon as it is downloaded, the "malware" is detected by VirusTotal and automatically deleted!

---

### 11.12. Use case 11 — Vulnerability detection

Wazuh uses its **Vulnerability Detection** module to identify vulnerabilities in the operating systems and applications running on the endpoints.

This use case shows how Wazuh detects unpatched CVEs (Common Vulnerabilities and Exposures) on the monitored endpoints.

**Infrastructure**

| Endpoint | Description |
| --- | --- |
| Ubuntu 22.04 | The Vulnerability Detection module scans the OS and installed applications on this Linux endpoint for vulnerabilities. |

#### Configuration

The Vulnerability Detection module is enabled by default. On the Wazuh server, check that it is enabled and correctly configured.

**11.1.** Open `/var/ossec/etc/ossec.conf` on the Wazuh server and check the following settings:

- Vulnerability detection is enabled:

```xml
<vulnerability-detection>
  <enabled>yes</enabled>
  <index-status>yes</index-status>
  <feed-update-interval>60m</feed-update-interval>
</vulnerability-detection>
```

![Use case screenshot 56](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-056.jpg align="center")

- The indexer connection is correctly configured. By default, one host is set in the indexer settings, `0.0.0.0`:

```xml
<indexer>
  <enabled>yes</enabled>
  <hosts>
    <host>https://0.0.0.0:9200</host>
  </hosts>
  <ssl>
    <certificate_authorities>
      <ca>/etc/filebeat/certs/root-ca.pem</ca>
    </certificate_authorities>
    <certificate>/etc/filebeat/certs/filebeat.pem</certificate>
    <key>/etc/filebeat/certs/filebeat-key.pem</key>
  </ssl>
</indexer>
```

Replace `0.0.0.0` with the IP address or hostname of your Wazuh indexer node. You can find this value in the Filebeat configuration file, `/etc/filebeat/filebeat.yml`. Make sure the Filebeat certificate and key names match the files in `/etc/filebeat/certs`.

If you have a Wazuh indexer cluster, add a `<host>` entry for each node. For example, with two nodes:

```xml
<hosts>
  <host>https://10.0.0.1:9200</host>
  <host>https://10.0.0.2:9200</host>
</hosts>
```

Vulnerability detection reports to the first node in the list, and switches to the next one if it is unavailable.

**11.2.** If you changed the configuration, restart the Wazuh manager:

```bash
sudo systemctl restart wazuh-manager
```

#### Viewing the vulnerabilities

![Use case screenshot 57](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-057.jpg align="center")

![Use case screenshot 58](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-058.jpg align="center")

Wazuh identifies the vulnerabilities on our endpoints, with their severity and the affected packages.

---

### 11.13. Use case 12 — Detecting hidden processes

In this use case, we show how Wazuh detects **hidden processes created by a rootkit** on a Linux endpoint. We deploy a kernel-mode rootkit, **Diamorphine**, on an Ubuntu endpoint.

This rootkit hides itself from the list of kernel modules, and hides selected processes from the `ps` utility. Wazuh still detects it, using the `setsid()`, `getpid()` and `kill()` system calls.

**Infrastructure**

| Endpoint | Description |
| --- | --- |
| Ubuntu 22.04 | We download, compile and load a rootkit on this endpoint, then configure the Wazuh rootcheck module to detect the anomaly. |

#### Configuration

On the Ubuntu endpoint, emulate a rootkit and run a rootcheck scan to detect it.

**12.1.** Switch to the root user and update the packages:

```bash
sudo su
apt update
```

**12.2.** Install the packages needed to build the rootkit:

```bash
apt -y install gcc git
```

![Use case screenshot 59](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-059.jpg align="center")

**12.3.** Configure the Wazuh agent to run rootcheck scans **every 2 minutes**. In `/var/ossec/etc/ossec.conf`, set the `frequency` option of the `<rootcheck>` section to `120`:

```xml
<rootcheck>
  <disabled>no</disabled>
  <check_files>yes</check_files>
  <check_trojans>yes</check_trojans>
  <check_dev>yes</check_dev>
  <check_sys>yes</check_sys>
  <check_pids>yes</check_pids>
  <check_ports>yes</check_ports>
  <check_if>yes</check_if>

  <!-- rootcheck execution frequency - every 12 hours by default -->
  <frequency>120</frequency>

  <rootkit_files>etc/shared/rootkit_files.txt</rootkit_files>
  <rootkit_trojans>etc/shared/rootkit_trojans.txt</rootkit_trojans>
  <skip_nfs>yes</skip_nfs>
</rootcheck>
```

![Use case screenshot 60](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-060.jpg align="center")

**12.4.** Restart the Wazuh agent to apply the changes:

```bash
systemctl restart wazuh-agent
```

#### Attack emulation — Ubuntu endpoint

- Get the Diamorphine rootkit source code from GitHub:

```bash
git clone https://github.com/m0nad/Diamorphine
```

- Go to the Diamorphine directory and compile the source code:

```bash
cd Diamorphine
make
```

![Use case screenshot 61](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-061.jpg align="center")

**12.5.** Load the rootkit kernel module:

```bash
insmod diamorphine.ko
```

The Diamorphine kernel-level rootkit is now installed on the Ubuntu endpoint.

**12.6.** By default, Diamorphine hides itself, so `lsmod` won't show it. Sending signal `63` to any process (whether it exists or not) toggles the module between hidden and visible:

```bash
lsmod | grep diamorphine
kill -63 509
lsmod | grep diamorphine
```

**12.7.** The rootkit can also hide selected processes from `ps`. Sending signal `31` to a process hides or unhides it. Let's hide the `rsyslogd` process. First, it is visible:

```bash
ps auxw | grep rsyslogd | grep -v grep
```

You get an output like this:

```plaintext
root  732  0.0  0.7  214452  3572 ?  Ssl  14:53  0:00 /usr/sbin/rsyslogd -n
```

Now hide it, and check again:

```bash
kill -31 <PID_OF_RSYSLOGD>
ps auxw | grep rsyslogd | grep -v grep
```

This time, the output is empty: the process is hidden.

The next rootcheck scan runs and alerts on the `rsyslogd` process hidden by the Diamorphine rootkit.

#### Viewing the alerts

Open the **Threat Hunting** module and filter the alerts with:

```plaintext
rule.groups:rootcheck
```

![Use case screenshot 62](https://raw.githubusercontent.com/yvesstan/soc-blog-images/main/usecase-062.jpg align="center")

If you run the same `kill -31` command against the process again, it becomes visible, and the following rootcheck scans no longer raise an alert about it.

---

### 11.14. Going further

Depending on the environment your SOC protects, you will build many more use cases. The twelve above are among the most common ones implemented right after deploying a SOC, whether internal or external.

The goal of this part is to give analysts hands-on practice with the SOC against the kinds of incidents they will face in a real enterprise environment.

## 12\. Conclusion

This guide covered the full lifecycle of an operational SOC:

- **Architecture:** a high-level design that explains the role of each component, and a low-level design that details how they communicate.
- **Deployment:** a pfSense firewall, an Ubuntu server hosting Wazuh, TheHive, Cortex and MISP, all the integrations between them, and Shuffle for automation.
- **Operations:** twelve attack scenarios, from brute-force and SQL injection to malware and rootkits, each detected and, where possible, answered automatically.

The result is a complete, open-source SOC that any team can reproduce, and a solid foundation for real-world detection and incident response.
