Skip to content
WETNav

Lateral movement

Remote service creation

sc.exe \\host createImpacket services.pyNew-Service -ComputerName

Creating or modifying a service on a remote host over the SCM to run a command as SYSTEM. Recorded as 7045 on the destination.

Artifacts by host

Every place this technique leaves a trace. Collect all three sides; each one fills gaps the others leave.

Source

Where the operator ran the tool

  • Sysmon1

    sc.exe with a \\host argument, or python.exe (services.py), launched on the source.

  • Sysmon3

    Outbound TCP connection to the destination on port 445.

  • Security4648

    Explicit-credential logon when alternate credentials are passed to the remote SCM call.

Destination

The machine being accessed

  • Security4624

    Network logon, LogonType 3, for the account authenticating to the SCM.

  • System7045

    Service installed; ServiceName, ImagePath, start type, and account are recorded.

  • Security4697

    Service install in the Security log when the Security System Extension subcategory is enabled.

  • System7036

    Service Control Manager reports the new service entering the running state.

  • System7040

    Start type change when an existing service is reconfigured rather than newly created.

  • Sysmon1

    The service process as a child of services.exe, and any command it spawns.

  • Security5145

    ADMIN$ share access when the service binary is uploaded before the install.

  • Registry: HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>

    Service key with ImagePath and start type; persists until the service is removed.

  • Amcache / ShimCache: the service binary

    Program execution evidence for the installed binary, surviving service deletion.

Domain controller

Authentication records

  • Security4769

    Kerberos service ticket for the destination: ServiceName is the destination computer account (DEST$) for the cifs/<dest> or HOST/<dest> SPN, and IpAddress is the source host. The DC-side record that ties source, account and destination together.

  • Security4768

    TGT request for the account from the source IP, when it had no valid TGT yet (for example right after runas or an explicit-credential logon on the source).

  • Security4776

    NTLM credential validation with Workstation set to the source name, when NTLM was used instead of Kerberos (destination addressed by IP, or pass-the-hash). Domain accounts only; local accounts are validated on the destination.

Fingerprints

Strings and values specific enough to search for directly.

  • 017045 ImagePath pointing at cmd.exe, powershell.exe, or a path under Temp/user-writable directories
  • 02Service created over the \svcctl named pipe from a remote host
  • 034624 LogonType 3 immediately before the 7045 install
  • 04binPath set to a command line rather than a service-aware executable
  • 05Service name that is random or impersonates a legitimate Windows service

How it works

The Service Control Manager can be driven remotely over RPC (the \svcctl named pipe over SMB). An operator uses sc.exe \\host create, Impacket's services.py, or New-Service with -ComputerName to install a service on the target whose ImagePath is their binary or a command interpreter running a payload, then starts it to execute as LocalSystem. Unlike PsExec, no helper framework is required; this is the bare SCM mechanism those tools build on. On the destination the install is recorded as System 7045 (and Security 4697 when enabled), the start produces a state-change event, and the service's child process shows the payload. The ImagePath is the key discriminator: a command interpreter or a path in a temporary or user-writable directory is the tell.

Hunt queries

Get-WinEvent -FilterHashtable @{LogName='System'; ProviderName='Service Control Manager'; Id=7045} |
  Where-Object { $_.Message -match 'cmd.exe|powershell|%COMSPEC%|\\Temp\\|rundll32' }

Benign look-alikes

  • Legitimate remote administration and software deployment that installs services.
  • Clustering and management tools that create services across hosts.
  • PsExec and similar admin tools run by your own staff (see the psexec technique).

References