Lateral movement is a technique that enables an adversary to access and control remote systems on a network. It is a critical phase in any attack, and understanding the methods that can be used to perform lateral movement, along with how those protocols display themselves in NetWitness, is paramount in detecting attackers moving laterally in your environment. It is also important to understand that many of the mechanisms used by attackers for lateral movement, are also used by administrators for legitimate reasons, and thus why it is important to monitor these mechanisms to understand what is typical behaviour, and what is not.
In this blog post, Winexe will be used. Winexe is a GNU/Linux based application that allows users to execute commands remotely on WindowsNT/2000/XP/2003/Vista/7/8 systems. It installs a service on the remote system, executes the command and uninstalls the service. Winexe allows execution of most of the windows shell commands.
The attacker has successfully gained access to your network and dumped credentials, all without any detection from your Security Operations Center (SOC). The attacker decides to move laterally using Winexe, they connect to one of the hosts they had previously identified and begin to execute commands:
The use of Winexe is not overly stealthy. Its use creates a large amount of noise that is easily detectable. Searching for winexesvc.exe within the filename metadata returns the SMB transfer of the executable to the ADMIN$ share:
Using the time the file transfer took place as the pivot point to continue investigation, it is also possible to see the use of the Windows Service Control Manager (SCM) directly afterward to create and start a service on the remote endpoint. SCM acts as a remote procedure call (RPC) server so that services on remote endpoints can be controlled:
Reconstructing the raw session as text, it is possible to see the service name being created, winexesvc, and the associated executable that was previously transferred being used as the service base, winexesvc,exe:
Continuing to analyse the SMB traffic around the same time frame, it is also possible to see another named pipe, ahexec, being used. This is the named pipe that Winexe uses:
Reconstructing these raw sessions as text, it is possible to see the commands that were executed:
As well as the output that was returned to the attacker:
Based on the artefacts we have seen leftover from Winexe's execution over the network, there are multiple pieces of logic we could use for our application rule to detect this type of traffic. The following application rule logic would pick up on the initial transfer of the winexesvc.exe executable, and the subsequent use of the named pipe, ahexec:
(filename = 'ahexec','winexesvc.exe') && (service = 139)
Searching for winexesvc.exe as the filename source
shows the usage of Winexe on the endpoints, this is because this is the executable that handles the commands sent to over the ahexec named pipe. The filename destination
meta key shows the executables invoked via the use of Winexe:
A simple application rule could be created for this activity by simply looking for winexesvc.exe as the filename source:
(filename.src = 'winexesvc.exe')
Analysing the endpoint, you can see the winexesvc.exe process running from task manager:
As well as the service that was installed via SCM over the network:
This service creation also creates a log entry in the System event log as event ID 7045:
This means if you were ingesting logs into NetWitness, you could create an application rule to trigger on Winexe usage with the following logic:
(reference.id = '7045') && (service.name = 'winexesvc')
We can also see the named pipe which Winexe uses by executing Sysinternals pipelist tool:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.