Cybersecurity guides, explanations and reader checklists on whilenetworking.com

Hands-On Lab: Analyzing Windows Event Logs to Identify Successful RDP Brute Force Attacks

Remote Desktop Protocol (RDP) remains one of the most targeted vectors for ransomware and unauthorized access. Attackers often employ automated bots to…

Remote Desktop Protocol (RDP) remains one of the most targeted vectors for ransomware and unauthorized access. Attackers often employ automated bots to attempt billions of credential combinations against exposed systems, a tactic known as “brute forcing.” For defensive security professionals, the ability to distinguish between noise and a genuine breach within Windows Event Logs is a critical skill. This guide provides a hands-on lab approach to identifying successful RDP brute force attacks, focusing on log analysis, incident response, and system hardening.

Understanding the Attack Vector and Log Sources

Before analyzing logs, it is essential to understand what constitutes a successful attack. A brute force attack involves an attacker repeatedly guessing passwords until one works. When a login attempt fails, Windows generates a failure event. However, when the password is correct, the system generates a success event. The danger lies in the fact that if an attacker guesses the credentials correctly after hundreds of failed attempts, they may have already established persistence before alerts trigger.

In a standard Active Directory environment, authentication events are recorded in the Security log on Domain Controllers and member servers. The primary Event ID to monitor is 4624 (An account was successfully logged on). Within this event, specific fields reveal whether the login originated from an RDP session or if it was local.

Lab Setup: Creating a Safe Test Environment

To practice these skills safely without risking production data, you must construct a controlled lab environment. This section outlines the prerequisites and setup steps required to simulate both the attacker’s activity and the defender’s analysis tools.

Prerequisites

  • Target Machine: A Windows 10 or Windows Server machine (e.g., Windows Server 2022) with remote desktop enabled.
  • Monitoring Machine: A separate Windows system running a local administrator account to access logs remotely or via PowerShell remoting.
  • Network Connectivity: The two machines must be on the same subnet or have firewall rules permitting RDP (TCP port 3389).

Step-by-Step Lab Configuration

  1. Enable Remote Desktop on the Target:
    Open “Local Security Policy” (secpol.msc) on the target machine. Navigate to Local Policies > Security Options. Ensure “Network access: Sharing and security model for local accounts” is set appropriately, but most importantly, verify that “Microsoft account password protection” allows changes if applicable. To enable RDP specifically, run PowerShell as Administrator:
    powershell
    Enable-RemoteDesktop -ComputerName <TargetHostname>
  2. Configure Log Collection:
    Ensure the Windows Event Log service is running. By default, Windows retains logs for a specific period (often 14 days) before overwriting them. For this lab, we will assume standard retention settings but emphasize that in a real incident, you must secure the log immediately.
  3. Simulate the Attack:
    From the monitoring machine, attempt to log into the target using an incorrect password multiple times to generate noise, followed by one successful login using the correct credentials. This mimics a brute force scenario where the attacker eventually succeeds.

Identifying Successful Logins in Event Viewer

Once the simulation is complete, the analysis phase begins. The most direct method is using the Windows Event Viewer.

Locating the Critical Event ID

  1. Open Event Viewer (eventvwr.msc) on the target machine (or remotely).
  2. Navigate to Windows Logs > Security.
  3. Filter the log for Event ID 4624.

When you inspect a successful login event, look at the <EventData> section. You will see several fields:
* TargetUserName: The account used (e.g., Administrator).
* LogonType: This is crucial. A value of 10 indicates an interactive logon over the network via RDP. Values like 2 (Network) or 3 (Cached) differ.
* WorkstationName: The name of the machine initiating the connection.

Distinguishing Brute Force from Normal Activity

In a normal environment, you might see one or two Event ID 4624 entries with LogonType 10 per day. In a brute force scenario, you will see a pattern:
* Event ID 4625 (Failed logon): These appear frequently in the minutes leading up to success.
* Event ID 4624 (Successful logon): This appears after a cluster of failures.

Illustrative Output Analysis:
Imagine viewing Event ID 4624 where LogonType is 10, and the SourceNetworkAddress matches an IP known for malicious activity (based on threat intelligence). If this IP has generated dozens of Event ID 4625 events in the preceding hour, you have a high-confidence indicator of a brute force compromise.

Automated Analysis with PowerShell

Manually scrolling through logs is inefficient for large datasets. Using PowerShell allows for rapid correlation between failed and successful attempts. This script demonstrates how to identify accounts that had both failures and successes within a short window.

PowerShell Script for Log Correlation

Run this script on the target machine or via remote session:

# Define time range for analysis (e.g., last 24 hours)
$StartDate = (Get-Date).AddHours(-24)
$EndDate = Get-Date

# Retrieve failed logons (Event ID 4625) and successful logons (Event ID 4624)
$FailedLogons = Get-WinEvent -FilterHashtable @{ LogName='Security'; Id=4625; StartTime=$StartDate; EndTime=$EndDate } | Select-Object TimeCreated, Message
$SuccessfulLogons = Get-WinEvent -FilterHashtable @{ LogName='Security'; Id=4624; StartTime=$StartDate; EndTime=$EndDate } | Select-Object TimeCreated, Message

# Extract usernames and IPs from the raw messages (Note: Regex parsing varies by Windows version)
# This is a simplified example focusing on Event ID correlation
$FailuresByUser = $FailedLogons | Group-Object { ($_.Message -split '\|')[0] } # Simplified grouping logic

Note: Parsing raw log messages in PowerShell can be complex due to variable formatting. In production, tools like Splunk, ELK Stack, or Microsoft Sentinel are preferred for regex extraction.

However, a simpler native check involves filtering for specific patterns. You can search for the combination of a user account having multiple 4625 events followed by a single 4624 event from the same IP address.

Verification and Incident Response Steps

Finding the log entry is only half the battle; verifying the compromise and containing it are equally important.

Step 1: Verify the Compromise

  • Check Session State: If you have remote access to the compromised machine, open a new RDP session. Check if the attacker’s session is still active or if they have logged off.
  • Review Security Associations: Use net user and net localgroup administrators to ensure no new accounts were created during the session.
  • Check Scheduled Tasks: Run schtasks /query /fo LIST /v to see if persistence mechanisms were installed.

Step 2: Containment Actions

If a breach is confirmed:
1. Disable the Account: Immediately disable the compromised user account via Active Directory Users and Computers or PowerShell (Disable-ADAccount).
2. Block the IP: Update your firewall or network segmentation rules to block the source IP addresses associated with the brute force attempts.
3. Reset Credentials: Force a password reset for the affected account and any others that might have been guessed during the attack window.

Step 3: Hardening Recommendations

To prevent recurrence, implement these security controls:
* Network Segmentation: Place RDP servers in a DMZ or isolated subnet, accessible only by jump hosts (bastions), not directly from the internet.
* Just-in-Time Access: Use tools that grant temporary RDP access rather than permanent open ports.
* Multi-Factor Authentication (MFA): Enforce MFA for all RDP connections. This renders password guessing ineffective, as the attacker would need the second factor code.

Common Mistakes and Pitfalls

When analyzing logs, practitioners often make specific errors that hinder incident response:
1. Ignoring LogonType: Focusing solely on Event ID 4624 without checking if it was an interactive (LogonType 10) or network logon can lead to false positives regarding RDP attacks.
2. Overlooking Time Gaps: An attacker might pause between attempts to avoid detection thresholds. Ensure your analysis window covers the full duration of the attack campaign, not just a single hour.
3. Assuming Local Accounts are Safe: While less common for domain attacks, local accounts can still be targeted. Always check the TargetDomainName field; if it is empty or shows “UNKNOWN,” verify if it is a legitimate local service or a compromised local account.

Conclusion

Analyzing Windows Event Logs for RDP brute force attacks requires a blend of manual inspection and automated correlation. By understanding Event IDs 4624 and 4625, identifying LogonType 10, and correlating source IPs with failure patterns, defenders can rapidly detect successful intrusions. Remember that terms, availability, and specific log retention policies depend on your organization’s configuration and jurisdiction. Always operate within authorized lab environments or approved incident response procedures. Regular practice in a safe sandbox is the best way to maintain these critical defensive skills.

Educational-use notice: This tutorial is for learning and controlled lab use only. Test carefully, use backups, and obtain authorization before making changes. Do not run unfamiliar commands on production systems. We accept no responsibility for misuse, damage, data loss, or production issues.