private void Connect() { if (_Socket != null) { _Socket.Close(); Trace2(_uin + "disc:" + _oldConnectionStatus); } _NetworkStream = new MemoryStream(); TcpClient _TcpClient = new TcpClient(servers.Pop(), 5190); _Socket = _TcpClient.Client; _NetworkStream = new NetworkStream(_Socket); new Flap { _ICQ = this }.Receive(); // receive hello Flap _Flap2 = new Flap { _ICQ = this }; _Flap2.ch = 1; _Flap2._data.Write(new byte[] { 0, 0, 0, 1 }); _Flap2._Tvls.Add(new Tvl { type = 1, data = _uin.ToBytes() }); _Flap2._Tvls.Add(new Tvl { type = 2, data = XOR(_passw) }); _Flap2._Tvls.Add(new Tvl { type = 3, data = "chatbot".ToBytes() }); _Flap2.WriteTvl(); _Flap2.Send(@"00 16 00 02 01 0A 00 17 00 02 00 05 00 18 00 02 00 25 00 19 00 02 00 01 00 1A 00 02 0E 90 00 14 00 04 00 00 00 55 00 0F 00 02 65 6E 00 0E 00 02 75 73".Hex()); Flap _Flap = new Flap { _ICQ = this }.Receive().ReadTvl(); //1 uin //2 ip 3 cookie Match m = Regex.Match(_Flap._Tvls[2].data.ToStr(), @"(.+?):(\d+)"); if (!m.Success) { throw new ExceptionB("cannot Connect"); } ip = m.Groups[1].Value; port = int.Parse(m.Groups[2].Value); _Cookie = _Flap._Tvls[3].data; _Socket.Close(); BossSimple(); }
public void BossSimple() { TcpClient _TcpClient = new TcpClient(ip, port); _Socket = _TcpClient.Client; _NetworkStream = new NetworkStream(_Socket); Flap hello = new Flap { _ICQ = this }.Receive(); //receive hello Flap _Flap1 = new Flap { _ICQ = this, ch = 1 }; _Flap1._data.Write(new byte[] { 0, 0, 0, 1 }); _Flap1._Tvls.Add(new Tvl { data = _Cookie, type = 6 }); _Flap1.WriteTvl().Send(); Flap _Flap2 = new Flap { _ICQ = this }.Receive().ReadSnac(); Flap _Flap3 = new Flap { _ICQ = this }; _Flap3.ch = 2; _Flap3._Snac.ID1 = 1; _Flap3._Snac.ID2 = 2; _Flap3._Snac.flag1 = _Flap3._Snac.flag2 = 0; _Flap3.WriteSnac();//.Write(); while (_Flap2._data.Position != _Flap2._data.Length) { UInt16 a = _Flap2._data.ReadUInt16(); _Flap3._data.WriteUint16(a); _Flap3._data.Write("00 01 01 10 04 7B".Hex()); } _Flap3.Send(); Flap _Flap4 = new Flap { _ICQ = this }; _Flap4.Receive().ReadSnac(); if (_Flap4._Snac.ID1 != 11 || _Flap4._Snac.ID2 != 2) { throw new Exception(); } Thread.Sleep(1000); }