TDS协议 加密密码算法

看freetds的源码:

unsigned char *
tds7_crypt_pass(const unsigned char *clear_pass, int len, unsigned char *crypt_pass)
{
 int i;

 for (i = 0; i < len; i++)
  crypt_pass[i] = ((clear_pass[i] << 4) | (clear_pass[i] >> 4)) ^ 0xA5;
 return crypt_pass;
}

 

调用:tds7_crypt_pass((unsigned char *) unicode_string, password_len, (unsigned char *) unicode_string); 

这一点,wireshark早已经解析出来了。只是,当时不知道用哪种算法实现。

 

附调试代码:

#include <stdio.h>
#include "stdlib.h"
#include <string.h>
unsigned char *tds7_crypt_pass(const unsigned char *clear_pass, int len, unsigned char *crypt_pass)
{
 int i;
 
 for (i = 0;i < len; i++)
  crypt_pass[i] = ((clear_pass[i] << 4) | (clear_pass[i] >> 4)) ^ 0xA5;
 return crypt_pass;
}
int main()
{
 const unsigned char password[]="abc123";
 unsigned char buf[30];
 unsigned char *encrpted_pass=buf;
 int i;
 memset(encrpted_pass,0,sizeof(buf));
 tds7_crypt_pass(password,sizeof(password)-1,encrpted_pass);
 for(i=0;i<sizeof(password)-1;i++)
 {
  printf("%c     ",password[i]);
  printf("%x/n",encrpted_pass[i]);
 }
 return 0;
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值