T1563.002: RDP Hijacking

Adversaries may hijack a legitimate user’s remote desktop session to move laterally within an environment. Remote desktop is a common feature in operating systems. It allows a user to log into an interactive session with a system desktop graphical user interface on a remote system. Microsoft refers to its implementation of the Remote Desktop Protocol (RDP) as Remote Desktop Services (RDS).

Adversaries may perform RDP session hijacking which involves stealing a legitimate user's remote session. Typically, a user is notified when someone else is trying to steal their session. With System permissions and using Terminal Services Console, c:\windows\system32\tscon.exe [session number to be stolen], an adversary can hijack a session without the need for credentials or prompts to the user. This can be done remotely or locally and with active or disconnected sessions. It can also lead to Remote System Discovery and Privilege Escalation by stealing a Domain Admin or higher privileged account session. All of this can be done by using native Windows commands, but it has also been added as a feature in red teaming tools.

Positive Technologies products that cover the technique

MaxPatrol SIEM knowledge base

mitre_attck_lateral_movement: PT-CR-227: RDP_Session_Hijacking: Startup of "tscon" for RDP session hijacking is detected mitre_attck_lateral_movement: PT-CR-787: RDP_Shadow_Session_Initiation: Startup of mstsc.exe with the /shadow flag to establish a shadow RDP connection is detected hacking_tools: PT-CR-2134: SharpToken_Usage: SharpToken was used. This tool can find leaked tokens from all processes in the system and exploit them. If attackers accessed a low-privileged account, they can use this tool to upgrade to "NT AUTHORITY\SYSTEM" privileges. SharpToken can also be used to capture interactive user sessions.

Detection

IDDS0028Data source and componentLogon Session: Logon Session CreationDescription

Use of RDP may be legitimate, depending on the network environment and how it is used. Other factors, such as access patterns and activity that occurs after a remote login, may indicate suspicious or malicious behavior with RDP. Windows security log Event ID 4624 (An account was successfully logged on) is generated when a user logs onto a remote machine using RDP.

Correlating logon session creation events with RDP network flows can provide a clearer picture of RDP activity and serve as a useful starting point for investigating suspicious RDP connections.

IDDS0009Data source and componentProcess: Process CreationDescription

Consider monitoring processes for tscon.exe usage. Using tscon.exe to hijack an RDP session requires SYSTEM level permissions. Therefore, we recommend also looking for Privilege Escalation techniques that may be used for this purpose in conjunction with RDP Session Hijacking.

In addition to tscon.exe, mstsc.exe can similarly be used to hijack existing RDP sessions. In this case, we recommend looking for the command-line parameters of /noconsentPrompt and /shadow:, which allow for stealthy hijacking of an RDP session with no prompt and without kicking off the existing session.

IDDS0017Data source and componentCommand: Command ExecutionDescription

monitor service creation that uses cmd.exe /k or cmd.exe /c in its arguments to detect RDP session hijacking. Windows PowerShell log Event ID 4104 (PS script execution) can be used to capture PowerShell script block contents which may contain commands used as a precursor to RDP hijacking. For example, the following command in a PowerShell script block may be used to enumerate the systems on a network which have RDP access: Find-DomainLocalGroupMember -GroupName "Remote Desktop Users" | select -expand ComputerName.

IDDS0029Data source and componentNetwork Traffic: Network Traffic ContentDescription

Monitor and analyze traffic patterns and packet inspection associated to protocol(s) that do not follow the expected protocol standards and traffic flows (e.g extraneous packets that do not belong to established flows, gratuitous or anomalous traffic patterns, anomalous syntax, or structure). Consider correlation with process monitoring and command line to detect anomalous processes execution and command line arguments associated to traffic patterns (e.g. monitor anomalies in use of files that do not normally initiate connections for respective protocol(s)). Network Analysis frameworks such as Zeek can be used to capture, decode, and alert on network protocols including RDP.

IDDS0029Data source and componentNetwork Traffic: Network Traffic FlowDescription

Monitor network data for uncommon data flows. Processes utilizing the network that do not normally have network communication or have never been seen before are suspicious. RDP sessions may be split up into multiple flows and would therefore need to be aggregated.

Anomaly detection using machine learning or other methods based on baselined RDP network flows may be a viable approach to alerting on potential RDP session hijacking.

Mitigation

IDM1018NameUser Account ManagementDescription

Limit remote user permissions if remote access is necessary.

IDM1026NamePrivileged Account ManagementDescription

Consider removing the local Administrators group from the list of groups allowed to log in through RDP.

IDM1028NameOperating System ConfigurationDescription

Change GPOs to define shorter timeouts sessions and maximum amount of time any single session can be active. Change GPOs to specify the maximum amount of time that a disconnected session stays active on the RD session host server.

IDM1030NameNetwork SegmentationDescription

Enable firewall rules to block RDP traffic between network security zones within a network.

IDM1035NameLimit Access to Resource Over NetworkDescription

Use remote desktop gateways.

IDM1042NameDisable or Remove Feature or ProgramDescription

Disable the RDP service if it is unnecessary.

IDM1047NameAuditDescription

Audit the Remote Desktop Users group membership regularly. Remove unnecessary accounts and groups from Remote Desktop Users groups.