Skip to content

Project shows how to build a mini honeypot with Azure, ingest log files from real traffic into Microsoft Sentinel using Law Analytics Workspace . Also showing how to respond to incidents on Sentinel Dashboard. Writing KQL scripts , Using NIST 800-53 Access Control and NIST 800-61 Incidnet Response to harden environment.

Notifications You must be signed in to change notification settings

hendo87/Azure-Honeypot-SIEM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 

Repository files navigation

Azure Honeypot + SIEM

68747470733a2f2f692e696d6775722e636f6d2f744d78626270642e706e67

Introduction


In this project, a mini honeynet was constructed in Microsoft Azure and log sources were integrated into a Log Analytics workspace. Microsoft Sentinel was employed to trigger alerts and create incidents based on the ingested logs. Additionally, metrics were measured in the insecure environment before security controls were applied, and then again after implementing security measures. It is noteworthy that the number of security events and incidents were drastically reduced after the security controls were applied, demonstrating their effectiveness.

Azure Resources Deployed, Technologies, and Regulations used


Step 1. Create Windows and Linux Virtual Machines

create_azure_vm

Basics

  • Go to portal.azure.com
  • Search for "virtual machines"
  • Create > Azure virtual machine

Project details

  • Create new resource group and give it a unique name

  • A resource group is a collection of resources that share the same lifecycle, permissions, and policies.

Instance details

  • Name your VM
  • Select a recommended region ((US) East US 2)
  • Availability options: No infrastructure redundancy required
  • Security type: Standard
  • Image: Windows 10 Pro, version 21H2 - x62 Gen2
  • VM Architecture: x64
  • Size: Default is okay (Standard_D2s_v3 – 2vcpus, 8 GiB memory)

Administrator account

  • Create a username and password for virtual machine

  • IMPORTANT NOTE: These credentials will be used to log into the virtual machine (Keep them handy)

Inbound port rules

  • Public inbound ports: Allow RDP (3389)
  • Licensing

  • Confirm licensing
  • Select Next : Disks >
  • vm1

    Disks

    • Leave all defaults
    • Select Next : Networking >

    Networking

    Network interface

    • NIC network security group: Advanced > Create new

    • A network security group contains security rules that allow or deny inbound network traffic to, or outbound network traffic from, the virtual machine. In other words, security rules management.

    • Remove Inbound rules (1000: default-allow-rdp) by clicking three dots
    • Add an inbound rule
    • Destination port ranges: * (wildcard for anything)
    • Protocol: Any
    • Action: Allow
    • Priority: 100 (low)
    • Name: Anything (ALLOW_ALL_INBOUND)
    • Select Review + create

    network_sec_grp

    Normally you would never allow all inbound traffic but for the purpose of this honeypot we want to make our machine easily discoverable for bad actors

    Create Linux VM

    We will create the Linux VM the same way as the Windows VM except for a few minor changes

    • Make sure you choose the same resource group as the Windows VM
    • Set to the same region as the Windows VM
    • Image: Ubuntu Server 20.04

    Linux VM


    • Set Admin account to same username and password as the Windows VM so its easy to remember
    • Confirm Licensing
    • Select Next : Disks >
    • Leave all Disks to Defaults
    • Select Next : Networking >
    • Copy same steps as you did for the Windows VM and allow all inbound traffic

    Step 2: Create Log Analytics Workspace


    Log Analytics Workspace is a repository for storing logs in JSON format. It's a versatile tool that helps manage and analyze large volumes of data


    • Search for "Log analytics workspaces"
    • Select Create Log Analytics workspace
    • Put it in the same resource group as VM
    • Give it a desired name
    • Add to same Region as VM
    • Select Review + create

    log_an_wrk

    Step 3: Configure Microsoft Sentinel


    Microsoft Sentinel is a cloud security information and event management service (SIEM). It is designed to provide security analytics and threat intelligence. We will forward the logs from Log Analytics Workspace to Sentinel


    • Search for "Microsoft Sentinel"
    • Click Create Microsoft Sentinel
    • Select Log Analytics workspace name (honeypot-log)
    • Click Add

    sentinel_log


    Creating a Watchlist in Sentinel

    In this instance the Watchlist is network blocks with corresponding latitude and longitude points , we are going to use this to derive geolocation from attackers so we can plot them on a map to see where the attacks are coming from


    • First download Geo Data file Here
    • Then in Azure search for "Microsoft Sentinel"
    • Select the instance you've created
    • Configurations > Watchlist
    • Create New
    • Name/Alias : geoip
    • Source type: local file
    • File Type : CSV
    • Number of lines before row: 0
    • Upload the Geo data file you've downloaded
    • Search Key: Network
    • Review and Create > Create

    This could take awhile there are around 27000 rows

    Step 4: Configure Microsoft Defender for Cloud


    Microsoft Defender is a comprehensive cloud security solution. It offers tools and services designed to protect cloud-based resources, including virtual machines, databases, and containers.

    • Search for "Microsoft Defender for Cloud"
    • Scroll down to "Environment settings" > subscription name >
    • Where you see your Log Analytics Workspace name , click the 3 dots to the right to edit settings

    • mcrsft_dfndr

    • Servers > Turn on > Save
    • Settings > Data collection
    • Select "All Events"
    • Save

    This will allow us to collect all security events from the logs


    defender_plans

    Enable Microsoft Defender for Cloud for Subscription

  • Scroll down to "Environment settings" > Azure Subscription
  • click the 3 dots to the right to edit settings
  • Defender Plans
  • Server > ON , Storage > ON , Key Vault > ON
  • On the Server tab , under monitoring coverage , select settings

  • Screenshot (58)


  • Log Analytic Agent > Edit Configuration
  • Custom Workspace > Select your Log Analytic Workspace instance
  • Select Apply > Then Continue > Save
  • Select Continous Export > Log Analytics Workspace
  • Check boxes for : Security Recommendations , Secure Score , Security Alerts , Regulatory Compliance , Security attack paths
  • Scroll down to Export Configuration > Choose your resource group
  • Export target > Target Workspace > Select your Log Analytic Workspace instance
  • Save

  • Step 5: Enable Log Collection for VMs and Network Security Groups


    Create Azure Storage Account

    You can think of a Storage account as place to store files , it stores the logs from the Network Security Groups momentarily before it passes on to Log Analytics Workspace

    • Search "Storage Account"
    • Create New
    • Select your resource
    • Give storage Account unique name
    • Choose same region as your VM's
    • Review and Create

    Storage


    Enable NSG flow logs for Windows and Linux VM's

    • Search "Network Security Group"
    • Select your Windows VM
    • Monitoring > NSG flow logs
    • Create Flow logs
    • Select resource and select both Windows and Linux VM then confirm selection
    • Now choose the storage account that you've created
    • Retention Days: 0
    • Go to Analytics
    • Make sure you are on Version 2
    • Select Enable traffic analytics

    • This is where Defender will determine if traffic is malicious or beniegn . We use this later to map the attacks


    • Traffic Analytics Processing Interval : 10mins
    • Log Analytic Workspace : Choose your instance
    • Review and Create

    Screenshot (51)


    Configure Data Collection Rules

    The data collection rule works in conjuction with Microsoft Defender to choose which logs are forwarded to Log Analytic Workspace , you dont want to forward all logs because that can become expensive

    • Search "Log Analytics Workspace"
    • Settings > Agents
    • Select Data Collection Rules
    • Create
    • Choose rule name
    • Choose same region as your Virtual MAchines
    • Platform type : All
    • Next > Resources
    • Add Resources
    • Choose the Resource group you've created , click the arrow to expand and select both your VM's
    • Next > Collect and Deliver
    • Add Data Source
    • Select Linux Syslog
    • The only log we want is the LOG_AUTH , which is the Authentication logs Leave it set to LOG_Debug , and turn the rest to none

    • Screenshot (55)

    • Next > Destination
    • Add Data Source
    • Windows Event Log
    • For Application select information
    • For Security select Audit Success and Failure
    • Destination>
    • Create the Data collection rule

    Configure Special Windows Event Data Collection rule

    We are creating a Data source that will log anytime our firewall is modified or if the system detects malware on the machine

    • Search "Log Analytic Workspace
    • Settings > Agents
    • Select Data Collection Rule
    • Choose the collection rule that you have created
    • Screenshot (56)


    • Data Sources > Windows Event Log
    • Change from Basic to Custom
    • Download Xpath queries Here

    • We need to put a Xpath query to filter event logs. These queries are to trigger alerts when the firewall has been modified or when malware is detected on the system


      Screenshot (57)


    • Copy both queries and add them to the filter list
    • Save

    Installing Windows Defender Agent on virtual Machine

    • Search Log Analytics Workspace
    • Select your instance
    • Agents >
    • Expand Log Analytics Agent Instruction
    • Copy the workspace ID and Primary Key into a notepad , you will need it later
    • For Download Windows Agent (64) > right click > Copy link

    • Screenshot (59)


    • Open your windows virtual machine
    • Paste the link from Download Windows Agent to in Microsoft edge
    • Download the file
    • Select connect agent to log analytics
    • Paste the Workspace ID and Primary Key
    • Azure cloud : Azure commercial
    • Next > Finsih

    Step 6. Building Attack Maps & Creating Alerts for Sentinel

    We are building a Attack map for the Windows VM - RDP Authentication failures , Linux - SSH Authentication Failures & Network Sucurity Groups - Malicous inbound network flow

    • Go to JSON files Here - We are only going to be dealing with , nsg-malicious-allowed-in.json , linux-ssh-auth-fail.json , windows-rdp-auth-fail.json
    • Go back to Azure portal , Search Sentinel
    • Workbooks > Add Workbooks > Edit
    • Remove the existing workbook
    • Add > Add Query > Advanced Editor
    • Copy the linux-ssh-auth-fail.json files from the link and paste them into the editor

    • Screenshot (62)


    • Done editing > Save > Name your map " linux-ssh-auth-fail.json"
    • Repeat steps to create maps for the windows-rdp-auth-fail.json and nsg-malicious-allowed-in.json
    • You Map shoud look like this :

    • Screenshot (63)

    Create Alerts for Microsoft Sentinel

    • Go to Microsoft Sentinel > Analytics > Active Rules
    • Create Schedule Query Rule
    • NAME : TEST: Brute Force ATTEMPT - Windows
    • Description : When the same person fails to log in to the same VM more then 10 times
    • Next > Rule Logic
    • Paste in the KQL Query -

      SecurityEvent


      | where EventID == 4625


      | where TimeGenerated > ago(60m)


      | summarize FailureCount = count() by AttackerIP = IpAddress, EventID, Activity, DestinationHostName = Computer


      | where FailureCount >= 10


    • Screenshot (64)

    • Add new Entity
    • IP > Address > Attacker IP
    • Host > Hostname > DestinationHostname
    • Run Query: every 5 minutes
    • Look up Data from the past 5 hours
    • Next > Incident Settings > Next > Save

    Importing Alerts

    • Click Here to download JSON files
    • Go back Azure portal , Search Sentinel
    • Analytics > Import
    • Import in the JSON file you downloaded

    • Screenshot (9)

    Step 7. Working Incidents

    Now that i've left the Vm's up for 24hrs with our firewall rules disabled. I've given bad actors plenty of time to attack the environment and generate incidents

  • Go to Sentinel > Incidents > Select First Incident > Change owner to yourself , Change status to active > Select view full details
  • 68747470733a2f2f692e696d6775722e636f6d2f385a504d384d6a2e706e67


    As you can see once you click on the IP address it gives you the Geo location of the attacker. This IP address is located in China. This could be a red flag


    Also The activity log section is where we observe the history of the triggered alerts for this incident. As you can see from the screenshot, the attacker has been triggering alerts over a span of hours. Lets investigate further


  • Click Investigate

  • This gives us a visualization of the connections between the entites , you can also hover over the entity and see the related events connected with the IP address. Here we can see the IP address is associated with alot of alerts on our system

    Screenshot (72)

    After seeing the visuals of all the alerts triggered by this IP address , I wanted to check the logs in Sentinel to see if this IP address has triggered any successful log on attempts. I did so by writing this KQL scripts:

  • SecurityEvent (This allows us to see the Windows Security Events)
  • | where EventID == 4624 // (Filter for successful logon events)
  • | where IpAddress == "159.27.11.148"

  • Screenshot (92)


    this hacker was not able to brute force into the system. This IP address did not generate any successful login attempts. I will close this incident out as a false positive but before i do i'll make sure to notate everything i discovered in my investigation.


    68747470733a2f2f692e696d6775722e636f6d2f6836347937674c2e706e67


    Utilizing NIST 800.61 Computer Incident Handling Guide

    Screenshot (93)


    Each organization will have policies related to an incident response that should be followed. This event is just a walkthrough for possible actions to take in the detection of malware on a workstation.

    Preparation

    The Azure lab was set up to ingest all of the logs into Log Analytics Workspace, Sentinel and Defender were configured, and alert rules were put in place.

    Detection & Analysis

  • Malware has been detected on a workstation with the potential to compromise the confidentiality, integrity, or availability of the system and data.
  • Assigned alert to an owner, set the severity to "High", and the status to "Active"
  • Identified the primary user account of the system and all systems affected.
  • A full scan of the system was conducted using up-to-date antivirus software to identify the malware.
  • Verified the authenticity of the alert as a "True Positive".
  • Sent notifications to appropriate personnel as required by the organization's communication policies.
  • Containment, Eradication & Recovery

  • The infected system and any additional systems infected by the malware were quarantined.
  • If the malware was unable to be removed or the system sustained damage, the system would have been shut down and disconnected from the network.
  • Depending on organizational policies the affected systems could be restored known clean state, such as a system image or a clean installation of the operating system and applications. Or an up-to-date anti-virus solution could be used to clean the systems.
  • Post-Incident Activity

  • In this simulated case, an employee had downloaded a game that contained malware.
  • All information was gathered and analyzed to determine the root cause, extent of damage, and effectiveness of the response.
  • Report disseminated to all stakeholders.
  • Corrective actions are implemented to remediate the root cause.
  • And a lessons-learned review of the incident was conducted.
  • Hardening the Environment

    I am going to lock down the Network Security Group assigned to that VM/Subnet , allow only neccesary traffic. Even though the would be attacker did not infiltrate our resources , the attacker should not have the oppurtunity to even brute force our system


    • Go to virtual machines > Linux-VM > Networking > Click on the first rule > Change source to My IP address > Save
    • Screenshot (75)

    Implementing Azure Private link

    Azure Private Link is a service provided by Microsoft Azure that allows you to access Azure services and resources over a private connection. This means you can securely connect to these resources through a private IP address in your own virtual network (VNet), rather than over the public internet.

    • Go to Key Vault
    • Select your instance
    • Go to Networking
    • Firewalls and Virtual Networks > Disable Public Access
    • Go to Private endpoint connections
    • Create >

    • Screenshot (79)


    • Next > Resources
    • Resource type : Key Vault
    • Resource : Choose your instance
    • Next > Create

    Enable Regulatory Compliance for NIST 800-53 Access controls inside Microsoft Defender for Cloud

    • Go to Defender for Cloud >
    • Regulatory Compliance >
    • Manage Compliance Standards >
    • Select your instance >
    • Security Policy >
    • Select NIST 800-53 Rev 5

    • Screenshot 7)

    Metrics Before Hardening / Security Controls

    The following table shows the metrics we measured in our insecure environment for 24 hours: Start Time 2024-07-15 17:04:29 Stop Time 2024-07-16 17:04:29

    Metric Count
    SecurityEvent 19470
    Syslog 3028
    SecurityAlert 10
    SecurityIncident 348
    AzureNetworkAnalytics_CL 843

    Metrics After Hardening / Security Controls

    The following table shows the metrics we measured in our environment for another 24 hours, but after we have applied security controls: Start Time 2024-07-18 15:37 Stop Time 2024-07-19 15:37

    Metric Count
    SecurityEvent 8778
    Syslog 25
    SecurityAlert 0
    SecurityIncident 0
    AzureNetworkAnalytics_CL 0

    Thank you

    About

    Project shows how to build a mini honeypot with Azure, ingest log files from real traffic into Microsoft Sentinel using Law Analytics Workspace . Also showing how to respond to incidents on Sentinel Dashboard. Writing KQL scripts , Using NIST 800-53 Access Control and NIST 800-61 Incidnet Response to harden environment.

    Topics

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published