Exemplo n.º 1
0
        public static void SendPrivateXmlMsg(long thisQQ, long sendQQ, string xmlMsg)
        {
            API.ThisQQ = thisQQ;
            API.SendQQ = sendQQ;
            var zipByte = API.CompressData(Encoding.UTF8.GetBytes(xmlMsg));

            FriendMsg.SendFriendMsg(thisQQ, sendQQ, zipByte, API.MsgType.XmlMsg);
        }
Exemplo n.º 2
0
 public static void PrivateMsgWithdraw(long sendQQ, long MsgReqId, long MsgTimeStamp, long MsgRandomId = 0)
 {
     API.SendQQ = sendQQ;
     FriendMsg.WithdrawFriendMsg(sendQQ, MsgReqId, MsgTimeStamp, MsgRandomId);
 }
Exemplo n.º 3
0
 public static API.FriendWithdrawInfo SendPrivateMsg(long thisQQ, long sendQQ, string szMsg)
 {
     API.ThisQQ = thisQQ;
     API.SendQQ = sendQQ;
     return(FriendMsg.SendFriendMsg(thisQQ, sendQQ, Encoding.UTF8.GetBytes(szMsg), API.MsgType.TextMsg));
 }
Exemplo n.º 4
0
        public static byte[] UnPackReceiveData(byte[] ReceiveData)
        {
            if (ReceiveData.Length == 0)
            {
                return(null);
            }
            byte[] teaBytes = null;
            try
            {
                UpdateSyncCoookies();
                Debug.Print("收到包:" + ReceiveData.Length.ToString() + "\r\n" + BitConverter.ToString(ReceiveData).Replace("-", " "));
                var packType   = ReceiveData.Skip(7).Take(1).ToArray()[0];
                var encrptType = ReceiveData.Skip(8).Take(1).ToArray()[0];
                int pos        = API.SearchBytes(ReceiveData, API.QQ.UTF8);

                var bytes = ReceiveData.Skip(pos + API.QQ.UTF8.Length).ToArray();
                teaBytes = bytes;
                HashTea Hash = new HashTea();

                if (packType == 0xB && packType == 9)
                {
                    if (encrptType == 1)
                    {
                        bytes = Hash.UNHashTEA(bytes, API.QQ.key, 0, true);
                    }
                    else if (encrptType == 2)
                    {
                        bytes = Hash.UNHashTEA(bytes, API.QQ.shareKey, 0, true);
                    }
                }
                else if (packType == 0xA && packType == 8)
                {
                    if (encrptType == 1)
                    {
                        bytes = Hash.UNHashTEA(bytes, API.QQ.shareKey, 0, true);
                    }
                    else if (encrptType == 2)
                    {
                        bytes = Hash.UNHashTEA(bytes, API.QQ.key, 0, true);
                    }
                }
                else if (packType == 0xA && packType == 10)
                {
                    if (encrptType == 1)
                    {
                        bytes = Hash.UNHashTEA(bytes, API.UN_Tlv.T305_SessionKey, 0, true);
                    }
                    else if (encrptType == 2)
                    {
                        bytes = Hash.UNHashTEA(bytes, API.QQ.key, 0, true);
                    }
                }
                else
                {
                    bytes = Hash.UNHashTEA(bytes, API.UN_Tlv.T305_SessionKey, 0, true);
                }

                Debug.Print("解密后:" + bytes.Length.ToString() + "\r\n" + BitConverter.ToString(bytes).Replace("-", " "));

                //取出第一层包头中的包长度值
                if (BitConverter.ToInt16(bytes.Take(2).ToArray(), 0) != 0)
                {
                    Debug.Print("未解析" + "\r\n" + BitConverter.ToString(teaBytes).Replace("-", " "));
                    Debug.Print("ShareKey" + "\r\n" + BitConverter.ToString(API.QQ.shareKey).Replace("-", " "));
                    Debug.Print("SessionKey" + "\r\n" + BitConverter.ToString(API.UN_Tlv.T305_SessionKey).Replace("-", " "));
                    return(null);
                }
                var    head1_len = BitConverter.ToInt32(bytes.Take(4).ToArray().Reverse().ToArray(), 0);
                byte[] bodyBytes = bytes.Skip(head1_len).ToArray();
                Debug.Print("主包体:" + bodyBytes.Length.ToString() + "\r\n" + BitConverter.ToString(bodyBytes).Replace("-", " "));
                if (head1_len > 4)
                {
                    bytes = bytes.Skip(4).Take(head1_len - 4).ToArray();
                    bytes = bytes.Skip(4).ToArray();
                    if (bytes.Skip(4).Take(4).ToArray() == new byte[] { 0, 0, 0, 0 })
                    {
                        bytes = bytes.Skip(4).ToArray();
                    }
                    else
                    {
                        var head3_len = BitConverter.ToInt32(bytes.Skip(4).Take(4).ToArray().Reverse().ToArray(), 0);
                        bytes = bytes.Skip(head3_len + 4).ToArray();
                    }
                    var str_len = BitConverter.ToInt32(bytes.Take(4).ToArray().Reverse().ToArray(), 0);
                    if (str_len > 4)
                    {
                        var serviceCmd = Encoding.UTF8.GetString(bytes.Skip(4).ToArray(), 0, str_len - 4);
                        if (serviceCmd.Contains("wtlogin.login"))
                        {
                            Debug.Print("收到命令:wtlogin.login");
                            //解析登录包体
                            var status = Un_Pack_Login(bodyBytes);
                            Debug.Print("status:" + status.ToString());
                            if (status == 1)
                            {
                                Debug.Print("wtlogin.login");
                                SDK.GetLog("登录成功");
                                //发上线包
                                API.TClient.SendData(Pack.PackOnlineStatus("StatSvc.register", 0));
                            }
                            else if (status == 0)
                            {
                                Microsoft.VisualBasic.Interaction.MsgBox(API.getLastError(), (Microsoft.VisualBasic.MsgBoxStyle)((int)Microsoft.VisualBasic.Constants.vbInformation + (int)Microsoft.VisualBasic.Constants.vbMsgBoxSetForeground + (int)Microsoft.VisualBasic.Constants.vbSystemModal + (int)Microsoft.VisualBasic.Constants.vbCritical + (int)Microsoft.VisualBasic.Constants.vbInformation), "登录失败");
                            }
                            else if (status == 2)
                            {
                                API.QQ.loginState = (int)API.LoginState.Logining;
                                if (API.UN_Tlv.T143_token_A2 != null && API.QQ.shareKey != null && API.UN_Tlv.T10A_token_A4 != null)
                                {
                                    API.TClient.SendData(Pack.PackOnlineStatus("StatSvc.register", 1));
                                }
                            }
                        }
                        else if (serviceCmd.Contains("PushService.register"))
                        {
                            Debug.Print("服务器注册成功:PushService.register");
                        }
                        else if (serviceCmd.Contains("RegPrxySvc.PushParam"))
                        {
                            Debug.Print("RegPrxySvc.PushParam命令");
                        }
                        else if (serviceCmd.Contains("ConfigPushSvc.PushDomain"))
                        {
                            Debug.Print("成功登录服务器:ConfigPushSvc.PushDomain");
                            SDK.GetLog("上线成功");
                        }
                        else if (serviceCmd.Contains("OnlinePush.ReqPush"))
                        {
                            Debug.Print("OnlinePush.ReqPush系统推送消息、撤回、加好友等");
                        }
                        else if (serviceCmd.Contains("ConfigPushSvc.PushReq"))
                        {
                            Debug.Print("回执ConfigPushSvc.PushReq");
                            JceStructSDK.ReplyConfigPushSvc(bodyBytes, API.QQ.mRequestID);
                        }
                        else if (serviceCmd.Contains("StatSvc.SimpleGet"))
                        {
                            Debug.Print("收到心跳包");
                            SDK.GetHeartBeatResult(true);
                        }
                        else if (serviceCmd.Contains("MessageSvc.PushNotify"))
                        {
                            Debug.Print("通知好友消息:" + bytes.Length.ToString() + "\r\n" + BitConverter.ToString(bytes).Replace("-", " "));
                            bytes = bytes.Reverse().ToArray();
                            var code     = bytes.Skip(15).Take(4).ToArray().Reverse().ToArray();
                            var sendByte = Pack.PackFriendMsg(code);                             //组包获取好友消息
                            API.TClient.SendData(sendByte);
                        }
                        else if (serviceCmd.Contains("MessageSvc.PbGetMsg"))
                        {
                            Debug.Print("收到好友消息");
                            FriendMsg.ParsingFriendMsg(bodyBytes);
                        }
                        else if (serviceCmd.Contains("OnlinePush.PbPushGroupMsg"))
                        {
                            Debug.Print("群聊消息");
                            GroupMsg.ParsingGroupMsg(bodyBytes);
                        }
                        else if (serviceCmd.Contains("MessageSvc.RequestPushStatus"))
                        {
                            Debug.Print("上线下线状态改变");
                        }
                        else if (serviceCmd.Contains("MessageSvc.PushReaded"))
                        {
                            Debug.Print("已读私人消息");
                        }
                        else if (serviceCmd.Contains("OnlinePush.PbC2CMsgSync"))
                        {
                            Debug.Print("发私人消息");
                        }
                        else if (serviceCmd.Contains("RegPrxySvc.PbGetGroupMsg"))
                        {
                            Debug.Print("群消息");
                        }
                        else if (serviceCmd.Contains("RegPrxySvc.PullGroupMsgSeq"))
                        {
                            Debug.Print("拉取群消息Seq");
                        }
                        else if (serviceCmd.Contains("MessageSvc.PbGetOneDayRoamMsg"))
                        {
                            Debug.Print("解析漫游消息");
                        }
                        else if (serviceCmd.Contains("RegPrxySvc.PbSyncMsg"))
                        {
                            Debug.Print("同步历史消息");
                        }
                        else if (serviceCmd.Contains("SSO.HelloPush"))
                        {
                            Debug.Print("回执SSO.HelloPush");
                            Pack.ReplySSOHelloPush(bodyBytes, API.QQ.mRequestID);
                        }
                        else if (serviceCmd.Contains("StatSvc.SvcReqMSFLoginNotify"))
                        {
                            Debug.Print("平板上/下线通知");
                        }
                        else if (serviceCmd.Contains("MessageSvc.RequestPushStatus"))
                        {
                            Debug.Print("电脑上/下线通知");
                        }
                        else if (serviceCmd.Contains("StatSvc.ReqMSFOffline"))
                        {
                            Debug.Print("异常提醒");
                        }
                        else if (serviceCmd.Contains("StatSvc.QueryHB"))
                        {
                            Debug.Print("StatSvc.QueryHB");
                        }
                        else if (serviceCmd.Contains("MessageSvc.PushForceOffline"))
                        {
                            Debug.Print("被顶下线");
                            SDK.GetLog("被顶下线");
                        }
                        else if (serviceCmd.Contains("MessageSvc.PbSendMsg"))
                        {
                            Debug.Print("递增发送信息");
                            API.QQ.mRequestID = API.QQ.mRequestID + 1;
                        }
                        else if (serviceCmd.Contains("OnlinePush.PbC2CMsgSync"))
                        {
                            Debug.Print("同步递增发送信息");
                        }
                        else if (serviceCmd.Contains("OnlinePush.PbPushDisMsg"))
                        {
                            Debug.Print("讨论组消息");
                        }
                        else if (serviceCmd.Contains("OnlinePush.PbPushTransMsg"))
                        {
                            Debug.Print("管理员变动");
                        }
                        else if (serviceCmd.Contains("friendlist.GetTroopListReqV2"))
                        {
                            Debug.Print("群列表");
                            JceStructSDK.GetGrouplist(bodyBytes);
                        }
                        else if (serviceCmd.Contains("friendlist.getFriendGroupList"))
                        {
                            Debug.Print("好友列表");
                            JceStructSDK.GetFriendlist(bodyBytes);
                        }
                        else if (serviceCmd.Contains("friendlist.GetTroopMemberList"))
                        {
                            Debug.Print("群成员列表");
                            JceStructSDK.GetGroupMemberlist(bodyBytes);
                        }
                        else if (serviceCmd.Contains("OidbSvc.0x899_0"))
                        {
                            Debug.Print("群管理列表");
                            ProtoSDK.GetGroupAdminlist(bodyBytes);
                        }
                        else if (serviceCmd.Contains("ProfileService.Pb.ReqSystemMsgNew.Friend"))
                        {
                            Debug.Print("新好友提醒");
                        }
                        else if (serviceCmd.Contains("ProfileService.Pb.ReqNextSystemMsg.Friend"))
                        {
                            Debug.Print("加好友消息提醒");
                        }
                        else if (serviceCmd.Contains("ProfileService.Pb.ReqSystemMsgNew.Group"))
                        {
                            Debug.Print("新群提醒");
                        }
                        else if (serviceCmd.Contains("QualityTest.PushList"))
                        {
                            Debug.Print("回执QualityTest.PushList");
                            Pack.ReplyQualityTest(API.QQ.mRequestID + 1);
                        }
                        else if (serviceCmd.Contains("OnlinePush.SidTicketExpired"))
                        {
                            Debug.Print("回执门票过期");
                        }
                        else if (serviceCmd.Contains("PubAccountSvc.get_follow_list"))
                        {
                            Debug.Print("获取列表");
                        }
                        else if (serviceCmd.Contains("account.RequestQueryQQMobileContactsV3"))
                        {
                            Debug.Print("查询内容");
                        }
                        else if (serviceCmd.Contains("ProfileService.GetSimpleInfo"))
                        {
                            Debug.Print("获取QQ资料信息");
                            JceStructSDK.GetSimpleInfo(bodyBytes);
                        }
                        else if (serviceCmd.Contains("StatSvc.register"))
                        {
                            Debug.Print("注册上线:StatSvc.register");
                        }
                        else if (serviceCmd.Contains("PbMessageSvc.PbMsgReadedReport"))
                        {
                            Debug.Print("已读消息");
                        }
                        else if (serviceCmd.Contains("OidbSvc.0x59f"))
                        {
                            Debug.Print("OidbSvc.0x59f命令");
                            JceStructSDK.GetRegSync_Info();
                        }
                        else if (serviceCmd.Contains("RegPrxySvc.infoSync"))
                        {
                            Debug.Print("RegPrxySvc.infoSync命令");
                        }
                        else if (serviceCmd.Contains("RegPrxySvc.GetMsgV2"))
                        {
                            Debug.Print("RegPrxySvc.GetMsgV2命令");
                        }
                        else if (serviceCmd.Contains("LongConn.OffPicUp"))
                        {
                            Debug.Print("收到图片反馈LongConn.OffPicUp");
                            FriendMsg.SendFriendMsg(API.ThisQQ, API.SendQQ, bodyBytes, API.MsgType.PicMsg);
                        }
                        else if (serviceCmd.Contains("ImgStore.GroupPicUp"))
                        {
                            Debug.Print("收到群图片反馈ImgStore.GroupPicUp");
                            GroupMsg.SendGroupMsg(API.ThisQQ, API.GroupId, bodyBytes, API.MsgType.PicMsg, API.SendQQ);
                        }
                        else if (serviceCmd.Contains("PttStore.GroupPttUp"))
                        {
                            Debug.Print("收到群语音反馈PttStore.GroupPttUp");
                            GroupMsg.SendGroupAudio(bodyBytes, API.FileHash);
                        }
                        else if (serviceCmd.Contains("PttCenterSvr.pb_pttCenter_CMD_REQ_APPLY_UPLOAD-500"))
                        {
                            Debug.Print("收到好友语音反馈PttCenterSvr.pb_pttCenter_CMD_REQ_APPLY_UPLOAD-500");
                            FriendMsg.SendFriendAudio(API.ThisQQ, API.SendQQ, bodyBytes, API.FileHash);
                        }
                        else if (serviceCmd.Contains("PttCenterSvr.pb_pttCenter_CMD_REQ_APPLY_DOWNLOAD-1200"))
                        {
                            Debug.Print("取语音下载地址PttCenterSvr.pb_pttCenter_CMD_REQ_APPLY_DOWNLOAD-1200");
                            //FriendMsg.GetFriendAudioUrl(bodyBytes)
                        }
                        else if (serviceCmd.Contains("PbMessageSvc.PbMsgWithDraw"))
                        {
                            Debug.Print("撤回消息反馈PbMessageSvc.PbMsgWithDraw");
                        }
                        else if (serviceCmd.Contains("SharpSvr.s2c"))
                        {
                            Debug.Print("语音视频电话SharpSvr.s2c");
                        }
                        else
                        {
                            Debug.Print("其他命令" + serviceCmd);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message.ToString());
            }

            return(null);
        }