Expand description
§mssql-browser
mssql-browser is a Rust implementation of the SQL Server Resolution Protocol.
The SQL Server Resolution Protocol enables finding endpoint information of MSSQL servers running in the current network.
The SQL Server Resolution Protocol (SSRP) [MC-SQLR] is a simple application-level protocol for the transfer of requests and responses between clients and database server discovery services. To determine the communication endpoint information of a particular database instance, the client sends a single request to a specific machine and waits for a single response. To enumerate database instances in the network and obtain the endpoint information of each instance, the client broadcasts or multicasts a request to the network and waits for responses from different discovery services on the network.
The SQL Server Resolution Protocol is appropriate for retrieving database endpoint information or for database instance enumeration in scenarios where network or local connectivity is available.
§Examples
Below are a few different ways to get endpoint information of MSSQL server instances.
§Discover endpoint information of instances within network
use std::net::{ IpAddr, Ipv4Addr };
use std::error::Error;
use mssql_browser::{ browse, BrowserError };
async fn run() -> Result<(), Box<dyn Error>> {
let broadcast_addr = IpAddr::V4(Ipv4Addr::BROADCAST);
let mut iterator = browse(broadcast_addr).await?;
while let instance = iterator.next().await? {
println!("Found instance {} on host {}.", instance.instance_name, instance.addr);
}
Ok(())
}
§Discover endpoint information of instances on host
use std::net::{ IpAddr, Ipv4Addr };
use std::error::Error;
use mssql_browser::{ browse_host, BrowserError };
async fn run() -> Result<(), Box<dyn Error>> {
let host_addr = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
let mut iterator = browse_host(host_addr).await?;
while let Some(instance) = iterator.next()? {
println!("Found instance {}", instance.instance_name);
}
Ok(())
}
§Discover endpoint information of specific instance
use std::net::{ IpAddr, Ipv4Addr };
use std::error::Error;
use mssql_browser::{ browse_instance, BrowserError };
async fn run() -> Result<(), Box<dyn Error>> {
let host_addr = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
let instance = browse_instance(host_addr, "MSSQLSERVER").await?;
if let Some(tcp) = instance.tcp_info {
println!("Instance is available via TCP on port {}", tcp.port);
}
if let Some(np) = instance.np_info {
println!("Instance is available via named pipe {}", np.name);
}
Ok(())
}
§Discover DAC endpoint information
use std::net::{ IpAddr, Ipv4Addr };
use std::error::Error;
use mssql_browser::{ browse_instance_dac, BrowserError };
async fn run() -> Result<(), Box<dyn Error>> {
let host_addr = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
let dac_info = browse_instance_dac(host_addr, "MSSQLSERVER").await?;
println!("DAC is exposed on port {}", dac_info.port);
Ok(())
}
Modules§
- custom_
socket - Types and functions related to using a custom socket implementation
Structs§
- Adsp
Info - Contains information about an AppleTalk endpoint
- Async
Instance Iterator - Iterates over the instances returned by
browse
- BvInfo
- Contains information about an Banyan VINES endpoint
- DacInfo
- Contains information about the DAC endpoint of an instance
- Instance
Info - Information send in a browser protocol response See SVR_RESP
- Instance
Iterator - Iterates over the instances returned by
browse_host
- Named
Pipe Info - Information about the named pipe endpoint
- RpcInfo
- Contains information about an RPC endpoint
- SpxInfo
- Contains information about an SPX service endpoint
- TcpInfo
- Information about the Tcp endpoint
- ViaAddress
- A combination of NIC name and port.
- ViaInfo
- Information about the Virtual Interface Architecture endpoint
Enums§
- Browser
Error - An error that can be returned from the different browser operations
- Browser
Protocol Error - Received an unexpected response from the server
- Browser
Protocol Field - Different fields found in a browser response
- Browser
Protocol Token - The value that was expected.
Constants§
- MAX_
INSTANCE_ NAME_ LEN - Maximum length of an instance name
Functions§
- browse
- Discovers any SQL Server instances running on hosts reached by the given multicast address.
- browse_
host - Discovers any SQL Server instances running on the given host
- browse_
instance - Gets information about the given instance.
- browse_
instance_ dac - Gets DAC information about the given instance