Skip to content

Back to the Category Index / Back to the Command Index

Reads legacy LAPS and Windows LAPS attributes from LDAP. It retrieves GKDI keys to decrypt encrypted Windows LAPS passwords.

ItemDetails
Implementationexamples/GetLAPSPassword.py
CategoryActive Directory / LDAP / Account Management
Size299 lines
DistributionInstalled as a script through scripts=examples/*.py in setup.py

Check python examples/GetLAPSPassword.py -h for the current option definitions.

ArgumentDescription
targetdomain[/username[:password]]
-computerTarget a specific computer by name.
-tsAdd timestamps to log output.
-debugEnable debug logging.
-outputfile / -oWrite output to a file.
-hashesNTLM hashes in LMHASH:NTHASH format.
-no-passSkip the password prompt (useful with -k).
-kUse Kerberos authentication. Read credentials from the ccache (KRB5CCNAME) based on the target; fall back to command-line credentials if none are valid.
-aesKey128- or 256-bit AES key for Kerberos authentication.
-dc-ipDomain controller IP address. Defaults to the domain (FQDN) in target.
-dc-hostDomain controller hostname. Defaults to the domain (FQDN) in the account parameter.
-ldaps / -use-ldapsUse LDAPS instead of LDAP.

Related technology: LDAP and DPAPI-NG / GKDI in DPAPI / SAM / LSA / NTDS.

The command searches LDAP for computer objects and LAPS attributes, formatting plaintext attributes directly. For encrypted attributes, it decodes the CMS blob as ASN.1, connects to GKDI through the RPC Endpoint Mapper, derives the KEK/CEK from the group key, and decrypts the DPAPI-NG payload. Results go to a table or the file specified by -o.

Legacy LAPS and Windows LAPS return different kinds of LDAP values. Legacy LAPS attributes return the password directly if the reader has permission. Encrypted Windows LAPS attributes contain a CMS envelope and DPAPI-NG metadata; an LDAP search alone cannot produce plaintext. run() first enumerates computers and attributes, then separates plaintext and encrypted paths by attribute format.

For encrypted values, the command parses EncryptedPasswordBlob and CMS ASN.1, identifies the required GKDI group key from the blob’s key identifier, then finds the GKDI RPC endpoint through the Endpoint Mapper. As an authorized caller, it retrieves key material, derives a KEK with a KDF, and decrypts the wrapped CEK followed by the ciphertext. This crosses several protocol boundaries: LDAP → ASN.1/CMS → GKDI RPC → DPAPI-NG.

Decryption may fail because the attribute cannot be read, GKDI access is denied, the key generation ID does not match, or the blob is damaged. In getLAPSv2Decrypt(), keeping track of the stage reached, rather than collapsing these into one generic error, makes maintenance easier. In JSON and table output, keep the password associated with its computer and expiration time.

SymbolLocationEntry Point for Tracing Behavior
GetLAPSPassword41__init__(), printTable(), getLAPSv2Decrypt(), getUnixTime(), run()
ModuleMain Names Used
impacketversion
impacket.dcerpc.v5transport
impacket.dcerpc.v5.epmhept_map
impacket.dcerpc.v5.gkdiGkdiGetKey, GroupKeyEnvelope, MSRPC_UUID_GKDI
impacket.dcerpc.v5.rpcrtRPC_C_AUTHN_LEVEL_PKT_INTEGRITY, RPC_C_AUTHN_LEVEL_PKT_PRIVACY
impacket.dpapi_ngEncryptedPasswordBlob, KeyIdentifier, compute_kek, create_sd, decrypt_plaintext, unwrap_cek
impacket.exampleslogger
impacket.examples.utilsldap_login, parse_identity
impacket.ldapldap, ldapasn1
Import NameDistribution PackageUsage / Declaration Status
pyasn1pyasn1Imported directly; declared dependency
pyasn1_modulespyasn1_modulesImported directly; declared dependency

Output, Side Effects, and Required Privileges

Section titled “Output, Side Effects, and Required Privileges”
  • Primarily queries and authentication attempts. Repeated runs can affect audit logs, account lockouts, and target load.
  • Depending on options, creates or updates a local file. Check how existing files are handled and the permissions on output containing secrets.
  • On failure, use protocol status to determine whether name resolution, connection, authentication, service state, or permissions stopped the operation.

This command uses ldap / ldapasn1, dcerpc.v5.gkdi, dpapi_ng, pyasn1, and pyasn1_modules.rfc5652. getLAPSv2Decrypt() is the boundary between LDAP and RPC and the central point for changes to the encryption format.