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(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 }
/// <summary> /// </summary> /// <param name="buf">The buf.</param> public void Read(ByteBuffer buf) { ByteBuffer temp = new ByteBuffer(); int i = 0; while (true) { byte b = buf.Get(); if (b != 0x1F) { if (b != 0x1E) { temp.Put(b); } else { if (i == 0) { QQ = Utils.Util.GetInt(Utils.Util.GetString(temp.ToByteArray()), 0000); } else if (i == 1) Nick = Utils.Util.GetString(temp.ToByteArray()); else if (i == 2) Province = Utils.Util.GetString(temp.ToByteArray()); i++; temp.Initialize(); } } else { Face = Utils.Util.GetInt(Utils.Util.GetString(temp.ToByteArray()), 0); break; } } }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " Decoded Data:" + Utils.Util.ToHex(buf.ToByteArray())); Client.LogManager.Log(ToString() + ":No use data until now!You can check this dat! It's said it has a key"); #endif }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif ReplyCode = (ReplyCode)buf.Get(); }
protected override void PutBody(ByteBuffer buf) { buf.Put(Reply); #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif }
protected override void PutBody(ByteBuffer buf) { // 要加的QQ号的字符串形式 buf.PutInt(To); #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif }
protected override void ParseBody(ByteBuffer buf) { byte[] b = buf.ToByteArray(); QQ = Utils.Util.GetInt(Utils.Util.GetString(b), 0); if (QQ == user.QQ) Success = true; else Success = false; }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif SubCommand =(AddFriendAuthSubCmd) buf.Get(); To = buf.GetInt(); ReplyCode = (ReplyCode)buf.Get(); }
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 }
/// <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(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(Client.ServerInfo.GetBytes()); //DecodedBuf.Put(zeros);//15字节长度00 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() + " Uncrypt Body:" + Utils.Util.ToHex(DecodedBuf.ToByteArray())); #endif }
protected override void PutBody(ByteBuffer buf) { buf.Position += 15;//16个00 buf.Put(0x00); //buf.Put(user.PasswordKey); #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 }
/// <summary> /// 将serverInfo转成byte[] /// </summary> /// <returns></returns> public byte[] GetBytes() { ByteBuffer buf = new ByteBuffer(); buf.Put(CSP_wRedirectCount); buf.Put(CSP_cRedirectCount); buf.Put(CSP_dwConnIspID); buf.Put(CSP_dwServerReserve); buf.Put(CSP_dwConnIP); return buf.ToByteArray(); }
protected override void PutBody(ByteBuffer buf) { byte[] data = new byte[16]; byte[] QQBytes = Utils.Util.GetBytes(user.QQ.ToString()); Array.Copy(QQBytes,data,QQBytes.Length); buf.Put(data); #if DEBUG Client.LogManager.Log(ToString() + " UnBody:" + Utils.Util.ToHex(buf.ToByteArray())); #endif }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " Decoded Data:" + Utils.Util.ToHex(buf.ToByteArray())); #endif buf.GetChar();//length or sth.. ReplyCode = buf.Get(); int len = 0; switch (ReplyCode) { case 0x00://success! Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " Login Success!"); len = buf.GetChar();//0x0020 Client.QQUser.QQKey.LoginInfo_Token = buf.GetByteArray(len); Client.QQUser.QQKey.LoginInfo_UnknowData = buf.GetByteArray(4); //buf.GetInt() Client.ServerTime = buf.GetByteArray(4); len = buf.GetChar(); Client.QQUser.QQKey.LoginInfo_Data_Token = buf.GetByteArray(len); len = buf.GetChar(); Client.QQUser.QQKey.LoginInfo_Magic_Token = buf.GetByteArray(len); Client.QQUser.QQKey.LoginInfo_Key1 = buf.GetByteArray(16); buf.GetChar();//0x00 00 if (buf.Position + 3 < buf.Length)//判断来的包是否包含LoginInfo_Key3 因为有的版本没这个key 应该说本人用的正式版本没这个 { Client.QQUser.QQKey.LoginInfo_Key3 = buf.GetByteArray(16); #if DEBUG Client.LogManager.Log(ToString() + "Client.QQUser.QQKey.LoginInfo_Key3:" + Utils.Util.ToHex(Client.QQUser.QQKey.LoginInfo_Key3)); #endif } buf.GetChar();//0x00 00 return; case 0x33: case 0x51://denied! Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " Denied!"); break; case 0xBF: Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " No this QQ number!"); break; case 0x34: Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " Wrong password!"); break; default: Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " Unknow ReplyCode!"); break; } buf.Position = 11; len =(int) buf.GetChar(); byte[] data = buf.GetByteArray(len); ReplyMessage = Utils.Util.GetString(data); Client.LogManager.Log(ToString() + ":0x" + ReplyCode.ToString("X2") + " Message Data(UTF-8): "+Utils.Util.ToHex(data)+"-->" + ReplyMessage); }
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 ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif FriendQQ = buf.GetInt(); ReplyCode = (ReplyCode)buf.Get(); if (ReplyCode == ReplyCode.OK) { AuthCode = (AuthType)buf.Get(); } }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif buf.Get();//00 Onlines = buf.GetInt(); IP = Utils.Util.GetIpStringFromBytes(buf.GetByteArray(4));//client ip Port = (int)buf.GetChar(); buf.GetChar();//unknown 00 3c ServerTime = Utils.Util.GetDateTimeFromMillis(buf.GetInt() * 1000L); Client.LogManager.Log(ToString() + " Onlines:" +Onlines.ToString()+" IP:"+IP+" ServerTime:"+ServerTime.ToString()); }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " Decoded Data:" + Utils.Util.ToHex(buf.ToByteArray())); #endif buf.GetChar();//01 66 length or sth... buf.GetChar();//01 00 Client.QQUser.QQKey.LoginInfo_Key2 = buf.GetByteArray(16); buf.Position += 8;//00 00 00 01 00 00 00 64 Client.QQUser.QQKey.LoginInfo_UnknowData2 = buf.GetByteArray(4); Client.ServerTime = buf.GetByteArray(4); Client.ClientIP = buf.GetByteArray(4); buf.GetInt();//00000000 int len = (int)buf.GetChar(); Client.QQUser.QQKey.LoginInfo_Large_Token = buf.GetByteArray(len); buf.GetInt();//???? len = (int)buf.Get(); NickName = Utils.Util.GetString(buf.GetByteArray(len)); Client.LogManager.Log(ToString() + ": Hello," + NickName); }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif ReplyCode = buf.Get(); buf.GetInt(); switch (ReplyCode) { case 0x88: buf.GetInt();//00000003 unknown this.Level = buf.GetUShort(); this.ActiveDays = buf.GetUShort(); buf.GetChar();//unknown this.UpgradeDays = buf.GetUShort(); Client.LogManager.Log(ToString() + " " + string.Format("level:{0} active_days:{1} upgrade_days:{2}", this.Level, this.ActiveDays, this.UpgradeDays)); break; default: Client.LogManager.Log(ToString()+"unknown ReplyCode:0x"+ReplyCode.ToString("X")); break; } }
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 ParseBody(ByteBuffer buf) { ReplyCode = (ReplyCode)buf.Get(); switch (ReplyCode) { case ReplyCode.OK: // 001-016字节是session key SessionKey = buf.GetByteArray(QQGlobal.QQ_LENGTH_KEY); // 017-020字节是用户QQ号 buf.GetUInt(); // 021-024字节是服务器探测到的用户IP IP = buf.GetByteArray(4); // 025-026字节是服务器探测到的用户端口 Port = buf.GetUShort(); // 027-030字节是服务器自己的IP ServerIP = buf.GetByteArray(4); // 031-032字节是服务器的端口 ServerPort = buf.GetUShort(); // 033-036字节是本次登陆时间,为什么要乘1000?因为这个时间乘以1000才对,-_-!... LoginTime = (long)buf.GetUInt() * 1000L; // 037-038, 未知的2字节 buf.GetUShort(); // 039-062, 认证令牌 AuthToken = buf.GetByteArray(24); // 063-066字节是一个未知服务器1的ip // 067-068字节是一个未知服务器1的端口 // 069-072是一个未知服务器2的ip // 073-074是一个未知服务器2的端口 // 075-076是两个未知字节 // 077-078是两个未知字节 buf.GetByteArray(buf.Position + 16); // 079-110是client key,这个key用在比如登录QQ家园之类的地方 ClientKey = buf.GetByteArray(32); // 111-122是12个未知字节 buf.GetByteArray(buf.Position + 12); // 123-126是上次登陆的ip LastLoginIP = buf.GetByteArray(4); // 127-130是上次登陆的时间 LastLoginTime = (long)buf.GetUInt() * 1000L; // 39个未知字节 // do nothing break; case ReplyCode.LOGIN_REDIRECT: // 登陆重定向,可能是为了负载平衡 // 001-004字节是用户QQ号 buf.GetUInt(); // 005-008字节是重定向到的服务器IP RedirectIP = buf.GetByteArray(4); // 009-010字节是重定向到的服务器的端口 RedirectPort = buf.GetUShort(); break; case ReplyCode.LOGIN_FAIL: // 登录失败,我们得到服务器发回来的消息 byte[] b = buf.ToByteArray(); ReplyMessage = Utils.Util.GetString(b, 1, b.Length - 1); break; } }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif buf.Position += 10; // 当前好友列表位置 Position = buf.GetUShort(); Finished = Position == 0xFFFF; buf.Position += 5; // 只要还有数据就继续读取下一个friend结构 Friends = new List<QQFriend>(); while (buf.Position+5<buf.Length) { int qq = buf.GetInt(); QQFriend friend=Client.QQUser.Friends.Get(qq); if(friend==null) friend=Client.QQUser.Friends.Add(qq); friend.Read(buf); Friends.Add(friend); } }
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) { 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 }
/// <summary> /// 解析包体,从buf的开头位置解析起 /// <remark>abu 2008-02-18 </remark> /// </summary> /// <param name="buf">The buf.</param> protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif Empty = false; // 检查消息长度,至少要有16字节,因为我们需要前16字节做为确认发回 if (buf.Remaining() < 16) { throw new PacketParseException("收到的消息太短,抛弃该消息"); } // 得到前16个字节用作回复 Reply = buf.GetByteArray(16); // 读取消息头 buf.Position = 0; Header = new ReceiveIMHeader(); Header.Read(buf); // 检查输入流可用字节 if (!buf.HasRemaining()) { Empty = true; return; } // 判断消息类型 int len = 0; switch (Header.Type) { case RecvSource.FRIEND_0801: //手机消息 buf.Position += 10;//buf.GetInt(); ParseNormalIM(buf); break; case RecvSource.FRIEND_0802: ParseNormalIM(buf); break; case RecvSource.FRIEND_09: buf.Position += 11; ParseNormalIM(buf); break; case RecvSource.FRIEND_09SP1: buf.Position += 2; int len1 = buf.GetUShort(); buf.Position += len1; ParseNormalIM(buf); break; case RecvSource.STRANGER: /* 是从好友或者陌生人处发来的消息 */ ParseNormalIM(buf); break; case RecvSource.TEMP_SESSION: TempSessionIM = new TempSessionIM(); TempSessionIM.Read(buf); break; case RecvSource.SYS_MESSAGE: /* 是系统消息 */ buf.GetInt();//00 00 00 00 ParseSystemMessage(buf); break; case RecvSource.CLUSTER_09: /* 群消息09 */ ParseClusterIM09(buf); break; case RecvSource.CLUSTER: /* 群消息 */ ParseClusterIM(buf); break; case RecvSource.TEMP_CLUSTER: /* 临时群消息 */ ParseTempClusterIM(buf); break; case RecvSource.UNKNOWN_CLUSTER: ParseUnknownClusterIM(buf); break; case RecvSource.BIND_USER: SMS = new SMS(); SMS.ReadBindUserSMS(buf); break; case RecvSource.MOBILE_QQ: SMS = new SMS(); SMS.ReadMobileQQSMS(buf); break; case RecvSource.MOBILE_QQ_2 : SMS = new SMS(); SMS.ReadMobileQQ2SMS(buf); break; case RecvSource.MOBILE: SMS = new SMS(); SMS.ReadMobileSMS(buf); break; case RecvSource.CREATE_CLUSTER: case RecvSource.ADDED_TO_CLUSTER: case RecvSource.DELETED_FROM_CLUSTER: ExternalId = buf.GetInt(); ClusterType = (ClusterType)buf.Get(); Sender = buf.GetInt(); break; case RecvSource.APPROVE_JOIN_CLUSTER: case RecvSource.REJECT_JOIN_CLUSTER: case RecvSource.REQUEST_JOIN_CLUSTER: ExternalId = buf.GetInt(); ClusterType = (ClusterType)buf.Get(); Sender = buf.GetInt(); len = buf.Get() & 0xFF; byte[] b = buf.GetByteArray(len); Message = Utils.Util.GetString(b); break; case RecvSource.CLUSTER_NOTIFICATION: ExternalId = buf.GetInt(); ClusterType = (ClusterType)buf.Get(); OpCode = buf.Get(); MemberQQ = buf.GetInt(); Role = buf.Get(); Sender = ExternalId; break; case RecvSource.SIGNATURE_CHANGE: SignatureOwner = buf.GetInt(); ModifiedTime = buf.GetInt(); len = buf.Get() & 0xFF; Signature = Utils.Util.GetString(buf, len); break; case RecvSource.QQLIVE: QQLive = new QQLive(); QQLive.Read(buf); break; case RecvSource.MEMBER_LOGIN_HINT: buf.Get(); break; case RecvSource.CUSTOM_HEAD_CHANGE: int count = buf.Get() & 0xFF; if (count > 0) { HeadChanges = new List<CustomHead>(); while (buf.HasRemaining()) { CustomHead change = new CustomHead(); change.Read(buf); HeadChanges.Add(change); } } break; case RecvSource.PROPERTY_CHANGE : PropertyChange = new UserPropertyChange(); PropertyChange.Read(buf); break; case RecvSource.INPUT_STATE_CHANGE: //输入状态 buf.GetInt();//00 00 00 00 Sender = buf.GetInt();//09 58 8C 87 buf.Get();//00 break; default: // 其他类型的消息我们现在没有办法处理,忽略 Client.LogManager.Log(ToString() + " Unknown RecvSource=0x" + Header.Type.ToString("X")); break; } }
protected override void ParseBody(ByteBuffer buf) { //怎么我得到的数据是//01 00 05 00 00 20 78 09 D7 43 99 8B DD 87 59 82 EA 85 7D 09 9A B2 92 77 53 5B 6D E3 6C B6 66 B3 21 75 6B 0B 37 85 #if DEBUG Client.LogManager.Log(ToString() + " Decoded Data:" + Utils.Util.ToHex(buf.ToByteArray())); #endif ReplyCode = buf.Get();//03: ok 04: need verifying 可是我得到的是01是由于前面错了了一个byte buf.Get();//0x00 buf.Get();//0x05 Png_Data = buf.Get(); int len = 0; if (Png_Data == 0x00 && ReplyCode == 0x01) { len = (int)buf.Get(); while (len == 0) { len = (int)buf.Get(); } } else //ReplyCode != 0x01按下面走 兼容多版本 { buf.GetInt();//需要验证码时为00 00 01 23,不需要时为全0 len=(int)buf.GetChar(); } Answer_Token = buf.GetByteArray(len); if (Png_Data== 0x01)//有验证码数据 { len = (int)buf.GetChar(); byte[] data = buf.GetByteArray(len); buf.Get(); Next = buf.Get(); string directory = Utils.Util.MapPath("/Verify/"); this.CodeFileName = Path.Combine(directory, Client.QQUser.QQ + ".png"); FileStream fs=null; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } if (Next != 0x00) { fs = new FileStream(this.CodeFileName, FileMode.Create, FileAccess.ReadWrite, FileShare.Read); } else fs = new FileStream(this.CodeFileName, FileMode.Append, FileAccess.Write, FileShare.Read); //fs.Seek(0, SeekOrigin.End); fs.Write(data,0,data.Length); fs.Close(); fs=null; len = (int)buf.GetChar(); Png_Token = buf.GetByteArray(len); } // if (Png_Data!=0x00) { if (Next!=0x00) { //prot_login_request(qq, &png_token, 0, 1); Client.LogManager.Log("接收到部分验证码图片数据,继续接收...."); OutPacket outPacket = new LoginRequestPacket(Client, Png_Token, 0, 1);//发送一个请求验证码的包 Client.PacketManager.SendPacketAnyway(outPacket, QQPort.Main.Name); } else { //qq->data.verify_token = answer_token; //qqclient_set_process(qq, P_VERIFYING); Client.LoginStatus = LoginStatus.NeedVerifyCode; Client.QQUser.QQKey.Verify_Token = Answer_Token; Client.LogManager.Log("Need input Verify Code"); //Client.LoginManager.OnLoginNeedVerifyCode(e); } } else { //DBG("process verify password"); //qq->data.token_c = answer_token; //prot_login_verify(qq); Client.LogManager.Log("Process LoginRequest Success! Now Process Verify Password..."); Client.QQUser.QQKey.Answer_Token = Answer_Token; OutPacket outPacket = new LoginVerifyPacket(Client);//发送一个登陆请求包 Client.PacketManager.SendPacketAnyway(outPacket, QQPort.Main.Name); } }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " Decoded data:" + Utils.Util.ToHex(buf.ToByteArray())); #endif //byte result = buf.Get(); IsRedirect = false; ReplyCode = (ReplyCode)buf.Get(); if (ReplyCode == ReplyCode.OK) { ServerTime = buf.GetByteArray(4); ClientIP = buf.GetByteArray(4); buf.Position += 9; int len = (int)buf.Get(); Token = buf.GetByteArray(len); byte result=buf.Get(); if (result != 0x00) { IsRedirect = true; Client.LoginRedirect = true; Client.ServerInfo.CSP_wRedirectCount = result; Client.ServerInfo.CSP_cRedirectCount = buf.Get(); Client.ServerInfo.CSP_dwConnIspID = buf.GetByteArray(4); Client.ServerInfo.CSP_dwServerReserve = buf.GetByteArray(4); RedirectIP=buf.GetByteArray(4); Client.ServerInfo.CSP_dwConnIP =RedirectIP ; } } else { Client.LogManager.Log(string.Format(ToString() + " ReplyCode!=ReplyCode.OK: {0:X}", ReplyCode)); } }