We've covered why RDP is so useful for attackers and what makes a session suspicious in the first place. Now we need to understand the event-log artifacts this technique leaves behind, because that's where most of the investigation happens.
RDP is a built-in admin tool, so the presence of an RDP connection is never the finding by itself. What makes a session suspicious are the answers to the following questions:
- Whose account it was
- Which workstation it came from
- Whether the connection was expected
- What happened during the session
For this walkthrough we'll focus on a single source-to-destination RDP connection, so the artifact split between the two sides is easy to see. In the real world, you might find multi-hop RDP lateral movement, as you will in Task 6.
Now let's see what artifacts RDP leaves on the source and the destination hosts.
Make sure that you follow along with the VM open, so you can apply what you learn directly. You'll find the artifacts in D:\Walkthrough\, one folder per host (THM-MKT-WS, THM-SHR-SRV). There's also a Walkthrough shortcut on the Desktop that opens the same folder. The challenge triage in D:\Challenge\ has a THM-SHR-SRV folder too, from a different intrusion, so for Tasks 4 and 5 use the folders under D:\Walkthrough\.
Opening the Logs
Each host's event logs are in D:\Walkthrough\<host>\uploads\auto\C%3A\Windows\System32\winevt\Logs\. The triage tool keeps each file's original path, writes C: as C%3A, and writes the % in a log's file name as %25. So the Sysmon log, which Windows names Microsoft-Windows-Sysmon%4Operational.evtx, is Microsoft-Windows-Sysmon%254Operational.evtx here, and the Security log is Security.evtx.
Here are the log files you'll need in that folder. The %254 in the file names is how the triage tool wrote the %4 that Windows uses in the real file names:
| Evidence |
Log file in the Logs folder |
Host |
| Sysmon Events 1 and 3 |
Microsoft-Windows-Sysmon%254Operational.evtx |
Source |
| RDP client Events 1024/1025 |
Microsoft-Windows-TerminalServices-RDPClient%254Operational.evtx |
Source |
| Logon Event 4624 |
Security.evtx |
Destination |
| Event 1149 |
Microsoft-Windows-TerminalServices-RemoteConnectionManager%254Operational.evtx |
Destination |
| Events 21 to 25 |
Microsoft-Windows-TerminalServices-LocalSessionManager%254Operational.evtx |
Destination |
Reading Logs with Event Viewer
For the Security and Terminal Services logs, we'll use Event Viewer:
- Click Open Saved Log... in the Actions pane and pick the
.evtx file (you can paste the full path into the file name box).
- Click Filter Current Log... and type the event ID into the Includes/Excludes Event IDs box, for example
4624.
- Click an event and read the General tab. Use the Details tab (XML View) when the field you need isn't shown on the General tab.
A 4624 filter will still show you many logons that aren't RDP. On each event's General tab, the Logon Type line tells you which kind it is, and we're after 10. To list only the Type 10 logons in one go, use PowerShell with an XPath filter (XPath is a query syntax for selecting events by their fields):
PS C:\Users\DFIRUser> Get-WinEvent -Path "D:\Walkthrough\THM-SHR-SRV\uploads\auto\C%3A\Windows\System32\winevt\Logs\Security.evtx" -FilterXPath "*[System[EventID=4624] and EventData[Data[@Name='LogonType']='10']]" | Select-Object TimeCreated, Id, Message | Format-List
Sysmon (a logging tool covered just below) is not installed on this analyst VM, so Event Viewer's General tab cannot show the description of Sysmon events. Parse the Sysmon log with EvtxECmd instead:
Parsing the Sysmon Log with EvtxECmd
C:\Users\DFIRUser> cd "C:\Users\DFIRUser\DFIR Tools\EZ Tools\EvtxeCmd"
C:\Users\DFIRUser\DFIR Tools\EZ Tools\EvtxeCmd> .\EvtxECmd.exe -f "D:\Walkthrough\THM-MKT-WS\uploads\auto\C%3A\Windows\System32\winevt\Logs\Microsoft-Windows-Sysmon%254Operational.evtx" --csv "C:\Users\DFIRUser\Desktop" --csvf THM-MKT-WS-sysmon.csv
This writes THM-MKT-WS-sysmon.csv to the Desktop. To read it:
- Open the CSV in Timeline Explorer (the
TimelineExplorer folder next to EvtxeCmd).
- Press Ctrl+F to open the Find window and search for
mstsc.exe. You can also type mstsc into the filter row above the Executable Info column.
- Look at the
Event Id column. Rows with 1 are process creation (Event 1) and rows with 3 are network connections (Event 3).
The CSV doesn't have one column per Sysmon field. UserName holds the User field (written as domain\account), Executable Info holds the process or its command line, and the other Sysmon fields, such as DestinationIp, are spread across the Payload Data1 to Payload Data6 columns. If you can't find a field, widen the columns or select the row and read the Payload or Map Description details.
Tip: Parsing a whole Logs folder at once is faster than doing it log by log. Replace the -f option and its file path with -d and the path of the whole Logs folder, and EvtxECmd will parse every .evtx file in it into one CSV, which you can then filter by the Channel column in Timeline Explorer.
Source Host Artifacts
We'll start at the source side, the workstation where the operator initiated RDP from.
Sysmon Event ID 1 (mstsc.exe Process Creation)
When mstsc.exe runs on the source, Sysmon (System Monitor, a Microsoft tool that logs system activity such as process creation and network connections to the Windows event log) Event 1 captures the process creation with the full command line and confirms the RDP client launched on this workstation. Its User field is the source-side answer to whose account it was: the logged-on user who started the client. That is not always the account the session logs on with at the destination, because the client can send other credentials, typed in or saved for that host. The account that logs on shows in the destination's Event 4624 (below), and in this walkthrough the two are different accounts.
Sysmon Event ID 3 (Outbound TCP 3389)
Sysmon Event 3 records the network connections the Sysmon configuration includes (network logging is off unless the configuration turns it on). When mstsc.exe reaches out to the RDP server, the corresponding Event 3 shows mstsc.exe as the image, DestinationIp set to the RDP server, and DestinationPort=3389. The fact that this fires on the source is the source-side answer to which workstation it came from, and the DestinationIp tells us where the attempt landed.
On the source, the image is mstsc.exe, the process that made the connection, not its parent. Where Sysmon logs network connections on the destination too, the same connection shows there with both IPs and the port, but its image is the process listening on 3389: svchost.exe, which hosts TermService.
TerminalServices-RDPClient Event IDs 1024/1025 (RDP Client Connection)
The TerminalServices-RDPClient Operational channel logs the client's view of each RDP connection:
- Event 1024 fires on attempt: "RDP ClientActiveX is trying to connect to the server" followed by the server name in brackets
- Event 1025 fires on success: "RDP ClientActiveX has connected to the server"
The server name in Event 1024 directly records the destination hostname mstsc.exe tried to reach, corroborating the source's view of where the operator was headed. In Event Viewer, filter the RDPClient log for 1024 and read the server name on the General tab.
These come in handy when attackers attempt to clear logs as an anti-forensic technique and we want to trace RDP connections. Attackers sometimes clear only the main log sources, such as the Sysmon and Security logs, and leave the TerminalServices-RDPClient channel behind.
Another benefit of this channel is that it's enabled by default, so these logs will exist without any extra configuration.
Destination Host Artifacts
Now let's move to the destination side, the host that accepted the RDP connection. Most of the evidence for RDP lateral movement exists on the destination.
Security Event ID 4624 (Type 10)
Event 4624 with LogonType 10 (RemoteInteractive) is a successful interactive RDP logon. The TargetUserName field answers whose account it was, IpAddress answers which workstation it came from, and comparing these against your normal baseline would be one way to determine whether the connection was expected.
On the General tab of the event, these fields appear under different headings:
| Field |
Where it appears on the General tab |
What to read |
LogonType |
Logon Information > Logon Type |
10 means RDP |
TargetUserName |
New Logon > Account Name |
The account that logged on |
IpAddress |
Network Information > Source Network Address |
The IP the connection came from |
Warning: The Subject section at the top of a 4624 also has an Account Name, but it holds the account that asked for the logon (usually the destination's own SYSTEM or computer account), not the person who connected. Always read the account from the New Logon section.
It's important to mention that this isn't the only way to determine whether this session is malicious, but we can combine this with understanding further context about what happened during the session, which would give us a complete picture of this activity.
TS-RemoteConnectionManager Event ID 1149
TS-RemoteConnectionManager Event 1149 (TS is short for TerminalServices, as in the full channel name) fires when the NLA handshake succeeds, recording the user and source network address. It confirms the network leg but not that a session was created, so pair it with the 4624 Type 10.
The fields to look at are the user and the source IP. The General tab shows them as a sentence, and the Details tab shows them as Param1 (user), Param2 (domain) and Param3 (source network address). The user corroborates whose account it was and the source IP corroborates which workstation it came from, the same two questions the 4624 Type 10 answers, now confirmed from a second channel.
TS-LocalSessionManager Event IDs 21, 22, 23, 24, 25
The TS-LocalSessionManager Operational channel records the session lifecycle on the destination:
- Event 21 is session logon succeeded
- Event 22 is shell start (the operator received an interactive desktop)
- Event 23 is logoff, session destroyed
- Event 24 is disconnect, session preserved on the server
- Event 25 is reconnect
These don't directly answer one of the four questions, but they confirm the session actually happened end-to-end (the operator got a shell, not just a network handshake) and bracket when the activity occurred.
Below is a diagram of events 21, 22, 23, and 24 from Event Viewer, showing the RDP lifecycle.
Event ID Reference
Below is a summary of source and destination artifacts in event logs that we've discussed in this task:
| Host |
Log |
Event ID |
What it tells us |
| Source |
Sysmon |
1 |
mstsc.exe started, and by which user |
| Source |
Sysmon |
3 |
mstsc.exe connected to a destination IP on TCP 3389 |
| Source |
TerminalServices-RDPClient |
1024 / 1025 |
RDP connection attempt / success, with the destination name |
| Destination |
Security |
4624 (Type 10) |
RDP logon, with the account and source IP |
| Destination |
TS-RemoteConnectionManager |
1149 |
NLA handshake succeeded, with the user and source IP |
| Destination |
TS-LocalSessionManager |
21 / 22 |
Session logon succeeded / shell started |
| Destination |
TS-LocalSessionManager |
23 / 24 / 25 |
Logoff / disconnect / reconnect |
The same summary as a diagram:
Use the events above to answer the following.
You'll find the artifacts in D:\Walkthrough\ (the Walkthrough shortcut on the Desktop opens it): THM-MKT-WS is the source workstation the RDP session came from, and THM-SHR-SRV is the destination server.