Esempio n. 1
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
        }
Esempio n. 2
0
        public static int Un_Pack_Login(byte[] bytes)
        {
            var head1_len = BitConverter.ToInt32(bytes.Take(4).ToArray().Reverse().ToArray(), 0);

            bytes = bytes.Skip(4).ToArray();
            bytes = bytes.Skip(1).ToArray();
            var head2_len = Convert.ToInt32(BitConverter.ToInt16(bytes.Take(2).ToArray().Reverse().ToArray(), 0));

            bytes = bytes.Skip(14).ToArray();
            int result = bytes[0];

            Debug.Print("验证类型码:" + result.ToString());
            bytes = bytes.Skip(1).Take(head2_len - 16 - 1).ToArray();
            HashTea Hash = new HashTea();

            bytes = Hash.UNHashTEA(bytes, API.QQ.shareKey, 0, true);
            Debug.Print("Un_Pack_Login:"******"-", " "));
            if (bytes.Take(2).ToArray()[1] == 25)
            {
                var len = BitConverter.ToInt16(bytes.Take(2).ToArray().Reverse().ToArray(), 0);
                bytes = bytes.Skip(2).ToArray();
                var publickey = bytes.Take(len).ToArray();
                bytes = bytes.Skip(len).ToArray();
                var sharekey = ECDH.GetECDHKeysEx(publickey, API.QQ.pub_key, API.QQ.prikey);
                bytes = Hash.UNHashTEA(bytes, sharekey, 0, true);
            }
            if (result == 0)
            {
                bytes = bytes.Skip(7).ToArray();
                var len = Convert.ToInt32(BitConverter.ToInt16(bytes.Take(2).ToArray().Reverse().ToArray(), 0));
                bytes = bytes.Skip(2).Take(len).ToArray();
                bytes = Hash.UNHashTEA(bytes, API.QQ.TGTKey, 0, true);
                Debug.Print("解密后登录成功数组:" + Environment.NewLine + BitConverter.ToString(bytes).Replace("-", " "));
                DecodeTlv(bytes);
                API.QQ.key        = API.UN_Tlv.T305_SessionKey;
                API.QQ.loginState = (int)API.LoginState.LoginSccess;
                return(1);
            }
            if (result == 2)
            {
                DecodeTlv(bytes.Skip(3).ToArray());
                if (API.UN_Tlv.T192_captcha != null)
                {
                    WebForm.Url = API.UN_Tlv.T192_captcha;
                    WebForm f1 = new WebForm();
                    f1.ShowDialog();
                    API.QQ.loginState = (int)API.LoginState.Logining;
                    if (API.QQ.Ticket != null)
                    {
                        API.TClient.SendData(Pack.VieryTicket(API.QQ.Ticket));
                    }
                }
                API.QQ.loginState = (int)API.LoginState.LoginFaild;
                return(2);
            }
            else if (result == 3)
            {
                Debug.Print("接收异常");
                API.QQ.loginState = (int)API.LoginState.LoginFaild;
            }
            else if (result == 1)
            {
                Debug.Print("登录账号或密码错误");
                API.QQ.loginState = (int)API.LoginState.LoginFaild;
            }
            else if (result == 40)
            {
                Debug.Print("账号被回收或无此账号");
                API.QQ.loginState = (int)API.LoginState.LoginFaild;
            }
            else if (result == 40)
            {
                Debug.Print("账号被冻结,或者账号密码已泄漏,存在被盗风险");
                API.QQ.loginState = (int)API.LoginState.LoginFaild;
            }
            else if (result == 160)
            {
                Debug.Print(result.ToString() + ":" + "\r\n" + BitConverter.ToString(bytes).Replace("-", " "));
                DecodeTlv(bytes.Skip(3).ToArray());
                SDK.GetLog(API.UN_Tlv.T17E_message);
                Debug.Print(API.UN_Tlv.T17E_message);
                if (API.UN_Tlv.T204_url_safeVerify != null)
                {
                    WebForm2.Url = API.UN_Tlv.T204_url_safeVerify;
                    WebForm2 f1 = new WebForm2();
                    f1.ShowDialog();
                    ClearWebDate();
                }
                else
                {
                    API.TClient.SendData(Pack.VieryPhoneCode());
                    string Answer = Microsoft.VisualBasic.Interaction.InputBox("请输入手机验证码");
                    if (!string.IsNullOrEmpty(Answer))
                    {
                        Pack.SubmitVertificationCode(Answer);
                    }
                }
                API.QQ.loginState = (int)API.LoginState.LoginVertify;
                return(2);
            }
            else if (result == 161)
            {
                Debug.Print("今日操作次数过多,请等待一天后再试");
                DecodeTlv(bytes.Skip(3).ToArray());
                WebForm2.Url = API.UN_Tlv.T204_url_safeVerify;
                WebForm f1 = new WebForm();
                f1.ShowDialog();
                ClearWebDate();
                API.QQ.loginState = (int)API.LoginState.LoginVertify;
                return(2);
            }
            else if (result == 162)
            {
                Debug.Print("验证码获取频繁,60s后重试");
                DecodeTlv(bytes.Skip(3).ToArray());
                WebForm2.Url = API.UN_Tlv.T204_url_safeVerify;
                WebForm2 f1 = new WebForm2();
                f1.ShowDialog();
                ClearWebDate();
                SendMobile = 3;
                //Thread.Sleep(60 * 1000)
                API.QQ.loginState = (int)API.LoginState.LoginVertify;
                return(2);
            }
            else if (result == 180)
            {
                Debug.Print("腾讯服务器繁忙,请重启框架重试");
                SDK.GetLog("腾讯服务器繁忙,请重启框架重试.");
                API.QQ.loginState = (int)API.LoginState.LoginVertify;
                return(2);
            }
            else if (result == 204)
            {
                if (API.UN_Tlv.T104 == null)
                {
                    Debug.Print("正在验证设备锁...");
                    //SDK.GetLog("正在验证设备锁...");
                    DecodeTlv(bytes.Skip(3).ToArray());
                    API.TClient.SendData(Pack.VieryLock());
                    API.QQ.loginState = (int)API.LoginState.LoginVertify;
                }
                return(2);
            }
            else if (result == 235)
            {
                Debug.Print("账号密码错误");
                API.QQ.loginState = (int)API.LoginState.LoginVertify;
            }
            else if (result == 237)
            {
                Debug.Print("验证ticket输入错误或环境异常");
                API.QQ.loginState = (int)API.LoginState.LoginVertify;
            }
            else if (result == 239)
            {
                Debug.Print(result.ToString() + ":" + "\r\n" + BitConverter.ToString(bytes).Replace("-", " "));
                DecodeTlv(bytes.Skip(3).ToArray());
                SDK.GetLog(API.UN_Tlv.T17E_message);
                Debug.Print(API.UN_Tlv.T17E_message);
                if (API.UN_Tlv.T204_url_safeVerify != null)
                {
                    WebForm2.Url = API.UN_Tlv.T204_url_safeVerify;
                    WebForm2 f1 = new WebForm2();
                    f1.ShowDialog();
                    ClearWebDate();
                }
                else
                {
                    API.TClient.SendData(Pack.VieryPhoneCode());
                    string Answer = Microsoft.VisualBasic.Interaction.InputBox("请输入手机验证码");
                    if (!string.IsNullOrEmpty(Answer))
                    {
                        Pack.SubmitVertificationCode(Answer);
                    }
                }
                API.QQ.loginState = (int)API.LoginState.LoginVertify;
                return(2);
            }
            else
            {
                Debug.Print("错误的验证类型:" + result.ToString());
                API.QQ.loginState = (int)API.LoginState.LoginVertify;
            }
            Un_Pack_ErrMsg(result, bytes);
            return(3);
        }