Skip to content

Impacket getArch.py

Back to the category index / Back to the command index

Infers whether a target host is 32-bit or 64-bit from its response to an RPC Endpoint Mapper connection.

ItemDetails
Implementationexamples/getArch.py
CategorySMB / MSRPC / NTLM
Size111 lines
DistributionInstalled as a script through scripts=examples/*.py in setup.py

Run python examples/getArch.py -h for the current option definitions.

ArgumentDescription
-target
-targetsFile listing target systems, one per line, whose architecture to query
-timeoutSocket connection timeout (default: 2 seconds)
-debugEnable debug output
-tsAdd a timestamp to each log message

The tool creates an EPM transport to TCP port 135 and attempts a bind that includes the NDR64 transfer syntax. It maps a successful bind or specific faults to an architecture estimate, records timeouts and unreachable targets separately, and proceeds to the next target.

DCE/RPC can negotiate NDR32 and NDR64 transfer syntaxes. This command connects to the Endpoint Mapper on TCP port 135 and infers the target architecture from the response to a bind that includes a transfer syntax available on 64-bit systems. It does not read OS version strings or SMB banners.

Each target is probed with a separate transport and socket. The tool classifies bind acknowledgments, provider rejections, RPC faults, and timeouts. It maps acceptance of the expected syntax or a specific transfer-syntax rejection to a 64-bit or 32-bit result. A closed port, disabled EPM, or response altered by a middlebox leaves the architecture undetermined.

For a batch supplied with -targets, a timeout on one host must not prevent other targets from being checked; results remain matched to input order. This estimate depends on RPC runtime behavior, so do not assume CPU, process, and installed OS architectures are always the same when interpreting the output.

SymbolLocationWhere to trace its responsibility
TARGETARCH39__init__(), run()
ModuleMain names used
impacketversion
impacket.exampleslogger
impacket.dcerpc.v5.rpcrtDCERPCException
impacket.dcerpc.v5.transportDCERPCTransportFactory
impacket.dcerpc.v5.epmMSRPC_UUID_PORTMAP

Output, side effects, and required privileges

Section titled “Output, side effects, and required privileges”
  • The tool primarily makes queries and authentication attempts. Frequent runs can affect audit logs, account lockouts, and target load.
  • On failure, use protocol status codes to determine whether name resolution, connection, authentication, service state, or permissions caused the stop.

The code depends on dcerpc.v5.transport, epm, and rpcrt. TARGETARCH.run() owns the target loop and probes. Distinguish network errors from RPC errors indicating an architecture mismatch.