protected override void PutBody(ByteBuffer buf) { buf.Put((byte)SubCommand); buf.PutInt(ClusterId); buf.PutInt(0); buf.PutInt(Start); }
protected override void PutBody(ByteBuffer buf) { buf.Put((byte)SubCommand); buf.Put((byte)Type); buf.PutInt(ParentClusterId); buf.PutInt(ClusterId); }
protected override void PutBody(ByteBuffer buf) { // 群命令类型 buf.Put((byte)SubCommand); // 群内部ID buf.PutInt(ClusterId); // 接收者QQ号 buf.PutInt(QQ); }
protected override void PutBody(ByteBuffer buf) { buf.Put(0x01); buf.PutInt(0); buf.PutInt(0); buf.Put(0x02); buf.PutUShort(StartPosition); buf.Put(0); #if DEBUG Client.LogManager.Log(ToString() + " " + 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.Put((byte)SubCommand); buf.PutInt(ClusterId); buf.Put(Operation); foreach (int i in Members) buf.PutInt(i); }
protected override void PutBody(ByteBuffer buf) { // 要加的QQ号的字符串形式 buf.PutInt(To); #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif }
/// <summary> /// 初始化包体 /// </summary> /// <param name="buf">The buf.</param> protected override void PutBody(ByteBuffer buf) { buf.Put((byte)0x1F); buf.Put((byte)0x01); buf.PutInt(BeginFrom); #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif }
protected override void PutBody(ByteBuffer buf) { buf.Put(0x88); buf.PutInt(Client.QQUser.QQ); buf.Put(0x00); #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif }
protected override void PutBody(ByteBuffer buf) { // 命令类型 buf.Put((byte)SubCommand); // 内部ID buf.PutInt(ClusterId); #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif }
protected override void PutBody(ByteBuffer buf) { // 命令类型 buf.Put((byte)SubCommand); // 内部ID buf.PutInt(ClusterId); // 需要得到信息的成员QQ号列表 foreach (int qq in Members) buf.PutInt(qq); }
protected override void PutBody(ByteBuffer buf) { buf.Put((byte)SubCommand); buf.PutInt(ClusterId); buf.Put((byte)0); foreach (Member m in Members) { buf.PutInt(m.QQ); buf.Put((byte)m.Organization); } }
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); } }
protected override void PutBody(ByteBuffer buf) { // 命令类型 buf.Put((byte)SubCommand); // 子命令 buf.Put((byte)OpByte); switch (OpByte) { case ClusterSubCmd.GET_SUBJECT_LIST: buf.PutInt(ClusterId); break; case ClusterSubCmd.GET_DIALOG_LIST: buf.PutInt(0); break; } }
protected override void PutBody(ByteBuffer buf) { // 命令类型 buf.Put((byte)SubCommand); // 类型 buf.Put((byte)Type); // 内部ID buf.PutInt(ParentClusterId); // 外部ID buf.PutInt(ClusterId); }
protected override void PutBody(ByteBuffer buf) { buf.PutInt(RemoveFrom); }
private void InitVibrationContent(ByteBuffer buf) { //00 00 00 01 00 09 41 A1 34 00 00 00 00//屏幕闪动内容 //buf.PutInt(1); buf.Put(0); buf.PutInt(Receiver); buf.PutInt(0); }
/// <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)); }
/// <summary> /// 初始化普通消息包的其余部分 /// </summary> /// <param name="buf">The buf.</param> private void InitTextContent(ByteBuffer buf) { // 消息方式,是发送的,还是自动回复的,1字节 buf.Put((byte)ReplyType); //09 add buf.PutInt(0x4D534700);//"MSG" buf.PutInt(0); // 发送时间 int time = (int)(Utils.Util.GetTimeMillis(DateTime.Now) / 1000); buf.PutInt(time); buf.PutInt((MessageId << 16) | MessageId);//maybe a random interger buf.PutInt(0); buf.PutInt(0x09008600); byte[] Font_Name = Utils.Util.GetBytes(FontStyle.FontName); buf.PutUShort((ushort)Font_Name.Length); buf.Put(Font_Name); buf.PutUShort(0); buf.Put(0x01); buf.PutUShort((ushort)(Message.Length+3)); buf.Put(1); buf.PutUShort((ushort)(Message.Length)); // 写入消息正文字节数组 if (Message != null) buf.Put(Message); //// 最后一个分片时追加空格 //if (FragmentSequence == TotalFragments - 1) // buf.Put((byte)0x20); //// 消息尾部,字体修饰属性 //FontStyle.Write(buf); }
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 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 }
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); }
public void ByteBuffer_PutIntChecksLengthAndOffset() { var buffer = new byte[4]; var uut = new ByteBuffer(buffer); Assert.Throws<ArgumentOutOfRangeException>(() => uut.PutInt(2, 0x0A0B0C0D)); }
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.Put((byte)SubCommand); switch (SubCommand) { case SignatureSubCmd.MODIFY: buf.Put((byte)0x01); byte[] b = Utils.Util.GetBytes(Signature); buf.Put((byte)b.Length); buf.Put(b); break; case SignatureSubCmd.GET: buf.Put((byte)0); buf.Put((byte)Signatures.Count); foreach (Signature sig in Signatures) { buf.PutInt(sig.QQ); buf.PutInt(sig.ModifiedTime); } break; } }
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((byte)Type); if (Type == GroupSubCmd.UPLOAD) { // 循环写入各个组 int size = Groups.Count; for (int i = 0; i < size; i++) { String name = Groups[i]; // 组序号 buf.Put((byte)(i + 1)); // 组名称 byte[] nameBytes = Utils.Util.GetBytes(name); // 超过最大长度的,截短;小于最大长度的,补0 if (nameBytes.Length > QQGlobal.QQ_MAX_GROUP_NAME) buf.Put(nameBytes, 0, QQGlobal.QQ_MAX_GROUP_NAME); else { buf.Put(nameBytes); int j = QQGlobal.QQ_MAX_GROUP_NAME - nameBytes.Length; while (j-- > 0) buf.Put((byte)0); } } } else { // 未知字节0x2 buf.Put((byte)0x2); // 未知4字节,全0 buf.PutInt(0); } }
/// <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); }
public void ByteBuffer_PutIntPopulatesBufferCorrectly() { var buffer = new byte[4]; var uut = new ByteBuffer(buffer); uut.PutInt(0, 0x0A0B0C0D); // Ensure Endianness was written correctly Assert.AreEqual(0x0D, buffer[0]); Assert.AreEqual(0x0C, buffer[1]); Assert.AreEqual(0x0B, buffer[2]); Assert.AreEqual(0x0A, buffer[3]); }
protected override void PutBody(ByteBuffer buf) { // 群命令类型 buf.Put((byte)SubCommand); // 群内部ID buf.PutInt(ClusterId); // 认证消息类型 buf.Put((byte)Type); // 接收者QQ号 buf.PutInt(Receiver); // 附加消息长度 byte[] b = Utils.Util.GetBytes(Message); buf.Put((byte)(b.Length & 0xFF)); // 附加消息 buf.Put(b); }