ms-tds
Pure-Rust TDS 7.4 client for Microsoft SQL Server, with an
offensive-security lean: pentest primitives (xp_cmdshell, UNC coerce via
xp_dirtree, linked-server enumeration, sp_configure toggling,
IS_SRVROLEMEMBER checks) are shipped in-tree. Aimed at attack-tooling
authors who today rely on the spec mssqlclient.py or PowerUpSQL.
Status
0.1.0-dev — pre-alpha, expect breaking changes before 0.1.0.
Compile-clean skeleton with a partial wire implementation; not fit for
anything beyond exploration. Part of the
icedracon Rust offensive AD ecosystem.
What it does
Implements enough of MS-TDS 7.4 (Tabular Data Stream) to reach and drive a SQL Server login session:
- Packet layer — 8-byte BE header;
frame()segments a payload acrosspacket_size;Transport::recv()reassembles untilEND_OF_MESSAGE. - PreLogin — encode / decode round-trip.
- TLS-in-TDS handshake tunneling —
TlsTunnelwraps rustls handshake records inside TDSPRELOGINpackets and flips to passthrough afterwards, so a SQL Server withForce Encryption = yesaccepts the login. TDS framing then rides on top of the TLS layer unchanged. - Login7 — full fixed header + OffsetLength block + variable data,
including the NTLM SSPI blob in
ibSSPIwithINTEGRATED_SECURITYset. Password obfuscation (XOR 0xA5+ nibble swap) implemented. - Token stream reader —
LOGINACK,SSPI,ENVCHANGE,DONE/DONEPROC/DONEINPROC,INFO,ERROR. - Async client —
TdsClient::{connect, login_ntlm, sql_batch}drives the handshake end-to-end ontokio. - Pentest string builders —
pentest::{xp_cmdshell, xp_dirtree_unc, enum_linked_servers, is_srvrolemember, sp_configure_toggle}.
Usage
use ;
# async
What works / what does not (this version)
- Working
- Packet framing, PreLogin round-trip, TLS-in-TDS handshake tunneling.
- Login7 encode + NTLM SSPI blob wrapping.
- Async
connect/login_ntlm/sql_batch— wire handshakes driven end-to-end. - DONE-token row-count reporting.
- Pentest string builders.
- Stubbed / TODO
- ROW / COLMETADATA decoding —
sql_batchreturns an emptyResultSeteven when rows are sent. Needs the full TYPE_INFO matrix (variable-length prefixes,COLLATIONforVARCHAR, precision/scale forNUMERIC, PLP forvarchar(max)/text/image). - SQL Browser (UDP 1434) — named-instance resolution not implemented;
connect()takesinstance: Option<&str>for API stability but ignores it. - Kerberos SPNEGO —
login_ntlmis NTLM-only. - Channel binding / Extended Protection for Authentication — outstanding.
- ROW / COLMETADATA decoding —
Design
- One thin module per protocol layer:
packet->prelogin/login7/token->transport/tls_tunnel->client. #![deny(unsafe_code)].- Dep budget kept small:
ntlmssp(SSPI blobs),tokio,tokio-rustls(ring backend — no cmake/nasm on Windows),thiserror,byteorder,bytes,encoding_rs.
Related icedracon crates
msldap-ext— MS-ADTS LDAP extension controls (Paged / DirSync / ExtendedDN / SD_FLAGS / VLV).ms-even6— MS-EVEN6 EventLog Remoting v6 client + BinXml decoder (remote log pulls over\pipe\eventlog).
Together the three cover the LDAP / EventLog / MSSQL data-plane primitives that Python + spec-vector captures dominate today.
License
MIT (c) 2026 zevs