Skip to main content

Crate ms_tds

Crate ms_tds 

Source
Expand description

ms-tds — pure-Rust TDS 7.4 client for Microsoft SQL Server.

§STATUS: pre-alpha

Compile-clean skeleton with partial implementation:

  • TDS packet framing (header + segmentation across packet_size)
  • PreLogin token round-trip
  • TLS-in-TDS handshake tunneling — TlsTunnel wraps rustls handshake records inside TDS PRELOGIN packets and flips to passthrough afterwards, so an encrypted SQL Server (“Encrypt = yes / Force Encryption”) accepts the login. Post-handshake, TDS packet framing rides on top of the TLS layer unchanged.
  • Login7 with NTLM SSPI blob wrapping (INTEGRATED_SECURITY)
  • TdsClient connect / login_ntlm / sql_batch — the wire is driven but ROW / COLMETADATA decoding is not implemented, so sql_batch returns an empty ResultSet even when the server sends rows.

§Minimal usage sketch

let mut c = ms_tds::TdsClient::connect("sql01", 1433, None).await?;
c.login_ntlm("CORP", "svc_scan", "pw").await?;
let _ = c.sql_batch(ms_tds::pentest::enum_linked_servers()).await?;

Re-exports§

pub use client::Column;
pub use client::ResultSet;
pub use client::Row;
pub use client::TdsClient;
pub use error::Error;
pub use error::Result;
pub use tls_tunnel::TlsTunnel;
pub use tls_tunnel::TunnelMode;
pub use transport::AsyncStream;
pub use transport::Transport;

Modules§

client
High-level TDS 7.4 client.
error
login7
Login7 packet (MS-TDS §2.2.6.4). Strings are UTF-16LE; the password field uses the trivial “nibble-swap ^ 0xA5” obfuscation.
packet
TDS packet framing (MS-TDS §2.2.3).
pentest
Pentest primitives — SQL string builders for offensive TDS work.
prelogin
PreLogin token stream (MS-TDS §2.2.6.5). Client and server both send this shape.
tls
TLS-in-TDS handshake driver.
tls_tunnel
TLS-in-TDS handshake tunneling wrapper (MS-TDS §3.3.5.1).
token
Token stream (MS-TDS §2.2.5). Skeleton reader — recognizes token kinds and their length prefixes so the caller can walk the stream, but does not decode ROW / COLMETADATA yet (that needs the full type-info decoder — future work).
transport
Async transport with TDS packet framing.