Post

Azure SIEM Honeypot

Set up an Honeypot that aggregates logs and detects intruders from which country based on the IP addresses.

Azure SIEM Honeypot

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

overview

Walkthrough

Create log analytics workspace

First, we need to create a Log Analytics Workspace that will be used connect to Azure Sentinel.

overview

Click “Create” to create new Log Analytics workspaces

overview

Create anew resource group if you don’t have one, and give a name to the Log Analytics workspace

overview

Create VM

Create a Window VM that will be access by attacker.

overview

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.

overview

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.

overview

Be sure to agree the license before we go to Networking configuration.

overview

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

  1. Log in to the VM
  2. Open Windows PowerShell ISE and create a new shell

    overview

  3. You can download or copy the custom log exporter from —> Custom_Security_Log_Exporter.ps1
  4. 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
  5. 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.
  6. Replace the API key and run the script.

    overview

  7. Verify the script is running by login with wrong username.

    overview

    overview

  8. 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.

    overview

Connect Log Analytics Workspace to Microsoft Sentinel

Navigate to Content hub

overview

Install 2 solution on Content hub

  • Windows Security Event
  • Custom logs AMA

overview

Connect Windows VM Event log to Sentinel via Windows Security Events

  1. Select Windows Security Events, then select “Manage” on the right-hand panel

    overview

  2. Find “Windows Security Events via AMA” and click “Open connector page”

    overview

  3. Create a new Data Collection Rule, this rule are used ingest log data from VM.

    overview

  4. In the Resources tab, select the VM you created just now.

    overview

  5. The default configuration will collect all security events. After this, you can review and create the rule.

    overview

Connect custom log generate by Windows VM to Microsoft Sentinel via Custom logs AMA

  1. Select Custom logs AMA, then select “Manage” on the right-hand panel

    overview

  2. Select “Custom logs via AMA” and click “Open connection page”

    overview

  3. Create new Data Collection Rule

    overview

  4. Select which VM to apply the rule.

    overview

  5. Select “Custom new table” and give the table a name, specific the file path of the custom log.

    overview

    overview

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.

overview

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”.

overview

overview

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”.

overview

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.

overview

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.

  1. 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”

    overview

    overview

  2. 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
    

    overview

  3. Go to Log Analytics workspaces, and select your workspace. Then select Setting > Table.

    overview

  4. Select “Edit scheme”

    overview

  5. Add custom field in “Custom Column”
    • All new column as type String, except Timestamp_CF as datetime

    overview

  6. 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
    
  7. Go to “Data collection rules”, select the custom log rule. Go to Configuration > Data sources

    overview

  8. Paste the query into “Transform” field and save it.

    overview

  9. 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.

    overview

Create new workbook

Last but not least, we will create a map for us to visualize where the attack come from.

  1. Go to Microsoft Sentinel, select the Log analytics workspace. Select Threat management > Workbooks.

    overview

  2. Create a new Workbook. Remove all the default metric.

    overview

  3. Add new query.

    overview

  4. 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 != ""
    

    overview

  5. Select Visualization > Map

    overview

  6. Configure the map as following

    overview

    overview

  7. Click Done Editing and save the workbook. Now you have a map that show where the attack came from.

    overview

    overview

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.

  1. Go to Vitual Machine, and select the VM you wish to expose more port. Select Networking > Network settings.

    overview

  2. Add new inbound port rule.

    overview

  3. Allow all destination port, and make this rule as top priority by set it to 100.

    overview overview

  4. Delete the default rule created by Network security group.

    overview

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.

  1. Search “Resource groups” on top of Azure portal

    overview

  2. 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

    overview

References

This post is licensed under CC BY 4.0 by the author.