protected override void ParseBody(ByteBuffer byteBuffer) { //密文 byte[] CipherText = byteBuffer.ToByteArray(); //明文 bodyDecrypted = QQTea.Decrypt(CipherText, byteBuffer.Position, CipherText.Length - byteBuffer.Position - 1, _secretKey); //提取数据 ByteBuffer buf = new ByteBuffer(bodyDecrypted); VerifyType = buf.Get(); buf.GetChar(); Status = buf.Get(); buf.GetByteArray(4); user.QQ_PACKET_00BAVerifyToken = buf.GetByteArray(buf.GetChar()); VerifyCode = buf.GetByteArray(buf.GetChar()); VerifyCommand = buf.Get(); if (VerifyCommand == 0x00) { VerifyCommand = buf.Get(); } buf.Get(); if (user.QQ_PACKET_00BAVerifyCode?.Length == 0 || user.QQ_PACKET_00BAVerifyCode == null) { user.QQ_PACKET_00BAVerifyCode = VerifyCode; } else { byte[] resultArr = new byte[user.QQ_PACKET_00BAVerifyCode.Length + VerifyCode.Length]; user.QQ_PACKET_00BAVerifyCode.CopyTo(resultArr, 0); VerifyCode.CopyTo(resultArr, user.QQ_PACKET_00BAVerifyCode.Length); user.QQ_PACKET_00BAVerifyCode = resultArr; } user.QQ_PACKET_00BAToken = buf.GetByteArray(buf.GetChar()); buf.GetByteArray(buf.GetChar()); }
protected override void ParseBody(ByteBuffer byteBuffer) { //密文 byte[] CipherText = byteBuffer.ToByteArray(); //明文 bodyDecrypted = QQTea.Decrypt(CipherText, byteBuffer.Position, CipherText.Length - byteBuffer.Position - 1, user.QQ_0828_rec_decr_key); //提取数据 ByteBuffer buf = new ByteBuffer(bodyDecrypted); if (GetPacketLength() == 407) { buf.GetByteArray(15); user.QQ_SessionKey = buf.GetByteArray(0x10); } else if (GetPacketLength() == 439 || GetPacketLength() == 527) { buf.GetByteArray(63); user.QQ_SessionKey = buf.GetByteArray(0x10); } else { throw new Exception("登录失败"); } }
protected override void ParseBody() { Decrypt(User.TXProtocol.BufDhShareKey); Result = Reader.ReadByte(); //返回错误 if (Result == (byte)ResultCode.DoMain || Result == (byte)ResultCode.其它错误 || Result == (byte)ResultCode.密码错误 || Result == (byte)ResultCode.帐号被回收 || Result == (byte)ResultCode.要求切换TCP || Result == (byte)ResultCode.过载保护 || Result == (byte)ResultCode.需要验证密保 || Result == (byte)ResultCode.需要验证码) { var tlvs = Tlv.ParseTlv(Reader.ReadBytes((int)(Reader.BaseStream.Length - 1))); //重置指针(因为tlv解包后指针已经移动到末尾) Reader.BaseStream.Position = 1; TlvExecutionProcessing(tlvs); if (tlvs.Any(c => c.Tag == 0x0100)) { var errorData = tlvs.FirstOrDefault(c => c.Tag == 0x0100); var errReader = new BinaryReader(new MemoryStream(errorData.Value)); var tlv = new TLV0100(); tlv.Parser_Tlv2(User, errReader, errorData.Length); ErrorMsg = tlv.ErrorMsg; } } else { BodyDecrypted = QQTea.Decrypt(BodyDecrypted, User.TXProtocol.BufTgtgtKey); Reader = new BinaryReader(new MemoryStream(BodyDecrypted)); Result = Reader.ReadByte(); var tlvs = Tlv.ParseTlv(Reader.ReadBytes((int)(Reader.BaseStream.Length - 1))); //重置指针(因为tlv解包后指针已经移动到末尾) Reader.BaseStream.Position = 1; TlvExecutionProcessing(tlvs); } }
protected override void ParseBody(ByteBuffer byteBuffer) { //密文 byte[] CipherText = byteBuffer.ToByteArray(); //明文 bodyDecrypted = QQTea.Decrypt(CipherText, byteBuffer.Position, CipherText.Length - byteBuffer.Position - 1, user.QQ_SessionKey); //提取数据 ByteBuffer buf = new ByteBuffer(bodyDecrypted); buf.GetByteArray(4); buf.GetByteArray(4); //自己的QQ buf.GetByteArray(10); MessageType = buf.GetChar(); //消息类型 if (MessageType == (char)0x0052) { buf.GetByteArray(2); buf.GetByteArray(buf.GetChar()); Group = (long)Util.GetQQNumRetUint(Util.ToHex(buf.GetByteArray(4))); //群号 buf.Get(); FromQQ = (long)Util.GetQQNumRetUint(Util.ToHex(buf.GetByteArray(4))); //发消息人的QQ buf.GetByteArray(4); ReceiveTime = buf.GetByteArray(4); //接收时间 buf.GetByteArray(24); SendTime = buf.GetByteArray(4); //发送时间 buf.GetByteArray(12); Font = buf.GetByteArray(buf.GetChar()); //字体 buf.GetByteArray(6); Message = Util.ConvertHexToString(Util.ToHex(buf.GetByteArray(buf.GetChar()))); //消息 buf.GetByteArray(58); buf.GetByteArray(buf.GetChar()); //消息 buf.GetByteArray(11); } }
protected override void ParseBody(ByteBuffer byteBuffer) { //密文 byte[] CipherText = byteBuffer.ToByteArray(); //明文 bodyDecrypted = QQTea.Decrypt(CipherText, byteBuffer.Position, CipherText.Length - byteBuffer.Position - 1, user.QQ_SessionKey); //提取数据 ByteBuffer buf = new ByteBuffer(bodyDecrypted); FromQQ = (long)Util.GetQQNumRetUint(Util.ToHex(buf.GetByteArray(4))); buf.GetByteArray(4);//自己的QQ buf.GetByteArray(10); MessageType = buf.GetByteArray(2); buf.GetChar(); buf.GetByteArray(buf.GetChar()); //未知 buf.GetChar(); //消息来源QQ的版本号 buf.GetByteArray(4); //FromQQ buf.GetByteArray(4); //自己的QQ buf.GetByteArray(20); MessageDateTime = buf.GetByteArray(4); buf.GetChar(); //00 buf.GetByteArray(4); //MessageDateTime buf.GetByteArray(5); //00 buf.GetByteArray(3); buf.GetByteArray(5); //00 buf.GetByteArray(4); //MessageDateTime buf.GetByteArray(4); buf.GetByteArray(8); FontStyle = buf.GetByteArray(buf.GetChar()); buf.GetByteArray(6); MessageLength = buf.GetChar(); MessageData = Util.ConvertHexToString(Util.ToHex(buf.GetByteArray(MessageLength))); buf.GetByteArray(22); }
protected override void ParseBody(ByteBuffer byteBuffer) { //密文 byte[] CipherText = byteBuffer.ToByteArray(); //明文 bodyDecrypted = QQTea.Decrypt(CipherText, byteBuffer.Position, CipherText.Length - byteBuffer.Position - 1, user.QQ_SessionKey); //提取数据 ByteBuffer buf = new ByteBuffer(bodyDecrypted); }
public void Decrypt(byte[] key) { BodyDecrypted = QQTea.Decrypt(Buffer, (int)Reader.BaseStream.Position, (int)(Buffer.Length - Reader.BaseStream.Position - 1), key); if (BodyDecrypted == null) { throw new Exception($"包内容解析出错,抛弃该包: {ToString()}"); } Reader = new BinaryReader(new MemoryStream(BodyDecrypted)); }
private void Menu_Tea_d0(object sender, RoutedEventArgs e) { byte[] tmp_key = new byte[16]; byte[] tmp_data = QQTea.Strtobyte(textEditor.SelectedText); if (tmp_data.Length > 0 && tmp_key.Length > 0) { byte[] redata = QQTea.Decrypt(tmp_data, 0, tmp_data.Length, tmp_key); if (redata != null) { textEditor.SelectedText += "\nTea解密 key " + QQTea.Bytetostr(tmp_key) + "\n" + QQTea.Bytetostr(redata) + "\nTea解密end"; } } }
private void Btn_click_d(object sender, RoutedEventArgs e) { byte[] tmp_key = QQTea.Strtobyte(Tea_key.Text); byte[] tmp_data = QQTea.Strtobyte(Tea_in.Text); if (tmp_data.Length > 0 && tmp_key.Length > 0) { byte[] redata = QQTea.Decrypt(tmp_data, 0, tmp_data.Length, tmp_key); if (redata != null) { Tea_out.Text = QQTea.Bytetostr(redata); } } }
protected override void ParseBody(ByteBuffer byteBuffer) { //密文 byte[] CipherText = byteBuffer.ToByteArray(); //明文 if (!user.IsLoginRedirect) { bodyDecrypted = QQTea.Decrypt(CipherText, byteBuffer.Position, CipherText.Length - byteBuffer.Position - 1, user.QQ_PACKET_0825KEY); } else { bodyDecrypted = QQTea.Decrypt(CipherText, byteBuffer.Position, CipherText.Length - byteBuffer.Position - 1, user.QQ_PACKET_REDIRECTIONKEY); } if (bodyDecrypted == null) { throw new Exception($"包内容解析出错,抛弃该包: {ToString()}"); } ByteBuffer buf = new ByteBuffer(bodyDecrypted); DataHead = buf.Get(); buf.GetChar(); //0112 buf.GetChar(); //0038 user.QQ_0825Token = buf.GetByteArray(0x38); if (DataHead == 0xFE) { buf.GetByteArray(6); user.LoginTime = buf.GetByteArray(4); buf.GetByteArray(2); buf.GetByteArray(4); buf.GetByteArray(18); user.ServerIp = buf.GetByteArray(4); buf.GetByteArray(6); } else { buf.GetByteArray(6); user.LoginTime = buf.GetByteArray(4); buf.GetByteArray(2); buf.GetByteArray(4); buf.GetByteArray(6); user.ServerIp = buf.GetByteArray(4); } //从原始数据包提取加密包 byteBuffer.GetByteArray(CipherText.Length - 1); }
protected override void ParseBody(ByteBuffer byteBuffer) { //密文 byte[] CipherText = byteBuffer.ToByteArray(); //明文 bodyDecrypted = QQTea.Decrypt(CipherText, byteBuffer.Position, CipherText.Length - byteBuffer.Position - 1, user.QQ_SessionKey); //提取数据 ByteBuffer buf = new ByteBuffer(bodyDecrypted); buf.GetByteArray(4); user.QQ_Skey = Util.ConvertHexToString(Util.ToHex(buf.GetByteArray(10))); if (string.IsNullOrEmpty(user.QQ_Skey)) { throw new Exception("skey获取失败"); } else { user.QQ_Cookies = "uin=o" + user.QQ + ";skey=" + user.QQ_Skey + ";"; user.QQ_Gtk = Util.GET_GTK(user.QQ_Skey); } }
protected override void ParseBody() { var CipherText2 = QQTea.Decrypt(buffer, (int)reader.BaseStream.Position, (int)(buffer.Length - reader.BaseStream.Position - 1), user.QQ_SHARE_KEY); if (CipherText2 == null) { throw new Exception($"包内容解析出错,抛弃该包: {ToString()}"); } if (GetPacketLength() == 871) { bodyDecrypted = CipherText2; reader = new BinaryReader(new MemoryStream(bodyDecrypted)); reader.ReadBytes(20); user.QQ_PACKET_00BAVerifyToken = reader.ReadBytes(reader.BEReadChar()); VerifyCode = reader.ReadBytes(reader.BEReadChar()); VerifyCommand = reader.ReadByte(); if (VerifyCommand == 0x00) { VerifyCommand = reader.ReadByte(); } user.QQ_PACKET_00BAVerifyCode = VerifyCode; user.QQ_PACKET_00BAToken = reader.ReadBytes(reader.BEReadChar()); reader.ReadBytes(reader.BEReadChar()); } else { bodyDecrypted = QQTea.Decrypt(CipherText2, _secretKey); if (bodyDecrypted == null) { throw new Exception($"包内容解析出错,抛弃该包: {ToString()}"); } //提取数据 reader = new BinaryReader(new MemoryStream(bodyDecrypted)); DataHead = reader.ReadByte(); if (GetPacketLength() == 271 || GetPacketLength() == 207) { reader.BEReadChar(); user.QQ_PACKET_TgtgtKey = reader.ReadBytes(reader.BEReadChar()); reader.BEReadChar(); user.QQ_tlv_0006_encr = reader.ReadBytes(reader.BEReadChar()); reader.ReadBytes(6); if (GetPacketLength() == 271) { user.QQ_0836Token = reader.ReadBytes(reader.BEReadChar()); } reader.BEReadChar(); reader.ReadBytes(reader.BEReadChar()); } else if (GetPacketLength() > 700) { reader.ReadBytes(6); user.QQ_0828_rec_ecr_key = reader.ReadBytes(0x10); reader.BEReadChar(); user.QQ_0836_038Token = reader.ReadBytes(0x38); reader.ReadBytes(60); var Judge = reader.ReadBytes(2); var MsgLength = 0; if (Util.ToHex(Judge) == "01 07") { MsgLength = 0; } else if (Util.ToHex(Judge) == "00 33") { MsgLength = 28; } else if (Util.ToHex(Judge) == "01 10") { MsgLength = 64; } reader.ReadBytes(28); reader.ReadBytes(MsgLength); user.QQ_0828_rec_decr_key = reader.ReadBytes(0x10); reader.BEReadChar(); user.QQ_0836_088Token = reader.ReadBytes(0x88); reader.ReadBytes(159); user.QQ_ClientKey = reader.ReadBytes(112); reader.ReadBytes(28); var nick_length = reader.ReadByte(); user.NickName = Encoding.UTF8.GetString(reader.ReadBytes(nick_length)); user.Gender = reader.ReadByte(); reader.ReadBytes(4); user.Age = reader.ReadByte(); reader.ReadBytes(10); reader.ReadBytes(0x10); } } }
protected override void ParseBody(ByteBuffer byteBuffer) { //密文 byte[] CipherText = byteBuffer.ToByteArray(); //明文 byte[] CipherText2 = QQTea.Decrypt(CipherText, byteBuffer.Position, CipherText.Length - byteBuffer.Position - 1, user.QQ_SHARE_KEY); if (CipherText2 == null) { throw new Exception($"包内容解析出错,抛弃该包: {ToString()}"); } bodyDecrypted = QQTea.Decrypt(CipherText2, _secretKey); if (bodyDecrypted == null) { throw new Exception($"包内容解析出错,抛弃该包: {ToString()}"); } //提取数据 ByteBuffer buf = new ByteBuffer(bodyDecrypted); DataHead = buf.Get(); if (GetPacketLength() == 271 || GetPacketLength() == 207) { buf.GetChar(); buf.GetChar(); user.QQ_PACKET_TgtgtKey = buf.GetByteArray(0x10); buf.GetChar(); buf.GetChar(); user.QQ_tlv_0006_encr = buf.GetByteArray(0x78); buf.GetByteArray(6); buf.GetChar(); user.QQ_0836Token = buf.GetByteArray(0x38); buf.GetChar(); buf.GetChar(); buf.GetByteArray(0x10); } else if (GetPacketLength() > 700) { buf.GetByteArray(6); user.QQ_0828_rec_ecr_key = buf.GetByteArray(0x10); buf.GetChar(); user.QQ_0836_038Token = buf.GetByteArray(0x38); buf.GetByteArray(60); var Judge = buf.GetByteArray(2); var MsgLength = 0; if (Util.ToHex(Judge) == "01 07") { MsgLength = 0; } else if (Util.ToHex(Judge) == "00 33") { MsgLength = 28; } else if (Util.ToHex(Judge) == "01 10") { MsgLength = 64; } buf.GetByteArray(28); buf.GetByteArray(MsgLength); user.QQ_0828_rec_decr_key = buf.GetByteArray(0x10); buf.GetChar(); user.QQ_0836_088Token = buf.GetByteArray(0x88); buf.GetByteArray(159); user.QQ_ClientKey = buf.GetByteArray(112); buf.GetByteArray(28); var nick_length = buf.Get(); user.NickName = Util.ConvertHexToString(Util.ToHex(buf.GetByteArray(nick_length))); user.Gender = buf.Get(); buf.GetByteArray(4); user.Age = buf.Get(); buf.GetByteArray(10); buf.GetByteArray(0x10); } }