Skip to main content

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

Local admin (no domain):

Execute Specific Command

Run a PowerShell command:

How It Works

  1. Authenticates to the target via SMB (port 445).
  2. Connects to the Service Control Manager (SCM) via RPC.
  3. For each command, creates a new service with a random name.
  4. The service binPath runs %COMSPEC% /Q /c to 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 use 127.0.0.1 or place the command directly in binPath.
  5. Starts the service, which executes the command and writes output to the share.
  6. Reads the output file over SMB.
  7. Deletes the output file and the service immediately after.
The shell runs as SYSTEM because Windows services execute under the SYSTEM context.

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

With both LM and NT hash:

Kerberos Authentication

Requires a valid ccache file or keytab.
With explicit DC IP:
Using AES key directly:

Specify Share for Output

By default, output goes to C$. 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.

Common Errors and Fixes


Quick Reference