Azure SIEM Honeypot
Set up an Honeypot that aggregates logs and detects intruders from which country based on the IP addresses.
This showcase is for my lab practice. I setup a Azure SIEM to gather the event data that try to break into my VM machine, and show a map to see where the attack come from.
Overview
Walkthrough
Create log analytics workspace
First, we need to create a Log Analytics Workspace that will be used connect to Azure Sentinel.
Click “Create” to create new Log Analytics workspaces
Create anew resource group if you don’t have one, and give a name to the Log Analytics workspace
Create VM
Create a Window VM that will be access by attacker.
This VM just for my lab practice, so no redundancy are required, and set the security to standard as this is a honeypot for any attacker to access.
Size will be at least 2 vcpu and 8gb memory for my preference, we need to setup something in the VM later. You need to remember the username and password.
Be sure to agree the license before we go to Networking configuration.
Select Advanced network security group for Microsoft to create a network security group resource. We will use this to configure the network firewall with this resource later.
Setup custom log extract on VM
- Log in to the VM
Open Windows PowerShell ISE and create a new shell
- You can download or copy the custom log exporter from —> Custom_Security_Log_Exporter.ps1
- his script are written by Josh Madakor, the script just loop all the failed login from Windows Event and retrieve the geolocation by the IP address using IP Geolocation API —> IP Geolocation API
- You will need to sign up an account in IP Geolocation API to get a API key, the account is free but have 1000 daily limit query.
Replace the API key and run the script.
Verify the script is running by login with wrong username.
The script will generate a list of sample log once run, these sample log will be used to configure on data extract to Azure table later.
Connect Log Analytics Workspace to Microsoft Sentinel
Navigate to Content hub
Install 2 solution on Content hub
- Windows Security Event
- Custom logs AMA
Connect Windows VM Event log to Sentinel via Windows Security Events
Select Windows Security Events, then select “Manage” on the right-hand panel
Find “Windows Security Events via AMA” and click “Open connector page”
Create a new Data Collection Rule, this rule are used ingest log data from VM.
In the Resources tab, select the VM you created just now.
The default configuration will collect all security events. After this, you can review and create the rule.
Connect custom log generate by Windows VM to Microsoft Sentinel via Custom logs AMA
Select Custom logs AMA, then select “Manage” on the right-hand panel
Select “Custom logs via AMA” and click “Open connection page”
Create new Data Collection Rule
Select which VM to apply the rule.
Select “Custom new table” and give the table a name, specific the file path of the custom log.
Verify the data connector
Before we continue, we need to make sure all the log will be send to Microsoft Sentinel by verify all the data connector is connected. In our case, we need the “Windows Security Events via AMA” & “Security Events via Legacy Agent” to be connected.
“Windows Security Events via AMA” is for the default Windows Event log.
“Security Events via Legacy Agent” is for the custom log our script or application generated.
Go to Microsoft Sentinel > Configuration > Data connectors.
As picture showed above, the “Security Events via Legacy Agent” is not connected. We need to fix the connection. On top of Azure portal, search “Data collection rules”.
In this page, you can see the rules you had created previously. Now, we want to focus on the rule that associate with my custom log, which is “FAILED_RDP_CUSTOM_LOG”.
We go to Configuration > Resources, set the “Data Connection endpoint” that associate with Microsoft Sentinel. After that, we verify the Data connectors on Microsoft Sentinel.
Customize custom log table
By default, the custom log that gather from VM will ingest as long string data. In order to make the data useful and easy to read, we need to let Microsoft Sentinel know how to transform the data.
Go to Microsoft Sentinel > General > Logs. Select the table that created during “Connect custom log generate by Windows VM to Microsoft Sentinel via Custom logs AMA”
- Create a query that will output the data as you expected. Here will provide the query I used for this log.
FAILED_RDP_CL | parse RawData with * "latitude:" Latitude_CF ",longitude:" Longitude_CF ",destinationhost:" Destinationhost_CF ",username:" Username_CF ",sourcehost:" Sourcehost_CF ",state:" State_CF ", country:" Country_CF ",label:" Label_CF ",timestamp:" Timestamp_CF:datetime | project Latitude_CF, Longitude_CF, Destinationhost_CF, Username_CF, Sourcehost_CF, State_CF, Country_CF, Label_CF, Timestamp_CF | limit 10 Go to Log Analytics workspaces, and select your workspace. Then select Setting > Table.
Select “Edit scheme”
- Add custom field in “Custom Column”
- All new column as type String, except Timestamp_CF as datetime
- Copy the parse query that you just created
| parse RawData with * "latitude:" Latitude_CF ",longitude:" Longitude_CF ",destinationhost:" Destinationhost_CF ",username:" Username_CF ",sourcehost:" Sourcehost_CF ",state:" State_CF ", country:" Country_CF ",label:" Label_CF ",timestamp:" Timestamp_CF:datetime Go to “Data collection rules”, select the custom log rule. Go to Configuration > Data sources
Paste the query into “Transform” field and save it.
The new transformed data only apply to new added data. Wait for few minute for new data to pass in or you can create new data by RDP to the VM with wrong username.
Create new workbook
Last but not least, we will create a map for us to visualize where the attack come from.
Go to Microsoft Sentinel, select the Log analytics workspace. Select Threat management > Workbooks.
Create a new Workbook. Remove all the default metric.
Add new query.
- Copy the query below to create a summarize the event count of the geolocation data gather by custom log.
FAILED_RDP_CL | summarize event_count=count() by Sourcehost_CF, Latitude_CF, Longitude_CF, Country_CF, Label_CF, Destinationhost_CF | where Destinationhost_CF != "samplehost" | where Sourcehost_CF != "" Select Visualization > Map
Configure the map as following
Click Done Editing and save the workbook. Now you have a map that show where the attack came from.
Extra: Expose more port for attacker
Currently, only port 3389 is open for attacker to login. We can enable more port for attacker access that machine.
Go to Vitual Machine, and select the VM you wish to expose more port. Select Networking > Network settings.
Add new inbound port rule.
Allow all destination port, and make this rule as top priority by set it to 100.
Delete the default rule created by Network security group.
Conclusion
We have create a new virtual machine that open to internet. Anyone can access or break into that VM. We also configure data collection rules to collect the data from that VM. Moreover, we enable the Azure SIEM (Microsoft Sentinel) to aggregate all the log data from that machine and visualize those data as a map to know where the attack come from.
Clean up
After finish the lab practice, we need to clean up the machine and service create on this lab practice to avoid these service used up all the credit we have.
Search “Resource groups” on top of Azure portal
Delete the resource group created on this lab practice. For my case is “Honeypot-RG” and “NetworkWatcherRG”.
Note: Network Watcher created when you created a VM and no Network Watcher in that region
References
- SC-200T00A-Microsoft-Security-Operations-Analyst
- SIEM Tutorial for Beginners
- Collect logs from text files with the Azure Monitor Agent and ingest to Microsoft Sentinel - AMA
- Data collection endpoints in Azure Monitor - Azure Monitor
- Migration of custom fields to KQL-based transformations in Azure Monitor - Azure Monitor
- What is Network Watcher and How Did It Get In My Subscription!























































