Giter Club home page Giter Club logo

tdsbridge's Introduction

TDSBridge

Description

A C# library to implement a SQL Server TDS protocol bridge with packet inspection. It basically relays TDS messages to a SQL server and sends the answer back; it's almost completely transparent to applications (it even works with server side forced encryption). The library right now recognizes the AttentionMessage, RPCRequestMessage and SQLBatchMessage. Everything else falls into the generic TDSMessage class. I will add more specialized classes in the future. It comes with a simple console application that can be useful for didactic purposes, but I plan to develop a more elegant interactive console. Developed following the [MS-TDS]: Tabular Data Stream Protocol specification version 12.0.

Reference: [MS-TDS] Tabular Data Stream Protocol http://msdn.microsoft.com/en-us/library/dd304523.aspx.

Here is a screenshot of the sample console inspector. As you can see, even though I connected to the bridge I can still access SQL Server as normal. You can also see the SQL Batch statement inspected by the library:

SELECT @@SERVERNAME;
SELECT * FROM sys.dm_exec_connections;

To use the sample, please specify the listening port (must be available) and the SQL Server TCP endpoint (no browser support right now). For example if I have a SQL Instance running on my PC listening on 1433 this could be the syntax:

The resulting connections could be like this diagram:

If you need to parse the output you can redirect it to a file (as you will see, SSMS intellisense will bloat your window :) ).

Please feel free to use it in your demo/classes and if you need any help don't hesitate to contact me.

tdsbridge's People

Contributors

mindflavor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tdsbridge's Issues

Compression

If you were to add compression to this, where would you do it? At the payload area, or the full stream itself?

Crystal Reports 10 Data Transmission Closes

I tried to load my .NET program using login and simple data retrieval. It worked fine until I tried running a module that has a Crystal Report form to get the data from the SQL Server. It froze as the log emitted a closed connection.

image

The report:

image

TabularResult

Is there anyway to show the tabularresult coming from the SQL Server?

Is it possible to modify the response data?

Maybe it's unrelated to this project, but I'm curious and just want to ask a TDS pro like you.

Is it possible to modify the response data coming from SQL Server?

For example, I have a table contains two columns, but with the proxy I want to clear the second column data when a user queries it.

Thanks in advance.

SocketException when receiving large packets?

Hi,

I just did some stress tests and I found it seems to break down when there are large packets (>10,000 bytes)?

I used the following test code to try to insert 100,000 records to the database:

	    List<string> nums = new List<string>();
	    for (int i = 0; i < 1000; i++)
            {
                  nums.Add($"('{i:D10}')");
            }

            var insert = new SqlCommand($@"INSERT INTO TestTable (Str) VALUES {string.Join(",", nums)};", conn) { CommandTimeout = 0 };

            for (int i = 0; i < 100; i++)
            {
                  insert.ExecuteNonQuery();
            }

It will throw a System.Data.SqlClient.SqlException(inner exception: SocketException ID 10054 "An existing connection was forcibly closed by the remote host") on insert.ExecuteNonQuery();. Could you tell me what's the problem? That code works if I don't use TDSBridge.

Here is the log of TDSBridge:

12:01:20.282551|TDSBridge.Common.Packet.TDSPacket[Header=TDSBridge.Common.Header.TDSHeader[Type=SQLBatch;StatusBitMask=4;LengthIncludingHeader=8000;PayloadSize=7992]]
12:01:20.283552|TDSBridge.Common.Packet.TDSPacket[Header=TDSBridge.Common.Header.TDSHeader[Type=48;StatusBitMask=0;LengthIncludingHeader=12544;PayloadSize=12536]]
12:01:20.285551|TDSBridge.Common.Packet.TDSPacket[Header=TDSBridge.Common.Header.TDSHeader[Type=48;StatusBitMask=0;LengthIncludingHeader=12288;PayloadSize=12280]]
12:01:20.753550|Connection BridgeSQL closed (TDSBridge.Common.SocketCouple[ClientBridgeSocket.RemoteEndPoint=127.0.0.1:59996, BridgeSQLSocket.RemoteEndPoint=[fe80::6102:841:e0ce:274%10]:1433])
12:01:20.767549|Connection ClientBridge closed (TDSBridge.Common.SocketCouple[ClientBridgeSocket.RemoteEndPoint=127.0.0.1:59996, BridgeSQLSocket.RemoteEndPoint=[fe80::6102:841:e0ce:274%10]:1433])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.