Skip to content
WETNav

Lateral movement

PsExec and service-based execution

PsExec (Sysinternals)Impacket psexec.pypaexec

Remote execution over SMB by dropping a service binary to ADMIN$ and running it as a service. Leaves a named service and pipes.

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

  • Security4648

    Logon with explicit credentials when PsExec is run with -u/-p or alternate credentials.

  • Sysmon1

    PsExec.exe (or python.exe for psexec.py) launched, with the target host in the command line.

  • Sysmon3

    Outbound TCP connection to the destination on port 445.

Destination

The machine being accessed

  • Security4624

    Network logon, LogonType 3, for the account used to authenticate to the share and SCM.

  • Security4672

    Special privileges assigned to the logon when the account is an administrator.

  • Security5145

    Detailed file share access to ADMIN$ for the service binary (PSEXESVC.exe or a random name).

  • System7045

    Service install: ServiceName PSEXESVC (Sysinternals) or a random name; ImagePath in %SystemRoot%.

  • Security4697

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

  • Sysmon1

    The service process (PSEXESVC.exe) as a child of services.exe, then the requested command as its child.

  • Sysmon17

    Named pipe created: PSEXESVC pipes, or Impacket's RemCom_communicaton pipe.

  • Sysmon18

    Named pipe connected for stdin/stdout/stderr relay.

  • Prefetch: C:\Windows\Prefetch\PSEXESVC.EXE-*.pf

    Execution of the service binary on the destination, with first and last run times.

  • Registry: HKLM\SYSTEM\CurrentControlSet\Services\PSEXESVC

    Service key left by Sysinternals PsExec; the ImagePath points at the dropped binary.

  • Amcache / ShimCache: PSEXESVC.exe (or the dropped random binary)

    Program execution evidence that survives after the binary and service are removed.

Domain controller

Authentication records

  • Security4769

    Kerberos service ticket for the destination: ServiceName is the destination computer account (DEST$) for the cifs/<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.

  • 01Service name PSEXESVC (Sysinternals default)
  • 02Named pipes \PSEXESVC-<host>-<pid>-stdin, -stdout, -stderr on newer PsExec versions
  • 03ADMIN$\PSEXESVC.exe dropped on the destination
  • 04Impacket psexec.py named pipe \RemCom_communicaton (note the misspelling)
  • 057045 ImagePath %SystemRoot%\PSEXESVC.exe
  • 064624 LogonType 3 immediately preceding the 7045 service install

How it works

PsExec authenticates to the target over SMB, copies a service executable into the ADMIN$ share, and uses the Service Control Manager to install and start it. The service runs the requested command, usually as LocalSystem, and relays input and output back over named pipes. Sysinternals PsExec drops PSEXESVC.exe and registers a PSEXESVC service; Impacket's psexec.py drops a randomly named executable and service and communicates over a distinctively misspelled pipe. On the destination this produces a network logon, a share access to the dropped binary, a service install, and the service's child process. On the source it produces an outbound SMB connection and an explicit-credential logon when alternate credentials are supplied.

Hunt queries

Get-WinEvent -FilterHashtable @{LogName='System'; ProviderName='Service Control Manager'; Id=7045} |
  Where-Object { $_.Message -match 'PSEXESVC' }

Benign look-alikes

  • IT staff and management tools that use PsExec for legitimate remote administration.
  • Software deployment systems that install and start services remotely.
  • Monitoring agents that create named pipes with similar patterns (verify the exact pipe name).

References