Homelab honeypot
This project will setup a lab environment that have a honeypot server with a ELK server keep monitoring it and trigger an alert once unauthorized access to the honeypot server.
Introduction
This project will guide you to build an ELK stack and a honeypot server. An ELK stack is a log management platform that uses three open-source projects to collect, process, and analyze data from multiple sources. ELK provides a centralized solution for managing large volumes of data, offering real-time insights and analytics. A honeypot server is a cybersecurity tool that lures and analyzes cyberattacks to help organizations improve their security. Honeypots are designed to look like legitimate targets but isolated from critical systems to prevent attackers from causing real damage.
This project will set up a honeypot server in our lab, and forward the generated logs to the ELK stack through an elastic agent. Furthermore, it also included instructions on how to set up an alert that detects brute-force authentication attempts. Set up a dashboard to overview those users and IP addresses that tried to log in to the system but failed.
Last but not least, this project prepared a bash script to simulate brute force and other attacks from the attacker’s perspective. Use the bash script to test the ELK alert and view the log from the ELK stack.
Methodology
Network setup
We will use pfSense firewall router to do network segmentation and enhance network security by limiting the connection between networks.
Install pfSense
File > New Virtual Machine
Uncheck “Power on this virtual machine after creation”, and select “Customize Hardware”

- Add new Network Adapters

Create new network segments as “CFC Lab”, and assign it to the Network Adapters added previously.

Power on the machine
Go ahead with the default, until you reach the ZFS configuration screen. Press spacebar to check the box, then press enter key.

Use arrow key to select “Yes”, then press enter key to confirm.

- Select “Reboot”, and wait for it.

- Done

Configure pfSense
After we install pfSense, we can manually assign the IP address to each interface to have more control over the network.
Select Option 1 to
Assign interfacesto decide which network adapter will be used for which network

- Enter “n” to select no vlan, “em0” as WAN interface, “em1” as LAN interface

Now you configured the network for different interfaces, configure the IP network in the next step.

Select option 2 in the main menu to
Set Interface IP Address- Configure as follows.
- Disable DHCP assign IPv4 for this interface.
- Enter the IPv4 address for this interface.
- Enter the network subnet for this interface.
- Because we setting up LAN, can leave it empty.
We are not going to use IPv6, can enter “n” for no and leave empty for options.

No need to setup DHCP server for this network, we going to configure IP address manually to have more control over the network.

We need to allow access to the web UI, go into
Shelland use commandpfctl -dto disable packet filtering.

- Access pfSense web UI via my host OS (which is in VMware NAT as 192.168.236.132 in my case) through the WAN IP of pfSense.
- user: admin
- pw: pfsense
- Input the address for Google’s DNS servers, then Next

When you reload the machine, you need to go back to your shell and enter
pfctl -dagain

- We need to allow WAN network able to access pfSense to do configuration, so that we don’t have disable pfSense package filter again in the future.

Configure it to allow traffic access to pfSense at port 443 (HTTPS).

- Last but not least, enable DNS Resolver to forward DNS query to 8.8.8.8 or 8.8.4.4 as configured in the firewall.


Set up Honeypot server
We will set up a Windows Server 2016 as our honeypot server.
Install Windows Server 2016
Open browser and navigate to https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2016, and select “Download ISO”.

Download Windows Server 2016 ISO
- Install the ISO

Enter the username for your user, no need to key in the product key
Click “Yes”
- Setup Administrator account.
- Username: Administrator
- Password: Passw0rd!
This password just for demonstrate on this walkthrough, you can use any password you like.
1

Installed Windows Server 2016, login into VM, with VMware you can press
ctrl + alt + insertto unlock instead.

Configure honeypot
Close the VM if it is running, and assign
CFC Labinto network adaptor.

Launch the VM.
Click “Local Server”, select the network interface which is “Ethernet0” in this case.

- Configure a static IP for it.
- IP address: The static IP address for the machine.
- Subnet mask: Subnet mask of this network.
- Default gateway: The IP address of the pfSense router.
- Preferred DNS server: The IP address of the pfSense router, pfSense router will help to resolve the DNS query.
- Verify the configuration by ping the pfSense router.

- We need to enable RDP. From Server Manager, open Local Server > Remote Desktop
- RDP allow administrator configure the system remotely. RDP is disabled by default, we will enable it for this lab.
- Select allow remote connection, the Administrator is allowed to use RDP by default. If you have other users who need to access via RDP, you can grant RDP access to your user by adding the user to it.

- Click “OK” to close it.

- Press F5 on Server Manager, then it will show “Enabled” on remote desktop.

Install sysmon
- Navigate to Sysmon and download Sysmon

Download Sysmon config file from sysmonconfig-export.xml

Install Sysmon with the config file by following command:
1
.Sysmon.exe \-n \-accepteula \-i .sysmonconfig-export.txt
Install tools to configure ELK VM
There are a lot of commands and config to be set in order to configure ELK VM, but the Ubuntu server does not support the copy & paste feature if you directly interact with the server. To make our life easier, we can install tools like MobaXterm to establish SSH connection and configure it.
I will install MobaXterm on the honeypot VM because it is on same network, so that I don’t have to configure a firewall rule to forward my traffic to the ELK VM.
On honeypot VM, open the browser and search for “MobaXterm”.
- If you encounter this popup window, just click “Add”.
Honeypot hardening
We don’t want attackers to be aware that they are attacking a Honeypot server, to lure them in, we need to configure the server as a normal server.
Close unnecessary port
By default, Windows server closed all ports except port 5985. Port 5985 is used for the “Windows Remote Management” (WinRM) service, for admin to connect it and manage the server.
Let assume we have opened some unnecessary ports, we can disable them through the Firewall setting.
- Go to Tools > Windows Firewall with Advanced Security

- Find the firewall rules press right click and select “Disable Rule”

Setup strong password policy
Press Windows key + R to open the Run program, and type “gpedit.msc”.

Navigate to Computer Configuration> Windows Settings > Security Settings > Account Policies > Password Policy

Change your Administrator’s password if password length less than 12 character.

Configure to auto update
Press Windows key + R to open Run program, and type “gpedit.msc”.

- Navigate to Computer Configuration > Administrative Templates > Windows Components > Windows Update

Select “Enable” to enable to auto update, since we want this machine is honeypot and we won’t often access to this machine, we want it update automatically, so we select “4 - Auto download and schedule the install” and make it run on every Sunday.
- 3 - Auto download and notify for install: This option will download latest update and let admin choose when to install
- 4 - Auto download and schedule the install: This option will force the machine to install the update once it downloaded.
- Click “Ok” to finish the setting.

Setup ELK
The ELK stack is a collection of three open-source tools that work together to process and analyze data from multiple sources. This walkthrough will guild you to setup a Ubuntu server and install ELK stack on that server.
Install Ubuntu server
First we need to download the Ubuntu ISO from the Internet and configure it.
- Reference video: https://www.youtube.com/watch?v=xdP2xJrxCTo
- Download latest version of Ubuntu server. By the time of writing, the latest version was Ubuntu 24.04.1.
- Download URL: https://ubuntu.com/download/server
- Select “New Virtual Machine”

Other option can use default options. Click “Next >” until last window, then click “Finish”.
Enter the server name and your username. For this lab setup, I will keep it simple to use
elkas my username, server name, and password.

- I want to enable remote connect into this server via SSH, so I select “Install OpenSSH server”.

- Leave as default and click “Done”

Wait for the server install necessary packages and click “Reboot Now”

Press enter after you see this screen, then the server will start to reboot.

- After that, the server is ready

Close the VM if it is running, and assign
CFC Labinto network adaptor.

- Launch the VM.
Configure Ubuntu server
After installed the Ubuntu server, we need to configure the time zone of the server. The timestamp logged into ELK will follow the time set on the server. The time zone across all the servers should be the same.
There are a lot of commands and config to be set in order to configure ELK VM, but the Ubuntu server does not support the copy & paste feature if you directly interact with the server. We will connect via MobaXterm for better configuration.
- Find the name of your time zone
1
timedatectl list-timezones | grep -i Singapore
- Set the time zone
1
sudo timedatectl set-timezone Asia/Singapore - Verify it

Configure static IP address
Beware before installing the ELK package, during installation of the ELK package, it will generate a certificate with the server’s IP address. If you switch the IP address in the future, you will need to reinstall the ELK or change the ELK certificate.
For this setup, I don’t want DHCP to assign the IP address to this server, so I assign a static IP address to it.
Create a file in
/etc/cloud/cloud.cfg.d/99-disable-network-config.cfg.
- Copy the following into the file
1
network: {config: disabled}
- Disable network interface if it is up, verify with
ip a- ip a: Command that output all the network interfaces’ information.
1
sudo networkctl down ens33 - Modify netplan
1 2 3 4 5 6 7 8 9 10 11 12 13
network: version: 2 ethernets: ens33: dhcp4: false addresses: - 10.10.10.2/24 routes: - to: default via: 10.10.10.1 nameservers: addresses: - 10.10.10.1
Verify the latest netplan with
sudo netplan try- Enable network interface
1
sudo networkctl up ens33 Verify it.
ip route: This command will output assigned IPv4 address and the default gateway of the network.
ping -c 1 8.8.8.8: Ping command to check we have network connection.
Install Elasticsearch
In this step, we can finally install the Elasticsearch. We can follow the instructions from Elastic official website to install it into our Ubuntu server.
Elastic official link: https://www.elastic.co
There are a lot of commands and config to be set in order to configure ELK VM, but the Ubuntu server does not support the copy & paste feature if you directly interact with the server. We will connect via MobaXterm for better configuration.
- Make sure the SSH service is started on the ELK server.

- Open MobaXterm, and start a SSH session to ELK VM
- Username: elk
- Password: elk
Connected to ELK VM, now we can copy and paste the command with mouse right click.
- Import Elasticsearch GPG key
1
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
- Create Elasticsearch repo file
1 2
sudo apt-get install apt-transport-https echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
- Install Elasticsearch from apt
- During the installation of Elasticsearch, it will generate the password for the superuser. We need to record down the password for future use.
1
sudo apt-get update && sudo apt-get install elasticsearch
- During the installation of Elasticsearch, it will generate the password for the superuser. We need to record down the password for future use.
- Enable the Elasticsearch
1 2
sudo systemctl daemon-reload && / sudo systemctl enable elasticsearch.service sudo systemctl start elasticsearch.service
Verify the Elasticsearch with the superuser password generated.
1
curl -X GET -k https://elastic:{superuser password}@localhost:9200
Install Kibana
Kibana is a user interface for the admin to interact with.
Reference link: https://www.elastic.co
- Install Kibana from apt
1
sudo apt-get install kibana
- Create enrollment token to connect Elasticsearch and Kibana
1
sudo /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana
Copy the token to Kibana setup
1
sudo /usr/share/kibana/bin/kibana-setup- Enable Kibana web interface
- Modify
/etc/kibana/kibana.yml
- Modify
Enable Kibana
1 2 3
sudo systemctl daemon-reload sudo systemctl enable kibana.service sudo systemctl start kibana.service
- You can access Kibana now at http://10.10.10.2:5601.

- Login as elastic, password of the superuser.

Create API key to enable Kibana alert feature
Kibana alert feature is not enable by default, we need generate and install the API key in order to enable Kibana alert.
- Generate Kibana encryption key
1
sudo /usr/share/kibana/bin/kibana-encryption-keys generate - Add these keys into Kibana
1
sudo /usr/share/kibana/bin/kibana-keystore add {key name}
- Restart Kibana service
1
sudo systemctl restart kibana.servicez - Navigate to Security > Alert to verify it. If no warning, then you’re good to go.

Install Elastic Agent in Honeypot server
In order to analyze the log or set up an intrusion alert in ELK, we need to forward the log from the Honeypot server to the ELK stack. It can be achieved by installing Elastic Agent in the Honeypot server.
- From the Honeypot server, navigate to http://10.10.10.2:5601/ and log in to ELK with the superuser password
- Username: elastic
Open the elastic-agent.yml with notebook, search for “api-key” and paste the generated API key

Scroll down to the bottom, since our honeypot server is Windows, we will follow Windows instruction

Open PowerShell with Administrator from “Download” folder for easier management.

- Copy the command to PowerShell one by one until the command before installation
If the link return 404 error, try to check the URL. The URL should look like https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-xxx.zip
- Copy the previously downloaded yml file into Elastic agent folder, replace the original file

- Go back to PowerShell and install Elastic agent
- Select “Y” to run it as a service
- Select “N” to enroll it into fleet
Let’s verify the agent is sending data to ELK, open the event viewer and clear security log

- Query “event.code: 1102”, if it shows the result, it means the Elastic Agent is working

Set up Elastic Alert
Elastic Alert will notify the admin if the log matches the pattern configured at Elastic Alert so that the organization can take action as soon as possible before further damage is done.
The following setup will demonstrate brute force attack, bear in mind that this is a simple configuration for brute force attack.
Brute force attempts alert
Login with the wrong password to generate an event log for failed authentication

Form the query to detect the brute force attack. After research on the Internet, we know that Windows categorized unauthorized access with event id 4625.

- Write a KQL query out of that log, we also specify the agent name that is used for the Honeypot server.
- event.code: 4625: Filter out log with 4625 Event ID
- agent.name: “WIN-M8ON1R5EUG6”: The agent name that is installed in the Honeypot server. The agent name will be assigned during elastic agent installation, by default is the machine name. Your agent name should be different from this.
- Copy the KQL query statement and navigate to Security > Alerts

- Click “Manage rules”

- Click “Create new rule”

- Select “Threshold” and scroll down.
- Threshold: This rule will only be triggered if same pattern had been detected number of time on short period.
- Paste in the KQL query, fill in the details and click “Continue”

Fill in the name of the alert and description, you can also set the severity level based on the alert.

- In the advanced setting, you can fill in additional information such as MITRE ID to support this alert investigation.

- We can also include the investigation guide on what to do after the alert is triggered.

Set to 5 minutes for both the rule’s time frame and look-back time.

Leave empty for action, because we didn’t connected to any messaging service.

Verify the rule by brute force on the Honeypot server. We can use Msfconsole in Kali with auxiliary/scanner/winrm/winrm_login to brute force the credential, or Hydra to brute force RDP service.

- Check ELK, it will take around 5 to 10 min for the alert to trigger.

Kibana Dashboard
We can create a Kibana dashboard to get an overview of recent events before getting into details. Let’s take brute force attack for example.
- We can see 3 sections here.

- 1: This section is the available data that can be dragged and dropped into the table. From the view of the table.
- 2: You can write a query on this section to further filter the data that will show on the table.
- 3: This is the configuration of this visualization. You can rearrange the column position, change to pie chart, etc.
- Drag the timestamp, source.ip, and user.name into middle

- We can customize each column. Let’s take timestamp for example, select timestamp from the right panel.

Next, select the source.ip and change the number of value to 99. We want to see as many IP addresses as possible trying to brute force us instead of the top 3.

- Name the dashboard

- Done

Simulate the attack
We will test the ELK alert by simulating an attack. I had already prepared an attack script written in bash that can run on a Linux machine, you can download the script from my github repo.
Github Url: https://github.com/firstwan/vulner
| ./vulner.sh -f --skip-udp 10.10.10.3 | | :————————————- |
It will start the network scan and try to brute force credential

- If the machine has other services, it will output a list of available scanning techniques.

- After running the script, we can see it generatesan few ELK alert

Conclusion
We set up a new Ubuntu server and installed the ELK stack into it. Allow us to ingest log data from different sources. Furthermore, we set up a new Windows Server 2016 as our Honeypot server, acting as a legitimate target for attackers to access it by hardening the server like closing unnecessary ports, scheduling auto-updates, configuring a strong password policy, etc.
Furthermore, we set up an Elastic Alert to notify the admin once brute force is detected, and a dashboard to overview the failed login logs.
Moreover, we use a bash script to attack the Honeypot server to verify the Elastic Alert is working properly and view the generated logs.
Reference
- Download Elasticsearch
- Installing Logstash
- IppSec. (2022, October 10). Setting Up Elastic 8 with Kibana, Fleet, Endpoint Security, and Windows Log Collection
- Raj. (2024, July 16). WinRM Penetration Testing - Hacking Articles. Hacking Articles.
- Security Log in Event Viewer does not store IPs.
- Startup or run key Registry modification
- The Devops Diary. (2023a, September 26). “Step-by-Step Guide: Installing Logstash for Beginners”
- The Devops Diary. (2023b, September 28). Setting Up the ELK Stack in 2024: Step-by-Step Tutorial


























































































































