Build a SIEM Home Lab with Elastic Security and Create Custom Alerts
Mohammed Almughamisi
Cybersecurity | Automation | Security+ | Certified Ethical Hacker ( CEHv12)
In this guide, we’ll configure Elastic Security in a home lab to analyze and interpret logs, understand key values, and create custom alerts for effective threat detection.
Notes:
Step 1: Sign Up for Elastic
Sign up for elastic account by going to the following link: https://cloud.elastic.co/registration
Step 2: Install the Elastic Agent
Once logged in to your Elastic account, navigate to the left sidebar and click on Integrations.
In the search bar, type Elastic Defend and press Enter, then click on it to begin the configuration process.
Click the blue Add Elastic Defend button to integrate Elastic into your environment.
After clicking Add Elastic Defend, you will be redirected to a page with instructions to install the Elastic Agent.
Select the appropriate platform (e.g., Linux, Mac, Windows, etc.) from the tabs above.
For our setup, choose Linux. Copy the full command provided and paste it into your terminal to proceed with the installation.
At this step, the installation process will prompt you to confirm if you want to continue. Type Y and press Enter.
After completing the installation, return to the Elastic website, where you should see the confirmation message: "1 agent has been enrolled."
Step 3: Testing Detection and Understanding Logs
Now that everything is set up, let’s perform a test to verify detection and analyze the logs.
Open your Linux terminal and execute the following command:
nmap -A -sV localhost
When you click on the log, additional details will be displayed. Here are the most important ones:
Command Executed: The process.command_line field displays the full command: nmap -A -sV localhost.
Process Name: The process.name field identifies the process as nmap.
Note: This field will be used to create a custom alert targeting processes named "nmap."
User and Host Information:
Parent Process: The process.parent.name field shows the parent process as bash, confirming it was executed via the terminal.
Although the logs contain many additional details, these key fields are the most relevant for understanding the detected activity and will be used in the next step to create an alert.
Step 4: Creating an Alert
Navigate to the Alerts Section:
领英推荐
This will open a rule creation wizard where you can define the conditions and triggers for your alert based on specific events or data patterns.
Select Rule Type:
Define the Query:
process.name: "nmap"
Click Continue to proceed to the next step.
In the About Rule section,
you can define the following details for your custom rule:
In the Schedule Rule section:
After completing the configuration, click Continue to proceed to the next step.
Set Actions for Triggered Alerts:
When selecting Email:
Once the configuration is complete, click Create & enable rule to finish creating the alert.
Step 5: Testing the Alert and Verifying Detection
Now that the alert rule has been created, let’s test it by performing another Nmap scan.
Open your Linux terminal and execute the following command:
nmap -A -sV localhost
Check the Alerts Section:
After performing the Nmap scan, go to the Alerts section in Elastic Security.
The generated alerts should display the following details:
The alert rule "Nmap Scan Detection" was triggered, confirming that the system identified the scan activity.
The severity is set to High, with a risk score of 73, indicating a significant security event.
The alert specifies that a network event was detected with the process nmap originating from 127.0.0.1.
The alert is associated with the host parrot, where the scan was executed.
This email from Elastic Security confirms the "Nmap Scan Detection" rule was triggered. It includes a link to view the rule in Kibana for further details.
Everything is now set up! You can explore more of Elastic Security's powerful capabilities, and it certainly doesn't stop here.