> For the complete documentation index, see [llms.txt](https://www.impacket.wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.impacket.wiki/reference/script-reference/mssql-scripts.md).

# MSSQL Scripts

The MSSQL examples demonstrate SQL Server discovery, login, and interactive use through Impacket's TDS implementation.

## Script List

* `mssqlclient.py` -- Interactive MSSQL client (TDS protocol)
* `mssqlinstance.py` -- Discover MSSQL instances via SQL Browser
* `checkMSSQLStatus.py` -- Check MSSQL server availability

## Main Scripts

| Script                | Purpose                                                     | What to study                                 |
| --------------------- | ----------------------------------------------------------- | --------------------------------------------- |
| `mssqlclient.py`      | Interactive SQL Server client                               | TDS login, Windows auth, SQL auth, query loop |
| `mssqlinstance.py`    | Discovers SQL Server instances                              | Browser service discovery                     |
| `checkMSSQLStatus.py` | Checks whether channel binding token enforcement is present | TLS, authentication hardening checks          |

## MSSQL Client

`mssqlclient.py` connects to SQL Server and provides an interactive shell.

```bash
python examples/mssqlclient.py CONTOSO/alice:'Passw0rd!'@sql01.contoso.local -windows-auth
```

SQL authentication can be used when the target expects SQL logins:

```bash
python examples/mssqlclient.py sa:'StrongPassw0rd!'@sql01.contoso.local
```

The exact authentication mode matters. Read the script help before connecting so you know whether you are using Windows authentication or SQL authentication.

## Instance Discovery

`mssqlinstance.py` queries SQL Server Browser information.

```bash
python examples/mssqlinstance.py 10.10.10.25
```

This is a good compact script for learning UDP-based SQL Server discovery.

## Channel Binding Status

`checkMSSQLStatus.py` checks behavior related to channel binding token enforcement.

```bash
python examples/checkMSSQLStatus.py CONTOSO/alice:'Passw0rd!'@sql01.contoso.local
```

This script is useful when you want to understand how authentication hardening changes client behavior.

## Considerations

SQL Server environments can expose several authentication paths: local SQL users, Windows users, Kerberos, NTLM, and linked server contexts. When building with Impacket's MSSQL code, keep login mode and transport setup visible in your own code, because hidden defaults make failures hard to reason about.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://www.impacket.wiki/reference/script-reference/mssql-scripts.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
