public static byte[] StatSvcRegister() { var bytes = JceStruct.writeFlag(JceStruct.JceType.TYPE_STRUCT_BEGIN, 0); bytes = bytes.Concat(JceStruct.writeLong(API.QQ.LongQQ, 0)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(7, 1)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(0, 2)).ToArray(); bytes = bytes.Concat(JceStruct.writeString("", 3)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong((long)API.OnlineStaus.hide, 4)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(0, 5)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(0, 6)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(0, 7)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(0, 8)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(0, 9)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(0, 10)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(21, 11)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(1, 12)).ToArray(); bytes = bytes.Concat(JceStruct.writeString("", 13)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(0, 14)).ToArray(); bytes = bytes.Concat(JceStruct.writeSimpleList(API.Device.GUIDBytes, 16)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(2052, 17)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(0, 18)).ToArray(); bytes = bytes.Concat(JceStruct.writeString(API.Device.model, 19)).ToArray(); bytes = bytes.Concat(JceStruct.writeString(API.Device.model, 20)).ToArray(); bytes = bytes.Concat(JceStruct.writeString(API.Device.os_version, 21)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(1, 22)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(14798, 23)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(0, 24)).ToArray(); bytes = bytes.Concat(JceStruct.writeLong(0, 26)).ToArray(); bytes = bytes.Concat(JceStruct.writeInt(API.IPToInt32("111.30.181.202"), 27)).ToArray(); bytes = bytes.Concat(JceStruct.writeFlag(JceStruct.JceType.TYPE_STRUCT_END, 6)).ToArray(); Dictionary <object, object> dic = new Dictionary <object, object>() { { "SvcReqRegister", bytes } }; bytes = JceStruct.writeMap(dic, 0); bytes = Pack_HeadJce(0, "PushService", "SvcReqRegister", bytes); //Debug.Print("StatSvcRegister" + Environment.NewLine + BitConverter.ToString(bytes).Replace("-", " ")) bytes = API.PackCmdHeader("StatSvc.register", bytes); HashTea Hash = new HashTea(); byte[] EncodeByte = Hash.HashTEA(bytes, API.UN_Tlv.T305_SessionKey, 0, true); bytes = new byte[] { 0x0, 0x0, 0x0, 0xB, 1 }; bytes = bytes.Concat(BitConverter.GetBytes(API.QQ.mRequestID + 1).Reverse().ToArray()).ToArray(); bytes = bytes.Concat(new byte[] { 0x0 }).ToArray(); bytes = bytes.Concat(API.QQ.UTF8).ToArray(); bytes = bytes.Concat(EncodeByte).ToArray(); bytes = BitConverter.GetBytes(bytes.Length + 4).Reverse().ToArray().Concat(bytes).ToArray(); API.TClient.SendData(bytes); return(bytes); }
public static void ReplySidTicketExpired(int ssoseq) { var bytes = API.PackCmdHeader("OnlinePush.SidTicketExpired", new byte[0]); HashTea Hash = new HashTea(); byte[] encodeByte = Hash.HashTEA(bytes, API.UN_Tlv.T305_SessionKey, 0, true); bytes = new byte[] { 0, 0, 0, 0xB, 1 }.Concat(BitConverter.GetBytes(ssoseq).Reverse().ToArray()).Concat(new byte[] { 0, 0, 0 }).ToArray(); bytes = bytes.Concat(BitConverter.GetBytes(Convert.ToInt16(API.QQ.UTF8.Length + 4)).Reverse().ToArray()).ToArray().Concat(API.QQ.UTF8).ToArray(); bytes = bytes.Concat(encodeByte).ToArray(); bytes = BitConverter.GetBytes(bytes.Length + 4).Reverse().ToArray().Concat(bytes).ToArray(); API.TClient.SendData(bytes); }
public static byte[] VieryCode(string code) { byte[] bytes = new byte[] { 0, 2, 0, 4 }; bytes = bytes.Concat(TLV.tlv193(code)).ToArray(); bytes = bytes.Concat(TLV.tlv008()).ToArray(); bytes = bytes.Concat(TLV.tlv104(API.UN_Tlv.T104)).ToArray(); bytes = bytes.Concat(TLV.tlv116(10)).ToArray(); HashTea Hash = new HashTea(); bytes = Hash.HashTEA(bytes, API.QQ.shareKey, 0, true); bytes = PackLoginHeader("wtlogin.login", bytes, 1); return(bytes); }
public static void PackOidbSvc_0x59f() { var cmd = "OidbSvc.0x59f"; if (API.QQ.mRequestID > 2147483647) { API.QQ.mRequestID = 10000; } else { API.QQ.mRequestID += 1; } var bytes1 = BitConverter.GetBytes(API.QQ.mRequestID).Reverse().ToArray(); bytes1 = bytes1.Concat(BitConverter.GetBytes(API.QQ.Appid).Reverse().ToArray()).ToArray(); bytes1 = bytes1.Concat(BitConverter.GetBytes(API.QQ.Appid).Reverse().ToArray()).ToArray(); bytes1 = bytes1.Concat(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 }).ToArray(); bytes1 = bytes1.Concat(BitConverter.GetBytes(API.UN_Tlv.T10A_token_A4.Length + 4).Reverse().ToArray()).ToArray().Concat(API.UN_Tlv.T10A_token_A4).ToArray(); bytes1 = bytes1.Concat(BitConverter.GetBytes(cmd.Length + 4).Reverse().ToArray()).ToArray().Concat(Encoding.UTF8.GetBytes(cmd)).ToArray(); //命令行 bytes1 = bytes1.Concat(BitConverter.GetBytes(API.QQ.MsgCookies.Length + 4).Reverse().ToArray()).ToArray().Concat(API.QQ.MsgCookies).ToArray(); //MsgCookies bytes1 = bytes1.Concat(BitConverter.GetBytes(API.Device.imei.Length + 4).Reverse().ToArray()).ToArray().Concat(Encoding.UTF8.GetBytes(API.Device.imei)).ToArray(); //Device.imei bytes1 = bytes1.Concat(new byte[] { 0, 0, 0, 4 }).ToArray(); bytes1 = bytes1.Concat(BitConverter.GetBytes(Convert.ToInt16(API.Device.Ver.Length + 2)).Reverse().ToArray()).ToArray().Concat(Encoding.UTF8.GetBytes(API.Device.Ver)).ToArray(); //Device.Ver bytes1 = bytes1.Concat(new byte[] { 0, 0, 0, 4 }).ToArray(); bytes1 = BitConverter.GetBytes(bytes1.Length + 4).Reverse().ToArray().Concat(bytes1).ToArray(); var bytes2 = new byte[] { 0x8, 0x9F, 0xB, 0x10, 0x1, 0x18, 0x0, 0x22, 0x0, 0x32 }; bytes2 = bytes2.Concat(BitConverter.GetBytes((API.Device.os_type + " " + API.Device.os_version).Length).ToArray().Take(1).ToArray()).Concat(Encoding.UTF8.GetBytes(API.Device.os_type + " " + API.Device.os_version)).ToArray(); //os_type bytes2 = BitConverter.GetBytes(bytes2.Length + 4).Reverse().ToArray().Concat(bytes2).ToArray(); HashTea Hash = new HashTea(); byte[] retByte = Hash.HashTEA(bytes1.Concat(bytes2).ToArray(), API.UN_Tlv.T305_SessionKey, 0, true); var bytes3 = new byte[] { 0, 0, 0, 0xA, 1 }; bytes3 = bytes3.Concat(BitConverter.GetBytes(API.UN_Tlv.T143_token_A2.Length + 4).Reverse().ToArray()).ToArray().Concat(API.UN_Tlv.T143_token_A2).ToArray(); bytes3 = bytes3.Concat(new byte[] { 0 }).ToArray(); bytes3 = bytes3.Concat(BitConverter.GetBytes(API.QQ.UTF8.Length + 4).Reverse().ToArray()).ToArray().Concat(API.QQ.UTF8).ToArray(); var bytes = bytes3.Concat(retByte).ToArray(); bytes = BitConverter.GetBytes(bytes.Length + 4).Reverse().ToArray().Concat(bytes).ToArray(); Debug.Print("OidbSvc_0x59f:" + bytes.Length.ToString() + "\r\n" + BitConverter.ToString(bytes).Replace("-", " ")); API.TClient.SendData(bytes); }
public static byte[] VieryLock() { byte[] bytes = new byte[] { 0, 0x14, 0, 4 }; bytes = bytes.Concat(TLV.tlv008()).ToArray(); bytes = bytes.Concat(TLV.tlv104(API.UN_Tlv.T104)).ToArray(); bytes = bytes.Concat(TLV.tlv116(10)).ToArray(); bytes = bytes.Concat(TLV.tlv401()).ToArray(); Debug.Print("VieryLock:" + bytes.Length.ToString() + "\r\n" + BitConverter.ToString(bytes).Replace("-", " ")); HashTea Hash = new HashTea(); bytes = Hash.HashTEA(bytes, API.QQ.shareKey, 0, true); bytes = PackLoginHeader("wtlogin.login", bytes, 0); return(bytes); }
public static byte[] SubmitVertificationCode(string code) { byte[] bytes = new byte[] { 0, 7, 0, 7 }; bytes = bytes.Concat(TLV.tlv008()).ToArray(); bytes = bytes.Concat(TLV.tlv104(API.UN_Tlv.T104)).ToArray(); bytes = bytes.Concat(TLV.tlv116(8)).ToArray(); bytes = bytes.Concat(TLV.tlv174(API.UN_Tlv.T174)).ToArray(); bytes = bytes.Concat(TLV.tlv17c(code)).ToArray(); bytes = bytes.Concat(TLV.tlv401()).ToArray(); bytes = bytes.Concat(TLV.tlv198()).ToArray(); HashTea Hash = new HashTea(); bytes = Hash.HashTEA(bytes, API.QQ.shareKey, 0, true); bytes = PackLoginHeader("wtlogin.login", bytes, 1); return(bytes); }
public static byte[] VieryPhoneCode() { byte[] bytes = new byte[] { 0, 8, 0, 6 }; bytes = bytes.Concat(TLV.tlv008()).ToArray(); bytes = bytes.Concat(TLV.tlv104(API.UN_Tlv.T104)).ToArray(); bytes = bytes.Concat(TLV.tlv116(8)).ToArray(); bytes = bytes.Concat(TLV.tlv174(API.UN_Tlv.T174)).ToArray(); bytes = bytes.Concat(TLV.tlv17a()).ToArray(); bytes = bytes.Concat(TLV.tlv197()).ToArray(); //bytes = bytes.Concat(TLV.tlv542).ToArray Debug.Print("VieryPhoneCode1:" + bytes.Length.ToString() + "\r\n" + BitConverter.ToString(bytes).Replace("-", " ")); HashTea Hash = new HashTea(); bytes = Hash.HashTEA(bytes, API.QQ.shareKey, 0, true); bytes = PackLoginHeader("wtlogin.login", bytes, 1); return(bytes); }
public static byte[] tlv144(byte[] TGTKey, byte[] tlv109, byte[] tlv52d, byte[] tlv124, byte[] tlv128, byte[] tlv16e) { var bytes = new byte[] { 0, 5 }.Concat(tlv109).ToArray(); bytes = bytes.Concat(tlv52d).ToArray(); bytes = bytes.Concat(tlv124).ToArray(); bytes = bytes.Concat(tlv128).ToArray(); bytes = bytes.Concat(tlv16e).ToArray(); //Debug.Print("tlv144:" + bytes.Length.ToString + Environment.NewLine + BitConverter.ToString(bytes).Replace("-", " ")) HashTea Hash = new HashTea(); var byteHash = Hash.HashTEA(bytes, TGTKey, 0, true); byte[] bytesLen = BitConverter.GetBytes(Convert.ToInt16(byteHash.Length)).Reverse().ToArray(); var retByte = new byte[] { 1, 0x44 }.Concat(bytesLen).Concat(byteHash).ToArray(); //Debug.Print("tlv144:" + retByte.Length.ToString + Environment.NewLine + BitConverter.ToString(retByte).Replace("-", " ")) return(retByte); }
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)); }
public static byte[] tlv106(byte[] user, byte[] md5pass, byte[] md5_2pass, byte[] _TGTKey, byte[] guidBytes, byte[] times, int appId, byte[] QQUTF8) { var bytes = new byte[] { 0, 4 }.Concat(API.GetRandByteArray(4)).ToArray(); bytes = bytes.Concat(new byte[] { 0, 0, 0, 0xD }).ToArray(); bytes = bytes.Concat(new byte[] { 0, 0, 0, 0x10 }).ToArray(); bytes = bytes.Concat(new byte[] { 0, 0, 0, 0 }).ToArray(); bytes = bytes.Concat(new byte[] { 0, 0, 0, 0 }).ToArray(); bytes = bytes.Concat(user).ToArray(); bytes = bytes.Concat(times).ToArray(); bytes = bytes.Concat(new byte[] { 0, 0, 0, 0 }).ToArray(); bytes = bytes.Concat(new byte[] { 1 }).ToArray(); bytes = bytes.Concat(md5pass).ToArray(); bytes = bytes.Concat(_TGTKey).ToArray(); bytes = bytes.Concat(new byte[] { 0, 0, 0, 0, 1 }).ToArray(); bytes = bytes.Concat(guidBytes).ToArray(); if (appId < 0) { bytes = bytes.Concat(new byte[] { 0, 0, 0, 2 }).ToArray(); } else { bytes = bytes.Concat(BitConverter.GetBytes(appId).Reverse().ToArray()).ToArray(); } bytes = bytes.Concat(new byte[] { 0, 0, 0, 1 }).ToArray(); bytes = bytes.Concat(BitConverter.GetBytes(Convert.ToInt16(QQUTF8.Length)).Reverse().ToArray()).ToArray(); bytes = bytes.Concat(QQUTF8).ToArray(); bytes = bytes.Concat(new byte[] { 0, 0 }).ToArray(); //Debug.Print("tlv106:" + bytes.Length.ToString + Environment.NewLine + BitConverter.ToString(bytes).Replace("-", "")) HashTea Hash = new HashTea(); var byteHash = Hash.HashTEA(bytes, md5_2pass, 0, true); byte[] bytesLen = BitConverter.GetBytes(Convert.ToInt16(byteHash.Length)).Reverse().ToArray(); var retByte = new byte[] { 1, 6 }.Concat(bytesLen).Concat(byteHash).ToArray(); //Debug.Print("tlv106:" + retByte.Length.ToString + Environment.NewLine + BitConverter.ToString(retByte).Replace("-", "")) return(retByte); }
public static byte[] PackAllHeader(byte[] bodyBytes) { HashTea Hash = new HashTea(); byte[] encodeByte = Hash.HashTEA(bodyBytes, UN_Tlv.T305_SessionKey, 0, true); //加密包体 if (QQ.mRequestID > 2147483647) { QQ.mRequestID = 10000; } else { QQ.mRequestID += 1; } var headerBytes = new byte[] { 0, 0, 0, 0xB, 1 }.Concat(BitConverter.GetBytes(QQ.mRequestID).Reverse().ToArray()).ToArray().Concat(new byte[] { 0, 0, 0 }).ToArray(); var qqBytes = BitConverter.GetBytes(Convert.ToInt16(QQ.UTF8.Length + 4)).Reverse().ToArray().Concat(QQ.UTF8).ToArray(); headerBytes = headerBytes.Concat(qqBytes).ToArray(); var bytes = headerBytes.Concat(encodeByte).ToArray(); bytes = BitConverter.GetBytes(bytes.Length + 4).Reverse().ToArray().Concat(bytes).ToArray(); return(bytes); }
public static void PackFriendHistoryMsg() { var timeStamp = Convert.ToInt64(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds); var Str = "model:SM-G9009D;os:21;version:v2man:samsungsys:LRX21T.G9009DKES1BPG2"; var cmd = "MessageSvc.PbGetMsg"; API.QQ.mRequestID = API.QQ.mRequestID + 1; byte[] bytesSyncCoookie1 = null; SyncCoookie1Struct SyncCoookie1 = new SyncCoookie1Struct { DeviceInfo = Str, ErrorCode = 0, TimeStamp = timeStamp, TimeStamp1 = timeStamp - 300, TimeStamp2 = timeStamp - 300, TimeStamp3 = timeStamp - 300 }; using (var ms = new MemoryStream()) { Serializer.Serialize(ms, SyncCoookie1); bytesSyncCoookie1 = ms.ToArray(); } byte[] bytesSyncCoookie2 = null; SyncCoookie2Struct SyncCoookie2 = new SyncCoookie2Struct { ErrorCode = 0, Field3 = 0, Field4 = 20, Field5 = 3, Field6 = 1, Field7 = 1, Field9 = 0, TimeInfo = API.QQ.SyncCoookies }; using (var ms = new MemoryStream()) { Serializer.Serialize(ms, SyncCoookie2); bytesSyncCoookie2 = ms.ToArray(); } var bytes = BitConverter.GetBytes(cmd.Length + 4).Reverse().ToArray().Concat(Encoding.UTF8.GetBytes(cmd).ToArray()).ToArray(); bytes = bytes.Concat(BitConverter.GetBytes(API.QQ.MsgCookies.Length + 4).Reverse().ToArray()).Concat(API.QQ.MsgCookies).ToArray(); bytes = bytes.Concat(BitConverter.GetBytes(bytesSyncCoookie1.Length + 4).Reverse().ToArray()).Concat(bytesSyncCoookie1).ToArray(); bytes = BitConverter.GetBytes(bytes.Length + 4).Reverse().ToArray().Concat(bytes).ToArray(); bytes = bytes.Concat(BitConverter.GetBytes(bytesSyncCoookie2.Length + 4).Reverse().ToArray()).Concat(bytesSyncCoookie2).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); bytes = new byte[] { 0x0, 0x0, 0x0, 0xB, 0x1 }.Concat(BitConverter.GetBytes(API.QQ.mRequestID).Reverse().ToArray()).ToArray().Concat(new byte[] { 0x0, 0x0, 0x0 }).ToArray(); bytes = bytes.Concat(BitConverter.GetBytes(Convert.ToInt16(API.QQ.UTF8.Length)).ToArray()).ToArray().Concat(API.QQ.UTF8).ToArray(); bytes = bytes.Concat(encodeByte).ToArray(); bytes = BitConverter.GetBytes(bytes.Length + 4).Reverse().ToArray().Concat(bytes).ToArray(); Debug.Print("获取好友历史消息全部:" + bytes.Length.ToString() + "\r\n" + BitConverter.ToString(bytes).Replace("-", " ")); API.TClient.SendData(bytes); }
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); }
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); }
public static byte[] PackLoginHeader(string servicecmd, byte[] bytesIn, int loginType) //0 = 普通登录 1 = 验证码登录 { var HeaderBytes = BitConverter.GetBytes(API.QQ.mRequestID).Reverse().ToArray(); HeaderBytes = HeaderBytes.Concat(BitConverter.GetBytes(API.QQ.Appid).Reverse().ToArray()).ToArray(); HeaderBytes = HeaderBytes.Concat(BitConverter.GetBytes(API.QQ.Appid).Reverse().ToArray()).ToArray(); HeaderBytes = HeaderBytes.Concat(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 4 }).ToArray(); HeaderBytes = HeaderBytes.Concat(BitConverter.GetBytes(servicecmd.Length + 4).Reverse().ToArray()).ToArray(); HeaderBytes = HeaderBytes.Concat(Encoding.UTF8.GetBytes(servicecmd)).ToArray(); HeaderBytes = HeaderBytes.Concat(new byte[] { 0, 0, 0, 8 }).ToArray(); if (loginType == 0) { HeaderBytes = HeaderBytes.Concat(new byte[] { 0x6C, 0x6A, 0xED, 0x65 }).ToArray(); } else if (loginType == 1) { HeaderBytes = HeaderBytes.Concat(new byte[] { 0xB, 0x63, 0xE0, 0x82 }).ToArray(); } HeaderBytes = HeaderBytes.Concat(BitConverter.GetBytes(API.Device.imei.Length + 4).Reverse().ToArray()).ToArray(); HeaderBytes = HeaderBytes.Concat(Encoding.UTF8.GetBytes(API.Device.imei)).ToArray(); HeaderBytes = HeaderBytes.Concat(new byte[] { 0, 0, 0, 4 }).ToArray(); HeaderBytes = HeaderBytes.Concat(BitConverter.GetBytes(Convert.ToInt16(API.Device.Ver.Length + 2)).Reverse().ToArray()).ToArray(); HeaderBytes = HeaderBytes.Concat(Encoding.UTF8.GetBytes(API.Device.Ver)).ToArray(); HeaderBytes = HeaderBytes.Concat(new byte[] { 0, 0, 0, 0x2A }).ToArray(); HeaderBytes = HeaderBytes.Concat(Encoding.UTF8.GetBytes("b$1ebc85de7365de4d155ce40110001581471d")).ToArray(); var HeaderLen = BitConverter.GetBytes(Convert.ToInt16(HeaderBytes.Length + 4)).Reverse().ToArray(); HeaderBytes = new byte[] { 0, 0 }.Concat(HeaderLen).ToArray().Concat(HeaderBytes).ToArray(); var bytes2 = new byte[] { 0x1F, 0x41, 8, 0x10, 0, 1 }; bytes2 = bytes2.Concat(API.QQ.user).ToArray(); if (loginType == 0) { bytes2 = bytes2.Concat(new byte[] { 0x3, 0x87, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x1 }).ToArray(); } else if (loginType == 1) { bytes2 = bytes2.Concat(new byte[] { 0x3, 0x7, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x1 }).ToArray(); } bytes2 = bytes2.Concat(API.GetRandByteArray(16)).ToArray(); bytes2 = bytes2.Concat(new byte[] { 1, 0x31, 0, 1 }).ToArray(); bytes2 = bytes2.Concat(new byte[] { 0, 0x41 }).ToArray(); bytes2 = bytes2.Concat(API.QQ.pub_key).ToArray(); //65字节 bytes2 = bytes2.Concat(bytesIn).ToArray(); //1392 var BodyLen = BitConverter.GetBytes(Convert.ToInt16(bytes2.Length + 4)).Reverse().ToArray(); bytes2 = new byte[] { 2 }.Concat(BodyLen).ToArray().Concat(bytes2).ToArray().Concat(new byte[] { 3 }).ToArray(); var bytes = HeaderBytes.Concat(BitConverter.GetBytes(bytes2.Length + 4).Reverse().ToArray()).ToArray().Concat(bytes2).ToArray(); //Debug.Print("PackLoginHeader:" + bytes.Length.ToString + Environment.NewLine + BitConverter.ToString(bytes).Replace("-", " ")) HashTea Hash = new HashTea(); byte[] EncodeByte = Hash.HashTEA(bytes, API.QQ.key, 0, true); //Debug.Print("EncodeByte:" + EncodeByte.Length.ToString + Environment.NewLine + BitConverter.ToString(EncodeByte).Replace("-", " ")) var retByte = PackHeader(EncodeByte, loginType); return(retByte); }
public static byte[] PackOnlineStatus(string cmd, int LonginType) { if (API.QQ.mRequestID > 2147483647) { API.QQ.mRequestID = 10000; } else { API.QQ.mRequestID += 1; } var bytes1 = BitConverter.GetBytes(API.QQ.mRequestID).Reverse().ToArray(); bytes1 = bytes1.Concat(BitConverter.GetBytes(API.QQ.Appid).Reverse().ToArray()).ToArray(); bytes1 = bytes1.Concat(BitConverter.GetBytes(API.QQ.Appid).Reverse().ToArray()).ToArray(); bytes1 = bytes1.Concat(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 }).ToArray(); bytes1 = bytes1.Concat(BitConverter.GetBytes(API.UN_Tlv.T10A_token_A4.Length + 4).Reverse().ToArray()).ToArray().Concat(API.UN_Tlv.T10A_token_A4).ToArray(); bytes1 = bytes1.Concat(BitConverter.GetBytes(cmd.Length + 4).Reverse().ToArray()).ToArray().Concat(Encoding.UTF8.GetBytes(cmd)).ToArray(); //命令行 bytes1 = bytes1.Concat(BitConverter.GetBytes(API.QQ.MsgCookies.Length + 4).Reverse().ToArray()).ToArray().Concat(API.QQ.MsgCookies).ToArray(); //MsgCookies bytes1 = bytes1.Concat(BitConverter.GetBytes(API.Device.imei.Length + 4).Reverse().ToArray()).ToArray().Concat(Encoding.UTF8.GetBytes(API.Device.imei)).ToArray(); //Device.imei if (LonginType == 0) { bytes1 = bytes1.Concat(new byte[] { 0, 0, 0, 4 }).ToArray(); } else if (LonginType == 1) { bytes1 = bytes1.Concat(API.GetRandByteArray(16)).ToArray(); } else if (LonginType == 2) { bytes1 = bytes1.Concat(new byte[16]).ToArray(); } bytes1 = bytes1.Concat(new byte[] { 0, 0x23 }).ToArray(); bytes1 = bytes1.Concat(Encoding.UTF8.GetBytes(API.Device.Ver)).ToArray(); bytes1 = bytes1.Concat(new byte[] { 0, 0, 0, 0x2A }).ToArray(); bytes1 = bytes1.Concat(Encoding.UTF8.GetBytes("b$1ebc85de7365de4d155ce40110001581471d")).ToArray(); var bytes2 = new byte[] { 0x10, 3, 0x2C, 0x3C, 0x4C, 0x56, 0xB }; bytes2 = bytes2.Concat(Encoding.UTF8.GetBytes("PushService")).ToArray(); bytes2 = bytes2.Concat(new byte[] { 0x66, 0xE }).ToArray(); bytes2 = bytes2.Concat(Encoding.UTF8.GetBytes("SvcReqRegister}")).ToArray(); if (LonginType == 0) { bytes2 = bytes2.Concat(new byte[] { 0, 1, 0, 0xE6, 8, 0 }).ToArray(); } else if (LonginType == 1) { bytes2 = bytes2.Concat(new byte[] { 0, 1, 0, 0xEA, 8, 0 }).ToArray(); } else if (LonginType == 2) { bytes2 = bytes2.Concat(new byte[] { 0, 1, 0, 0xBD, 8, 0 }).ToArray(); } bytes2 = bytes2.Concat(new byte[] { 1, 6, 0xE }).ToArray(); bytes2 = bytes2.Concat(Encoding.UTF8.GetBytes("SvcReqRegister")).ToArray(); if (LonginType == 0) { bytes2 = bytes2.Concat(new byte[] { 0x1D, 0, 1, 0, 0xCE, 0xA, 3, 0, 0, 0, 0 }).ToArray(); } else if (LonginType == 1) { bytes2 = bytes2.Concat(new byte[] { 0x1D, 0, 1, 0, 0xD2, 0xA, 3, 0, 0, 0, 0 }).ToArray(); } else if (LonginType == 2) { bytes2 = bytes2.Concat(new byte[] { 0x1D, 0, 1, 0, 0xA5, 0xA, 3, 0, 0, 0, 0 }).ToArray(); } bytes2 = bytes2.Concat(API.QQ.user).ToArray(); if (LonginType == 2) { bytes2 = bytes2.Concat(new byte[] { 0x1C }).ToArray(); } else { bytes2 = bytes2.Concat(new byte[] { 0x10, 7 }).ToArray(); } bytes2 = bytes2.Concat(new byte[] { 0x2C, 0x36, 0 }).ToArray(); if (LonginType == 2) { bytes2 = bytes2.Concat(new byte[] { 0x40, 0x15 }).ToArray(); } else { bytes2 = bytes2.Concat(new byte[] { 0x40, 0xB }).ToArray(); } bytes2 = bytes2.Concat(new byte[] { 0x5C, 0x6C, 0x7C, 0x8C, 0x9C, 0xA0, 0x75, 0xB0, 0x16, 0xC0, 1, 0xD6, 0, 0xEC, 0xFD, 0x10, 0, 0, 0x10 }).ToArray(); bytes2 = bytes2.Concat(API.Device.GUIDBytes).ToArray(); bytes2 = bytes2.Concat(new byte[] { 0xF1, 0x11, 8, 4, 0xFC, 0x12 }).ToArray(); bytes2 = bytes2.Concat(new byte[] { 0xF6, 0x13 }).ToArray(); bytes2 = bytes2.Concat(BitConverter.GetBytes(Convert.ToInt16(API.Device.model.Length)).ToArray().Take(1).ToArray()).ToArray(); bytes2 = bytes2.Concat(Encoding.UTF8.GetBytes(API.Device.model)).ToArray(); bytes2 = bytes2.Concat(new byte[] { 0xF6, 0x14 }).ToArray(); bytes2 = bytes2.Concat(BitConverter.GetBytes(Convert.ToInt16(API.Device.model.Length)).ToArray().Take(1).ToArray()).ToArray(); bytes2 = bytes2.Concat(Encoding.UTF8.GetBytes(API.Device.model)).ToArray(); bytes2 = bytes2.Concat(new byte[] { 0xF6, 0x15 }).ToArray(); bytes2 = bytes2.Concat(BitConverter.GetBytes(Convert.ToInt16(API.Device.os_version.Length)).ToArray().Take(1).ToArray()).ToArray(); bytes2 = bytes2.Concat(Encoding.UTF8.GetBytes(API.Device.os_version)).ToArray(); bytes2 = bytes2.Concat(new byte[] { 0xF0, 0x16, 1 }).ToArray(); if (LonginType == 2) { bytes2 = bytes2.Concat(new byte[] { 0xF1, 0x17 }).ToArray(); } else { bytes2 = bytes2.Concat(new byte[] { 0xF1, 0x17, 0, 0xD7 }).ToArray(); } bytes2 = bytes2.Concat(new byte[] { 0xFC, 0x18 }).ToArray(); if (LonginType == 0) { bytes2 = bytes2.Concat(new byte[] { 0xF3, 0x1A, 0, 0, 0, 0, 0xA6, 0x3C, 0x5E, 0x7D, 0xF2, 0x1B, 0x5F, 0xD, 0x60, 0x71 }).ToArray(); } else if (LonginType == 1) { bytes2 = bytes2.Concat(new byte[] { 0xF3, 0x1A, 0, 0, 0, 0, 0xD9, 0xC, 0x60, 0x71, 0xF3, 0x1B, 0, 0, 0, 0, 0xA6, 0x3C, 0x5E, 0x7D }).ToArray(); } else if (LonginType == 2) { bytes2 = bytes2.Concat(new byte[] { 0xFC, 0x1A, 0xFC, 0x1B }).ToArray(); } bytes2 = bytes2.Concat(new byte[] { 0xF6, 0x1C, 0, 0xFC, 0x1D }).ToArray(); if (LonginType == 2) { bytes2 = bytes2.Concat(new byte[] { 0xF6, 0x1E, 0, 0xF6, 0x1F, 0 }).ToArray(); } else { bytes2 = bytes2.Concat(new byte[] { 0xF6, 0x1E, 7, 0x5B, 0x75, 0x5D, 0x6F, 0x70, 0x70, 0x6F, 0xF6, 0x1F, 0x14, 0x3F, 0x4C, 0x59, 0x5A, 0x32, 0x38, 0x4E, 0x3B, 0x61, 0x6E, 0x64, 0x72, 0x6F, 0x69, 0x64, 0x5F, 0x78, 0x38, 0x36, 0x2D }).ToArray(); } bytes2 = bytes2.Concat(new byte[] { 0xF6, 0x20, 0x0, 0xFD, 0x21, 0x0, 0x0, 0x11, 0xA, 0x8, 0x8, 0x2E, 0x10, 0x9A, 0xEF, 0x9C, 0xFB, 0x5, 0xA, 0x5, 0x8, 0x9B, 0x2, 0x10, 0x0, 0xFC, 0x22, 0xFC, 0x24 }).ToArray(); if (LonginType == 2) { bytes2 = bytes2.Concat(new byte[] { 0xF0, 0x26, 0xFF }).ToArray(); } else { bytes2 = bytes2.Concat(new byte[] { 0xFC, 0x26 }).ToArray(); } bytes2 = bytes2.Concat(new byte[] { 0xFC, 0x27, 0xFA, 0x2A, 0x0, 0x1, 0xB, 0xB, 0x8C, 0x98, 0xC, 0xA8, 0xC }).ToArray(); var bytes = BitConverter.GetBytes(bytes1.Length + 4).Reverse().ToArray(); bytes = bytes.Concat(bytes1).ToArray(); bytes = bytes.Concat(BitConverter.GetBytes(bytes2.Length + 4).Reverse().ToArray()).ToArray(); bytes = bytes.Concat(bytes2).ToArray(); Debug.Print("在线状态包:" + bytes.Length.ToString() + "\r\n" + BitConverter.ToString(bytes).Replace("-", " ")); HashTea Hash = new HashTea(); byte[] retByte = Hash.HashTEA(bytes, API.UN_Tlv.T305_SessionKey, 0, true); return(PackHeader(retByte, 2)); }
public static byte[] TlvPackage(string LoginType = "") { var bytes = new byte[0]; if (LoginType == "AndroidQQ") { bytes = new byte[] { 0, 9, 0, 24 }; //24个包 bytes = bytes.Concat(TLV.tlv018(API.QQ.user)).ToArray(); bytes = bytes.Concat(TLV.tlv001(API.QQ.user, API.QQ.login_Time)).ToArray(); bytes = bytes.Concat(TLV.tlv106(API.QQ.user, API.QQ.md5_1, API.QQ.md5_2, API.QQ.TGTKey, API.Device.GUIDBytes, API.QQ.login_Time, API.QQ.Appid, API.QQ.UTF8)).ToArray(); bytes = bytes.Concat(TLV.tlv116(0)).ToArray(); bytes = bytes.Concat(TLV.tlv100(API.QQ.Appid.ToString())).ToArray(); bytes = bytes.Concat(TLV.tlv107()).ToArray(); if (API.UN_Tlv.T108_ksid.Length > 0) { bytes = bytes.Concat(TLV.tlv108(API.UN_Tlv.T108_ksid)).ToArray(); } bytes = bytes.Concat(TLV.tlv142()).ToArray(); bytes = bytes.Concat(TLV.tlv144(API.QQ.TGTKey, TLV.tlv109(API.Device.AndroidID), TLV.tlv52D(), TLV.tlv124(API.Device.os_type, API.Device.os_version, API.Device.network_type.ToString(), API.Device.apn), TLV.tlv128(API.Device.model, API.Device.GUIDBytes, API.Device.brands), TLV.tlv16e(API.Device.model))).ToArray(); bytes = bytes.Concat(TLV.tlv145(API.Device.GUIDBytes)).ToArray(); bytes = bytes.Concat(TLV.tlv147(API.Device.Apk_V, API.Device.ApkSig)).ToArray(); bytes = bytes.Concat(TLV.tlv154(API.QQ.mRequestID)).ToArray(); bytes = bytes.Concat(TLV.tlv141(API.Device.network_type.ToString(), API.Device.apn)).ToArray(); bytes = bytes.Concat(TLV.tlv008()).ToArray(); bytes = bytes.Concat(TLV.tlv511()).ToArray(); bytes = bytes.Concat(TLV.tlv187(API.Device.MacBytes)).ToArray(); bytes = bytes.Concat(TLV.tlv188(API.Device.AndroidID)).ToArray(); bytes = bytes.Concat(TLV.tlv194(API.Device.Imsi)).ToArray(); bytes = bytes.Concat(TLV.tlv191()).ToArray(); bytes = bytes.Concat(TLV.tlv202(API.Device.WIFIByteSSID, API.Device.WIFISSID)).ToArray(); bytes = bytes.Concat(TLV.tlv177(API.QQ.login_Time)).ToArray(); bytes = bytes.Concat(TLV.tlv516()).ToArray(); bytes = bytes.Concat(TLV.tlv521()).ToArray(); bytes = bytes.Concat(TLV.tlv525(1, API.QQ.login_Time, API.QQ.Appid)).ToArray(); bytes = bytes.Concat(TLV.tlv544()).ToArray(); } else if (LoginType == "HDQQ") { bytes = new byte[] { 0, 9, 0, 0x18 }; bytes = bytes.Concat(TLV.tlv018(API.QQ.user)).ToArray(); bytes = bytes.Concat(TLV.tlv001(API.QQ.user, API.QQ.login_Time)).ToArray(); bytes = bytes.Concat(TLV.tlv106(API.QQ.user, API.QQ.md5_1, API.QQ.md5_2, API.QQ.TGTKey, API.Device.GUIDBytes, API.QQ.login_Time, (int)API.Device.AppId, API.QQ.UTF8)).ToArray(); bytes = bytes.Concat(TLV.tlv116(0)).ToArray(); bytes = bytes.Concat(TLV.tlv100(API.QQ.Appid.ToString())).ToArray(); bytes = bytes.Concat(TLV.tlv107()).ToArray(); if (API.UN_Tlv.T108_ksid.Length > 0) { bytes = bytes.Concat(TLV.tlv108(API.UN_Tlv.T108_ksid)).ToArray(); } bytes = bytes.Concat(TLV.tlv142()).ToArray(); bytes = bytes.Concat(TLV.tlv144(API.QQ.TGTKey, TLV.tlv109(API.Device.AndroidID), TLV.tlv52D(), TLV.tlv124(API.Device.os_type, API.Device.os_version, API.Device.network_type.ToString(), API.Device.apn), TLV.tlv128(API.Device.model, API.Device.GUIDBytes, API.Device.brands), TLV.tlv16e(API.Device.model))).ToArray(); bytes = bytes.Concat(TLV.tlv145(API.Device.GUIDBytes)).ToArray(); bytes = bytes.Concat(TLV.tlv147(API.Device.Apk_V, API.Device.ApkSig)).ToArray(); bytes = bytes.Concat(TLV.tlv154(API.QQ.mRequestID)).ToArray(); bytes = bytes.Concat(TLV.tlv141(API.Device.network_type.ToString(), API.Device.apn)).ToArray(); bytes = bytes.Concat(TLV.tlv008()).ToArray(); bytes = bytes.Concat(TLV.tlv511()).ToArray(); bytes = bytes.Concat(TLV.tlv187(API.Device.MacBytes)).ToArray(); bytes = bytes.Concat(TLV.tlv188(API.Device.AndroidID)).ToArray(); bytes = bytes.Concat(TLV.tlv194(API.Device.Imsi)).ToArray(); bytes = bytes.Concat(TLV.tlv191()).ToArray(); bytes = bytes.Concat(TLV.tlv202(API.Device.WIFIByteSSID, API.Device.WIFISSID)).ToArray(); // BSSID MD5 WIFISSID/NAME bytes = bytes.Concat(TLV.tlv177(API.QQ.login_Time)).ToArray(); bytes = bytes.Concat(TLV.tlv516()).ToArray(); bytes = bytes.Concat(TLV.tlv521()).ToArray(); bytes = bytes.Concat(TLV.tlv525(1, API.QQ.login_Time, API.QQ.Appid)).ToArray(); } else if (LoginType == "企业QQ") { bytes = new byte[] { 0, 9, 0, 0x16 }; bytes = bytes.Concat(TLV.tlv018(API.QQ.user)).ToArray(); bytes = bytes.Concat(TLV.tlv001(API.QQ.user, API.QQ.login_Time)).ToArray(); bytes = bytes.Concat(TLV.tlv106(API.QQ.user, API.QQ.md5_1, API.QQ.md5_2, API.QQ.TGTKey, API.Device.GUIDBytes, API.QQ.login_Time, (int)API.Device.AppId, API.QQ.UTF8)).ToArray(); bytes = bytes.Concat(TLV.tlv116(0)).ToArray(); bytes = bytes.Concat(TLV.tlv100(API.QQ.Appid.ToString())).ToArray(); bytes = bytes.Concat(TLV.tlv107()).ToArray(); if (API.UN_Tlv.T108_ksid.Length > 0) { bytes = bytes.Concat(TLV.tlv108(API.UN_Tlv.T108_ksid)).ToArray(); } bytes = bytes.Concat(TLV.tlv144(API.QQ.TGTKey, TLV.tlv109(API.Device.AndroidID), TLV.tlv52D(), TLV.tlv124(API.Device.os_type, API.Device.os_version, API.Device.network_type.ToString(), API.Device.apn), TLV.tlv128(API.Device.model, API.Device.GUIDBytes, API.Device.brands), TLV.tlv16e(API.Device.model))).ToArray(); bytes = bytes.Concat(TLV.tlv142()).ToArray(); bytes = bytes.Concat(TLV.tlv145(API.Device.GUIDBytes)).ToArray(); bytes = bytes.Concat(TLV.tlv154(API.QQ.mRequestID)).ToArray(); bytes = bytes.Concat(TLV.tlv141(API.Device.network_type.ToString(), API.Device.apn)).ToArray(); bytes = bytes.Concat(TLV.tlv008()).ToArray(); bytes = bytes.Concat(TLV.tlv106(API.QQ.user, API.QQ.md5_1, API.QQ.md5_2, API.QQ.TGTKey, API.Device.GUIDBytes, API.QQ.login_Time, (int)API.Device.AppId, API.QQ.UTF8)).ToArray(); bytes = bytes.Concat(TLV.tlv147(API.Device.Apk_V, API.Device.ApkSig)).ToArray(); bytes = bytes.Concat(TLV.tlv177(API.QQ.login_Time)).ToArray(); bytes = bytes.Concat(TLV.tlv187(API.Device.MacBytes)).ToArray(); bytes = bytes.Concat(TLV.tlv188(API.Device.AndroidID)).ToArray(); bytes = bytes.Concat(TLV.tlv191()).ToArray(); bytes = bytes.Concat(TLV.tlv202(API.Device.WIFIByteSSID, API.Device.WIFISSID)).ToArray(); bytes = bytes.Concat(TLV.tlv194(API.Device.Imsi)).ToArray(); bytes = bytes.Concat(TLV.tlv511()).ToArray(); } else if (LoginType == "企点QQ") { bytes = new byte[] { 0, 9, 0, 0x16 }; bytes = bytes.Concat(TLV.tlv018(API.QQ.user)).ToArray(); bytes = bytes.Concat(TLV.tlv001(API.QQ.user, API.QQ.login_Time)).ToArray(); bytes = bytes.Concat(TLV.tlv106(API.QQ.user, API.QQ.md5_1, API.QQ.md5_2, API.QQ.TGTKey, API.Device.GUIDBytes, API.QQ.login_Time, API.QQ.Appid, API.QQ.UTF8)).ToArray(); bytes = bytes.Concat(TLV.tlv116(0)).ToArray(); bytes = bytes.Concat(TLV.tlv100(API.QQ.Appid.ToString())).ToArray(); bytes = bytes.Concat(TLV.tlv107()).ToArray(); if (API.UN_Tlv.T108_ksid.Length > 0) { bytes = bytes.Concat(TLV.tlv108(API.UN_Tlv.T108_ksid)).ToArray(); } bytes = bytes.Concat(TLV.tlv142()).ToArray(); bytes = bytes.Concat(TLV.tlv144(API.QQ.TGTKey, TLV.tlv109(API.Device.AndroidID), TLV.tlv52D(), TLV.tlv124(API.Device.os_type, API.Device.os_version, API.Device.network_type.ToString(), API.Device.apn), TLV.tlv128(API.Device.model, API.Device.GUIDBytes, API.Device.brands), TLV.tlv16e(API.Device.model))).ToArray(); bytes = bytes.Concat(TLV.tlv145(API.Device.GUIDBytes)).ToArray(); bytes = bytes.Concat(TLV.tlv147(API.Device.Apk_V, API.Device.ApkSig)).ToArray(); bytes = bytes.Concat(TLV.tlv154(API.QQ.mRequestID)).ToArray(); bytes = bytes.Concat(TLV.tlv141(API.Device.network_type.ToString(), API.Device.apn)).ToArray(); bytes = bytes.Concat(TLV.tlv008()).ToArray(); bytes = bytes.Concat(TLV.tlv511()).ToArray(); bytes = bytes.Concat(TLV.tlv187(API.Device.MacBytes)).ToArray(); bytes = bytes.Concat(TLV.tlv188(API.Device.AndroidID)).ToArray(); bytes = bytes.Concat(TLV.tlv191()).ToArray(); bytes = bytes.Concat(TLV.tlv202(API.Device.WIFIByteSSID, API.Device.WIFISSID)).ToArray(); bytes = bytes.Concat(TLV.tlv177(API.QQ.login_Time)).ToArray(); bytes = bytes.Concat(TLV.tlv516()).ToArray(); bytes = bytes.Concat(TLV.tlv194(API.Device.Imsi)).ToArray(); } else { bytes = new byte[] { 0, 9, 0, 0x18 }; bytes = bytes.Concat(TLV.tlv018(API.QQ.user)).ToArray(); bytes = bytes.Concat(TLV.tlv001(API.QQ.user, API.QQ.login_Time)).ToArray(); bytes = bytes.Concat(TLV.tlv106(API.QQ.user, API.QQ.md5_1, API.QQ.md5_2, API.QQ.TGTKey, API.Device.GUIDBytes, API.QQ.login_Time, (int)API.Device.AppId, API.QQ.UTF8)).ToArray(); bytes = bytes.Concat(TLV.tlv116(0)).ToArray(); bytes = bytes.Concat(TLV.tlv100(API.QQ.Appid.ToString())).ToArray(); bytes = bytes.Concat(TLV.tlv107()).ToArray(); if (API.UN_Tlv.T108_ksid.Length > 0) { bytes = bytes.Concat(TLV.tlv108(API.UN_Tlv.T108_ksid)).ToArray(); } bytes = bytes.Concat(TLV.tlv142()).ToArray(); bytes = bytes.Concat(TLV.tlv144(API.QQ.TGTKey, TLV.tlv109(API.Device.AndroidID), TLV.tlv52D(), TLV.tlv124(API.Device.os_type, API.Device.os_version, API.Device.network_type.ToString(), API.Device.apn), TLV.tlv128(API.Device.model, API.Device.GUIDBytes, API.Device.brands), TLV.tlv16e(API.Device.model))).ToArray(); bytes = bytes.Concat(TLV.tlv145(API.Device.GUIDBytes)).ToArray(); bytes = bytes.Concat(TLV.tlv147(API.Device.Apk_V, API.Device.ApkSig)).ToArray(); bytes = bytes.Concat(TLV.tlv154(API.QQ.mRequestID)).ToArray(); bytes = bytes.Concat(TLV.tlv141(API.Device.network_type.ToString(), API.Device.apn)).ToArray(); bytes = bytes.Concat(TLV.tlv008()).ToArray(); bytes = bytes.Concat(TLV.tlv511()).ToArray(); bytes = bytes.Concat(TLV.tlv187(API.Device.MacBytes)).ToArray(); bytes = bytes.Concat(TLV.tlv188(API.Device.AndroidID)).ToArray(); bytes = bytes.Concat(TLV.tlv194(API.Device.Imsi)).ToArray(); bytes = bytes.Concat(TLV.tlv191()).ToArray(); bytes = bytes.Concat(TLV.tlv202(API.Device.WIFIByteSSID, API.Device.WIFISSID)).ToArray(); // BSSID MD5 WIFISSID/NAME bytes = bytes.Concat(TLV.tlv177(API.QQ.login_Time)).ToArray(); bytes = bytes.Concat(TLV.tlv516()).ToArray(); bytes = bytes.Concat(TLV.tlv521()).ToArray(); bytes = bytes.Concat(TLV.tlv525(1, API.QQ.login_Time, API.QQ.Appid)).ToArray(); } HashTea Hash = new HashTea(); bytes = Hash.HashTEA(bytes, API.QQ.shareKey, 0, true); return(bytes); }