|
|
看了LUMAQQ的源码翻译了自动回复的代码,但不知道为什么,有时候可以,有时候不可以。哪位高手帮我看看啊
char fromqqbuf[4],toqqbuf[4];
memcpy(&fromqqbuf[0],&sBody.FromQQ,4);
memcpy(&toqqbuf[0],&sBody.ToQQ,4);
byte head[11];
head[0]=0x02;
head[1]=0x0e;
head[2]=0x1b;
head[3]=0x00;
head[4]=0x16;
srand(qd->uid);
head[5]=rand()%256;
head[6]=rand()%256;
head[7]=fromqqbuf[3];
head[8]=fromqqbuf[2];
head[9]=fromqqbuf[1];
head[10]=fromqqbuf[0];
char *StrSend="test";
long bytesCount = -1;
int bit;
byte *SendBuff;
SendBuff=new byte[strlen(StrSend)*2];
for(int i=0;i<strlen(StrSend);i++)
{
bit = StrSend;
if (bit > -1&& bit < 256) {
bytesCount = bytesCount + 1;
SendBuff[bytesCount] = (byte)bit;
}
else {
bytesCount = bytesCount + 2;
SendBuff[bytesCount - 1] = HIWORD(bit);
SendBuff[bytesCount] = LOWORD(bit);
}
}
byte *Plain;
Plain=new byte[68+bytesCount];
Plain[0]=fromqqbuf[3];
Plain[1]=fromqqbuf[2];
Plain[2]=fromqqbuf[1];
Plain[3]=fromqqbuf[0];
Plain[4]=toqqbuf[3];
Plain[5]=toqqbuf[2];
Plain[6]=toqqbuf[1];
Plain[7]=toqqbuf[0];
Plain[8]=0x0e;
Plain[9]=0x1b;
Plain[10] = fromqqbuf[3];
Plain[11] = fromqqbuf[2];
Plain[12] = fromqqbuf[1];
Plain[13] = fromqqbuf[0];
Plain[14] = toqqbuf[3];
Plain[15] = toqqbuf[2];
Plain[16] = toqqbuf[1];
Plain[17] = toqqbuf[0];
//'18 - 33 MD5
char b[20];
char c[16];
b[0] = fromqqbuf[3];
b[1] = fromqqbuf[2];
b[2] =fromqqbuf[1];
b[3] = fromqqbuf[0];
memcpy(&b[4], &qd->session_key,16);
md5_buffer((char *)b,sizeof(b),&c);
memcpy(& lain[18], &c[0], 16);
Plain[34] = 0;
Plain[35] = 11;
Plain[36] = rand()%256;
Plain[37] = rand()%256;
memcpy(& lain[38],&msgReq->sendtime,4);
Plain[42] = 0;
Plain[43] = 0;
Plain[44] = 0;
Plain[45] = 0;
Plain[46] = 0;
Plain[47] = 1;
Plain[48] = 1;
Plain[49] = 0;
Plain[50] = rand()%256;
Plain[51] = rand()%256;
Plain[52] = 2;
memcpy(& lain[53], &SendBuff[0], bytesCount+1);
Plain[68+bytesCount - 14] = 32;
Plain[68+bytesCount - 13] = 0;
Plain[68+bytesCount- 12] = 9;
Plain[68+bytesCount - 11] = 250;//frmMain.hsRed.value
Plain[68+bytesCount- 10] = 0;//frmMain.hsGreen.value
Plain[68+bytesCount - 9] = 0;//frmMain.hsBlue.value
Plain[68+bytesCount - 8] = 0;
Plain[68+bytesCount - 7] = 134;
Plain[68+bytesCount - 6] = 0;
Plain[68+bytesCount - 5] = 0xCB;
Plain[68+bytesCount - 4] = 0xCE;
Plain[68+bytesCount - 3] = 0xCC;
Plain[68+bytesCount- 2] = 0xE5;
Plain[68+bytesCount-1] = 13;
byte obuf[1024];
int ilen;
qq_encrypt(Plain,68+bytesCount,qd->session_key,(byte*)obuf,&ilen);
byte sbuf[1024];
memcpy(&sbuf[0],&head[0],11);
memcpy(&sbuf[11],&obuf[0],ilen);
sbuf[11+ilen]=3;
qqsend(qd,&sbuf[0],11+ilen+1); |
|