Skip to content

Impacket mssqlinstance.py

Back to the Category Index / Back to the Command Index

Queries SQL Server Browser over UDP to enumerate instance names, ports, versions, and named pipes.

ItemDetails
Implementationexamples/mssqlinstance.py
CategoryMSSQL / Exchange / MQTT
Size56 lines
DistributionInstalled as a script through scripts=examples/*.py in setup.py

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

ArgumentDescription
hostTarget host.
-timeoutTime to wait for a response (default: 5).
-debugEnable debug logging.
-tsAdd timestamps to log output.

The command creates an MSSQL helper from the host and timeout, sends an instance discovery packet to UDP 1434, parses multiple records according to their separators, and displays each instance’s properties.

SQL Server Browser accepts instance discovery requests on UDP 1434 and returns information about named instances on the host as delimited text records. The command does not log in to a database; it uses only the Browser service discovery protocol to collect instance names, versions, TCP ports, and named pipes.

One datagram may contain several instances, each as a series of key/value pairs. The parser distinguishes instance and field separators and allows missing fields or reordered fields when building a dictionary or table. Instance-name and port fields may differ between default and named instances.

With UDP, a missing response does not mean there are no instances. The Browser service may be stopped, a firewall may block traffic, packets may be lost, multiple interfaces may be involved, or a response may be spoofed. Report a timeout as one piece of evidence, and verify returned hosts and ports separately before connecting automatically.

SymbolLocationEntry Point for Tracing Behavior
module-level entry1Parses arguments and runs the operation at the top level
ModuleMain Names Used
impacket.exampleslogger
impackettds, version

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.
  • Distinguish missing input files, damaged files, truncated reads, and unsupported formats.

This small CLI depends on impacket.tds.MSSQL and UDP sockets. Because responses are unauthenticated datagrams, allow for missing or duplicate fields, timeouts, and malformed separators when parsing.

  • Syntax: python -m py_compile examples/mssqlinstance.py
  • CLI: python examples/mssqlinstance.py -h
  • No test specific to this command was found. Choose shared-module tests and, if needed, a run in an isolated environment.