Lateral movement
smbexec
Impacket smbexec.py
Semi-interactive SMB execution that creates a short-lived service per command and reads output from a file share.
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
python.exe (smbexec.py) launched with the target host and credentials in the command line.
- Sysmon3
Outbound TCP connection to the destination on port 445.
- Security4648
Explicit-credential logon when alternate credentials are supplied.
Destination
The machine being accessed
- Security4624
Network logon, LogonType 3, repeated as each command re-authenticates.
- System7045
Service install per command; ImagePath begins %COMSPEC% /Q /c echo and redirects to __output.
- Security4697
The same service install in the Security log when the Security System Extension subcategory is on.
- System7036
Service state changes (running, then stopped) as each short-lived service runs and is removed.
- Security5145
Detailed file share access to C$ (or the share) for the __output file holding command results.
- Sysmon1
cmd.exe spawned by services.exe running the echoed command and the generated batch file.
- Sysmon11
Creation of the __output results file and a temporary batch file under %TEMP%.
- File: __output on the target share, and a temporary .bat under %TEMP%
Command output and the generated batch; both are created and deleted rapidly per command.
- Prefetch: C:\Windows\Prefetch\CMD.EXE-*.pf
Heavy, repeated cmd.exe execution driven by the per-command service model.
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.
- 017045 ImagePath beginning %COMSPEC% /Q /c echo
- 02Output file named __output on the target share
- 03A new service created and deleted for every command (bursts of 7045)
- 04Redirection target \\127.0.0.1\C$\__output in the service command
- 05cmd.exe as a child of services.exe running an echoed command
How it works
smbexec gives a semi-interactive shell over SMB without dropping a payload binary. For each command it creates a Windows service whose ImagePath is a cmd.exe one-liner: the command runs, its output is redirected to a file on a share, and the file is read back over SMB; the service is then deleted. Because a new service is created and removed for every command, the destination accumulates repeated service-install events rather than a single one, each with a command-shell ImagePath rather than a real executable. The output file has a fixed name on the share. On the destination this produces a network logon, a burst of service installs and deletions, and share access to the output file; no attacker executable is written to disk.
Hunt queries
Get-WinEvent -FilterHashtable @{LogName='System'; ProviderName='Service Control Manager'; Id=7045} |
Where-Object { $_.Message -match '%COMSPEC%|cmd.exe /Q /c echo|__output' }Benign look-alikes
- Rare legitimate tooling that drives commands through transient services (verify ImagePath content).
- Backup or deployment agents that briefly register services (they do not use %COMSPEC% echo one-liners).