業務用エアコン関連の技術情報、エラーコード、環境問題対策に関する別サイト「エアコンの安全な修理・適切なフロン回収」

OpenSUSE15.6 : Suricata + Elastic Stack + Kibana + Filebeat

Prerequisite.

1.Suricata
SURICATA IDS/IPS is an open-source intrusion detection system that monitors network traffic and detects suspicious activity.
The basic mechanism is signature-based, enabling detection of predefined malicious communications.
Furthermore, Suricata is characterized by its ability to not only detect threats but also defend against them.

2.Elastic Stack,Kibana,Filebeat
Install and configure the Elastic Stack to enable visualization and search of SURICATA logs using Kibana and Filebeat.

This time, we will install Suricata IDS and ElasticStack on the following server.
・First server Suricata IDS & Filebeat : openSUSE 15.6 IP(192.168.11.83)
・Second server ElasticStack & kibana : openSUSE15.6 IP(192.168.11.85)

  First Server: Suricata Installation

1.Installing and Configuring Suricata

①Add a repository

➁Installing Suricata

➂Creating Suricata User Groups

④Set directory ownership and permissions

⑤Suricata determines the interface and IP address for inspecting network packets.

⑥Edit the configuration file

⑦Starting Suricata

⑧Suricataの起動確認

Check the log

To check the statistics, review the stats.log file (updated every 8 seconds by default).

The more advanced output format, EVE JSON, can be generated using the following command:

2.Suricata Testing

①Perform a ping test using the curl utility

②Check the log file using the specified rule number.
Suricata comes with the following two log files enabled by default.

/var/log/suricata/fast.log
/var/log/suricata/eve.log
To check the log entries corresponding to the curl request, use the grep command to examine the /var/log/suricata/fast.log log file.
2100498 Searches for log entries using the rule identifier. (For IPv4)

 ③Checking events in /var/log/suricata/eve.log

Install jq

Search for signature 2100498 and filter EVE log events
Display alert objects with a signature_id key matching the value 2100498

3.Suricata Rules Configuration

①Displaying the rule set packaged in Suricata

②Index of sources providing rule sets

③Enable source (when enabling tgreen/hunting)

Perform the update

Restart the Suricata service

4. Configuring Suricata as an IPS

Configure Suricata to start in IPS mode to drop malicious network traffic.

Create the following custom signature to scan SSH traffic to non-SSH ports, and include it in the file /var/lib/suricata/rules/local.rules (assuming the SSH port is 22):

Edit the /etc/suricata/suricata.yaml configuration file and include local.rules.

Verify SURICATA Configuration

Edit the SURICATA configuration file located at /etc/sysconfig/suricata

Restart Suricata

Status Check

Direct incoming network traffic to Suricata's NFQUEUE
Firewalld is installed and enabled, so add the necessary rules for Suricata to Firewalld.

Display direct rules in the configuration file (persistent)

Verify whether a direct rule exists

Verify that SURICATA is correctly dropping traffic.
Change the default action for signatures from alert or log to active dropping traffic.
Open the /var/lib/suricata/rules/suricata.rules file and comment out any entries matching sid:2100498.

Create a new rule named sid:2100498 in /var/lib/suricata/rules/local.rules.

Suricata restart

Test this rule using curl

Use jq to examine the eve.log file

"action": "blocked", is set

Integration of the ELK Stack and SURICATA

Install and configure the Elastic Stack to visualize and search SURICATA logs more efficiently.
This section is primarily performed on the second openSUSE 15.6 server (IP: 192.168.11.85).

1. Installing Elasticsearch

1.1 Download and install the public key

1.2 Create the repository definition in the /etc/zypp/repos.d directory.

1.3 Elasticsearch Installation

2. Elasticsearch Configuration

Elasticsearch is configured by default to accept only local connections. Furthermore, since authentication is disabled, tools like Filebeat cannot send logs. In this session, we will configure Elasticsearch's network settings and enable the xpack security module built into Elasticsearch.

2.1 Elasticsearch Network Configuration
Since the Elasticsearch and SURICATA servers are separate, Elasticsearch must be configured to listen for connections on the private network interface.

2.2 Start Elasticsearch

2.3 Create passwords for elastic and kibana_system
Be sure to copy the passwords for the elastic user and kibana_system user, as they will be needed later.
The kibana_system user is used for Kibana configuration.
If you forget the password used for Filebeat, Auditbeat configuration, and Kibana login, you can reset it again using the command.

[elastic] User password creation

※Resetting Elasticsearch Passwords
The automatically generated Elastic user password is too complex, so you can reset it using the /usr/share/elasticsearch/bin/elasticsearch-reset-password command.
To reset your password, execute the command.

[kibana_system] User Password Creation

3. Installing and Configuring Kibana

This section is primarily performed on the second openSUSE 15.6 server.

3.1 Create the repository definition in the /etc/zypp/repos.d directory.

3.2 Kibana Installation

3.3 xpack Security Module Configuration

Enable Kibana's xpack security features and generate several encryption keys that Kibana uses to store data in Elasticsearch.
Encryption keys are created using the kibana-encryption-keys utility located in the /usr/share/kibana/bin directory.
Store the three keys you created in a secure location.

Add these keys to Kibana's /etc/kibana/kibana.yml configuration file.

3.2 Kibana Network Configuration

3.3 Generating a Kibana-Elasticsearch Enrollment Token
To configure a Kibana instance to communicate with an existing Elasticsearch cluster with security enabled, an enrollment token is required. An enrollment token for Kibana can be generated using the following command:

3.4 Starting Kibana
Launch Kibana 9 and configure it to run at system startup.

Status Check

The following appears toward the end of the output:

Go to http://192.168.11.85:5601/?code=466649 to get started.

Copy the provided Kibana URL (including the code) and use it in your browser to access Kibana and complete the setup.

4. Accessing the Kibana 9 Dashboard

access http://192.168.11.85:5601/?code=466649
(Copy each person's appropriate address)

If the firewall is running, open the Kibana port.

When you access Kibana 9, the welcome page prompts you to configure Elastic.
First, enter the generated registration token.
Copy the Kibana token generated using the command /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana and paste it into the box.

access http://192.168.11.85:5601/?code=466649

Paste the token, and Kibana will automatically connect to Elasticsearch.
Click Configure Elastic. The settings will be saved, and Elasticsearch will be configured and restarted.

Proceed to the login page. Log in using the generated Elastic user credentials.
Username : elastic
Password : Password regenerated for clarity

On the welcome page, click "Explore on my own" to proceed to the Kibana 9.x dashboard.

Create a new user account so you don't need to use the elastic superuser account.
Open the main menu, then navigate to Stack Management > Security > Users.

Click the "Create user" button in the upper right corner.

Enter the new user information and assign the kibana_admin, kibana_system, monitoring_user, and editor roles under Privileges.
Finally, click [Create user].

Log out of the current profile and verify that you can log in with the newly created user account. Currently, since Filebeat and Auditbeat are not configured on the SURICATA host, there is no data available to display in Kibana.

Install Filebeat on the SURICATA server

This task will be performed on the first openSUSE 15.6 server (IP: 192.168.11.83) where Suricata is installed.

1. Filebeat Installation

1.1 Download and install the public key

1.2 Create the repository definition in the /etc/zypp/repos.d directory.

1.3 Install Filebeat

1.4 Creating an Elasticsearch CA Certificate
Download the Elasticsearch CA certificate and save it to any directory (in this case, save it as /etc/filebeat/elastic-ca.crt).
※Keep port 9200 open on the second server (the server running openSUSE 15.6 with Elasticsearch installed).

1.5 Configure Filebeat to connect to Elasticsearch and Kibana

1.6 Configuration File Test

1.7 Enable the built-in Suricata module in Filebeats

The above command will change /etc/filebeat/modules.d/suricata.yml.disabled to /etc/filebeat/modules.d/suricata.yml, but the contents remain unchanged. Therefore, edit it as follows:

1.8 Set up the initial environment
Load the pipeline into the Suricata service
Load the SIEM dashboard into Elasticsearch

1.9 Start the Filebeat service

2. Verify in Kibana

Log back into Kibana using the user you created. accsess http://192.168.11.85:5601

Enter "Suricata Events Overview" in the top search field, then click Events Overview.

All Suricata events from the past 15 minutes are displayed.

To display alerts for malicious traffic, click the "Alerts" text next to the Suricata logo.

Kibana offers a variety of features and tools for visualizing logs, so feel free to experiment with them.

Copied title and URL