Skip to content

Impacket rdp_check.py

Back to the category index / Back to the command index

Checks whether a specified account can authenticate through RDP/CredSSP.

ItemDetails
Implementationexamples/rdp_check.py
CategorySMB / MSRPC / NTLM
Size578 lines
DistributionInstalled as a script through scripts=examples/*.py in setup.py

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

ArgumentDescription
target[[domain/]username[:password]@]
-6 / --ipv6Test over IPv6.
-tsAdd a timestamp to each log message.
-debugEnable debug output.
-hashesNTLM hashes in LMHASH:NTHASH format.

After connecting over TCP, the tool selects a protocol through TPKT/X.224 negotiation and establishes TLS. It exchanges CredSSP TSRequest messages containing SPNEGO/NTLM tokens, then verifies server public-key binding and the authentication response. It distinguishes RDP negotiation failures from rejected credentials.

An RDP connection does not send user credentials immediately. It first negotiates a security protocol through an X.224 connection request, establishes TLS, and then proceeds to CredSSP/NLA. This command constructs the TPKT, TPDU, and RDP negotiation structures itself, first checking whether the server accepts TLS/CredSSP.

CredSSP wraps SPNEGO/NTLM tokens in ASN.1 TSRequest messages and exchanges challenges and responses over several round trips. After verifying binding to the TLS server certificate and public key, it places domain, user, and password information in TSCredentials and sends it through the encrypted channel. This checks NLA authentication, rather than only whether TCP port 3389 is reachable.

RDP negotiation failure codes, TLS handshake errors, NTLM rejection, and CredSSP protocol errors occur at different stages. Whether an account is considered valid depends on the target’s NLA policy, logon rights, and lockout policy. The code must not trust received lengths; it checks that TPKT/ASN.1 fields fit in the buffer before decoding them.

SymbolLocationWhere to trace its responsibility
TPKT58Structure or constant definition
TPDU67__init__()
CR_TPDU78Structure or constant definition
DATA_TPDU88__init__()
RDP_NEG_REQ99__init__()
RDP_NEG_RSP108Structure or constant definition
RDP_NEG_FAILURE113Structure or constant definition
TSPasswordCreds118__init__(), getData()
TSCredentials141__init__(), getData()
TSRequest163__init__(), fromString(), getData()
ModuleMain names used
impacket.exampleslogger
impacket.examples.utilsget_connected_socket, parse_target
impacket.structureStructure
impacket.spnegoASN1_OCTET_STRING, ASN1_SEQUENCE, GSSAPI, asn1decode, asn1encode
impacketntlm, version
Import nameDistribution packageImport path and declaration status
CryptodomepycryptodomexImported directly; declared
OpenSSLpyOpenSSLImported directly; declared

Output, side effects, and required privileges

Section titled “Output, side effects, and required privileges”
  • The tool primarily makes queries and authentication attempts. Frequent runs can affect audit logs, account lockouts, and target load.
  • Distinguish between a missing input file, a damaged file, an incomplete read, and an unsupported format.

The code depends on its own TPKT/TPDU/CredSSP structures, spnego, ntlm, and OpenSSL/socket helpers. TSRequest.fromString() and message framing process untrusted network input, so retain length validation.