tds协议还原:请问有谁做过这方面的解析么,一起讨论,学习。
分析tds协议,必须搞清楚里面个各个数据包类型,如: tds7.0登录包,tds7.0查询包,RPC包,Cancels包,Used in buld包,TDS5.0查询包,以及tds4.2/5.0登录包等。常见的就这几个。(这些不同的数据包可以根据下面的tds_hdr结构里的type字段来判断)
tds协议头
typedef struct tds_hdr{
u_int8 type; /*根据type的类型来确定tds数据包的类型.(假如type为response packet类型,接着判断后面的token类型)*/
u_int8 status;
u_int16 size; /*ntohs(tds.size)*/
u_int16 channel;
u_int8 packet_number;
u_int8 window;
}TDSHDR;
Tds头共8个字节
a) Type:包的类型 1个字节
b) Status: request 或者 response 的最后缓存 2个字节
c) Size: 包的字节大小,2个字节
d) Packet number:包数,1个字节
e) Window:窗口大小,1个字节
2包的类型
/*tds7.0登录包的包头结构*/
struct tds7_login_packet_hdr {
guint32 total_packet_size;
guint32 tds_version;
guint32 packet_size;
guint32 client_version;
guint32 client_pid;
guint32 connection_id;
guint8 option_flags1;
guint8 option_flags2;
guint8 sql_type_flags;
guint8 reserved_flags;
guint32 time_zone;
guint32 collation;
};
上面这个结构只是一部分,祥见ethereal分析。