Detecting Lateral Movement 101: Tracking movement SMB/Windows Admin Shares through Windows Log Analysis

MITRE ATT&CK Reference : Tactic: Lateral Movement
Technique id: T1021 (Remote Services)
Sub-technique Id: T1021.002 (Remote Services: SMB/Windows Admin Shares)

Adversaries, typically, start moving laterally once they get initial foothold in the victim organization. Once they get initial access, they escalate their privileges and move laterally with the escalated privileges either to propagate their malware or to further reconnaissance & collect the targeted information.

There are many techniques by which threat actors move laterally in the organization. MITRE ATT&CK is one the best resources to start with to understand these various techniques used by the adversaries. MITRE has very well organised these lateral movement techniques under “Lateral Movement” tactic. As a cyber defense team, we should be aware of these techniques and how to detect and prevent them.

In this quick article, I am going to talk about one of the techniques used by the adversaries for moving laterally — SMB Shares. This is one of the most used techniques by adversaries to move laterally in the organization and we should be better prepared to detect it. We will see how Windows Event Logs make this technique highly visible.

How Adversaries Use this technique?

Adversaries, once escalated privileges, map these shares from other workstations and copy their malware and move laterally. Moreover, they use windows native services/binaries like net.exe to connect to the shares to reduce any alerts generated by their movement. Following is the command used to map network share — this command maps c$ admin-share of the machine 192.168.189.155.

net use m: \\192.168.189.155\c$ /USER:kirtar

This activity creates a few footprints at the source as well as the target machines.Which logs we need to look for to detect this activity?

How to detect the lateral movement?

Event ID 4688 (Sysmon EventID 1): Process Create [ with command line auditing enabled]
EventID 4648: A logon was attempted using explicit credentials.

In a typical organization, normal users do not go around and map the admin shares of the other workstations or the servers. Hence, any Sysmon eventid 1 (4688 — security) for net.exe (mapping admin share/s) from the workstation of the normal users should be investigated.

EventID 1 (4688 with command line parameters) provides following key details
-Current Process with its full path
-Description
-Original File Name
-Command Line parameters passed with the binary while executed
-Current directory of the user
-the account/user who has spawn this process
-hashes for the process binary image
-Parent Process
-Parent Process command line parameters

The following screenshot shows that c$ share is mapped of the machine with IP Address 192.168.189.155 by using account of LAPTOP-O5R917V2\kirtar. The parent process shows that net.exe is executed via cmd.exe. The details related to hash, parent process command lines, image path can be seen in the screenshot.

This gives us crucial information about potentially compromised account and machine along with the machine(destination) where adversaries might have copied their malware.

Figure 1. Sysmon EventID 1 at Source — Process Create (net.exe)

The other log generated at the source is 4648. This log is generated as attacker uses an explicit credential to map the network share. This event provides very important information about the destination IP & hostname and both of the accounts (original and switched). This information will help us to substantiate the information received from the previous event. Look at the snapshot below.

Figure 2. 4648 (explicit credentials used)

As shown in the screenshot, the original account is LAPTOP-O5R917V2\kirtar and the switched account kirtar (this is used for authenticating to the remote machine). The hostname of the target machine SANS-SIFT. Furthermore, Network Information provides the destination IP address (192.168.189.155) — this can be verified against the command-line parameters of the previous event.

Detection at the Destination

The same command generates a few logs on the destination machine as well. Following logs are generated at the destination.

4776 — The computer attempted to validate the credentials for an account
4672 — Special privileges assigned to new logon
4624 (Type 3) — An account was successfully logged on

Figure 3. Typical trilogy for local authentication with administrative privileges

Look at the time for all these 3 events, they are logged at nearly same time. These events are generated because local NTLM authentication (4776) happens over the network (Type3) via local administrative account (4672).

One of the key logs generated at the destination is EventID 5140. This is “the log” for the actual event — network share access.

This log provides the following information
-the account used for accessing/mapping the share
-IP address of the source machine (from where the share is accessed)
-Name and Path of the share

Please see the following screenshot of 5140 EventID generated as a result of the command that we ran above. It shows that account Sans-SIFT\kirtar is used to access the C$ share. The IP of the source machine from where this share is accessed is 192.168.189.1.

Figure 4. EventID 5140 (A network share object was accessed.)

There are couple of caveats related to this log (5140). This log is not enabled by default, this needs to be enabled via GPO by enabling “File Share” auditing under “Object Access” in Advanced Audit Policy Configuration settings. Secondly, it is available in 2008R2+ editions. Look at the following screenshot that shows the audit policy configuration required for 5140.

Figure 5. Audit Policy configuration for 5140

So, as we have seen there are quite a few windows security event logs that can be leveraged to detect this lateral movement. Creating Alerts based on the precise filters will help in improving precision and reducing false positives in detecting lateral movement.

Similarly, event logs can be used to detect other lateral movement techniques as well. I will try to write articles for other techniques as well.

That’s it for now. Thanks for reading and happy hunting fellas !!

by :
Kirtar Oza
Twitter : @Krishna (kirtar_oza)
LinkedIn: https://www.linkedin.com/in/kirtaroza/
email: kirtar.oza@gmail.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store