Skip to content

Back to the Category Index / Back to the Command Index

Retrieves computer accounts’ operating systems, last logon times, and other details from LDAP. It can also look up IP addresses through DNS.

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

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

ArgumentDescription
targetdomain[/username[:password]]
-userRequest data for a specific user.
-tsAdd timestamps to log output.
-debugEnable debug logging.
-resolveIPResolve computer objects’ IP addresses through DNS lookups using the DC.
-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.

The command parses the identity, binds to LDAP or LDAPS, and searches for computer objects. processRecord() converts LDAP attributes and Windows timestamps for display. With -resolveIP, it queries DNS. -user restricts the search to a specific account.

The search targets LDAP computer objects. run() builds the base DN from the domain and, if a user is specified, filters by sAMAccountName. Otherwise, it retrieves computer accounts in bulk. Because returned attributes are not always present, processRecord() handles OS details, DNS hostnames, UAC, and time attributes separately, leaving missing values blank.

Active Directory time attributes use Windows FILETIME, which starts in 1601, rather than Unix timestamps. Conversion also prevents zero or unset values from appearing as ordinary dates. Disabled accounts are identified using userAccountControl bit flags, not strings. When adding attributes, normalize types and special values instead of passing LDAP byte/string values directly to the display layer.

-resolveIP is an additional step that resolves the LDAP dNSHostName to an A record using the configured DC resolver. A successful LDAP lookup does not guarantee DNS resolution, so computers without DNS records must remain in the results. Keep search filters, attribute conversion, and DNS enrichment separate.

SymbolLocationEntry Point for Tracing Behavior
GetADComputers42__init__(), getUnixTime(), processRecord(), run()
ModuleMain Names Used
impacketversion
impacket.dcerpc.v5.samrUF_ACCOUNTDISABLE
impacket.exampleslogger
impacket.examples.utilsldap_login, parse_identity
impacket.ldapldap, ldapasn1
Import NameDistribution PackageUsage / Declaration Status
dnsdnspythonImported directly; not declared as a direct 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.
  • On failure, use protocol status to determine whether name resolution, connection, authentication, service state, or permissions stopped the operation.

This command depends on impacket.ldap.ldap / ldapasn1, SAMR’s UF_ACCOUNTDISABLE, examples.utils.ldap_login, and dns.resolver. If you change search filters or attributes, update both run() and processRecord() and allow for missing attributes.