Skip to content

Back to the Category Index / Back to the Command Index

Retrieves users and account details from a target host or domain through SAMR and prints them as a table or CSV.

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

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

ArgumentDescription
target[[domain/]username[:password]@]<targetName or address>
-csvEnable CSV output.
-tsAdd timestamps to log output.
-debugEnable debug logging.
-dc-ipDomain controller IP address. Defaults to the domain (FQDN) in target.
-target-ipTarget machine IP address. Defaults to target; useful when the target is a NetBIOS name that cannot be resolved.
-portDestination SMB server port (choices: 139, 445; default: 445).
-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.

The command connects to the SAMR named pipe, opens server and domain handles, and enumerates users in pages. It then retrieves details for each RID, converts last logon and password timestamps, and displays the results.

SAMR user enumeration does not return all user details at once. dump() first opens server and domain handles, then receives RID and account-name lists in pages from EnumerateUsersInDomain. It opens a user handle for each RID and retrieves additional attributes with QueryInformationUser.

STATUS_MORE_ENTRIES is a continuation marker, not a failure. Pass the resume handle into the next request and collect pages through the last one. If a query for one user is denied, retain the other enumerated users and identify which RID lacks details.

Account timestamps are converted from Windows time and must mean the same thing in CSV and table output. CSV is machine-readable, so avoid casually changing blank display values, delimiters, or character encoding. The chosen domain handle determines whether users belong to the domain or local SAM.

SymbolLocationEntry Point for Tracing Behavior
ListUsersException36Structure and constant definitions
SAMRDump39__init__(), getUnixTime(), dump()
ModuleMain Names Used
impacket.exampleslogger
impacket.examples.utilsparse_target
impacketversion
impacket.nt_errorsSTATUS_MORE_ENTRIES
impacket.dcerpc.v5samr, transport
impacket.dcerpc.v5.rpcrtDCERPCException

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 dcerpc.v5.samr / transport and STATUS_MORE_ENTRIES. SAMRDump.dump() and getUnixTime() are its main implementation points. Treat pagination status as a continuation, not an error, and retain already retrieved records.