public static API.ECDH_Struct GetECDHKeys2() { API.ECDH_Struct ECDH = new API.ECDH_Struct(); byte[] Sharekey = new byte[16]; byte[] SvrPubKey = new byte[] { 0x4, 0xBF, 0x47, 0xA1, 0xCF, 0x78, 0xA6, 0x29, 0x66, 0x8B, 0xB, 0xC3, 0x9F, 0x8E, 0x54, 0xC9, 0xCC, 0xF3, 0xB6, 0x38, 0x4B, 0x8, 0xB8, 0xAE, 0xEC, 0x87, 0xDA, 0x9F, 0x30, 0x48, 0x5E, 0xDF, 0xE7, 0x67, 0x96, 0x9D, 0xC1, 0xA3, 0xAF, 0x11, 0x15, 0xFE, 0xD, 0xCC, 0x8E, 0xB, 0x17, 0xCA, 0xCF }; ECDH.PublicKey = new byte[25]; ECDH.Sharekey = new byte[16]; var eckey = OpenSSL.EC_KEY_new_by_curve_name(711); var ec_group = OpenSSL.EC_KEY_get0_group(eckey); var ec_point = OpenSSL.EC_POINT_new(ec_group); OpenSSL.EC_KEY_generate_key(eckey); OpenSSL.EC_POINT_point2oct(ec_group, (System.IntPtr)OpenSSL.EC_KEY_get0_public_key(eckey), 2, ECDH.PublicKey, 25, (System.IntPtr) 0); OpenSSL.EC_POINT_oct2point(ec_group, ec_point, SvrPubKey, 49, (System.IntPtr) 0); OpenSSL.ECDH_compute_key(ECDH.Sharekey, 16, ec_point, eckey, (System.IntPtr) 0); ECDH.Sharekey = API.MD5Hash(Sharekey); return(ECDH); }
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); }
public static byte[] GetECDHKeysEx(byte[] peerRawPublicKey, byte[] PublicKey, byte[] PrivateKey) { API.ECDH_Struct ECDH = new API.ECDH_Struct(); //Dim PrivateKey(1023) As Byte // Dim PublicKey(1023) As Byte //Dim Sharekey(15) As Byte var ec_key = OpenSSL.EC_KEY_new_by_curve_name(415); var bn = OpenSSL.BN_new(); OpenSSL.BN_mpi2bn(PrivateKey, PrivateKey.Length, bn); OpenSSL.EC_KEY_set_private_key(ec_key, bn); OpenSSL.BN_free(bn); var ec_group = OpenSSL.EC_KEY_get0_group(ec_key); var ec_point = OpenSSL.EC_POINT_new(ec_group); OpenSSL.EC_POINT_oct2point(ec_group, ec_point, peerRawPublicKey, peerRawPublicKey.Length, (System.IntPtr) 0); OpenSSL.ECDH_compute_key(PublicKey, 16, ec_point, ec_key, (System.IntPtr) 0); return(API.MD5Hash(PublicKey)); }
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 }