protected override void PutBody(ByteBuffer buf) { // 初始密钥 //buf.Put(user.QQKey.InitKey); buf.PutChar((char)user.QQKey.LoginInfo_Magic_Token.Length); buf.Put(user.QQKey.LoginInfo_Magic_Token); ByteBuffer DecodedBuf = new ByteBuffer(); DecodedBuf.PutChar((char)0x0101); DecodedBuf.PutChar((char)0x0000); DecodedBuf.Put((byte)Client.QQUser.QQKey.LoginInfo_Token.Length); DecodedBuf.Put(Client.QQUser.QQKey.LoginInfo_Token); DecodedBuf.Put(new byte[]{0x10,0x03,0xC8,0xEC,0xC8,0x96, 0x8B,0xF2,0xB3,0x6B,0x4D,0x0C,0x5C,0xE0,0x6A,0x51,0xCE});//unknown data //Client.QQUser.QQKey.Key = Client.QQUser.QQKey.LoginInfo_Key1;//可能要用到 byte[] EncodedBuf = crypter.Encrypt(DecodedBuf.ToByteArray(), user.QQKey.LoginInfo_Key1); #if DEBUG Client.LogManager.Log(ToString() + " key:" + Utils.Util.ToHex(user.QQKey.LoginInfo_Key1)); Client.LogManager.Log(ToString() + " UnBody:" + Utils.Util.ToHex(DecodedBuf.ToByteArray())); #endif buf.Put(EncodedBuf); #if DEBUG Client.LogManager.Log(ToString() + " EnBody:" + Utils.Util.ToHex(buf.ToByteArray())); #endif }
protected override void PutBody(ByteBuffer buf) { // 初始密钥 buf.PutChar((char)user.QQKey.LoginInfo_Magic_Token.Length); buf.Put(user.QQKey.LoginInfo_Magic_Token); ByteBuffer DecodedBuf = new ByteBuffer(); DecodedBuf.PutChar((char)0x010D); DecodedBuf.Put(0x00); DecodedBuf.Put(new byte[] { 0x01, 0x01 }); DecodedBuf.Put(VersionData.QQ09_LOCALE); DecodedBuf.Put(VersionData.QQ09_VERSION_SPEC); DecodedBuf.PutChar((char)Client.QQUser.QQKey.Answer_Token.Length); DecodedBuf.Put(Client.QQUser.QQKey.Answer_Token); DecodedBuf.PutChar((char)Client.QQUser.QQKey.LoginInfo_Token.Length); DecodedBuf.Put(Client.QQUser.QQKey.LoginInfo_Token); DecodedBuf.Put(Client.QQUser.QQKey.LoginInfo_UnknowData); DecodedBuf.Put(Client.ServerTime); DecodedBuf.PutChar((char)Client.QQUser.QQKey.LoginInfo_Data_Token.Length); DecodedBuf.Put(Client.QQUser.QQKey.LoginInfo_Data_Token); DecodedBuf.PutChar((char)0x0000); DecodedBuf.PutInt(0x00000000); //Client.QQUser.QQKey.Key = Client.QQUser.QQKey.LoginInfo_Key1;//可能要用到 byte[] EncodedBuf = crypter.Encrypt(DecodedBuf.ToByteArray(), user.QQKey.LoginInfo_Key1); buf.Put(EncodedBuf); #if DEBUG Client.LogManager.Log(ToString() + " key:" + Utils.Util.ToHex(user.QQKey.InitKey)); Client.LogManager.Log(ToString() + " UnBody: " + Utils.Util.ToHex(DecodedBuf.ToByteArray())); #endif }
protected override void PutBody(ByteBuffer buf) { buf.PutChar((char)Client.QQUser.QQKey.LoginInfo_Magic_Token.Length); buf.Put(user.QQKey.LoginInfo_Magic_Token); ByteBuffer DecodedBuf = new ByteBuffer(); DecodedBuf.PutChar((char)0x011A); DecodedBuf.PutChar((char)0x0001); DecodedBuf.Put(VersionData.QQ09_LOCALE); DecodedBuf.Put(VersionData.QQ09_VERSION_SPEC); DecodedBuf.Put((byte)0x00); DecodedBuf.Put((byte)Client.QQUser.QQKey.Answer_Token.Length); DecodedBuf.Put(Client.QQUser.QQKey.Answer_Token); DecodedBuf.Put(Client.QQUser.QQKey.LoginInfo_UnknowData2); DecodedBuf.Put(Client.ServerTime); DecodedBuf.Put(Client.ClientIP); DecodedBuf.Position += 4;//00 00 00 00 DecodedBuf.PutChar((char)Client.QQUser.QQKey.LoginInfo_Large_Token.Length); DecodedBuf.Put(Client.QQUser.QQKey.LoginInfo_Large_Token); DecodedBuf.PutUShort(this.Pos); DecodedBuf.Position += 2;// 00 00 DecodedBuf.PutChar((char)0x0071); DecodedBuf.Position += 0x0070;//0x0071 zeros DecodedBuf.Put(0x00); byte[] EncodedBuf = crypter.Encrypt(DecodedBuf.ToByteArray(), user.QQKey.LoginInfo_Key1); #if DEBUG Client.LogManager.Log(ToString() + " QQKey.LoginInfo_Key1:" + Utils.Util.ToHex(user.QQKey.LoginInfo_Key1)); Client.LogManager.Log(ToString() + " pos:"+this.Pos+" UnBody:" + Utils.Util.ToHex(DecodedBuf.ToByteArray())); #endif buf.Put(EncodedBuf); #if DEBUG Client.LogManager.Log(ToString() + " EnBody:" + Utils.Util.ToHex(buf.ToByteArray())); #endif }
protected override void PutBody(ByteBuffer buf) { buf.Put((byte)SubCommand); buf.PutInt(ClusterId); buf.PutChar((char)Organizations.Count); foreach (QQOrganization org in Organizations) { buf.Put((byte)org.Id); buf.PutInt(org.Path); byte[] nameBytes = Utils.Util.GetBytes(org.Name); buf.Put((byte)nameBytes.Length); buf.Put(nameBytes); } }
/// <summary> /// 初始化取消发送文件包 /// </summary> /// <param name="buf">The buf.</param> private void InitConnectionCanceled(ByteBuffer buf) { // 17 - 19. 怀疑也和发送消息包相同,但是在这种情况中,这部分没有使用,为全0,一共11个0字节 buf.PutLong(0); buf.PutChar((char)0); buf.Put((byte)0); // 传输类型 buf.Put((byte)TransferType); }
protected override void PutBody(ByteBuffer buf) { if (MessageId == 0) { MessageId = (ushort)this.Sequence; } // 发送者QQ号 buf.PutInt(user.QQ); // 接收者QQ号 //00 00 00 08 00 01 00 04 00 00 00 00 09SP1 changes buf.PutInt(Receiver); buf.PutInt(0x00000008); buf.PutInt(0x00010004); buf.PutInt(0x00000000); // 发送者QQ版本 buf.PutChar(Source); // 发送者QQ号 buf.PutInt(user.QQ); // 接收者QQ号 buf.PutInt(Receiver); // 文件传输会话密钥 buf.Put(user.QQKey.SessionKey); // 消息类型 buf.PutUShort((ushort)MessageType); // 顺序号 if (SessionId == 0) buf.PutChar(Sequence); else buf.PutUShort(SessionId); // 发送时间 int time = (int)(Utils.Util.GetTimeMillis(DateTime.Now) / 1000); buf.PutInt(time); // 发送者头像 char face = (char)user.ContactInfo.Head; buf.PutChar(face); // 字体信息,设成1 buf.PutInt(1); if (MessageType != NormalIMType.Vibration) { // 暂时为如来神掌做的设置 if (FakeIp) buf.PutInt(0); else { // 分片数 buf.Put((byte)TotalFragments); // 分片序号 buf.Put((byte)FragmentSequence); // 消息id buf.PutUShort(MessageId); } } // 判断消息类型 switch (MessageType) { case NormalIMType.TEXT: InitTextContent(buf); break; case NormalIMType.UDP_REQUEST: InitSendFileContent(buf); break; case NormalIMType.ACCEPT_UDP_REQUEST: InitSendFileAcceptContent(buf); break; case NormalIMType.REJECT_UDP_REQUEST: case NormalIMType.REJECT_TCP_REQUEST: InitSendFileRejectContent(buf); break; case NormalIMType.NOTIFY_IP: InitNotifyFilePortUDP(buf); break; case NormalIMType.REQUEST_CANCELED: InitConnectionCanceled(buf); break; case NormalIMType.ARE_YOU_BEHIND_FIREWALL: InitPleaseConnectMe(buf); break; case NormalIMType.Vibration: InitVibrationContent(buf); break; } #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif }
protected override void PutBody(ByteBuffer buf) { // 初始密钥 buf.Put(user.QQKey.InitKey); ByteBuffer DecodedBuf = new ByteBuffer(); DecodedBuf.Put(new byte[] { 0x00, 0x01 }); DecodedBuf.Put(VersionData.QQ09_LOCALE); DecodedBuf.Put(VersionData.QQ09_VERSION_SPEC); DecodedBuf.Put((byte)0x00); DecodedBuf.Put((byte)Client.QQUser.QQKey.LoginRequestToken.Length); DecodedBuf.Put(Client.QQUser.QQKey.LoginRequestToken); if (GetCode != 0) DecodedBuf.Put(0x04); else DecodedBuf.Put(0x03);//开头写成0x04了,结果后面出现Token不一致了 DecodedBuf.Put(0x00); DecodedBuf.Put(0x05); DecodedBuf.PutInt(0); DecodedBuf.Put((byte)Png_Data); if (GetCode != 0x00 && Token != null) { DecodedBuf.Put(0x04); DecodedBuf.PutInt(GetCode); //answer token DecodedBuf.PutChar((char)Token.Length); DecodedBuf.Put(Token); } else if (Png_Data == 0x01 && Token != null) { //png token DecodedBuf.PutChar((char)Token.Length); DecodedBuf.Put(Token); } else { DecodedBuf.Put(0x00); DecodedBuf.Put(0x00); } byte[] EncodedBuf = crypter.Encrypt(DecodedBuf.ToByteArray(), user.QQKey.InitKey); buf.Put(EncodedBuf); #if DEBUG Client.LogManager.Log(ToString() + " Key:" + Utils.Util.ToHex(user.QQKey.InitKey)); Client.LogManager.Log(ToString() + " UnBody:" + Utils.Util.ToHex(DecodedBuf.ToByteArray())); #endif }
protected override void PutBody(ByteBuffer buf) { // 初始密钥 buf.PutChar((char)user.QQKey.LoginInfo_Magic_Token.Length); buf.Put(user.QQKey.LoginInfo_Magic_Token); ByteBuffer DecodedBuf = new ByteBuffer(); DecodedBuf.PutChar((char)0x0001); DecodedBuf.Put(VersionData.QQ09_VERSION_SPEC); DecodedBuf.Put(Client.QQUser.QQKey.LoginInfo_UnknowData2); DecodedBuf.Put(Client.ServerTime); DecodedBuf.Put(Client.ClientIP); DecodedBuf.Position += 4;//00 00 00 00 DecodedBuf.PutChar((char)Client.QQUser.QQKey.LoginInfo_Large_Token.Length); DecodedBuf.Put(Client.QQUser.QQKey.LoginInfo_Large_Token); DecodedBuf.Position += 35;// 00 00 00...... DecodedBuf.Put(VersionData.QQ09_EXE_HASH); DecodedBuf.Put((byte)Utils.Util.Random.Next()); DecodedBuf.Put((byte)Client.QQUser.LoginMode); DecodedBuf.Put(unknown5); ServerInfo si=Client.ServerInfo; si.CSP_dwConnIP=Client.QQUser.ServerIp; DecodedBuf.Put(0x00); DecodedBuf.Put(si.GetBytes()); DecodedBuf.Put(VersionData.QQ09_LOCALE); DecodedBuf.Position += 16; DecodedBuf.PutUShort((ushort)Client.QQUser.QQKey.Answer_Token.Length); DecodedBuf.Put(Client.QQUser.QQKey.Answer_Token); DecodedBuf.PutInt(0x00000007); DecodedBuf.PutInt(0x00000000); DecodedBuf.PutInt(0x08041001); DecodedBuf.PutInt(0x40);//length of the following --To comment //DecodedBuf.Put(0x40); DecodedBuf.Put(0x01); DecodedBuf.PutInt(Utils.Util.Random.Next()); //DecodedBuf.PutInt(0x0741E9748); DecodedBuf.PutChar((char)unknown6.Length); DecodedBuf.Put(unknown6); DecodedBuf.Put(unknown5); DecodedBuf.Put(0x00); DecodedBuf.Put(si.GetBytes()); DecodedBuf.Put(0x02); DecodedBuf.PutInt(Utils.Util.Random.Next()); //DecodedBuf.PutInt(0x8BED382E); DecodedBuf.PutChar((char)unknown7.Length); DecodedBuf.Put(unknown7); DecodedBuf.Position += 248;//all zeros DecodedBuf.Put(0x00); byte[] EncodedBuf = crypter.Encrypt(DecodedBuf.ToByteArray(), user.QQKey.LoginInfo_Key1); #if DEBUG Client.LogManager.Log(ToString() + " QQKey.LoginInfo_Key1:" + Utils.Util.ToHex(user.QQKey.LoginInfo_Key1)); Client.LogManager.Log(ToString() + " Uncoded Body:" + Utils.Util.ToHex(DecodedBuf.ToByteArray())); #endif buf.Put(EncodedBuf); #if DEBUG Client.LogManager.Log(ToString() + " Encoded Body:" + Utils.Util.ToHex(buf.ToByteArray())); #endif }
/// <summary> /// 初始化请求发送文件包的其余部分 /// </summary> /// <param name="buf">The buf.</param> private void InitSendFileContent(ByteBuffer buf) { // 17 - 19. 怀疑也和发送消息包相同,但是在这种情况中,这部分没有使用,为全0,一共11个0字节 buf.PutLong(0); buf.PutChar((char)0); buf.Put((byte)0); // 我们先尝试UDP方式 buf.Put((byte)TransferType); buf.Put((byte)0x0); if (FakeIp) { buf.PutInt(0); buf.PutChar((char)0); } else { // 四个字节的发送者IP,这是外部IP buf.Put(user.IP); // 发送者端口 buf.PutChar((char)user.Port); } // 直接端口 buf.PutUShort(DirectPort); buf.PutInt(0); buf.PutChar((char)0); buf.Put((byte)0x20); buf.Put(DELIMIT); buf.Put(Utils.Util.GetBytes(FileName)); buf.Put(DELIMIT); buf.Put(Utils.Util.GetBytes(FileSize)); }
protected override void PutBody(ByteBuffer buf) { // 群命令类型 buf.Put((byte)SubCommand); // 群内部ID buf.PutInt(ClusterId); // 未知1字节 buf.Put((byte)Type); // 认证类型 buf.Put((byte)AuthType); // 2004群分类 buf.PutInt(OldCategory); // 群分类,同学,朋友,之类的 buf.PutInt(Category); // 群名称长度和群名称 byte[] b = Utils.Util.GetBytes(Name); buf.Put((byte)(b.Length & 0xFF)); buf.Put(b); // 未知的2字节 buf.PutChar((char)0); // 群声明长度和群声明 b = Utils.Util.GetBytes(Notice); buf.Put((byte)(b.Length & 0xFF)); buf.Put(b); // 群描述长度和群描述 b = Utils.Util.GetBytes(Description); buf.Put((byte)(b.Length & 0xFF)); buf.Put(b); }
protected override void PutBody(ByteBuffer buf) { // 初始密钥 buf.Put(user.QQKey.InitKey); #region 加密用户身份数据 ByteBuffer verifyBuf = new ByteBuffer(); verifyBuf.PutInt(Utils.Util.Random.Next());//random?? verifyBuf.PutChar((char)0x0001); verifyBuf.PutInt(Client.QQUser.QQ); verifyBuf.Put(VersionData.QQ09_VERSION_SPEC); verifyBuf.Put(0x00); verifyBuf.PutChar((char)0x0001); verifyBuf.Put(Client.QQUser.Password); verifyBuf.Put(Client.ServerTime); verifyBuf.Position += 13;//13个00 verifyBuf.Put(Client.ClientIP); verifyBuf.PutInt(0); verifyBuf.PutInt(0); verifyBuf.PutChar((char)0x0010); verifyBuf.Put(Client.QQUser.QQKey.Verify_Key1); verifyBuf.Put(Client.QQUser.QQKey.Verify_Key2); //加密 byte[] EncodeVerifyBuf = crypter.Encrypt(verifyBuf.ToByteArray(), user.QQKey.PasswordKey); #if DEBUG Client.LogManager.Log(ToString() + " User Data:" + Utils.Util.ToHex(verifyBuf.ToByteArray())); Client.LogManager.Log(ToString() + " Key:" + Utils.Util.ToHex(user.QQKey.PasswordKey)); Client.LogManager.Log(ToString() + " User Data:" + "len " + EncodeVerifyBuf.Length.ToString("") + "<--" + Utils.Util.ToHex(EncodeVerifyBuf)); #endif #endregion ByteBuffer DecodedBuf = new ByteBuffer(); DecodedBuf.PutChar((char)0x00CA); DecodedBuf.Put(new byte[] { 0x00, 0x01 }); DecodedBuf.Put(VersionData.QQ09_LOCALE); DecodedBuf.Put(VersionData.QQ09_VERSION_SPEC); DecodedBuf.Put((byte)0x00); DecodedBuf.Put((byte)Client.QQUser.QQKey.Answer_Token.Length); DecodedBuf.Put(Client.QQUser.QQKey.Answer_Token); DecodedBuf.PutChar((char)EncodeVerifyBuf.Length); DecodedBuf.Put(EncodeVerifyBuf); DecodedBuf.PutChar((char)0x0000); DecodedBuf.PutChar((char)0x018B); DecodedBuf.Put(0x2E);//length of the following info DecodedBuf.Put(0x01); DecodedBuf.PutInt(Utils.Util.Random.Next()); DecodedBuf.PutChar((char)0x0010); DecodedBuf.Put(new byte[]{0xE9,0xC4,0xD6,0x5C,0x4D,0x9D, 0xA0,0x17,0xE5,0x24,0x6B,0x55,0x57,0xD3,0xAB,0xF1});//unknow6 DecodedBuf.Put(0x02); DecodedBuf.PutInt(Utils.Util.Random.Next()); DecodedBuf.PutChar((char)0x0010); DecodedBuf.Put(new byte[]{0xCB,0x8D,0xA4,0xE2,0x61,0xC2, 0xDD,0x27,0x39,0xEC,0x8A,0xCA,0xA6,0x98,0xF8,0x9B});//unknow7 DecodedBuf.Position += 0x015B;//395 zeros? 348 -去后面补的一位 DecodedBuf.Put(0x00);//否则后面不补00 byte[] EncodedBuf = crypter.Encrypt(DecodedBuf.ToByteArray(), user.QQKey.InitKey); buf.Put(EncodedBuf); verifyBuf = null; #if DEBUG Client.LogManager.Log(ToString() + " Key:" + Utils.Util.ToHex(user.QQKey.InitKey)); Client.LogManager.Log(ToString() + " Uncode Body:" + Utils.Util.ToHex(DecodedBuf.ToByteArray())); #endif }
/// <summary> /// Puts the body. /// </summary> /// <param name="buf">The buf.</param> protected override void PutBody(ByteBuffer buf) { // 命令类型 buf.Put((byte)SubCommand); // 群内部ID buf.PutInt(ClusterId); // 后面数据的长度,这个长度需要根据后面的长度计算才能知道, // 所以先占个位置 //int pos = buf.Position; //buf.PutChar((char)0); ByteBuffer MsgBuf = new ByteBuffer(); // 未知的2字节 MsgBuf.PutChar((char)1); // 分片数 MsgBuf.Put((byte)TotalFragments); // 分片序号 MsgBuf.Put((byte)FragmentSequence); if (MessageId == 0) { MessageId = (ushort)this.Sequence; } // 消息id MsgBuf.PutUShort(MessageId); // 未知4字节 MsgBuf.PutInt(0); // 以0结束的消息,首先我们要根据用户设置的message,解析出一个网络可发送的格式 // 这一步比较麻烦,暂时想不到好的办法 MsgBuf.PutInt(0x4D534700);//"MSG" MsgBuf.PutInt(0); // 发送时间 int time = (int)(Utils.Util.GetTimeMillis(DateTime.Now) / 1000); MsgBuf.PutInt(time); MsgBuf.PutInt((MessageId << 16) | MessageId);//maybe a random interger MsgBuf.PutInt(0); MsgBuf.PutInt(0x09008600); byte[] Font_Name = Utils.Util.GetBytes(FontStyle.FontName); MsgBuf.PutUShort((ushort)Font_Name.Length); MsgBuf.Put(Font_Name); MsgBuf.PutUShort(0); MsgBuf.Put(0x01); MsgBuf.PutUShort((ushort)(MessageBytes.Length + 3)); MsgBuf.Put(1); MsgBuf.PutUShort((ushort)(MessageBytes.Length)); // 写入消息正文字节数组 if (MessageBytes != null) MsgBuf.Put(MessageBytes); //if (FragmentSequence == TotalFragments - 1) //{ // MsgBuf.Put((byte)0x20); //} byte[] MsgData = MsgBuf.ToByteArray(); buf.PutUShort((ushort)MsgData.Length); buf.Put(MsgData); MsgData = null; MsgBuf = null; //byte[] msgBytes = null; //int j, i = 0; //while ((j = Message.IndexOf((char)FaceType.DEFAULT, i)) != -1) //{ // string sub = Message.Substring(i, j); // if (!sub.Equals("")) // { // msgBytes = Utils.Util.GetBytes(sub); // buf.Put(msgBytes); // } // buf.Put((byte)FaceType.DEFAULT); // buf.Put((byte)(Message[j + 1] & 0xFF)); // i = j + 2; //} //if (i < Message.Length) //{ // string sub = Message.Substring(i); // msgBytes = Utils.Util.GetBytes(sub); // buf.Put(msgBytes); //} //// 只有最后一个分片有空格和字体属性 //if (FragmentSequence == TotalFragments - 1) //{ // buf.Put((byte)0x20); // FontStyle.Write(buf); //} // 写入长度 //int cur = buf.Position; //buf.Position = pos; //buf.PutChar((char)(cur - pos - 2)); //buf.Position = cur; #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif }
protected override void PutBody(ByteBuffer buf) { // 命令类型 buf.Put((byte)SubCommand); // 群类型 buf.Put((byte)Type); // 父群ID buf.PutInt(ParentClusterId); // 群内部ID buf.PutInt(ClusterId); // 后面数据的长度,这个长度需要根据消息长度和字体名称长度计算才能知道, // 所以先来产生消息和字体名称字节数组,先占个位置 int pos = buf.Position; buf.PutChar((char)0); // 未知2字节 buf.PutChar((char)1); // 分片数 buf.Put((byte)TotalFragments); // 分片序号 buf.Put((byte)FragmentSequence); // 消息id buf.PutUShort(MessageId); // 未知4字节 buf.PutInt(0); // 以0结束的消息,首先我们要根据用户设置的message,解析出一个网络可发送的格式 // 这一步比较麻烦,暂时想不到好的办法 byte[] msgBytes = null; int j, i = 0; while ((j = Message.IndexOf((char)FaceType.DEFAULT, i)) != -1) { String sub = Message.Substring(i, j); if (!sub.Equals("")) { msgBytes = Utils.Util.GetBytes(sub); buf.Put(msgBytes); } buf.Put((byte)FaceType.DEFAULT); buf.Put((byte)(Message[j + 1] & 0xFF)); i = j + 2; } if (i < Message.Length) { String sub = Message.Substring(i); msgBytes = Utils.Util.GetBytes(sub); buf.Put(msgBytes); } // 只有最后一个分片有空格和字体属性 if (FragmentSequence == TotalFragments - 1) { buf.Put((byte)0x20); FontStyle.Write(buf); } // 写入长度 int cur = buf.Position; buf.Position = pos; buf.PutChar((char)(cur - pos - 2)); buf.Position = cur; }
protected override void PutBody(ByteBuffer buf) { // 群命令类型 buf.Put((byte)SubCommand); // 群类型 buf.Put((byte)Type); // 认证类型 buf.Put((byte)AuthType); // 2004群分类 buf.PutInt(OldCategory); // 群的分类 buf.PutInt(Category); // 群名称长度和群名称 byte[] b = Utils.Util.GetBytes(Name); buf.Put((byte)(b.Length & 0xFF)); buf.Put(b); // 未知的2字节 buf.PutChar((char)0); // 群声明长度和群声明 b = Utils.Util.GetBytes(Notice); buf.Put((byte)(b.Length & 0xFF)); buf.Put(b); // 群描述长度和群描述 b = Utils.Util.GetBytes(Description); buf.Put((byte)(b.Length & 0xFF)); buf.Put(b); // 群中的好友 foreach (int i in Members) buf.PutInt(i); }
/// <summary> /// 初始化IP信息通知包 /// </summary> /// <param name="buf">The buf.</param> private void InitNotifyFilePortUDP(ByteBuffer buf) { // 17 - 19. 怀疑也和发送消息包相同,但是在这种情况中,这部分没有使用,为全0,一共11个0字节 buf.PutLong(0); buf.PutChar((char)0); buf.Put((byte)0); // 我们先尝试UDP方式 buf.Put((byte)TransferType); buf.Put((byte)0x0); // 四个字节的发送者IP,这是外部IP buf.Put(user.IP); // 发送者端口 buf.PutChar((char)user.Port); // 监听端口,含义未知,为连接服务器的端口,先随便写一个值 buf.PutUShort(DirectPort); // 真实IP和第二个端口 buf.Put(LocalIp); buf.PutUShort(LocalPort); }
protected override void PutBody(ByteBuffer buf) { // 短消息序号 buf.PutUShort(MessageSequence); // 未知2字节 buf.PutChar((char)0); // 未知4字节 buf.PutInt(0); // 发送者昵称 byte[] b = Utils.Util.GetBytes(SenderName); if (b.Length > QQGlobal.QQ_MAX_SMS_SENDER_NAME) { buf.Put(b, 0, QQGlobal.QQ_MAX_SMS_SENDER_NAME); } else { buf.Put(b); int stuff = QQGlobal.QQ_MAX_SMS_SENDER_NAME - b.Length; while (stuff-- > 0) buf.Put((byte)0); } // 未知1字节 buf.Put((byte)0x01); // 发送模式 buf.Put((byte)SendMode); // 内容类型 buf.Put((byte)ContentType); // 内容编号 buf.PutInt(ContentId); // 未知1字节 buf.Put((byte)0x01); // 手机个数 if (ReceiverMobile == null) buf.Put((byte)0); else { buf.Put((byte)ReceiverMobile.Count); foreach (String mobile in ReceiverMobile) { b = Utils.Util.GetBytes(mobile); if (b.Length > QQGlobal.QQ_MAX_SMS_MOBILE_LENGTH) { buf.Put(b, 0, QQGlobal.QQ_MAX_SMS_MOBILE_LENGTH); } else { buf.Put(b); int stuff = QQGlobal.QQ_MAX_SMS_MOBILE_LENGTH - b.Length; while (stuff-- > 0) buf.Put((byte)0); } // 未知的2字节 buf.PutChar((char)0); // 未知的1字节 buf.Put((byte)0); } } // QQ号码个数 if (ReceiverQQ == null) buf.Put((byte)0); else { buf.Put((byte)ReceiverQQ.Count); foreach (int qq in ReceiverQQ) buf.PutInt(qq); } // 未知1字节 buf.Put((byte)0x03); // 消息 if (Message == null) buf.PutChar((char)0); else { buf.PutChar((char)Message.Length); // 消息 buf.Put(Message); } }
/// <summary>初始化同意接收文件包的其余部分 /// <remark>abu 2008-02-29 </remark> /// </summary> /// <param name="buf">The buf.</param> private void InitSendFileAcceptContent(ByteBuffer buf) { // 17 - 19. 怀疑也和发送消息包相同,但是在这种情况中,这部分没有使用,为全0,一共11个0字节 buf.PutLong(0); buf.PutChar((char)0); buf.Put((byte)0); // 我们先尝试UDP方式 buf.Put((byte)TransferType); buf.Put((byte)0x0); // 四个字节的发送者IP,这是外部IP buf.Put(user.IP); // 发送者端口 buf.PutChar((char)user.Port); // 监听端口,含义未知,为连接服务器的端口,先随便写一个值 buf.PutUShort(DirectPort); // 后面全0 buf.PutInt(0); buf.PutChar((char)0); }
protected override void PutBody(ByteBuffer buf) { buf.Put((byte)SubCommand); buf.Put(IP); buf.PutChar((char)0); }
/// <summary>初始化拒绝接收文件包的其余部分 /// <remark>abu 2008-02-29 </remark> /// </summary> /// <param name="buf">The buf.</param> private void InitSendFileRejectContent(ByteBuffer buf) { // 17 - 19. 怀疑也和发送消息包相同,但是在这种情况中,这部分没有使用,为全0,一共11个0字节 buf.PutLong(0); buf.PutChar((char)0); buf.Put((byte)0); // 我们先尝试UDP方式 buf.Put((byte)TransferType); }
protected override void PutBody(ByteBuffer buf) { buf.Put((byte)SubCommand); switch (SubCommand) { case TempSessionSubCmd.SendIM: // 接收者 buf.PutInt(Receiver); // 未知 buf.PutInt(0); // nick byte[] b = Utils.Util.GetBytes(Nick); buf.Put((byte)b.Length); buf.Put(b); // site name b = Utils.Util.GetBytes(Site); buf.Put((byte)b.Length); buf.Put(b); // 未知 buf.Put((byte)1); // 未知 buf.PutInt(0); // 长度,最后再填 int pos = buf.Length; buf.PutChar((char)0); // 消息内容 b = Utils.Util.GetBytes(Message); buf.Put(b); buf.Put((byte)0x20); // 字体属性 FontStyle.Write(buf); // 回填长度 buf.PutChar(pos, (char)(buf.Length - pos - 2)); break; } }
protected override void PutHeader(ByteBuffer buf) { if (!user.IsUdp) buf.PutUShort(0); buf.Put(Header); buf.PutChar(Source); buf.PutUShort((ushort)Command); buf.PutChar(Sequence); buf.PutInt((uint)user.QQ); }
private static void testHet(int level, ByteBuffer b) { int p = b.Position; b.Limit = (b.Capacity); Show(level, b); output.Write(" put:"); b.PutChar((char)1); b.PutChar((char)char.MaxValue); output.Write(" char"); b.PutShort((short)1); b.PutShort((short)short.MaxValue); output.Write(" short"); b.PutInt(1); b.PutInt(int.MaxValue); output.Write(" int"); b.PutLong((long)1); b.PutLong((long)long.MaxValue); output.Write(" long"); b.PutFloat((float)1); b.PutFloat((float)float.MinValue); b.PutFloat((float)float.MaxValue); output.Write(" float"); b.PutDouble((double)1); b.PutDouble((double)double.MinValue); b.PutDouble((double)double.MaxValue); output.Write(" double"); output.WriteLine(); b.Limit = (b.Position); b.Position = (p); Show(level, b); output.Write(" get:"); ck(b, b.GetChar(), 1); ck(b, b.GetChar(), char.MaxValue); output.Write(" char"); ck(b, b.GetShort(), 1); ck(b, b.GetShort(), short.MaxValue); output.Write(" short"); ck(b, b.GetInt(), 1); ck(b, b.GetInt(), int.MaxValue); output.Write(" int"); ck(b, b.GetLong(), 1); ck(b, b.GetLong(), long.MaxValue); output.Write(" long"); ck(b, (long)b.GetFloat(), 1); ck(b, (long)b.GetFloat(), unchecked((long)float.MinValue)); ck(b, (long)b.GetFloat(), unchecked((long)float.MaxValue)); output.Write(" float"); ck(b, (long)b.GetDouble(), 1); ck(b, (long)b.GetDouble(), unchecked((long)double.MinValue)); ck(b, (long)b.GetDouble(), unchecked((long)double.MaxValue)); output.Write(" double"); output.WriteLine(); }