LinuxCommandLibrary

getadusers.py

Retrieve user information from Active Directory

TLDR

Enumerate all Active Directory users and their attributes

$ GetADUsers.py -all -dc-ip [domain_controller_ip] [domain]/[username]:[password]
copy

Retrieve information only for a specific user
$ GetADUsers.py -user [user] -dc-ip [domain_controller_ip] [domain]/[username]:[password]
copy

Extract user details using pass-the-hash authentication
$ GetADUsers.py -all -dc-ip [domain_controller_ip] -hashes [LM_Hash]:[NT_Hash] [domain]/[username]
copy

Save output to a file
$ GetADUsers.py -all -dc-ip [domain_controller_ip] [domain]/[username]:[password] > [path/to/output.txt]
copy

SYNOPSIS

GetADUsers.py [domain/username[:password]@dc-ip] [--options]

PARAMETERS

--all
    Enable all output columns and details.

--attributes ATTRS
    Comma-separated list of LDAP attributes to retrieve (e.g., samAccountName,pwdLastSet).

--dc-ip IP
    Domain Controller IP address.

--dc-host HOST
    Domain Controller hostname.

--hashes LMHASH:NTHASH
    NTLM hash authentication.

--no-pass
    Don't prompt for password (use hash or ticket).

--k
    Use Kerberos authentication.

--aesKey HEXKEY
    AES key for Kerberos.

--debug
    Turn on verbose debugging output.

--filter FILTER
    Custom LDAP search filter (e.g., (userAccountControl:1.2.840.113556.1.4.803:=512)).

-h, --help
    Show help message and exit.

DESCRIPTION

GetADUsers.py is a Python script from the Impacket suite, designed for enumerating user accounts in Microsoft Active Directory environments from Linux or Unix-like systems. It performs LDAP queries against a domain controller to retrieve detailed information about users, such as samAccountName, pwdLastSet, userAccountControl, service principal names, and more. The tool supports authentication via NTLM hashes, passwords, Kerberos tickets, or AES keys, making it versatile for penetration testing, security assessments, and administrative tasks.

By default, it lists basic user attributes but can be customized with filters, specific attributes, and output formats. It's particularly useful for identifying privileged accounts, service accounts, or users matching custom LDAP filters. The script handles multiple credential sets and supports targeting specific domain controllers by IP or hostname. Output is formatted in a tabular view for easy parsing, aiding in reconnaissance phases of security audits.

Impacket's implementation leverages low-level SMB/LDAP libraries, ensuring compatibility with modern Windows domains while avoiding common pitfalls like Kerberos pre-auth restrictions.

CAVEATS

Requires Impacket library installed; needs valid credentials and network access to DC. May trigger security alerts in monitored environments. Use ethically for authorized testing only.

INSTALLATION

pip3 install impacket
Or clone from GitHub: git clone https://github.com/fortra/impacket

EXAMPLE

GetADUsers.py 'domain/user:pass@10.0.0.1' --all
GetADUsers.py 'domain/user@dc.contoso.com' -hashes :nthash --filter '(servicePrincipalName=*)'

HISTORY

Part of Impacket toolkit, originally developed by Fox-IT (2010s), maintained by SecureAuth Corporation (now Fortra). Evolved with SMB/LDAP protocol support for modern Windows versions.

SEE ALSO

ldapsearch(1), wbinfo(1), samba(7)

Copied to clipboard