Elastic Stack Setup
Overview
End To End Incident Response Using Elastic Security
To get a feeling for how the user flow of an Analyst might look like, check out this Video: https://www.youtube.com/watch?v=C5bYHCjF4qI
Setting up the Basics
In this guide, based on the Elastic tutorials 2 3, we’ll set up the following:
Step 1: Set up the First Elasticsearch Node
- Create the following VM:
- Installing Elasticsearch from the APT repository
NOTE
- Copy the terminal output from the installation command to a local file (you’ll need that info later)
- Store the
elastic
password in your shell: - Enable Elasticsearch to run as a service:
Step 2: Configure the First Elasticsearch Node for Connectivity
- Copy the host’s IP somewhere (using
ip a
) - Uncomment and edit the following lines of the config:
Step 3: Start Elasticsearch
Now, it’s time to start the service and make sure it’s running properly:
Step 4: Set up Additional Elasticsearch Nodes
Elastic scales very well horizontally, but not very well vertically. So if you are experiencing performance issues, you need more nodes.5
To set up additional nodes, please have a look at steps 4 and 5 in the article this notes is based on:
Step 5: Install Kibana
- Create the following VM:
- Installing Kibana from the APT repository 6
- Back on the Kibana host, enable Kibana:
- Copy the host’s IP somewhere (using
ip a
) - Generate a new encryption keys:
- Uncomment and edit the following lines of the config: 7
- Start the service and make sure it’s running properly:
- In the status, copy out the URL with a 6 digit verification code to get started. It should look something like this:
- Generate a Kibana enrollment token on the first Elasticsearch Node:
- Open the website and paste the enrolment token we generated previously on the Elasticsearch Node
- When you see the Welcome to Elastic page, provide the username
elastic
the password that you copied when we installed the first Elasticsearch Node (theELASTIC_PASSWORD
one)
Step 6: Securing the Elastic Stack
NOTE
Beginning with Elastic 8.0, security is enabled in the Elastic Stack by default, meaning that traffic between Elasticsearch nodes and between Kibana and Elasticsearch is SSL-encrypted. While this is suitable for testing non-production viability of the Elastic platform, most production networks have requirements for the use of trusted CA-signed certificates. These steps demonstrate how to update the out-of-the-box self-signed certificates with your own trusted CA-signed certificates.
⇒ https://www.elastic.co/guide/en/elastic-stack/current/install-stack-demo-secure.html
Step 7: Install Fleet Server
- Create the following VM:
- Create a working directory:
- Copy the host’s IP somewhere (using
ip a
) - Back to your web browser, open the Kibana menu and go to
Management -> Fleet
- Click
Add Fleet Server
- Specify a name for your Fleet Server host, for example
FleetServer1
. - Specify the host URL where Elastic Agents will reach Fleet Server, for example:
https://10.2.2.52:8220
(use the IP from the host we just set up) - Click
Generate Fleet Server policy
- On the
Install Fleet Server to a centralized host
step, select theLinux Tar
tab - Copy and paste the generated commands in the terminal on your Fleet Server host
- At the prompt, enter
Y
to install Elastic Agent and run it as a service. Wait for the installation to complete - In the Kibana Add a Fleet Server flyout, wait for confirmation that Fleet Server has connected
- For now, ignore the Continue enrolling Elastic Agent option and close the flyout
Step 8: Install Elastic Agent
- Log in to the host where you’d like to set up Elastic Agent
- Create a working directory for the installation package:
- Open Kibana and go to
Management -> Fleet
- Open the
Settings
tab - Reopen the
Agents
tab and selectAdd agent
- In the flyout, choose a policy name, for example
Demo Agent Policy
. - Leave Collect system logs and metrics enabled.
- Click
Create policy
. - For the “Enroll in Fleet?” step, leave
Enroll in Fleet
selected - On the Install Elastic Agent on your host step, for this example we select the
Linux Tar
tab - Copy and paste the generated commands in the terminal on your Fleet Server host
- Append an
--insecure
flag at the end.If you want to set up secure communications using SSL certificates, refer to
- At the prompt, enter
Y
to install Elastic Agent and run it as a service. Wait for the installation to complete - In the Kibana Add a Fleet Server flyout, wait for confirmation that Elastic Agent has connected
Setting up the Security
Step 1: Add Elastic Defend Integration
- Go to the Integrations page, by going to Kibana:
Management -> Integrations
- Search for and select
Elastic Defend
, then select Add Elastic Defend - Configure the Elastic Defend integration with an Integration name, for example:
elastic-defend-policy
- Select
Traditional Endpoints
as the type of environment you want to protect - Select
Complete EDR
as the configuration preset - Click the
Existing hosts
tab and select the Demo one we just created. - Save and continue
Step 2: Test if the Integration is Working
- Log into an Endpoint where the Elastic Agent has been deployed
- Download a EICAR file:
wget https://secure.eicar.org/eicar.com.txt
- Under
Security -> Alerts
you should now see some alerts:
Step 3: Enable Detection Rules
- Go to the Rules page, by going to Kibana:
Security -> Rules -> Detection rules
- Click on
Add Elastic rules
- Click on
Install all
- Now go back and click on
Select all 1171 rules
- Under
Bulk actions
, selectEnable
Step 4: Configure Auditd & Windows Integrations
Auditd Manager
Install Auditd on Your Clients
Setup the Auditd Manager Integration
In this lab I’m going to use Audit Deamon Rules, so we’re going to copy and paste those rule into the Audit rules
field:
Make sure to use the existing Demo Agent Policy:
Make Sure Your Agents Are Still Healthy
If not you might need to change the Auditd rules.
Windows
- Head to
Managment -> Integrations
and search for an Integration called Windows: - Set the toggles you want and install it to the Demo Agent Policy we’ve already created:
Step 5: Configure Osquery Manager Integration
Make sure to use the existing Demo Agent Policy:
Once installed, enable all existing packs under Managment -> Osquery
:
(Optional) Step 6: Enable pfSense/OPNsense Integration
Install the Integration on Kibana
- Go to the Integrations page, by going to Kibana:
Management -> Integrations
- Search for and select
pfSense
. - Give the Integration a name, for example:
opnsense-1
- Set the Syslog Host to
0.0.0.0
- Set the Syslog Port to
9001
- Click the
Existing hosts
tab and selectFleet Server Policy
Configure Remote Logging on OPNsense
- Navigate to
System -> Settings -> Logging
- Click on the
Remote
tab - Add a new Logging/Target (Click the plus icon)
- Transport = UDP
- Applications = Nothing Selected (this will forwar all logs)
- Levels = Nothing Selected
- Facilities = Nothing Selected
- Hostname = IP of Fleet Server
10.2.2.52
- Port =
9001
- Description =
Syslog to Elasticsearch
- Click Save
- And don’t forget to hit
Apply
(Optional) Step 7: Enable Additional Integrations
AbuseCH
Network Packet Capture
Defend for Containers
Lateral Movement Detection
Data Exfiltration Detection
Living off the Land Attack Detection
Domain Generation Algorithm Detection
Relevant Note(s):
Footnotes
-
https://www.elastic.co/guide/en/starting-with-the-elasticsearch-platform-and-its-solutions/current/stack-components.html ↩
-
https://www.elastic.co/guide/en/elastic-stack/current/installing-stack-demo-self.html ↩
-
https://www.elastic.co/guide/en/elastic-stack/current/install-stack-demo-secure.html ↩
-
https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html ↩
-
https://blog.octoperf.com/elasticsearch-optimization-guide/ ↩
-
https://www.elastic.co/guide/en/kibana/current/xpack-security-secure-saved-objects.html ↩
-
https://www.elastic.co/guide/en/security/current/install-endpoint.html#add-security-integration ↩
-
https://www.elastic.co/security-labs/linux-detection-engineering-with-auditd ↩
-
https://www.elastic.co/guide/en/kibana/current/manage-osquery-integration.html ↩
-
https://www.elastic.co/guide/en/kibana/current/osquery.html ↩