Пример #1
0
        public static List <string> GetGroupMemberlist(byte[] BytesIn)
        {
            List <string> list = new List <string>();

            BytesIn = BytesIn.Skip(4).ToArray();
            JceStruct.StartDecode(BytesIn);
            if (JceStruct.DicSimpleList.Count > 0)             //取SimpleList
            {
                var hex = JceStruct.DicSimpleList[0].ElementAt(0).Value;
                JceStruct.StartDecode(API.HexStrToByteArray(hex));
                if (JceStruct.DicMAP.Count > 0)                 //取Map
                {
                    hex = JceStruct.DicMAP[0].ElementAt(0).Value.Item2;
                    JceStruct.StartDecode(API.HexStrToByteArray(hex));
                    if (JceStruct.DicList.Count > 0)                     //取List
                    {
                        for (var i = 0; i < JceStruct.DicList.Count; i++)
                        {
                            var info = JceStruct.DicList[i].ElementAt(0).Value.Trim().Split('/');
                            if (info.Count() < 42)
                            {
                                break;
                            }
                            list.Add(info[0] + "(" + info[4] + ")");
                        }
                        SDK.GetValue(list);
                    }
                }
            }
            return(list);
        }
Пример #2
0
        public static void DeleteGroup(long thisQQ, long GroupId)
        {
            var bytes = JceStruct.writeFlag(JceStruct.JceType.TYPE_STRUCT_BEGIN, 0);

            bytes = bytes.Concat(JceStruct.writeByte(9, 0)).ToArray();
            bytes = bytes.Concat(JceStruct.writeLong(thisQQ, 1)).ToArray();
            bytes = bytes.Concat(JceStruct.writeSimpleList(API.HexStrToByteArray(GroupId.ToString("X")).Concat(API.QQ.user).ToArray(), 2)).ToArray();
            bytes = bytes.Concat(JceStruct.writeZero(3)).ToArray();
            bytes = bytes.Concat(JceStruct.writeString("", 4)).ToArray();
            bytes = bytes.Concat(JceStruct.writeZero(5)).ToArray();
            bytes = bytes.Concat(JceStruct.writeZero(6)).ToArray();
            bytes = bytes.Concat(JceStruct.writeZero(7)).ToArray();
            bytes = bytes.Concat(JceStruct.writeZero(8)).ToArray();
            bytes = bytes.Concat(JceStruct.writeZero(9)).ToArray();
            bytes = bytes.Concat(JceStruct.writeZero(10)).ToArray();
            bytes = bytes.Concat(JceStruct.writeString("", 11)).ToArray();
            bytes = bytes.Concat(JceStruct.writeString("", 12)).ToArray();
            bytes = bytes.Concat(JceStruct.writeFlag(JceStruct.JceType.TYPE_STRUCT_END, 0)).ToArray();
            var dic = new Dictionary <object, object>()
            {
                { "GroupMngReq", bytes }
            };

            bytes = JceStruct.writeMap(dic, 0);
            //Debug.Print("解散群:" + Environment.NewLine + BitConverter.ToString(bytes).Replace("-", " "))
            bytes = JceStructSDK.Pack_HeadJce(API.QQ.mRequestID, "KQQ.ProfileService.ProfileServantObj", "GroupMngReq", bytes);
            bytes = API.PackCmdHeader("ProfileService.GroupMngReq", bytes);
            API.TClient.SendData(API.PackAllHeader(bytes));
        }
Пример #3
0
        public static byte[] PackFriendMsg(byte[] bytesIn)
        {
            var timeStamp = Convert.ToInt64(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds);
            var Str = "model:" + API.Device.model + ";os:22;version:v2man:" + API.Device.brands + "sys:LYZ28N";
            var bytes1 = new byte[] { 8, 0, 0x12 }.Concat(BitConverter.GetBytes(Str.Length).ToArray().Take(1).ToArray()).ToArray().Concat(Encoding.UTF8.GetBytes(Str)).ToArray();

            bytes1 = bytes1.Concat(new byte[] { 0x18 }).ToArray();
            bytes1 = bytes1.Concat(GetBytesFromLong(timeStamp + 0x18).Skip(1).ToArray()).ToArray();
            bytes1 = bytes1.Concat(new byte[] { 0x20 }).ToArray();
            bytes1 = bytes1.Concat(GetBytesFromLong(timeStamp + 0x20).Skip(1).ToArray()).ToArray();
            bytes1 = bytes1.Concat(new byte[] { 0x28 }).ToArray();
            bytes1 = bytes1.Concat(GetBytesFromLong(timeStamp + 0x28).Skip(1).ToArray()).ToArray();
            bytes1 = bytes1.Concat(new byte[] { 0x30 }).ToArray();
            bytes1 = bytes1.Concat(GetBytesFromLong(timeStamp + 0x30).Skip(1).ToArray()).ToArray();

            API.QQ.SyncCoookies = bytes1;

            var bytes2 = Encoding.UTF8.GetBytes("MessageSvc.PbGetMsg");

            bytes2 = bytes2.Concat(new byte[] { 0, 0, 0, 8 }).ToArray();
            bytes2 = bytes2.Concat(bytesIn).ToArray();
            bytes2 = bytes2.Concat(BitConverter.GetBytes(bytes1.Length + 4).Reverse().ToArray()).ToArray().Concat(bytes1).ToArray();
            bytes2 = new byte[] { 0, 0, 0, 0x17 }.ToArray().Concat(bytes2).ToArray();
            var bytes = BitConverter.GetBytes(bytes2.Length + 4).Reverse().ToArray().Concat(bytes2).ToArray();

            var bytes3 = new byte[] { 8 }.Concat(GetBytesFromLong(timeStamp).Skip(2).ToArray()).ToArray().Concat(new byte[] { 0x10 }).ToArray().Concat(GetBytesFromLong(timeStamp + 0x10).Skip(2).ToArray()).ToArray();

            bytes3 = bytes3.Concat(API.HexStrToByteArray("18DE8DA980032082D7E1BA0C28E482B9DC0A48A8D28AC6015896A182DE076051")).ToArray();
            bytes3 = bytes3.Concat(new byte[] { 0x68 }).ToArray().Concat(GetBytesFromLong(timeStamp).Skip(2).ToArray()).ToArray();
            bytes3 = bytes3.Concat(new byte[] { 0x70, 0 }).ToArray();
            bytes3 = BitConverter.GetBytes(Convert.ToInt16(bytes3.Length)).ToArray().Take(1).ToArray().Concat(bytes3).ToArray();

            var bytes4 = new byte[] { 8, 0, 0x12 }.Concat(bytes3).ToArray().Concat(new byte[] { 0x18, 0, 0x20, 0x14, 0x28, 3, 0x30, 1, 0x38, 1, 0x48, 0, 0x62, 0 }).ToArray();
            var bytes4Len = BitConverter.GetBytes(bytes4.Length + 4).Reverse().ToArray();

            bytes = bytes.Concat(bytes4Len).ToArray().Concat(bytes4).ToArray();

            Debug.Print("通知好友消息:" + bytes.Length.ToString() + "\r\n" + BitConverter.ToString(bytes).Replace("-", " "));
            HashTea Hash = new HashTea();

            byte[] encodeByte = Hash.HashTEA(bytes, API.UN_Tlv.T305_SessionKey, 0, true);
            API.QQ.mRequestID = API.QQ.mRequestID + 1;
            return(PackHeader(encodeByte, 3));
        }
Пример #4
0
 public static void ReplyConfigPushSvc(byte[] BytesIn, int ssoseq)
 {
     JceStruct.StartDecode(BytesIn);
     if (JceStruct.DicSimpleList.Count > 0)
     {
         var Hex = JceStruct.DicSimpleList[0].ElementAt(0).Value;
         JceStruct.StartDecode(API.HexStrToByteArray(Hex));
         if (JceStruct.DicSimpleList.Count > 0)
         {
             Hex = JceStruct.DicSimpleList[0].ElementAt(0).Value;
             JceStruct.StartDecode(API.HexStrToByteArray(Hex));
             byte P1 = new byte();
             long P2 = 0;
             if (JceStruct.DicByte.Count > 0)
             {
                 byte.TryParse(JceStruct.DicByte[0].ElementAt(0).Value, out P1);
                 if (P1 != 2)
                 {
                     return;
                 }
             }
             if (JceStruct.DicInt.Count > 0)
             {
                 P2 = int.Parse(JceStruct.DicInt[0].ElementAt(0).Value);
             }
             else if (JceStruct.DicLong.Count > 0)
             {
                 P2 = long.Parse(JceStruct.DicLong[0].ElementAt(0).Value);
             }
             var bytes = JceStruct.writeFlag(JceStruct.JceType.TYPE_STRUCT_BEGIN, 0);
             bytes = bytes.Concat(JceStruct.writeByte(P1, 1)).ToArray();
             bytes = bytes.Concat(JceStruct.writeLong(P2, 2)).ToArray();
             var dic = new Dictionary <object, object>()
             {
                 { "PushResp", bytes }
             };
             bytes = JceStruct.writeMap(dic, 1);
             Debug.Print("ReplyConfigPushSvc:" + bytes.Length.ToString() + "\r\n" + BitConverter.ToString(bytes).Replace("-", " "));
             bytes = JceStructSDK.Pack_HeadJce(API.QQ.mRequestID, "QQService.ConfigPushSvc.MainServant", "PushResp", bytes);
             bytes = API.PackCmdHeader("ConfigPushSvc.PushResp", bytes);
             API.TClient.SendData(API.PackAllHeader(bytes));
         }
     }
 }
Пример #5
0
        public static API.ECDH_Struct GetECDHKeys()
        {
            API.ECDH_Struct ECDH       = new API.ECDH_Struct();
            byte[]          PrivateKey = new byte[1024];
            byte[]          PublicKey  = new byte[1024];
            byte[]          Sharekey   = new byte[16];
            byte[]          SvrPubKey  = API.HexStrToByteArray("04EBCA94D733E399B2DB96EACDD3F69A8BB0F74224E2B44E3357812211D2E62EFBC91BB553098E25E33A799ADC7F76FEB208DA7C6522CDB0719A305180CC54A82E");
            var             eckey      = OpenSSL.EC_KEY_new_by_curve_name(415);

            if (eckey == IntPtr.Zero)
            {
                return(ECDH);
            }
            var res          = OpenSSL.EC_KEY_generate_key(eckey);
            var ec_group     = OpenSSL.EC_KEY_get0_group(eckey);
            var ec_point     = OpenSSL.EC_KEY_get0_public_key(eckey);
            var PublicKeyLen = OpenSSL.EC_POINT_point2oct(ec_group, (System.IntPtr)ec_point, 4, PublicKey, 65, (System.IntPtr) 0);

            Array.Resize(ref PublicKey, PublicKeyLen);
            ECDH.PublicKey = PublicKey;
            ec_point       = (int)OpenSSL.EC_KEY_get0_private_key(eckey);
            var PrivateKeyLen = OpenSSL.BN_bn2mpi((System.IntPtr)ec_point, PrivateKey);

            Array.Resize(ref PrivateKey, (System.Int32)PrivateKeyLen);
            ECDH.PrivateKey = PrivateKey;
            eckey           = OpenSSL.EC_KEY_new_by_curve_name(415);
            if (eckey == IntPtr.Zero)
            {
                return(ECDH);
            }
            var bn = OpenSSL.BN_new();

            OpenSSL.BN_mpi2bn(ECDH.PrivateKey, ECDH.PrivateKey.Length, bn);
            OpenSSL.EC_KEY_set_private_key(eckey, bn);
            OpenSSL.BN_free(bn);
            ec_group = OpenSSL.EC_KEY_get0_group(eckey);
            ec_point = (int)OpenSSL.EC_POINT_new(ec_group);
            OpenSSL.EC_POINT_oct2point(ec_group, (System.IntPtr)ec_point, SvrPubKey, SvrPubKey.Length, (System.IntPtr) 0);
            OpenSSL.ECDH_compute_key(Sharekey, 16, (System.IntPtr)ec_point, eckey, IntPtr.Zero);
            ECDH.Sharekey = API.MD5Hash(Sharekey);
            return(ECDH);
        }
Пример #6
0
 public static void GetSimpleInfo(byte[] BytesIn)
 {
     BytesIn = BytesIn.Skip(4).ToArray();
     JceStruct.StartDecode(BytesIn);
     if (JceStruct.DicSimpleList.Count > 0)
     {
         var hex = JceStruct.DicSimpleList[0].ElementAt(0).Value;
         JceStruct.StartDecode(API.HexStrToByteArray(hex));
         if (JceStruct.DicMAP.Count > 0)
         {
             hex = JceStruct.DicMAP[0].ElementAt(0).Value.Item2;
             JceStruct.StartDecode(API.HexStrToByteArray(hex));
             if (JceStruct.DicList.Count > 0)
             {
                 var info = JceStruct.DicList[0].ElementAt(0).Value.Trim().Split('/');
                 API.NickName = info[4];
                 List <string> list = new List <string> {
                     info[0], info[4], info[3], (info[5] == "0")?"女":"男", info[12], info[14]
                 };
                 SDK.GetValue(list);
             }
         }
     }
 }
Пример #7
0
        public static void Initialization(string Account, string Password)
        {
            API.QQ.Account = Account;
            API.QQ.LongQQ  = long.Parse(API.QQ.Account);
            API.QQ.UTF8    = Encoding.UTF8.GetBytes(API.QQ.Account);
            API.QQ.user    = API.HexStrToByteArray(API.QQ.LongQQ.ToString("X"));
            API.QQ.pass    = Password;
            API.QQ.md5_1   = API.MD5Hash(Encoding.UTF8.GetBytes(API.QQ.pass));
            byte[] md5_byte = API.QQ.md5_1.Concat(new byte[] { 0, 0, 0, 0 }).Concat(API.QQ.user).ToArray();
            API.QQ.md5_2 = API.MD5Hash(md5_byte);
            API.ECDH_Struct _ECDH = ECDH.GetECDHKeys();
            API.QQ.pub_key  = _ECDH.PublicKey;
            API.QQ.shareKey = _ECDH.Sharekey;
            API.QQ.prikey   = _ECDH.PrivateKey;

            API.QQ.mRequestID = 10000;
            API.QQ.key        = new byte[16];
            var timestampHex = ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000).ToString();

            API.QQ.login_Time = API.HexStrToByteArray(int.Parse(timestampHex).ToString("X"));


            API.QQ.TGTKey        = API.MD5Hash(API.QQ.pub_key);
            API.QQ.randKey       = API.MD5Hash(API.QQ.shareKey);
            API.QQ.MsgCookies    = API.GetRandByteArray(4);
            API.QQ.Appid         = 537065990;
            API.UN_Tlv.T108_ksid = API.HexStrToByteArray("93AC689396D57E5F9496B81536AAFE91");
            var          timestamp      = long.Parse(Convert.ToInt64(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds).ToString().Substring(0, 10));
            SyncCoookies SyncTimeStruct = new SyncCoookies
            {
                timestamp1 = timestamp,
                timestamp2 = timestamp,
                timestamp3 = timestamp,
                Field3     = 805979870,
                Field4     = 3344460674,
                Field5     = 82343012,
                Field6     = 3281833389,
                Field7     = 2696570484,
                Field8     = 81,
                Field10    = 0
            };

            using (var ms = new MemoryStream())
            {
                Serializer.Serialize(ms, SyncTimeStruct);
                API.QQ.SyncCoookies = ms.ToArray();
            }

            API.Device.imei         = "865166024867445";
            API.Device.Imsi         = "460001330114682";
            API.Device.WIFIByteSSID = API.MD5Hash(Encoding.UTF8.GetBytes("5c:11:21:11:19:1f"));
            API.Device.WIFISSID     = "dlb";
            API.Device.Ver          = "|" + API.Device.imei + "|A8.5.0.4003a808";    //手机串号加QQ版本
            API.Device.Version      = Encoding.UTF8.GetBytes("A8.5.0.4003a808");
            API.Device.MacBytes     = Encoding.UTF8.GetBytes("DA-EB-D5-1C-7B-CD");
            API.Device.MacId        = "84:18:38:38:96:36";
            API.Device.GUIDBytes    = API.MD5Hash(Encoding.UTF8.GetBytes("b7981398-337d-4d2c-ab64-22b5b6f297dc"));
            API.Device.AndroidID    = API.MD5Hash(Encoding.UTF8.GetBytes("95dcc49a9434f65a"));
            API.Device.AppId        = 537042771;
            API.Device.os_type      = "android";        //'安卓版本
            API.Device.os_version   = "5.1.1";
            API.Device.network_type = "China Mobile GSM";
            API.Device.apn          = "wifi";
            API.Device.model        = "oppo r9 plustm a";                                                                                            //手机型号
            API.Device.brands       = "oppo";                                                                                                        //手机品牌
            API.Device.Apk_Id       = "com.tencent.mobileqq";
            API.Device.Apk_V        = "8.5.0";                                                                                                       //安卓版本
            API.Device.ApkSig       = new byte[] { 0xA6, 0xB7, 0x45, 0xBF, 0x24, 0xA2, 0xC2, 0x77, 0x52, 0x77, 0x16, 0xF6, 0xF3, 0x6E, 0xB6, 0x8D }; //固定app_sign
        }