Overview
impacket-smbexec executes commands on a remote host by creating a temporary Windows service for each command. Unlike psexec, it does not upload any binary to the target. Each command is executed via cmd.exe /Q /c, with output redirected to a file on a writable share. The service is created and deleted per command.
Authentication Methods
Basic Usage — Interactive Shell
Execute Specific Command
How It Works
- Authenticates to the target via SMB (port 445).
- Connects to the Service Control Manager (SCM) via RPC.
- For each command, creates a new service with a random name.
- The service
binPathruns%COMSPEC% /Q /cto drop a temporary batch file (under%SYSTEMROOT%) that executes<command>and redirects output to\\%COMPUTERNAME%\<share>\__output 2>&1, then deletes it. It does not use127.0.0.1or place the command directly inbinPath. - Starts the service, which executes the command and writes output to the share.
- Reads the output file over SMB.
- Deletes the output file and the service immediately after.
OPSEC Considerations
Artifacts to expect:
- System Event ID 7045 (new service installed) for every command
- System Event ID 7009 (service timeout) after each execution
- Security Event ID 4624 (network logon type 3)
- Security Event ID 4697 (service installation)
- Temp output files briefly written to
C$
Pass-the-Hash
Kerberos Authentication
Requires a valid ccache file or keytab.Specify Share for Output
By default, output goes toC$. Use a different share:
When to Use: smbexec vs psexec vs wmiexec
When to choose each:
- psexec — Need a full interactive SYSTEM shell and stealth is not a concern.
- smbexec — Target blocks DCOM/WMI but allows SMB, and you cannot upload binaries (AV blocking writes to ADMIN$).
- wmiexec — Stealth matters. No service creation, no binary on disk. Best default choice when all ports are available.