/// <summary> /// </summary> /// <param name="errorType">Type of the error.</param> /// <param name="user">The user.</param> public ErrorPacket(ErrorPacketType errorType, QQClient client) : base(QQCommand.Unknown, client) { this.ErrorType = errorType; this.Family = ProtocolFamily.All; ErrorMessage = ""; }
public LoginResult Start(Action <string> qrCodeDownloadedCallback) => Start(_ => { var filePath = Path.GetFullPath("qrcode" + RandomHelper.GetRandomInt() + ".png"); File.WriteAllBytes(filePath, _); QQClient.ConsoleWriteImage(filePath); qrCodeDownloadedCallback(filePath); });
public byte[] get_tlv_0036(QQClient m_PCClient) { var data = new BinaryWriter(new MemoryStream()); if (this.wSubVer == 0x0002) { data.BEWrite(this.wSubVer); //wSubVer data.BEWrite(1); data.BEWrite(0); data.BEWrite(0); data.BEWrite(0); data.BEWrite(0); data.Write(0); data.Write(0); } else if (this.wSubVer == 0x0001) { data.BEWrite(this.wSubVer); //wSubVer data.BEWrite(1); data.BEWrite(0); data.BEWrite(0); } else { throw new Exception(string.Format("{0} 无法识别的版本号 {1}", this.Name, this.wSubVer)); } fill_head(this.cmd); fill_body(data.BaseStream.ToBytesArray(), data.BaseStream.Length); set_length(); return(get_buf()); }
static void Main(string[] args) { #if DEBUG uint qq = 976811781u; string pass = Console.ReadLine(); #else Console.Write("请输入QQ:"); uint qq = uint.Parse(Console.ReadLine()); Console.Write("请输入密码:"); string pass = Console.ReadLine(); #endif client = new QQClient(qq, pass); client.User.IsUdp = true; client.LoginStatusChanged += client_LoginStatusChanged; client.ReceiveClusterIM += client_ReceiveClusterIM; client.ReceiveNormalIM += client_ReceiveNormalIM; client.AddedToCluster += client_AddedToCluster; client.LoginSuccessed += client_LoginSuccessed; client.CardChanged += client_CardChanged; client.ClusterAdminChanged += client_ClusterAdminChanged; client.AddToClusterNeedAuth += client_AddToClusterNeedAuth; client.AddedToClusterInvite += client_AddedToClusterInvite; client.Login(); var input = Console.ReadLine(); while (client.User.LoginStatus == Coco.Framework.Entities.LoginStatus.NeedVerifyCode) { client.SendVerifyCode(input); input = Console.ReadLine(); } client.Logout(); }
public ConnectionManager(QQClient client, EventStrategy eventStrategy) { this.m_qqClient = client; this.m_eventStrategy = eventStrategy; this.NeedLocation = false; this.ServerPoint = new System.Net.IPEndPoint(IPAddress.Parse("112.95.242.111"), 8000); }
private void button1_Click(object sender, EventArgs e) { if (!had) { had = true; this.label5.Visible = true; msg = this.richTextBox1.Text.Trim() + "\n----------------------------------\n本消息由QQMessage发送\nhttp://www.2081.org/labs.html"; user = new QQUser(Int32.Parse(this.textBox1.Text.Trim()), this.textBox2.Text); client = new QQ.NET.QQClient(user); user.IsUdp = true; client.LoginServerHost = "219.133.62.8"; client.ConnectionManager.NetworkError += new EventHandler <ErrorEventArgs>(ConnectionManager_NetworkError); client.LoginManager.LoginFailed += new EventHandler <QQEventArgs <LoginReplyPacket, LoginPacket> >(LoginManager_LoginFailed); client.LoginManager.LoginSuccessed += new EventHandler <QQEventArgs <LoginReplyPacket, LoginPacket> >(LoginManager_LoginSuccessed); client.FriendManager.GetFriendListSuccessed += new EventHandler <QQEventArgs <GetFriendListReplyPacket, GetFriendListPacket> >(FriendManager_GetFriendListSuccessed); client.Error += new EventHandler <QQEventArgs <ErrorPacket, OutPacket> >(client_Error); client.MessageManager.ReceiveNormalIM += new EventHandler <QQEventArgs <ReceiveIMPacket, OutPacket> >(MessageManager_ReceiveNormalIM); client.Login(); } else { MessageBox.Show("请关闭程序后,重新登录发送。"); } }
public LoginRequestPacket(QQClient client) : base(QQCommand.LoginRequest, true, client) { this.Token = null; this.GetCode = 0; this.Png_Data = 0; }
public byte[] get_tlv_0015(QQClient m_PCClient) { var data = new BinaryWriter(new MemoryStream()); if (wSubVer == 0x0001) { data.BEWrite(wSubVer); //wSubVer data.Write(0x01); var thisKey = m_PCClient.QQUser.TXProtocol.bufComputerID; data.BEWrite(CRC32cs.CRC32(thisKey)); data.Write(thisKey); data.Write(0x02); thisKey = m_PCClient.QQUser.TXProtocol.bufComputerIDEx; data.BEWrite(CRC32cs.CRC32(thisKey)); data.Write(thisKey); } else { throw new Exception(string.Format("{0} 无法识别的版本号 {1}", Name, wSubVer)); } fill_head(cmd); fill_body(data.BaseStream.ToBytesArray(), data.BaseStream.Length); set_length(); return(get_buf()); }
public ClusterIM(QQClient qqClient, RecvSource source) { this.QQClient = qqClient; this.Source = source; FaceResolved = false; FontStyle = new FontStyle(); }
public SearchUserPacket(QQClient client) : base(QQCommand.Search_User_05, true, client) { Page = "0"; SearchType = FriendSearchType.SEARCH_ALL; QQStr = Nick = Email = string.Empty; }
//string portName; public ResendTrigger(QQClient client) { this.client = client; timeOutQueue = new List<OutPacket>(); //toPort = new Dictionary<OutPacket, string>(); ThreadExcutor.RegisterIntervalObject(this, this, QQGlobal.QQ_TIMEOUT_SEND, true); }
public KeepAlivePacket(QQClient client) : base(QQCommand.Keep_Alive, true, client) { // 刻意增加了keep alive包的发送次数,实验性质,不知能否减少网络包 // 太多情况下的掉线可能性 SendCount = 10; }
public static string[] GetID(string number) { try { string strSource = QQClient.Get("http://qq.ip138.com/idsearch/index.asp?action=idcard&userid=" + number.Trim() + "&B1=%B2%E9+%D1%AF", null, 100000, System.Text.Encoding.Default); //归属地 strSource = strSource.Substring(strSource.IndexOf("查询结果")); strSource = strSource.StripHTML(); strSource = strSource.Replace("\r", ""); strSource = strSource.Replace("\n", ""); strSource = strSource.Replace("\t", ""); strSource = strSource.Replace(" ", ""); strSource = strSource.Replace("查询结果 * ++", ""); strSource = strSource.Replace("-->", ""); string[] strnumber = strSource.Split(new string[] { "性别:", "出生日期:", "发证地:", "点击这里查询验证身份", "提示:" }, StringSplitOptions.RemoveEmptyEntries); string[] strnumber1 = null; if (strnumber.Length > 3) { strnumber1 = new string[] { strnumber[1].Trim(), strnumber[2].Trim(), strnumber[3].Trim() }; } return(strnumber1); } catch (Exception) { return(null); } }
public SendSMSPacket(QQClient client) : base(QQCommand.Send_SMS_05,true,client) { MessageSequence = 0; ContentType = SMSContentType.NORMAL; SendMode = SMSSendMode.NORMAL; }
/// <summary>创建一个基本输出包 /// </summary> /// <param name="header">The header.</param> /// <param name="command">包命令.</param> /// <param name="ack">包是否需要回复.</param> /// <param name="user">QQ用户对象.</param> public OutPacket(byte header, QQCommand command, bool ack, QQClient client) : base(header, QQGlobal.QQ_CLIENT_VERSION, command, GetNextSeq(), client) { this.ack = ack; this.resendCountDown = QQGlobal.QQ_SEND_TIME_NOACK_PACKET; this.SendCount = 1; }
/// <summary> /// /// </summary> /// <param name="client">QQclient</param> /// <param name="token">这个包发出去获取的令牌</param> /// <param name="getCode">1或0,1和验证码有关的请求</param> /// <param name="code">验证码的值</param> public LoginRequestPacket(QQClient client, byte[] token, uint getCode, byte png_data) : base(QQCommand.LoginRequest, true, client) { this.Token = token; this.GetCode = getCode; this.Png_Data = png_data; }
public SearchUserPacket(QQClient client) : base(QQCommand.Search_User_05,true,client) { Page = "0"; SearchType = FriendSearchType.SEARCH_ALL; QQStr = Nick = Email = string.Empty; }
public byte[] get_tlv_0309(QQClient m_PCClient) { var data = new BinaryWriter(new MemoryStream()); if (wSubVer == 0x0001) { data.BEWrite(wSubVer); //wSubVer data.Write(Util.IPStringToByteArray(m_PCClient.dwServerIP)); //LastServerIP - 服务器最后的登录IP,可以为0 data.Write((byte)m_PCClient.QQUser.RedirectIP.Count); //cRedirectCount - 重定向的次数(IP的数量) foreach (var ip in m_PCClient.QQUser.RedirectIP) { data.Write(ip); } data.Write(m_PCClient.QQUser.cPingType); //cPingType } else { throw new Exception($"{Name} 无法识别的版本号 {wSubVer}"); } fill_head(cmd); fill_body(data.BaseStream.ToBytesArray(), data.BaseStream.Length); set_length(); return(get_buf()); }
public void parser_tlv_0108(QQClient m_PCClient, BinaryReader buf) { byte[] buffer; ushort len; wSubVer = buf.BEReadUInt16(); //wSubVer if (wSubVer == 0x0001) { len = buf.BEReadUInt16(); buffer = buf.ReadBytes(len); var bufAccountBasicInfo = new BinaryReader(new MemoryStream(buffer)); len = bufAccountBasicInfo.BEReadUInt16(); buffer = bufAccountBasicInfo.ReadBytes(len); var info = new BinaryReader(new MemoryStream(buffer)); var wSSO_Account_wFaceIndex = info.BEReadUInt16(); len = info.ReadByte(); if (len > 0) { m_PCClient.QQUser.NickName = Encoding.UTF8.GetString(info.ReadBytes(len)); } var cSSO_Account_cGender = info.ReadByte(); var dwSSO_Account_dwUinFlag = info.BEReadUInt32(); m_PCClient.QQUser.Age = info.ReadByte(); var bufSTOther = bufAccountBasicInfo.ReadBytes( (int)(bufAccountBasicInfo.BaseStream.Length - bufAccountBasicInfo.BaseStream.Position)); } else { throw new Exception(string.Format("{0} 无法识别的版本号 {1}", Name, wSubVer)); } }
//string portName; public ResendTrigger(QQClient client) { this.client = client; timeOutQueue = new List <OutPacket>(); //toPort = new Dictionary<OutPacket, string>(); ThreadExcutor.RegisterIntervalObject(this, this, QQGlobal.QQ_TIMEOUT_SEND, true); }
public byte[] get_tlv_0004(QQClient m_PCClient) { if (m_PCClient.QQUser.QQ != 0) { return(null); } var data = new BinaryWriter(new MemoryStream()); if (wSubVer == 0x0000) { data.BEWrite(wSubVer); //wSubVer var bufAccount = Util.HexStringToByteArray(Util.QQToHexString(m_PCClient.QQUser.QQ)); data.BEWrite((ushort)bufAccount.Length); //账号长度 data.Write(bufAccount); //账号 } else { throw new Exception($"{Name} 无法识别的版本号 {wSubVer}"); } fill_head(cmd); fill_body(data.BaseStream.ToBytesArray(), data.BaseStream.Length); set_length(); return(get_buf()); }
public void parser_tlv_010E(QQClient m_PCClient, BinaryReader buf) { int len; byte[] buffer; wSubVer = buf.BEReadUInt16(); //wSubVer if (wSubVer == 0x0001) { len = buf.BEReadUInt16(); buffer = buf.ReadBytes(len); var sig = new BinaryReader(new MemoryStream(buffer)); var dwUinLevel = sig.BEReadInt32(); var dwUinLevelEx = sig.BEReadInt32(); len = sig.BEReadUInt16(); buffer = sig.ReadBytes(len); var buf24byteSignature = buffer; len = sig.BEReadUInt16(); buffer = sig.ReadBytes(len); var buf32byteValueAddedSignature = buffer; len = sig.BEReadUInt16(); buffer = sig.ReadBytes(len); var buf12byteUserBitmap = buffer; m_PCClient.QQUser.TXProtocol.ClientKey = buf32byteValueAddedSignature; //client.QQUser.ClientKeyString = Util.ToHex(buf32byteValueAddedSignature).Replace(" ", ""); //client.GetCookie(); } else { throw new Exception(string.Format("{0} 无法识别的版本号 {1}", Name, wSubVer)); } }
/// <summary>从buf中构造一个OutPacket,用于调试。这个buf里面可能包含了抓包软件抓来的数据 /// </summary> /// <param name="buf">The buf.</param> /// <param name="length">要解析的内容长度</param> /// <param name="user">The user.</param> protected Packet(ByteBuffer buf, int length, QQClient client) { this.Client = client; ParseHeader(buf); if (!ValidateHeader()) { throw new PacketParseException("包头有误,抛弃该包: " + ToString()); } // 得到包体 byte[] body = GetBodyBytes(buf, length); bodyDecrypted = DecryptBody(body, 0, body.Length); if (bodyDecrypted == null) { throw new PacketParseException("包内容解析出错,抛弃该包: " + ToString()); } // 包装到ByteBuffer ByteBuffer tempBuf = new ByteBuffer(bodyDecrypted); try { ParseBody(tempBuf); } catch (Exception e) { throw new PacketParseException(e.Message, e); } ParseTail(buf); this.DateTime = DateTime.Now; }
public byte[] get_tlv_0105(QQClient m_PCClient) { var data = new BinaryWriter(new MemoryStream()); if (wSubVer == 0x0001) { data.BEWrite(wSubVer); //wSubVer data.Write(1); data.Write(2); data.BEWrite(0x0014); data.BEWrite(0x01010010); data.Write(Util.RandomKey()); data.BEWrite(0x0014); data.BEWrite(0x01020010); data.Write(Util.RandomKey()); } else { throw new Exception($"{Name} 无法识别的版本号 {wSubVer}"); } fill_head(cmd); fill_body(data.BaseStream.ToBytesArray(), data.BaseStream.Length); set_length(); return(get_buf()); }
public IConnection Create(QQClient client, string serverHost, int port, bool start) { IConnection conn = null; ConnectionPolicy policy = null; EndPoint server = GetEndPoint(serverHost, port); switch (Name) { case "Main": policy = new ConnectionPolicy(client, Name, ProtocolFamily.Basic, ProtocolFamily.Basic); if (client.QQUser.IsUdp) { conn = client.ConnectionManager.ConnectionPool.NewUDPConnection(policy, server, start); } else { conn = client.ConnectionManager.ConnectionPool.NewTCPConnection(policy, server, start); } break; case "CLUSTER_CUSTOM_FACE": break; case "CUSTOM_HEAD_INFO": break; case "CUSTOM_HEAD_DATA": break; case "DISK": break; default: break; } return(conn); }
public SendSMSPacket(QQClient client) : base(QQCommand.Send_SMS_05, true, client) { MessageSequence = 0; ContentType = SMSContentType.NORMAL; SendMode = SMSSendMode.NORMAL; }
public static string[] GetPhone(string number) { try { string strSource = QQClient.Get("http://www.ip138.com:8080/search.asp?mobile=" + number + "&action=mobile", null, 100000, System.Text.Encoding.Default); //归属地 strSource = strSource.Substring(strSource.IndexOf(number)); strSource = strSource.StripHTML(); strSource = strSource.Replace("\r", ""); strSource = strSource.Replace("\n", ""); strSource = strSource.Replace("\t", ""); strSource = strSource.Replace(" ", ""); strSource = strSource.Replace("-->", ""); string[] strnumber = strSource.Split(new string[] { "归属地", "卡类型", "邮 编", "区 号", "更详细", "卡号" }, StringSplitOptions.RemoveEmptyEntries); string[] strnumber1 = null; if (strnumber.Length > 4) { strnumber1 = new string[] { strnumber[1].Trim(), strnumber[2].Trim(), strnumber[3].Trim(), strnumber[4].Trim() }; } return(strnumber1); } catch (Exception) { return(null); } }
public NormalIMFace(QQClient qqClient, byte[] buffer) { QQClient = qqClient; ByteBuffer buf = new ByteBuffer(buffer); Read(buf); }
/// <summary> /// 把ByteBuffer中的内容解析成一个InPacket子类,从buf的当前位置开始解析length字节 /// * 不论解析成功或者失败,buf的position将位于length后 /// </summary> /// <param name="parser">The parser.</param> /// <param name="buf">The buf.</param> /// <param name="length">The length.</param> /// <param name="user">The user.</param> /// <returns></returns> private InPacket ParseIn(IParser parser, ByteBuffer buf, int length, QQClient client) { // 保存当前位置 int offset = buf.Position; try { InPacket ret = parser.ParseIncoming(buf, length, client); bool duplicated = IsDuplicated(ret); bool needReply = parser.IsDuplicatedNeedReply(ret); if (duplicated && !needReply) { return(null); } else { ret.IsDuplicated = duplicated; return(ret); } } finally { buf.Position = offset + length; } }
public ClusterModifyInfoPacket(QQClient client) : base(client) { SubCommand = ClusterCommand.MODIFY_CLUSTER_INFO; AuthType = AuthType.NeedAuth; Name = Notice = Description = string.Empty; Type = ClusterType.PERMANENT; }
public AddFriendAuthorizePacket(QQClient client) : base(QQCommand.AddFriendAuthorize, true, client) { //SubCommand = AddFriendAuthSubCmd.Request;// 0x02; //ReverseAdd = RevenseAdd.Allow; DestGroup = 0; Message = string.Empty; }
public MessageManage(QQClient client) { Server = client.Server; this.client = client; EndPoint point = new IPEndPoint(IPAddress.Parse(client.LoginServerHost), client.LoginPort); client.Point = point; }
public AddFriendAuthorizePacket(QQClient client) : base(QQCommand.AddFriendAuthorize,true,client) { //SubCommand = AddFriendAuthSubCmd.Request;// 0x02; //ReverseAdd = RevenseAdd.Allow; DestGroup = 0; Message = string.Empty; }
public ConnectionPolicy(QQClient client, string id, ProtocolFamily supportedFamily, ProtocolFamily relocateFamily) { this.ID = id; this.client = client; this.SupportedFamily = supportedFamily; this.RelocateFamily = relocateFamily; helper = new PacketHelper(); }
public ClusterCreatePacket(QQClient client) : base(client) { this.SubCommand = ClusterCommand.CREATE_CLUSTER; this.Type = ClusterType.PERMANENT; this.AuthType = AuthType.NeedAuth; this.OldCategory = 0; }
public AdvancedSearchUserPacket(QQClient client) : base(QQCommand.Advanced_Search_05,true,client) { SearchOnline = true; HasCam = false; Page = ProvinceIndex = CityIndex = 0; AgeIndex = GenderIndex = 0; }
/// <summary> /// Initializes a new instance of the <see cref="ClusterSendIMExPacket"/> class. /// </summary> /// <param name="user">The user.</param> public ClusterSendIMExPacket(QQClient client) : base(client) { SubCommand = ClusterCommand.SEND_IM_EX09; TotalFragments = 1; FragmentSequence = 0; MessageId = (ushort)Utils.Util.Random.Next(); FontStyle = new FontStyle(); Message = string.Empty; }
/// <summary> /// /// </summary> /// <param name="client"></param> public LoginGetListPacket(QQClient client) : base(QQCommand.LoginGetList, true, client) { //this.Pos = 0; //if (!RequestCount.ContainsKey(client.QQUser.QQ)) //{ // RequestCount.Add(client.QQUser.QQ, 0); //} //else // RequestCount[this.Client.QQUser.QQ]++; }
/// <summary>构造一个指定参数的包 /// </summary> /// <param name="header">包头</param> /// <param name="source">包源</param> /// <param name="command">包命令 </param> /// <param name="sequence">包序号 </param> /// <param name="user">QQ用户对象</param> public Packet(byte header, char source, QQCommand command, char sequence, QQClient client) { //this.user = user; this.Client = client; this.Source = source; this.Command = command; this.Sequence = sequence; this.IsDuplicated = false; this.Header = header; this.DateTime = DateTime.Now; }
/// <summary>从buf中构造一个OutPacket,用于调试。这个buf里面可能包含了抓包软件抓来的数据 /// </summary> /// <param name="buf">The buf.</param> /// <param name="length">The length.</param> /// <param name="user">The user.</param> protected OutPacket(ByteBuffer buf, int length, QQClient client) : base(buf, length, client) { }
/// <summary>从buf中构造一个OutPacket,用于调试。这个buf里面可能包含了抓包软件抓来的数据 /// </summary> /// <param name="buf">The buf.</param> /// <param name="user">The user.</param> protected OutPacket(ByteBuffer buf, QQClient client) : base(buf, client) { }
public ReceiveIMReplyPacket(ByteBuffer buf, int length, QQClient client) : base(buf, length, client) { }
public ReceiveIMReplyPacket(byte[] reply, QQClient client) : base(QQCommand.Recv_IM, false, client) { this.Reply = reply; this.SendCount = 1; }
public GroupDataOpPacket(ByteBuffer buf, int length, QQClient client) : base(buf, length, client) { }
/// <summary> /// </summary> /// <param name="buf">The buf.</param> /// <param name="user">The user.</param> protected BasicOutPacket(ByteBuffer buf, QQClient client) : base(buf, buf.Length - buf.Position, client) { }
public RemoveSelfReplyPacket(ByteBuffer buf, int length, QQClient client) : base(buf, length, client) { }
public ClusterGetCardBatchPacket(QQClient client) : base(client) { SubCommand = ClusterCommand.GET_CARD_BATCH; }
public ClusterGetCardBatchPacket(ByteBuffer buf, int length, QQClient client) : base(buf, length, client) { }
public SignatureOpPacket(ByteBuffer buf, int length, QQClient client) : base(buf, length, client) { }
public SignatureOpPacket(QQClient client) : base(QQCommand.Signature_OP_05,true,client) { SubCommand = SignatureSubCmd.MODIFY; Signature = string.Empty; }
public LoginReplyPacket(ByteBuffer buf, int length, QQClient client) : base(buf, length, client) { }
public GroupDataOpPacket(QQClient client) : base(QQCommand.Group_Data_OP_05,true,client) { Type = GroupSubCmd.UPLOAD; Groups = new List<string>(); }
public UploadGroupFriendReplyPacket(ByteBuffer buf, int length, QQClient client) : base(buf, length, client) { }
/// <summary>构造一个参数指定的包. /// </summary> /// <param name="command">命令.</param> /// <param name="ack">是否需要回应.</param> /// <param name="user">The user.</param> protected BasicOutPacket(QQCommand command, bool ack, QQClient client) : base(QQGlobal.QQ_HEADER_BASIC_FAMILY, command, ack, client) { }