Skip to content

Back to the category index / Back to the command index

Connects to a Mimikatz RPC server and sends commands entered interactively or read from a file.

ItemDetails
Implementationexamples/mimikatz.py
CategoryRemote execution / WMI / services
Size238 lines
DistributionInstalled as a script through scripts=examples/*.py in setup.py

Run python examples/mimikatz.py -h for the current option definitions.

ArgumentDescription
target[[domain/]username[:password]@]
-fileFile containing commands for the mini shell
-debugEnable debug output
-tsAdd a timestamp to each log message
-hashesNTLM hashes in LMHASH:NTHASH format
-no-passDo not prompt for a password (useful with -k)
-kUse Kerberos authentication. Look for matching credentials in the ccache file named by KRB5CCNAME; if none are valid, use those specified on the command line
-aesKeyAES key for Kerberos authentication (128 or 256 bits)
-dc-ipDomain controller IP address; if omitted, use the domain name (FQDN) from the target parameter
-target-ipTarget machine IP address; if omitted, use the target value. Useful when a NetBIOS target name cannot be resolved

The tool creates an RPC transport from the target and credentials, then binds to the Mimikatz interface. MimikatzShell turns each line of input into a protocol request, decodes the response string, and displays it. With -file, it feeds lines through the same onecmd() path in a batch.

The command itself does not inject code into a remote process. Instead, it acts as a client of a Mimikatz RPC server already available on the target. It creates a DCE/RPC transport and string binding from the target, binds to the defined interface UUID, and places each input command in an NDR request structure.

MimikatzShell separates the local cmd.Cmd loop from remote RPC requests. It suppresses rerunning commands on empty lines. shell runs local OS commands, while onecmd() and default() send other input as remote Mimikatz commands. -file feeds each line through the same dispatch path, keeping interactive and batch protocol behavior consistent.

The client converts the server’s encoded response buffer to a string and displays it. A missing RPC server, an interface UUID mismatch, a server command error, and a character-encoding failure occur at different layers. Do not overinterpret new commands on the client; keep a clear boundary between bytes sent to the server and local shell commands.

SymbolLocationWhere to trace its responsibility
MimikatzShell45__init__(), emptyline(), precmd(), default(), onecmd(), do_exit(), do_shell(), do_help()
main()114Module function
ModuleMain names used
impacketversion
impacket.dcerpc.v5epm, mimilib
impacket.dcerpc.v5.rpcrtRPC_C_AUTHN_GSS_NEGOTIATE, RPC_C_AUTHN_LEVEL_PKT_PRIVACY
impacket.dcerpc.v5.transportDCERPCTransportFactory
impacket.exampleslogger
impacket.examples.utilsparse_target
Import nameDistribution packageImport path and declaration status
CryptodomepycryptodomexImported directly; declared

Output, side effects, and required privileges

Section titled “Output, side effects, and required privileges”
  • Some operations change the target’s state. Check the target name, SID, and path before making changes.
  • On failure, use protocol status codes to determine whether name resolution, connection, authentication, service state, or permissions caused the stop.

The code depends on dcerpc.v5.transport, the Mimikatz RPC interface, and the shared target parser. Keep the local shell command distinct from remote commands and preserve RPC errors when the server is unavailable.