Active Directory with Splunk
Setup a Active Directory environment and Splunk aggregate logs data and detect unauthorized login with Vultr cloud service provider.
Active Directory is a directory service developed by Microsoft for Windows domain networks. It acts as a central database and set of services that manage user accounts, computer objects, groups, policies, and other resources on the network, ensuring secure access to those resources.
Introduction
In this walkthrough, we will setup an Active Directory (AD) environment and send the log to Splunk Security Information and Event Management (SIEM). Furthermore, we will setup an alert to detect potential unauthorized event from any IP address we not familiar.
Overview
We will create 3 servers, a Windows server as AD Domain Controller, a normal Windows server that joined the AD, and a Splunk server. Those 2 Windows servers will send their Windows Event Log to Splunk server periodically.
Moreover, we will create an alert to detect any unauthorized login to the Windows servers and notify user if found any.
Servers
We will utilize Vultr to create and host all of the servers. Vultr is a cloud provider that offering a wide range of services, including virtual servers (VPS), cloud compute, and managed databases.
You can register an account through Vultr to get a $300 credit into your account and use it to setup this lab. But you need to bind your credit card in order to create virtual machine in this platform.
You can use AWS, Azure, or Google Cloud Platform if you want.
Domain Controller Server
We don’t need a lot of resource for this lab, since it this lab is more on practice and testing purpose.
Click the “Deploy” button.
Select the “Shared CPU” and choose the location that closer to your location. I will choose Singapore for my case.
Again this lab is for practice purpose, we don’t need the backup feature. Click “Disable” on right panel and disable it.
Let select 2 CPU and 2 GB of memory for Domain Controller server.
Select “Windows Standard 2022 x64” as the OS.
Leave other as blank for now, and name it as “SOC-ADDC01”.
Leave other as default and click “Deploy” on the right panel.
Normal Server
The step to create normal server is same as previous one. Go through the same step until select the size of the server. We can use a lower resources for normal server, since we won’t have much configuration on this machine.
Select 1 CPU and 2 GB of memory for normal server.
Select the “Windows Standard 2022 x64” as the OS.
Name is as “SOC-ADNormal”.
Splunk Server
Do the same as previous step for Splunk server, but we need a higher resources than other 2 servers. Because this Splunk machine will be aggregate the log from other 2 servers and running the alert to detect unauthorized login.
Let select 4 CPU and 8 GB of memory for Splunk server.
This server will be using different OS since it not need to join the AD. Select the “Ubuntu 22.04 x64” as the OS.
Name it as “SOC-Splunk”.
How to access servers
We will be connect to the servers and make configuration on it. There are 2 method to access the servers.
- Web Console
- RDP / SSH
Web Console
Vultr provided a way for us to access the server through web browser. But this method is not so convenient, it take extra step for copy & paste feature.
We can launch the web console by clicking this button.
It did provide some of the shortcut key for us to use. For example, we need to press Clrt+Alt+Delete in order to open the Windows lock screen. Vultr provided the shortcut key that will simulate pressing Clrt+Alt+Delete
In order to paste the word you copy through web console, you need to open the “Clipboard” panel and paste your word inside and click “Paste” button.
RDP / SSH
RDP and SSH is the most popular tools for remote connection. RDP is used on Windows machine and SSH is used on Linux machine. One of the differences between RDP and SSH is RDP will have GUI on connected remote server and SSH will be terminal base without GUI.
RDP
To connect server via RDP, search “RDP” on your local machine,
Enter the public IP address of the remote server. Click “Show Options”.
Enter the Username.
It will popup a window ask you to input password. Copy the password from Vultr.
It will popup a window ask do you trust the remote server, click “Yes”.
You successfully connect to remote server via RDP.
SSH
To connect remote server via SSH, search “PowerShell” on your local machine.
Type
ssh <username>@<remote server public IP>and press enter.Since this is the first time we try to access this server, it will ask do we trust this server. Type “yes” and enter.
Copy the password and paste in by right click on your mouse.
You successfully login via SSH.
Firewall
We need to enable firewall network to safeguard the lab environment.
Navigate to Network > Firewall > Add Firewall Groups.
Add a new Firewall Group name as “SOC-Network”.
We need to add 2 rules in the “Inbound IPv4 Rules”:
- Port 22 for SSH connection and only allow My IP address.
- Port 3389 for RDP connection and only allow My IP address.
This is the inbound rule after you added.
Apply firewall rules to servers
Now we created the firewall group, but it won’t auto apply to all the server. We need to apply it manually.
Navigate to Compute > SOC-ADDC01
Navigate to Settings > Firewall > Select the Firewall Group > Update the Firewall Group
Repeat the same step for SOC-ADNormal and SOC-Splunk.
Enable VPC Network
In order to let each server communicate with each other, we need to put them in same network. We can achieve it with VPC network, it will create a virtual network and connect all servers as it in same network.
Navigate to Settings > IPv4 > Enable VPC.
It will prompt to notify the server will be restart to enable it, click “Enable VPC”.
After few minute, the VPC will be enable. Repeat the same step for SOC-ADNormal and SOC-Splunk.
You will get something like below.
SOC-ADDC01
SOC-ADNormal
SOC-Splunk
Verify connection
After all the server restart, we can connect to our server and verify the connection.
First we connect to SOC-Splunk server and check the network interfaces by ip a command.
We can see that we have 3 network interfaces.
- First one is the loopback interface, we can ignore it.
- Second is the interface associate with public IP address.
- Third is the interface associate with private IP address, which is VPC network.
Let ping other server private IP address, it should be pingable since it in the same network.
From above image we know that SOC-ADDC01 is unreachable from SOC-Splunk.
Let connect to SOC-ADDC01 to check it. Check the network interface with ipconfig command.
We can see 2 network interfaces.
- First one is associate with public IP address.
- Second one is associate with private IP address but not the one show in VPC network.
We need to change the IP address to the one show on VPC network. Right click the Network icon from bottom right.
Open Network & Internet settings > Change adapter options.
The one we want to change is “Ethernet Instance 0 2”.
Double click it and navigate to Properties > IPv4 > Properties.
Enter the VPC IP address into the box as the picture showed below then click “Ok”.
Verify the changes.
Now ping it again from SOC-Splunk to SOC-ADDC01.
Now SOC-Splunk able to communicate with SOC-ADDC01.
Do the same for SOC-ADNormal.
Install AD service
AD service are not installed by default, we need to install it manually.
Navigate to Server Manager > Add roles and feature
Leave all as default, click Next until “Server Roles”. Check the “Active Directory Domain Services”.
Click “Add Features”.
Leave all as default, click Next until “Confirmation” and install it.
Wait for the installation. Once it done, you can click “Close” to close the window.
You can see a flag icon on top right of the navbar. Click the flag and click “Promote this server to a domain controller”.
Add a domain name for your domain.
- Create a strong password for your domain. The password need to be:
- More than 12 character.
- At lease 1 uppercase.
- At lease 1 lowercase.
- At lease 1 special character (symbol).
Leave all as default, click Next until “Prerequisites Check”. Click “Install”.
Wait for it install. Once it completed installation, you will be logout and RDP session will be end. Because the server need to restart for latest installed AD services.
After few minutes, you will be able connect to remote server via RDP again. You can verify the AD services successfully installed by the new AD tools in Tools added by AD services.
Add new domain user
Let create a domain user on the AD so that we can login into another AD machine with this user.
Navigate Tools > Active Directory Users and Computers.
Navigate to SOC.local > Users (Right click) > New > User
Fill in the user information, I name it as Jerry.
Create a password for this user. Since this user it just for practice purpose, we will disable the need of user change the password at next logon and enable password never expires.
Review the user creation and click “Finish”.
New user created.
Join the domain
Windows server won’t join a AD automatically, we need to configure and authorize it with Administrator account.
- RDP to SOC-ADNormal
Search for “This PC” and right click it to select “Properties”.
Select “Rename this PC (advanced)”
Click “Change”
Select the domain and enter domain name.
Take note here, we need to enter the Administrator credential on SOC-ADDC01 because it need the Administrator from Domain Controller to authorize it. It make sense, since an outsider trying to join your network, so it will need permission from you.
You might encounter this error, this is because the server unable to locate the Domain Controller.
Unable to locate Domain
To solve this problem, open the Network & Internet settings > Change adapter options.
Right click the “Ethernet Instance 0 2” and select Properties.
Navigate to IPv4 > Properties. Enter the private IP address of the SOC-ADDC01.
Now try again to join the domain.
It work and you need to restart the server to apply the change.
Use Domain User credential
After restart the server, we can login as the domain user we created on SOC-ADDC01.
Allow RDP login for Normal Machine
Now, let try login into Normal Machine as Domain User with RDP.
In order to login as domain user via RDP, we need to specific the domain in front of username.
Click “yes”.
It prompt error state user is not authorized for RDP.
Let allow the user to RDP. RDP to SOC-ADNormal with Administrator credential and search for “remote” and select “Allow remote connections to this computer”.
Click “Show settings”
Login with Domain Controller Administrator credential.
Click “Select Users”
Click “Add”, enter the domain user name and click “Check Names” to verify is the user exist then click “OK”.
Try to RDP with domain user again.
Successfully RDP with domain user credential.
Set up Splunk server
Splunk is one of the powerful SIEM tool that collecting and managing massive volumes of machine-generated data and analyze it.
We will open a port in Splunk to receive logs from other servers and create an alert to monitor the event to detect unauthorized successful logon.
- Connect to Ubuntu server via SSH or web console.
Update the Ubuntu package manager with
apt-get update && apt-get upgrade -yNavigate to Splunk and register an account. (You can log in your account if you already have one.)
Click “Trials & Downloads”
Find “Splunk Enterprise” and click “Get My Free Trial”
Switch to Linux tab and find .deb version and copy the wget link.
Paste the wget link into Ubuntu server. It will download Splunk deb package.
Install with
dpkg -i splunk-9.4.2-e9664af3d956-linux-amd64.debStart the splunk with
/opt/splunk/bin/splunk startRead through the term and condition and accept the license at the end.
Enter administrator username and a strong password.
Wait for the installation complete. Once completed, you will see message like below.
Access Splunk web interface
Now we can try to access the Splunk from our browser on https://<SOC-Splunk public IP>:8000. But browser state it unreachable. This is because port 8000 block by the Firewall Group on Vultr and firewall rule on Ubuntu server.
Configure Firewall Group
This this the inbound rules after you make the change.
Configure Ubuntu server’s firewall
Now we will able to access Splunk from browser.
Configure Splunk
Before we can actually use Splunk to analyze logs data, we need to make some of the configuration.
Time zone
Time zone will affect how we filter the data, we might miss out some of the data if the date out of range. We need configure the time zone into GMT to prevent this.
Install windows add-on
Windows add-on is pre-configure filter that apply into Windows Event Log, it included predefined field from the Windows Event Log so that you don’t have to do it yourself.
Navigate to Apps > Find More Apps
Search for Windows > Install “Splunk Add-on for Microsoft Windows”
Login Splunk account and agree the term & condition and install.
Login with the Splunk account, not the one used to login this web interface.
Once it complete the installation, you can close this window.
New index for our logs data
Splunk categorize data with index, we can create our own index for our servers’ logs. So that we can just filter this index to get all the data related to our servers.
Open receiving port
We need open a port for other servers send log data to our Splunk server periodically.
Navigate to Settings > Forwarding and receiving
Under Receive data section, click “Configure receiving”
Click “New Receiving Port”
Assign a port, by default is 9997 and save it.
Successfully enable receiving port
Install Splunk Forwarder
Splunk Forwarder is an agent installed on servers. This agent will aggregate server’s logs data and send it to Splunk via the Splunk’s receiving port.
Open browser, navigate to Splunk Download page, find “Universal Forwarder” and click “Get My Free Download”
Switch to Windows tab, select the Windows Server 2022 version and click “Download Now”
Agree the term & condition
Download the Splunk Forwarder.
RDP Connect to SOC-ADNormal. (I log on as the domain user I created, you can log on as Administrator if you want)
Copy and paste the Splunk Forwarder msi file into SOC-ADNormal. (RDP alow direct copy & paste feature)
Wait for it finish.
After finish copy, open the Splunk Forwarder. Agree the License Agreement, select on-premises and click “Next”
Enter a username and click “Next”
Click “Next” until “Receiving Indexer”. Enter the private IP address of SOC-Splunk and receiving port number.
Click “Install”
We need to login Administrator account, since this machine had join a Domain, we need to use the Administrator credential in Domain Controller. Unfortunately, this UAC popup is not allow we use copy and paste shortcut key, which mean we need to type in manually.
Once it finish install, click on the “Finish”
Splunk Forwarder configuration
We need to group our server’s log into the index we created - soc-ad.
Navigate to
C: > Program Files > SplunkUniversalForwarder, it going to ask you enter the Administrator credential again.Continue navigate to
etc > system > default, and copy a file nameinputs.confPaste it to
etc > system > localRight click the
inputs.confand click “Open with”Open the file with Notepad.
If you didn’t see Notepad, click “More apps” and select the Notepad to open it.
Scroll until the end of the file and add in below config.
1 2 3
[WinEventLog://Security] index = soc-ad disabled = false
Save the file and close it.
Configure the Splunk Forwarder service
I want Splunk Forwarder run with Windows system account.
Search for “Services” and right click it and select “Run as Administrator”
Enter Administrator credential again.
Find the SplunkForwarder
Right click it and select “Properties”
Navigate to “Log On” and select “Local System account”
Back to the Services window and restart the SplunkForwarder
You might encounter this Warning, but no need to worry. Just close the windows by click “OK”.
And start the SplunkForwarder manually.
Now do the same for SOC-ADDC01
Verify the Splunk Forwarder
Navigate to Splunk > Apps > Search & Reporting
And query our log with
index="soc-ad"- But we get 0 event. This is because the Splunk server’s firewall haven’t allow the port to receive the log from other server.
Go back to Splunk server and allow traffic from port 9997
Now we try again.
Configure Splunk Alert
In the nutshell, Splunk alert will trigger notification when it found an event that match the criterial you provided.
Before we create an alert, we need to let the alert what kind of event need to trigger the alert. Navigate to Splunk > Apps > Search & Reporting.
- We need to form the query text for alert to query the event.
We only want to have an alert when a user successfully login, the Event ID 4624 indicate a successful login.
So we can add in
EventCode=4624to filter out login event.There are different logon type indicated how the user login. When user login through RDP, it associate with type 7 or 10.
So we also want to filter out the logon type.
Next, let said we only allow access to the server through office IP — my IP in this case. We need to filter out my IP for the alert. From the filter on left panel, we can found a filter call “Source_Network_Address”. This filter is indicate the source of the IP connected to those servers.
There is a “-” in the filter. Let take deeper analysis on that. Click the “-” to filter event that have
Source_Network_Address=”-”It show that this kind of event is from logon type = 7. We login directly from the server windows screen.
For this walkthrough, we going to filter out
Source_Network_Address=”-”.This action just for demonstration, you might want to keep this for you alert in Production environment.
Now we need to filter out those login not from our office IP (my IP). Let said my office IP was start from 115. So we need to filter out those IP not start from 115.
- It normal if you see 0 event because we are connecting to server with our own IP so far.
- In order to generate event from other IP can connect to a VPN on our own machine and RDP to the server or wait for other connect to your server. But before this, we need to disable a firewall rule since it only allow my IP for RDP.
Navigate to Firewall configuration page and delete the RDP rule.
Add in RDP rule that accept any IP.
- Now anyone can connect to your server through RDP and successfully authorized if your user’s password is weak.
For this walkthrough, I had connected to a VPN and login to the server. Now Splunk should be have the unauthorize successful login event from IP other than 115.*.
To make it prettier, we only need to show those important information. For example like time, computer name, source IP address, and username.
If you not able to filter
user, it might cause by you didn’t install the “Splunk Add-on for Microsoft Windows”.Now we had form the query we want to use in alert, we can save it as our alert.
Enter a meaningful name for the alert.
For this walkthrough, we want the alert run scanning every 1 min so that we won’t to have too long just to see the result.
And for trigger action, we want Splunk to notify us when the alert trigger. Select “Add to Triggered Alerts”.
Severity can leave as default and save the alert.
We will receive a warning but can ignore it. We can close the window.
Verify the alert
Navigate to Activity > Triggered Alerts.
Wait about 1 minute for the alert to scan the aggregated log and we will have a alert in this page.
Clean up
To avoid unexpected charges, we need to destroy the server on Vultr.
Navigate to Compute. Click the three dot on the right and select “Server Destroy”
Check the box and click “Destroy Server”
Wait Vultr destroy the server.
It destroyed. Repeat the same for all other servers.
Conclusion
We had successfully created 3 server on Vultr. 2 servers running on Windows Server 2022 and 1 server running on Ubuntu. We installed Active Directory in one of the Windows Server and make it as Domain Controller, have another Windows server join into the same domain. We also created a domain user that can log on into any of the server that join the domain. Moreover, we also installed a Splunk SIEM on Ubuntu server and keep collection logs from other 2 servers. We also created a Splunk alert to keep monitoring the servers’ logs data to detect any unauthorized successful log on event.






















































































































































































