Skip to content

Back to the Category Index / Back to the Command Index

Enumerates user account SPNs from LDAP. When requested, it also obtains TGSs and outputs them in a format for offline analysis.

ItemDetails
Implementationexamples/GetUserSPNs.py
CategoryKerberos / Ticket Handling
Size541 lines
DistributionInstalled as a script through scripts=examples/*.py in setup.py

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

ArgumentDescription
targetdomain[/username[:password]]
-target-domainDomain to query or request if it differs from the user’s domain; supports Kerberoasting across trusts.
-no-preauthAccount without pre-authentication, used to obtain a service ticket through the AS exchange.
-stealthRemove the (servicePrincipalName=*) filter from the LDAP query for added stealth. This may consume substantial memory or cause errors in large domains.
-machine-onlyQuery only machine accounts by changing objectCategory=person to objectCategory=computer. Active Directory may limit results to 1,000 objects by default; LDAP paging is needed for more.
-usersfileFile with one user per line to test.
-requestRequest TGSs for users and output them in JtR/hashcat format (default: false).
-request-userRequest a TGS for the SPN associated with the specified user (username only; no domain needed).
-request-machineRequest a TGS for the SPN associated with the specified machine, for example workstation01$.
-saveSave requested TGSs to disk as <username>.ccache; also enables -request.
-outputfileFile for ciphertexts in JtR/hashcat format; also enables -request.
-no-rc4Do not force RC4-HMAC for the TGT.
-tsAdd timestamps to log output.
-debugEnable debug logging.
-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; ignored if -target-domain is set.
-dc-hostDomain controller hostname. Defaults to the domain (FQDN) in the account parameter.
-ldaps / -use-ldapsUse LDAPS instead of LDAP.

Related technology: the TGS-REP enc-part in Kerberos and SPN searches in LDAP.

The command searches LDAP for SPNs, UAC values, and delegation attributes and displays them. With -request / -request-user / -request-machine, it obtains a TGT, sends a TGS-REQ for each SPN to the KDC, and produces a string representation or ccache according to the response enctype. -stealth and -usersfile change how searching or requesting begins.

Kerberoasting targets the part of a service ticket encrypted with a user account’s long-term key, not the SPN string itself. The initial LDAP search collects accounts with servicePrincipalName and their UAC and delegation attributes, showing which account owns each service identity.

To request tickets, the caller obtains a TGT from a password, hash, AES key, or ccache, then sends a TGS-REQ for each target SPN. The KDC’s TGS-REP ticket encrypted part is protected with the service account key. The command converts it to hashcat/John format according to the enctype and the placement of checksum and ciphertext. -save writes the response as a separate ccache credential.

-no-rc4 changes the client’s enctype preference, while -stealth and -usersfile change the LDAP discovery method. Because the KDC’s actual enctype selection determines the output format, do not infer RC4 or AES solely from the client’s preference. Across domains, keep the authentication domain, search domain, and KDC distinct.

SymbolLocationEntry Point for Tracing Behavior
GetUserSPNs54__init__(), printTable(), getUnixTime(), getTGT(), outputTGS(), run(), request_users_file_TGSs(), request_multiple_TGSs()
ModuleMain Names Used
impacketversion
impacket.dcerpc.v5.samrUF_ACCOUNTDISABLE, UF_TRUSTED_FOR_DELEGATION, UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION
impacket.exampleslogger
impacket.examples.utilsldap_login, parse_identity
impacket.krb5constants
impacket.krb5.asn1AS_REP, TGS_REP
impacket.krb5.ccacheCCache
impacket.krb5.kerberosv5getKerberosTGS, getKerberosTGT
impacket.krb5.typesPrincipal
impacket.ldapldap, ldapasn1
impacket.ntlmcompute_lmhash, compute_nthash
Import NameDistribution PackageUsage / Declaration Status
pyasn1pyasn1Imported 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 depends on LDAP, krb5.kerberosv5 / ccache / asn1 / crypto, pyasn1, and NTLM hash helpers. LDAP records and TGS output formats remain separate within GetUserSPNs.