/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { BodyWriter.BeWrite(0x0000000C); BodyWriter.BeWrite(Util.GetTimeSeconds(DateTime.Now)); BodyWriter.BeWrite(0x000003E8); BodyWriter.WriteKey(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x07 }); var data = new BinaryWriter(new MemoryStream()); var data_0A = new BinaryWriter(new MemoryStream()); data_0A.Write((byte)0x08); data_0A.Write(Util.HexStringToByteArray(Util.PB_toLength(User.QQ))); data_0A.Write((byte)0x10); data_0A.Write(Util.HexStringToByteArray(Util.PB_toLength(_recvQQ))); data_0A.Write((byte)0x18); data_0A.Write(Util.HexStringToByteArray(Util.PB_toLength(_msgSequence))); //消息包序 data_0A.Write((byte)0x28); data_0A.Write( Util.HexStringToByteArray( Util.PB_toLength(Convert.ToInt64(Util.ToHex(MessageTime).Replace(" ", ""), 16)))); data_0A.Write(new byte[] { 0x30 }); data_0A.Write( Util.HexStringToByteArray( Util.PB_toLength(Convert.ToInt64(Util.ToHex(MessageId).Replace(" ", ""), 16)))); //消息Id data_0A.Write(new byte[] { 0x38, 0x01, 0x40, 0x00, 0x48, 0x00 }); data.Write((byte)0x0A); data.Write((byte)data_0A.BaseStream.Length); //length data.Write(data_0A.BaseStream.ToBytesArray()); data.Write(new byte[] { 0x10, 0x01, 0x18, 0x01, 0x20, 0x00, 0x2a, 0x04, 0x08, 0x00, 0x10, 0x00 }); //数据长度 BodyWriter.BeWrite(data.BaseStream.Length); BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x00 }); //数据 BodyWriter.Write(data.BaseStream.ToBytesArray()); }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x0D }); var data = new BinaryWriter(new MemoryStream()); data.Write(new byte[] { 0x0A, 0x12, 0x08 }); data.Write(Util.HexStringToByteArray(Util.PB_toLength(GroupQQ))); data.Write(new byte[] { 0x12, 0x0a, 0x38, 0x00, 0x40, 0x00, 0x4a, 0x04, 0x08, 0x00, 0x10, 0x00 }); //数据长度 BodyWriter.BeWrite(data.BaseStream.Length); BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x09 }); var data12 = new BinaryWriter(new MemoryStream()); data12.Write( Util.HexStringToByteArray( Util.PB_toLength(Convert.ToInt64(Util.ToHex(MessageIndex).Replace(" ", ""), 16)))); data12.Write(new byte[] { 0x88, 0x01, 0x04, 0x98, 0x01, 0x00 }); BodyWriter.Write((byte)data12.BaseStream.Length); BodyWriter.Write(data12.BaseStream.ToBytesArray()); //数据 BodyWriter.Write(data.BaseStream.ToBytesArray()); }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { BodyWriter.Write(new byte[] { 0x00, 0x02, 0x00, 0x00, 0x08, 0x04, 0x01, 0xE0 }); BodyWriter.BeWrite(User.TXProtocol.DwSsoVersion); BodyWriter.BeWrite(User.TXProtocol.DwServiceId); BodyWriter.BeWrite(User.TXProtocol.DwClientVer); BodyWriter.Write((byte)0x00); BodyWriter.WriteKey(User.TXProtocol.BufSigClientAddr); BodyWriter.Write(new byte[] { 0x01, 0x02 }); BodyWriter.WriteKey(User.TXProtocol.BufDhPublicKey); if (string.IsNullOrEmpty(VerifyCode)) { BodyWriter.Write(new byte[] { 0x13, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.Write(User.QQPacket00BaSequence); if (User.TXProtocol.PngToken == null || User.TXProtocol.PngToken?.Length == 0) { BodyWriter.Write((byte)0x00); } else { BodyWriter.WriteKey(User.TXProtocol.PngToken); } } else { var verifyCodeBytes = Util.HexStringToByteArray(Util.ConvertStringToHex(VerifyCode)); BodyWriter.Write(new byte[] { 0x14, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.BeWrite((ushort)verifyCodeBytes.Length); BodyWriter.Write(verifyCodeBytes); BodyWriter.WriteKey(User.TXProtocol.BufSigPic); //输入验证码后清空图片流 User.QQPacket00BaVerifyCode = new byte[] { }; } BodyWriter.WriteKey(User.QQPacket00BaFixKey); }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { BodyWriter.Write(new byte[] { 0x03 }); BodyWriter.BeWrite(AddQQ); }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { BodyWriter.Write(new byte[] { 0x01, 0x00 }); BodyWriter.Write((byte)AddType); BodyWriter.BeWrite(AddQQ); }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { var pic = new Bitmap(FileName); var width = pic.Size.Width; // 图片的宽度 var height = pic.Size.Height; // 图片的高度 var picBytes = ImageHelper.ImageToBytes(pic); var md5 = QQTea.MD5(picBytes); var data = new BinaryWriter(new MemoryStream()); data.Write(new byte[] { 0x01, 0x08, 0x01, 0x12 }); data.Write((byte)0x5A); data.Write((byte)0x08); data.Write(Util.HexStringToByteArray(Util.PB_toLength(User.QQ))); data.Write((byte)0x10); data.Write(Util.HexStringToByteArray(Util.PB_toLength(ToQQ))); data.BeWrite((ushort)0x1800); data.Write((byte)0x22); data.Write((byte)0x10); data.Write(md5); data.Write((byte)0x28); data.Write(Util.HexStringToByteArray(Util.PB_toLength(picBytes.Length))); data.Write((byte)0x32); data.Write((byte)0x1A); data.Write(new byte[] { 0x57, 0x00, 0x53, 0x00, 0x4E, 0x00, 0x53, 0x00, 0x4C, 0x00, 0x54, 0x00, 0x31, 0x00, 0x36, 0x00, 0x47, 0x00, 0x45, 0x00, 0x4F, 0x00, 0x5B, 0x00, 0x5F, 0x00 }); data.BeWrite((ushort)0x3801); data.BeWrite((ushort)0x4801); data.Write((byte)0x70); data.Write(Util.HexStringToByteArray(Util.PB_toLength(width))); data.Write((byte)0x78); data.Write(Util.HexStringToByteArray(Util.PB_toLength(height))); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x07 }); //数据长度 BodyWriter.BeWrite(data.BaseStream.Length); BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x03, 0x98, 0x01 }); //数据 BodyWriter.Write(data.BaseStream.ToBytesArray()); }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { if (AddType == AddFriendType.AddFriend) { BodyWriter.Write(new byte[] { 0x00 }); BodyWriter.BeWrite(AddQQ); if (User.AddFriend0018Value.Length > 0) { BodyWriter.BeWrite((ushort)User.AddFriend0018Value.Length); BodyWriter.Write(User.AddFriend0018Value); BodyWriter.BeWrite((ushort)User.AddFriend0020Value.Length); BodyWriter.Write(User.AddFriend0020Value); } else { BodyWriter.Write(new byte[] { 0x00, 0x00 }); BodyWriter.BeWrite((ushort)User.AddFriend0020Value.Length); BodyWriter.Write(User.AddFriend0020Value); } BodyWriter.Write(new byte[] { 0x10, 0x00 }); } else { BodyWriter.Write(new byte[] { 0x02 }); BodyWriter.BeWrite(AddQQ); BodyWriter.Write(new byte[] { 0x00, 0x00 }); BodyWriter.BeWrite((ushort)User.AddFriend0020Value.Length); BodyWriter.Write(User.AddFriend0020Value); BodyWriter.Write(new byte[] { 0x10, 0x00 }); BodyWriter.BeWrite((ushort)Message.Length); BodyWriter.Write(Message); } BodyWriter.Write(new byte[] { 0x01, 0x00, 0x00, 0x0F, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 }); }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { var pic = new Bitmap(FileName); var width = pic.Size.Width; // 图片的宽度 var height = pic.Size.Height; // 图片的高度 //var Md5 = Util.GetMD5ToGuidHashFromFile(fileName); var picBytes = ImageHelper.ImageToBytes(pic); var md5 = QQTea.MD5(picBytes); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x5E, 0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x01, 0x10, 0x01, 0x1A }); BodyWriter.Write((byte)0x5A); BodyWriter.Write((byte)0x08); BodyWriter.Write(Util.HexStringToByteArray(Util.PB_toLength(Group))); BodyWriter.Write((byte)0x10); BodyWriter.Write(Util.HexStringToByteArray(Util.PB_toLength(User.QQ))); BodyWriter.BeWrite((ushort)0x1800); BodyWriter.Write((byte)0x22); BodyWriter.Write((byte)0x10); BodyWriter.Write(md5); BodyWriter.Write((byte)0x28); BodyWriter.Write(Util.HexStringToByteArray(Util.PB_toLength(picBytes.Length))); //TODO: BodyWriter.Write((byte)0x32); BodyWriter.Write((byte)0x1A); BodyWriter.Write(new byte[] { 0x37, 0x00, 0x4D, 0x00, 0x32, 0x00, 0x25, 0x00, 0x4C, 0x00, 0x31, 0x00, 0x56, 0x00, 0x32, 0x00, 0x7B, 0x00, 0x39, 0x00, 0x30, 0x00, 0x29, 0x00, 0x52, 0x00 }); BodyWriter.BeWrite((ushort)0x3801); BodyWriter.BeWrite((ushort)0x4801); BodyWriter.Write((byte)0x50); BodyWriter.Write(Util.HexStringToByteArray(Util.PB_toLength(width))); //TODO: BodyWriter.Write((byte)0x58); BodyWriter.Write(Util.HexStringToByteArray(Util.PB_toLength(height))); //TODO: BodyWriter.BeWrite((ushort)0x6004); BodyWriter.BeWrite((ushort)0x6A05); BodyWriter.Write(new byte[] { 0x32, 0x36, 0x36, 0x35, 0x36 }); BodyWriter.BeWrite((ushort)0x7000); BodyWriter.BeWrite((ushort)0x7803); BodyWriter.BeWrite((ushort)0x8001); BodyWriter.Write((byte)0x00); }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x0D }); var data = new BinaryWriter(new MemoryStream()); data.Write(new byte[] { 0x0A, 0x12, 0x08 }); data.Write(Util.HexStringToByteArray(Util.PB_toLength(_groupQQ))); data.Write(new byte[] { 0x12, 0x0a, 0x38, 0x00, 0x40, 0x00, 0x4a, 0x04, 0x08, 0x00, 0x10, 0x00 }); //数据长度 BodyWriter.BeWrite(data.BaseStream.Length); BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x09, 0x10, 0x91, 0x07, 0x88, 0x01, 0x04, 0x98, 0x01, 0x00 }); //数据 BodyWriter.Write(data.BaseStream.ToBytesArray()); }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x07 }); var data = new BinaryWriter(new MemoryStream()); data.Write(new byte[] { 0x03, 0x08, 0x03, 0x22, 0x46, 0x08 }); data.Write(Util.HexStringToByteArray(Util.PB_toLength(_recvGroupQQ))); data.Write((byte)0x10); data.Write( Util.HexStringToByteArray( Util.PB_toLength(Convert.ToInt64(Util.ToHex(MessageTime).Replace(" ", ""), 16)))); data.Write(new byte[] { 0x20, 0x00 }); //数据长度 BodyWriter.BeWrite(data.BaseStream.Length); BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x00 }); //数据 BodyWriter.Write(data.BaseStream.ToBytesArray()); }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { var pic = new Bitmap(FileName.Content); var width = pic.Size.Width; // 图片的宽度 var height = pic.Size.Height; // 图片的高度 var picBytes = ImageHelper.ImageToBytes(pic); _md5 = QQTea.MD5(picBytes); FileName.Set("Md5", Md5); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x07 }); var data = new BinaryWriter(new MemoryStream()); data.Write(new byte[] { 0x10, 0x01, 0x1A, 0x5A, 0x08 }); data.Write(Util.HexStringToByteArray(Util.PB_toLength(Group))); data.Write((byte)0x10); data.Write(Util.HexStringToByteArray(Util.PB_toLength(User.QQ))); data.Write(new byte[] { 0x18, 0x00, 0x22, 0x10 }); data.Write(_md5); data.Write((byte)0x28); data.Write(Util.HexStringToByteArray(Util.PB_toLength(picBytes.Length))); data.Write(new byte[] { 0x32, 0x1a }); data.Write(new byte[] { 0x50, 0x00, 0x42, 0x00, 0x41, 0x00, 0x42, 0x00, 0x52, 0x00, 0x24, 0x00, 0x4d, 0x00, 0x36, 0x00, 0x5f, 0x00, 0x5a, 0x00, 0x32, 0x00, 0x25, 0x00, 0x39, 0x00 }); data.Write(new byte[] { 0x38, 0x01, 0x48, 0x01 }); data.Write((byte)0x50); data.Write(Util.HexStringToByteArray(Util.PB_toLength(width))); data.Write((byte)0x58); data.Write(Util.HexStringToByteArray(Util.PB_toLength(height))); data.Write(new byte[] { 0x60, 0x04, 0x6a, 0x05 }); data.Write(new byte[] { 0x32, 0x36, 0x36, 0x35, 0x32 }); data.Write(new byte[] { 0x70, 0x00, 0x78, 0x03, 0x80, 0x01, 0x00 }); //数据长度 BodyWriter.BeWrite(data.BaseStream.Length); BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x01 }); //数据 BodyWriter.Write(data.BaseStream.ToBytesArray()); //使用之后释放文件 pic.Dispose(); }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { var pbGroupId = Util.HexStringToByteArray(Util.PB_toLength(_groupId)); var pbMessageId = Util.HexStringToByteArray( Util.PB_toLength(Convert.ToInt64(Util.ToHex(_messageId).Replace(" ", ""), 16))); var pbMessageIndex = Util.HexStringToByteArray( Util.PB_toLength(Convert.ToInt64(Util.ToHex(_messageIndex).Replace(" ", ""), 16))); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x07 }); var data = new BinaryWriter(new MemoryStream()); data.Write(new byte[] { 0x08, 0x01, 0x10, 0x00, 0x18 }); data.Write(pbGroupId); data.Write(new byte[] { 0x22, 0x09, 0x08 }); data.Write(pbMessageIndex); //消息索引 data.Write((byte)0x10); data.Write(pbMessageId); //消息Id var data_2A = new BinaryWriter(new MemoryStream()); data_2A.Write(new byte[] { 0x08, 0x00 }); var data12 = new BinaryWriter(new MemoryStream()); data12.Write((byte)0x08); data12.Write(pbMessageIndex); //消息索引 data12.Write((byte)0x10); data12.Write(new byte[] { 0x00, 0x18, 0x01, 0x20, 0x00 }); data_2A.Write((byte)0x12); data_2A.Write((byte)data12.BaseStream.Length); data_2A.Write(data12.BaseStream.ToBytesArray()); data.Write((byte)0x2a); data.Write((byte)data_2A.BaseStream.Length); data.Write(data_2A.BaseStream.ToBytesArray()); //数据长度 BodyWriter.BeWrite(data.BaseStream.Length); BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x00 }); //数据 BodyWriter.Write(data.BaseStream.ToBytesArray()); }
protected override void PutBody() { var myid = Util.HexStringToByteArray(Util.PB_toLength(User.QQ)); var id = Util.HexStringToByteArray(Util.PB_toLength(_toQQ)); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00 }); BodyWriter.BeWrite(myid.Length + 11); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00 }); BodyWriter.BeWrite(myid.Length + id.Length + 8); BodyWriter.Write(new byte[] { 0x08, 0x01 }); BodyWriter.Write(new byte[] { 0x12 }); BodyWriter.BeWrite(myid.Length + 7); BodyWriter.Write(new byte[] { 0x08 }); BodyWriter.Write(myid); BodyWriter.Write(new byte[] { 0x10, 0xE3, 0x07, 0x98, 0x01, 0x00 }); BodyWriter.Write(new byte[] { 0x08, 0xE5, 0x0F }); BodyWriter.Write(new byte[] { 0x10, 0x01 }); BodyWriter.Write(new byte[] { 0x22 }); BodyWriter.BeWrite(id.Length + 6); BodyWriter.Write(new byte[] { 0x58 }); BodyWriter.Write(id); BodyWriter.Write(new byte[] { 0x60, 0x92, 0x4E }); BodyWriter.Write(new byte[] { 0x68, 0x01 }); }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { var dateTime = Util.GetTimeSeconds(DateTime.Now); var group = ConvertQQGroupId(_group); switch (Message.Snippets[0].Type) { case MessageType.At: case MessageType.Normal: case MessageType.Emoji: { BodyWriter.Write((byte)0x2A); BodyWriter.BeWrite(group); BodyWriter.BeWrite((ushort)(_data.Length + 50)); // 字符串长度 + 56,但是_data里面包含了和长度有关的额外六个byte BodyWriter.Write(new byte[] { 0x00, 0x01, _packetCount, _packetIndex, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x53, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.BeWrite(dateTime); BodyWriter.Write(Util.RandomKey(4)); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00 }); BodyWriter.Write(new byte[] { 0x00, 0x0C }); BodyWriter.Write(new byte[] { 0xE5, 0xBE, 0xAE, 0xE8, 0xBD, 0xAF, 0xE9, 0x9B, 0x85, 0xE9, 0xBB, 0x91 }); BodyWriter.Write(new byte[] { 0x00, 0x00 }); BodyWriter.Write(_data); break; } case MessageType.Xml: { BodyWriter.Write((byte)0x2A); BodyWriter.BeWrite(group); var compressMsg = GZipByteArray.CompressBytes(Message.Snippets[0].Content); BodyWriter.BeWrite((ushort)(compressMsg.Length + 64)); BodyWriter.Write(new byte[] { 0x00, 0x01, _packetCount, _packetIndex, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x53, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.BeWrite(dateTime); BodyWriter.Write(SendXml(compressMsg)); break; } case MessageType.Picture: { HttpUpLoadGroupImg(_group, User.Ukey, Message.Snippets[0].Content); BodyWriter.Write((byte)0x2A); BodyWriter.BeWrite(group); var guid = Encoding.UTF8.GetBytes(Util.GetMD5ToGuidHashFromFile(Message.Snippets[0].Content)); BodyWriter.Write(new byte[] { 0x00, 0x01, _packetCount, _packetIndex, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x53, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.BeWrite(dateTime); BodyWriter.Write(Util.RandomKey(4)); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00 }); BodyWriter.Write(new byte[] { 0xE5, 0xBE, 0xAE, 0xE8, 0xBD, 0xAF, 0xE9, 0x9B, 0x85, 0xE9, 0xBB, 0x91 }); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x03, 0x00, 0xCB, 0x02 }); BodyWriter.Write(new byte[] { 0x00, 0x2A }); BodyWriter.Write(guid); BodyWriter.Write(new byte[] { 0x04, 0x00, 0x04 }); BodyWriter.Write(new byte[] { 0x9B, 0x53, 0xB0, 0x08, 0x05, 0x00, 0x04, 0xD9, 0x8A, 0x5A, 0x70, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0x50, 0x07, 0x00, 0x01, 0x43, 0x08, 0x00, 0x00, 0x09, 0x00, 0x01, 0x01, 0x0B, 0x00, 0x00, 0x14, 0x00, 0x04, 0x11, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x00, 0x02, 0xBC, 0x16, 0x00, 0x04, 0x00, 0x00, 0x02, 0xBC, 0x18, 0x00, 0x04, 0x00, 0x00, 0x7D, 0x5E, 0xFF, 0x00, 0x5C, 0x15, 0x36, 0x20, 0x39, 0x32, 0x6B, 0x41, 0x31, 0x43, 0x39, 0x62, 0x35, 0x33, 0x62, 0x30, 0x30, 0x38, 0x64, 0x39, 0x38, 0x61, 0x35, 0x61, 0x37, 0x30 }); BodyWriter.Write(new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x35, 0x30, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }); BodyWriter.Write(guid); BodyWriter.Write(0x41); break; } case MessageType.AddGroup: { BodyWriter.Write(new byte[] { 0x08 }); BodyWriter.BeWrite(group); BodyWriter.Write(new byte[] { 0x01 }); BodyWriter.BeWrite((ushort)User.AddFriend0020Value.Length); BodyWriter.Write(User.AddFriend0020Value); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00 }); //备注信息 var messageData = Encoding.UTF8.GetBytes(Message.Snippets[0].Content); Writer.BeWrite((ushort)messageData.Length); Writer.Write(messageData); BodyWriter.Write(new byte[] { 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x09 }); break; } case MessageType.GetGroupImformation: { BodyWriter.Write(new byte[] { 0x72 }); BodyWriter.BeWrite(group); break; } case MessageType.ExitGroup: { BodyWriter.Write(new byte[] { 0x09 }); BodyWriter.BeWrite(group); break; } default: { throw new NotImplementedException(); } } }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { BodyWriter.BeWrite(AddQQ); }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { var dateTime = Util.GetTimeSeconds(DateTime.Now); var group = ConvertQQGroupId(_group); switch (Message.Snippets[0].Type) { case MessageType.At: case MessageType.Normal: case MessageType.Emoji: { BodyWriter.Write((byte)0x2A); BodyWriter.BeWrite(group); BodyWriter.BeWrite((ushort)(_data.Length + 50)); // 字符串长度 + 56,但是_data里面包含了和长度有关的额外六个byte BodyWriter.Write(new byte[] { 0x00, 0x01, _packetCount, _packetIndex, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x53, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.BeWrite(dateTime); BodyWriter.Write(Util.RandomKey(4)); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00 }); BodyWriter.Write(new byte[] { 0x00, 0x0C }); BodyWriter.Write(new byte[] { 0xE5, 0xBE, 0xAE, 0xE8, 0xBD, 0xAF, 0xE9, 0x9B, 0x85, 0xE9, 0xBB, 0x91 }); BodyWriter.Write(new byte[] { 0x00, 0x00 }); BodyWriter.Write(_data); break; } case MessageType.Xml: { BodyWriter.Write((byte)0x2A); BodyWriter.BeWrite(group); var compressMsg = GZipByteArray.CompressBytes(Message.Snippets[0].Content); BodyWriter.BeWrite((ushort)(compressMsg.Length + 64)); BodyWriter.Write(new byte[] { 0x00, 0x01, _packetCount, _packetIndex, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x53, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.BeWrite(dateTime); BodyWriter.Write(SendXml(compressMsg)); break; } case MessageType.Picture: { var _Snippets = Message.Snippets[0]; BodyWriter.Write((byte)0x2A); BodyWriter.BeWrite(group); var guid = Encoding.UTF8.GetBytes(Util.GetMD5ToGuidHashFromFile(Message.Snippets[0].Content) + Path.GetExtension(_Snippets.Content)); BodyWriter.Write(new byte[] { 0x01, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x53, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.BeWrite(dateTime); BodyWriter.Write(Util.RandomKey(4)); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x22 }); BodyWriter.WriteKey(new byte[] { 0xE5, 0xBE, 0xAE, 0xE8, 0xBD, 0xAF, 0xE9, 0x9B, 0x85, 0xE9, 0xBB, 0x91 }); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x03, 0x00, 0xCB, 0x02 }); BodyWriter.WriteKey(guid); BodyWriter.Write((byte)0x04); BodyWriter.WriteKey(Util.HexStringToByteArray(_Snippets["30Key"].ToString())); BodyWriter.Write((byte)0x05); BodyWriter.WriteKey(Util.HexStringToByteArray(_Snippets["48Key"].ToString())); BodyWriter.Write(new byte[] { 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0x50, 0x07, 0x00, 0x01, 0x43, 0x08, 0x00, 0x00, 0x09, 0x00, 0x01, 0x01, 0x0b, 0x00, 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x00, 0x05, 0xa0, 0x16, 0x00, 0x04, 0x00, 0x00, 0x04, 0x38, 0x18, 0x00, 0x04, 0x00, 0x01, 0xf5, 0x62, 0xff }); var data = new BinaryWriter(new MemoryStream()); data.Write(new byte[] { 0x15, 0x36, 0x20 }); data.Write(new byte[] { 0x39, 0x32, 0x6b, 0x41, 0x31, 0x43, 0x61, 0x37, 0x64, 0x63, 0x66, 0x34, 0x38, 0x37, 0x34, 0x39, 0x38, 0x64, 0x33, 0x33, 0x37, 0x39 }); data.Write(new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x35, 0x30, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }); data.Write(guid); data.Write((byte)0x41); BodyWriter.WriteKey(data.BaseStream.ToBytesArray()); break; } case MessageType.AddGroup: { BodyWriter.Write(new byte[] { 0x08 }); BodyWriter.BeWrite(group); BodyWriter.Write(new byte[] { 0x01 }); BodyWriter.BeWrite((ushort)User.AddFriend0020Value.Length); BodyWriter.Write(User.AddFriend0020Value); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00 }); //备注信息 var messageData = Encoding.UTF8.GetBytes(Message.Snippets[0].Content); Writer.BeWrite((ushort)messageData.Length); Writer.Write(messageData); BodyWriter.Write(new byte[] { 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x09 }); break; } case MessageType.GetGroupImformation: { BodyWriter.Write(new byte[] { 0x72 }); BodyWriter.BeWrite(group); BodyWriter.BeWrite(0x00); break; } case MessageType.ExitGroup: { BodyWriter.Write(new byte[] { 0x09 }); BodyWriter.BeWrite(group); break; } default: { throw new NotImplementedException(); } } }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { var dateTime = Util.GetTimeSeconds(DateTime.Now); var md5 = User.TXProtocol.SessionKey; foreach (var snippet in Message.Snippets) { switch (snippet.Type) { case MessageType.Xml: { var compressMsg = GZipByteArray.CompressBytes(snippet.Content); BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x04 }); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00 }); BodyWriter.Write(new byte[] { 0x37, 0x0F }); BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(md5); BodyWriter.Write(new byte[] { 0x00, 0x0B }); BodyWriter.Write(Util.RandomKey(2)); BodyWriter.BeWrite(dateTime); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, _packetCount, _packetIndex, 0x00, 0x00, 0x01, 0x4D, 0x53, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.Write(SendXml(dateTime, compressMsg)); break; } case MessageType.Shake: { BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00 }); BodyWriter.Write(new byte[] { 0x37, 0x0F }); BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(Util.RandomKey()); BodyWriter.Write(new byte[] { 0x00, 0xAF }); BodyWriter.Write(Util.RandomKey(2)); BodyWriter.BeWrite(dateTime); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.Write(Util.RandomKey(4)); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00 }); break; } case MessageType.Normal: { BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x0D, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x01 }); BodyWriter.Write(new byte[] { 0x36, 0x43 }); BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(md5); BodyWriter.Write(new byte[] { 0x00, 0x0B }); BodyWriter.Write(Util.RandomKey(2)); BodyWriter.BeWrite(dateTime); BodyWriter.Write(new byte[] { 0x02, 0x34, 0x00, 0x00, 0x00, 0x00, _packetCount, _packetIndex, 0x00, 0x00, 0x01, 0x4D, 0x53, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.BeWrite(dateTime); BodyWriter.Write(Util.RandomKey(4)); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00 }); BodyWriter.Write(new byte[] { 0x00, 0x06 }); BodyWriter.Write(new byte[] { 0xE5, 0xAE, 0x8B, 0xE4, 0xBD, 0x93 }); BodyWriter.Write(new byte[] { 0x00, 0x00 }); var messageData = Encoding.UTF8.GetBytes(snippet.Content); ConstructMessage(BodyWriter, messageData); break; } case MessageType.Emoji: { BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x0D, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x01 }); BodyWriter.Write(new byte[] { 0x36, 0x43 }); BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(md5); BodyWriter.Write(new byte[] { 0x00, 0x0B }); BodyWriter.Write(Util.RandomKey(2)); BodyWriter.BeWrite(dateTime); BodyWriter.Write(new byte[] { 0x02, 0x34, 0x00, 0x00, 0x00, 0x00, _packetCount, _packetIndex, 0x00, 0x00, 0x01, 0x4D, 0x53, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.BeWrite(dateTime); BodyWriter.Write(Util.RandomKey(4)); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00 }); BodyWriter.Write(new byte[] { 0x00, 0x06 }); BodyWriter.Write(new byte[] { 0xE5, 0xAE, 0x8B, 0xE4, 0xBD, 0x93 }); BodyWriter.Write(new byte[] { 0x00, 0x00 }); var messageData = ConstructMessage(snippet.Content); if (messageData.Length != 0) { BodyWriter.Write(messageData); } break; } default: { throw new NotImplementedException(); } } } }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { var dateTime = Util.GetTimeSeconds(DateTime.Now); var md5 = User.TXProtocol.SessionKey; switch (Message?.Snippets[0].Type ?? MessageType.Normal) { case MessageType.At: case MessageType.Normal: case MessageType.Picture: case MessageType.Emoji: { BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x0D, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x01 }); BodyWriter.Write(new byte[] { 0x36, 0x43 }); BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(md5); BodyWriter.Write(new byte[] { 0x00, 0x0B }); BodyWriter.Write(Util.RandomKey(2)); BodyWriter.BeWrite(dateTime); BodyWriter.Write(new byte[] { 0x02, 0x34, 0x00, 0x00, 0x00, 0x00, _packetCount, _packetIndex, 0x00, 0x00, 0x01, 0x4D, 0x53, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.BeWrite(dateTime); BodyWriter.Write(Util.RandomKey(4)); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00 }); BodyWriter.Write(new byte[] { 0x00, 0x06 }); BodyWriter.Write(new byte[] { 0xE5, 0xAE, 0x8B, 0xE4, 0xBD, 0x93 }); BodyWriter.Write(new byte[] { 0x00, 0x00 }); BodyWriter.Write(_data); break; } case MessageType.Xml: { BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x04 }); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00 }); BodyWriter.Write(new byte[] { 0x37, 0x0F }); BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(md5); BodyWriter.Write(new byte[] { 0x00, 0x0B }); BodyWriter.Write(Util.RandomKey(2)); BodyWriter.BeWrite(dateTime); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, _packetCount, _packetIndex, 0x00, 0x00, 0x01, 0x4D, 0x53, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.BeWrite(dateTime); BodyWriter.Write(SendXml(GZipByteArray.CompressBytes(Message.Snippets[0].Content))); break; } case MessageType.Shake: { BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00 }); BodyWriter.Write(new byte[] { 0x37, 0x0F }); BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(Util.RandomKey()); BodyWriter.Write(new byte[] { 0x00, 0xAF }); BodyWriter.Write(Util.RandomKey(2)); BodyWriter.BeWrite(dateTime); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.Write(Util.RandomKey(4)); BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00 }); break; } default: { throw new NotImplementedException(); } } }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { BodyWriter.Write((byte)0x88); BodyWriter.BeWrite(User.QQ); BodyWriter.Write((byte)0x00); }
/// <summary> /// 初始化包体 /// </summary> protected override void PutBody() { BodyWriter.Write(new byte[] { 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03 }); BodyWriter.BeWrite(ToQQ); BodyWriter.Write(new byte[] { 0x69, 0x8e, 0x7e, 0x44, 0x3c, 0x11, 0xea, 0x7c }); }