Skip to content

Commit d60cd4d

Browse files
committed
docs: add smbexec.py.md
1 parent a5bc38d commit d60cd4d

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

impacket/examples/smbexec.py.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,77 @@
11
# smbexec.py
22

3+
[smbexec.py](https://github.com/fortra/impacket/blob/master/examples/smbexec.py) can be used to execute commands on a remote Windows target by creating and running a temporary service over **SMB**.
4+
It provides a semi-interactive shell similar to wmiexec.py and dcomexec.py, but the execution mechanism relies on the **Windows Service Control Manager (SCM)**.
5+
6+
{% hint style="warning" %}
7+
### Required privileges
8+
9+
To use `smbexec.py`, the following prerequisites must be met on the target:
10+
11+
- **Administrative privileges**
12+
- **SMB reachable** (TCP 445 is required for service management and output retrieval)
13+
- **Service Control Manager (SCM) accessible**
14+
The authenticated user must be allowed to remotely create/start/delete services (default for local admin)
15+
{% endhint %}
16+
17+
## Commons
18+
19+
It has the following generic command line arguments, similar to other Impacket tools:
20+
21+
* required positional argument:
22+
`[[domain/]username[:password]@]<targetName or address>`
23+
Examples:
24+
- `domain.local/user@dc01`
25+
- `domain/user:password@10.10.0.1`
26+
27+
![](<../../.gitbook/assets/impacket_positional_arg-with target.png>)
28+
29+
* `-hashes`: the LM and/or NT hash to use for a [pass-the-hash](https://www.thehacker.recipes/ad/movement/ntlm/pth).
30+
Format: `[LMhash]:NThash` (LM optional, NT must be prefixed with `:`).
31+
32+
* `-aesKey`: AES128/256 key for [pass-the-key](https://www.thehacker.recipes/ad/movement/kerberos/ptk) authentication (Kerberos).
33+
34+
* `-k`: use Kerberos authentication (via a Ccache if `KRB5CCNAME` is set).
35+
36+
* `-no-pass`: required when no password is provided or when using `-k`.
37+
38+
* `-dc-ip`: IP address of the domain controller to use instead of DNS.
39+
40+
* `-debug`: enables verbose debugging output.
41+
42+
## Specificities
43+
44+
smbexec.py introduces some options specific to the service-based execution model:
45+
46+
* `-codec`: sets the Windows output encoding (default: `latin-1`).
47+
Useful for Unicode output on non-English systems.
48+
49+
* `-service-name`: specify a custom service name instead of a random one.
50+
51+
* `-shell-type`: either `cmd` (default) or `powershell`.
52+
53+
* `-keytab`: authenticate using Kerberos keys from a KEYTAB file.
54+
55+
* `-share`: share where the output will be grabbed from (default C$)
56+
57+
* `-mode`: Controls whether smbexec will start a local SMB server.
58+
59+
```bash
60+
# Cleartext authentication
61+
smbexec.py "$DOMAIN"/"$USER":"$PASSWORD"@"$IP"
62+
63+
# Pass-the-hash
64+
smbexec.py -hashes :"$NT_HASH" "$DOMAIN"/"$USER"@"$IP"
65+
66+
# Kerberos authentication
67+
smbexec.py -no-pass -k "$DOMAIN"/"$USER"@"$TARGET"
68+
69+
# PowerShell instead of cmd
70+
smbexec.py -shell-type powershell "$DOMAIN"/"$USER":"$PASSWORD"@"$IP"
71+
72+
# Custom service name
73+
smbexec.py -service-name MyService "$DOMAIN"/"$USER":"$PASSWORD"@"$IP"
74+
75+
# Select share
76+
smbexec.py -share ADMIN$ "$DOMAIN"/"$USER":"$PASSWORD"@"$IP"
77+
```

0 commit comments

Comments
 (0)