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 SendFriendAudio(long thisQQ, long sendQQ, byte[] AudioBytes) { using (var audioStream = new MemoryStream(AudioBytes)) { AudioBytes = audioStream.ToArray(); } API.FileHash = API.MD5Hash(AudioBytes); SendAudioMsgStruct AudioInfo = new SendAudioMsgStruct { AudioType = 500, Field2 = 0, AudioInfo = new AudioInfos { thisQQ = thisQQ, SendQQ = sendQQ, StartFlag = 2, AudioSize = AudioBytes.Length, AudioName = API.HashMD5(AudioBytes) + ".amr", AudioHash = API.FileHash }, Field101 = 17, Field102 = 104, AudioOtherInfo = new AudioOtherInfos { Field1 = 3, Field2 = 0, Field90300 = 1, Field90500 = 3, Field90600 = 2, Field90800 = 5 } }; using (var ms = new MemoryStream()) { Serializer.Serialize(ms, AudioInfo); var bytes = API.PackCmdHeader("PttCenterSvr.pb_pttCenter_CMD_REQ_APPLY_UPLOAD-500", ms.ToArray()); API.TClient.SendData(API.PackAllHeader(bytes)); } }
public static void SendFriendPic(long thisQQ, long sendQQ, byte[] picBytes) { var picMd5 = API.MD5Hash(picBytes); API.FileHash = picMd5; API.FileBytes = picBytes; SendPicMsgStruct PicInfo = new SendPicMsgStruct { Amount = 1, PicType = 3, PicInfo = new PicInfos { SendQQ = sendQQ, StartFlag = 0, PicHash = picMd5, PicLengh = picBytes.Length, PicName = API.HashMD5(picBytes) + ".jpg", Field7 = 5, Field8 = 9, Field10 = 0, Field12 = 1, Field13 = 0, PicWidth = 647, PicHeigh = 980, PicPix = 1000, PicVer = "7.9.8.999", Field21 = 0, Field22 = 0 } }; using (var ms = new MemoryStream()) { Serializer.Serialize(ms, PicInfo); var bytes = API.PackCmdHeader("LongConn.OffPicUp", ms.ToArray()); API.TClient.SendData(API.PackAllHeader(bytes)); } }
public static void SendGroupAudio(long thisQQ, long sendQQ, long groupId, byte[] AudioBytes) { using (var audioStream = new MemoryStream(AudioBytes)) { AudioBytes = audioStream.ToArray(); } API.FileHash = API.MD5Hash(AudioBytes); SendGroupAudioMsgStruct AudioInfo = new SendGroupAudioMsgStruct { AudioType = 3, Field2 = 3, GroupAudioInfo = new GroupAudioInfos { GroupId = groupId, SendQQ = sendQQ, StartFlag = 0, AudioHash = API.FileHash, AudioSize = AudioBytes.Length, AudioName = API.HashMD5(AudioBytes) + ".amr", Field7 = 5, Field8 = 9, Field9 = 3, AudioVer = "7.9.8.999", Field12 = 1, Field13 = 1, Field14 = 1, Field15 = 1 } }; using (var ms = new MemoryStream()) { Serializer.Serialize(ms, AudioInfo); var bytes = API.PackCmdHeader("PttStore.GroupPttUp", ms.ToArray()); API.TClient.SendData(API.PackAllHeader(bytes)); } }
public static void SendGroupPic(long thisQQ, long sendQQ, long groupId, byte[] picBytes) { var picMd5 = API.MD5Hash(picBytes); API.FileHash = picMd5; API.FileBytes = picBytes; SendGroupPicMsgStruct PicInfo = new SendGroupPicMsgStruct { Amount = 1, PicType = 3, GroupPicInfo = new GroupPicInfos { GroupId = groupId, SendQQ = sendQQ, StartFlag = 0, PicHash = picMd5, PicSize = picBytes.Length, PicName = API.HashMD5(picBytes) + ".jpg", Field7 = 5, Field8 = 9, Field9 = 1, PicWidth = 647, PicHeigh = 980, PicPix = 1000, PicVer = "7.9.8.999", Field15 = 1007, Field19 = 0 } }; using (var ms = new MemoryStream()) { Serializer.Serialize(ms, PicInfo); var bytes = API.PackCmdHeader("ImgStore.GroupPicUp", ms.ToArray()); API.TClient.SendData(API.PackAllHeader(bytes)); } }
public static void UploadFriendPicByTCP(long sendQQ, byte[] uKey, string Ip, int Port) { var TcpClient = new TCPIPClient(Ip, Port); byte[] SendBytes = null; int UploadLen = 0; var TempFileBytes = API.FileBytes; byte[] PBBytes = null; UploadFriendPicStruct UploadPicBytes = new UploadFriendPicStruct(); while (TempFileBytes.Length > 0) { if (TempFileBytes.Length >= 8192) { SendBytes = TempFileBytes.Take(8192).ToArray(); } else { SendBytes = TempFileBytes; } UploadPicBytes = new UploadFriendPicStruct { UploadFriendPicSendInfo = new UploadFriendPicSendInfos { amout = 1, sendQQ = sendQQ.ToString(), SendCmd = "PicUp.DataUp", RaqId = (new Random()).Next(90000, 99999), field5 = 0, appId = 537061440, sendSize = 4096, flag = 1 }, UploadFriendPicFileInfo = new UploadFriendPicFileInfos { fileSize = API.FileBytes.Length, uploadSize = UploadLen, sendSize = SendBytes.Length, uKey = uKey, sendFileHash = API.MD5Hash(SendBytes), TotalHash = API.FileHash } }; using (var ms = new MemoryStream()) { Serializer.Serialize(ms, UploadPicBytes); Debug.Print("上传好友图片:" + "\r\n" + BitConverter.ToString(ms.ToArray()).Replace("-", " ")); PBBytes = ms.ToArray(); } var bytes = new byte[] { 0x28 }; bytes = bytes.Concat(BitConverter.GetBytes(PBBytes.Length).Reverse().ToArray()).ToArray(); bytes = bytes.Concat(BitConverter.GetBytes(SendBytes.Length).Reverse().ToArray()).ToArray(); bytes = bytes.Concat(PBBytes).ToArray(); bytes = bytes.Concat(SendBytes).ToArray(); bytes = bytes.Concat(new byte[] { 0x29 }).ToArray(); Debug.Print("上传好友图片打包:" + "\r\n" + BitConverter.ToString(bytes).Replace("-", " ")); TcpClient.SendData(bytes); TempFileBytes = TempFileBytes.Skip(SendBytes.Length).ToArray(); UploadLen = UploadLen + SendBytes.Length; } Debug.Print("上传好友图片完成."); }
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 }