Skip to content

Back to the Category Index / Back to the Command Index

Determines whether a Windows host is standalone, a domain member, or a domain controller, and displays domain and forest information.

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

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

ArgumentDescription
target[[domain/]username[:password]@]<targetName or address>
-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 MS-DSSP interface over the SMB named pipe \\pipe\\lsarpc and displays the machine role, NetBIOS/DNS domain names, forest name, and domain GUID from the DsRolerGetPrimaryDomainInformation response.

MS-DSSP’s DsRolerGetPrimaryDomainInformation returns the host’s primary domain and machine role in one structure. The command makes a DCE/RPC connection to \\pipe\\lsarpc over SMB, binds to the DSSP interface, and requests the basic domain information level.

The response’s machine-role enum distinguishes standalone workstations and servers, member workstations and servers, and backup and primary DCs. The command also extracts the flat NetBIOS domain name, DNS domain name, forest name, and domain GUID. These describe domain membership and DC role, rather than merely identifying the OS product type.

The remoteName used for name resolution is separate from the actual connection destination, remoteHost. Kerberos needs a hostname for the SPN, so supplying an IP with -target-ip must not discard the logical name. Unknown enum values or NULL domain fields may occur on future versions or standalone hosts; avoid relying solely on direct dictionary indexing.

SymbolLocationEntry Point for Tracing Behavior
MachineRole34__init__(), print_info()
ModuleMain Names Used
impacket.exampleslogger
impacket.examples.utilsparse_target
impacketversion
impacket.uuidbin_to_string
impacket.dcerpc.v5dssp, transport

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.transport, dcerpc.v5.dssp, and the shared target/authentication parser. MachineRole handles the request and display. When adding enums or flags, ensure unknown values do not break the output.