Lab 2_ Security Monitoring with ELK Stack
Lab 2_ Security Monitoring with ELK Stack
OBJECTIVE:
Monitor security-related events in real-time and visualize patterns.
TASKS:
Deploy the ELK Stack using Docker. 2. Ingest and index security logs from various sources. 3.
Create dashboards to monitor login attempts, privilege escalations, and other security events. 4.
Set alerts for suspicious activities.
td
tl
Deploy the ELK Stack Using Docker
Pv
Install Docker:
If Docker is not already installed, follow the steps for your operating system:
ng
For Ubuntu/Debian
sudo apt update
sudo
sudo
apt install docker.io
systemctl start docker
ni
ar
sudo systemctl enable docker
Le
version: '3'
N
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0
AL
container_name: elasticsearch
environment:
- discovery.type=single-node
- xpack.security.enabled=false
ports:
- "9200:9200"
networks:
- elk
logstash:
image: docker.elastic.co/logstash/logstash:7.17.0
container_name: logstash
networks:
- elk
volumes:
- ./logstash:/usr/share/logstash/pipeline/
td
ports:
- "5000:5000"
tl
- "5044:5044"
- "9600:9600"
Pv
kibana:
image: docker.elastic.co/kibana/kibana:7.17.0
container_name: kibana
ng
environment:
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
ports:
- "5601:5601"
ni
ar
networks:
- elk
Le
networks:
elk:
driver: bridge
IE
docker ps
AL
Access Kibana:
td
tl
filebeat.inputs:
Pv
- type: log
enabled: true
paths:
ng
- /var/log/auth.log # Example log path for authentication logs
(adjust as needed)
output.logstash:
hosts: ["logstash:5044"]
ni
ar
Mount the configuration file into the Filebeat container
docker run -d --name=filebeat --user=root
Le
--volume="$(pwd)/filebeat.yml:/usr/share/filebeat/filebeat.yml"
--volume="/var/log:/var/log" --network=elk
docker.elastic.co/beats/filebeat:7.17.0
IE
input {
beats {
port => "5044"
AL
}
}
filter {
grok {
match => { "message" => "%{SYSLOGTIMESTAMP:timestamp} %{WORD:logsource}
%{DATA:program}(?:\[%{POSINT:pid}\])?: %{GREEDYDATA:log_message}" }
}
}
output {
elasticsearch {
hosts => ["http://elasticsearch:9200"]
index => "security-logs-%{+YYYY.MM.dd}"
}
stdout { codec => rubydebug }
td
}
Restart the Logstash container to apply the changes:
tl
docker-compose restart logstash
Pv
Ingest Logs:
Filebeat will now start shipping security logs (such as login attempts) from
ng
/var/log/auth.log to Logstash, which processes the logs and stores them in Elasticsearch.
Create Visualizations:
N
Login Attempts: Use the log_message field and count occurrences of successful/failed
logins.
Save Dashboards:
Save the visualizations and arrange them on your Kibana dashboard for real-time monitoring.
td
Configure Kibana Alerts:
tl
Create a New Alert:
Pv
Click Create Alert and choose Create Threshold Alert.
ng
Set the conditions for triggering an alert, e.g.:
Failed Login Attempts: Set a threshold to trigger an alert if the count of failed login attempts
ni
exceeds a certain number in a short time (e.g., more than 5 failed logins in 10 minutes).
ar
Privilege Escalation Alerts: Configure an alert if the log contains specific keywords (e.g.,
sudo, root access).
Le
Add an Email action to send notifications to your email or set up integrations with Slack or
IE
webhook.
Monitor Alerts:
AF
Alerts will now trigger based on suspicious activity like brute force login attempts or privilege
escalations.
N
Conclusion
AL
By following these steps, you will have successfully deployed the ELK Stack, ingested security
logs, created dashboards for monitoring security events, and set up alerts for suspicious
activities