public void Connect() { string[] address = realm.Address.Split(':'); byte[] test = new byte[1]; test[0] = 10; mCrypt = new PacketCrypt(test); IPAddress WSAddr = Dns.GetHostAddresses(address[0])[0]; int WSPort = Int32.Parse(address[1]); IPEndPoint ep = new IPEndPoint(WSAddr, WSPort); try { mSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); mSocket.Connect(ep); Log.WriteLine(LogType.Success, "Successfully connected to WorldServer at: {0}!", realm.Address); } catch (SocketException ex) { Log.WriteLine(LogType.Error, "Failed to connect to realm: {0}", ex.Message); Disconnect(); return; } byte[] nullA = new byte[24]; mCrypt = new PacketCrypt(nullA); Connected = true; pHandler = new PacketHandler(this); pLoop = new PacketLoop(this, mSocket); pLoop.Start(); pHandler.Initialize(); }
public void DoAuthSession() { try { PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_AUTH_SESSION); Sha1Hash sha = new Sha1Hash(); sha.Update(mUsername); sha.Update(new byte[4]); // t sha.Update(ClientSeed); sha.Update(ServerSeed); sha.Update(mKey); byte[] Digest = sha.Final(); packet.Write((UInt32)Config.Version.build); packet.Write((UInt32)0); packet.Write(mUsername); packet.Write((UInt32)0); packet.Write(ClientSeed); packet.Write((UInt64)0); packet.Write(Digest); bool WantToCrash = false; if (WantToCrash) { byte[] addons = { (byte)0x00 }; byte[] buffer2 = mClient.Shared.Compression.Compress(addons); UInt32 Size = (UInt32)addons.Length; packet.Write(Size); packet.Write(buffer2); } else { byte[] addon_data = { 0x56, 0x01, 0x00, 0x00, 0x78, 0x9c, 0x75, 0xcc, 0xbd, 0x0e, 0xc2, 0x30, 0x0c, 0x04, 0xe0, 0xf2, 0x1e, 0xbc, 0x0c, 0x61, 0x40, 0x95, 0xc8, 0x42, 0xc3, 0x8c, 0x4c, 0xe2, 0x22, 0x0b, 0xc7, 0xa9, 0x8c, 0xcb, 0x4f, 0x9f, 0x1e, 0x16, 0x24, 0x06, 0x73, 0xeb, 0x77, 0x77, 0x81, 0x69, 0x59, 0x40, 0xcb, 0x69, 0x33, 0x67, 0xa3, 0x26, 0xc7, 0xbe, 0x5b, 0xd5, 0xc7, 0x7a, 0xdf, 0x7d, 0x12, 0xbe, 0x16, 0xc0, 0x8c, 0x71, 0x24, 0xe4, 0x12, 0x49, 0xa8, 0xc2, 0xe4, 0x95, 0x48, 0x0a, 0xc9, 0xc5, 0x3d, 0xd8, 0xb6, 0x7a, 0x06, 0x4b, 0xf8, 0x34, 0x0f, 0x15, 0x46, 0x73, 0x67, 0xbb, 0x38, 0xcc, 0x7a, 0xc7, 0x97, 0x8b, 0xbd, 0xdc, 0x26, 0xcc, 0xfe, 0x30, 0x42, 0xd6, 0xe6, 0xca, 0x01, 0xa8, 0xb8, 0x90, 0x80, 0x51, 0xfc, 0xb7, 0xa4, 0x50, 0x70, 0xb8, 0x12, 0xf3, 0x3f, 0x26, 0x41, 0xfd, 0xb5, 0x37, 0x90, 0x19, 0x66, 0x8f }; packet.Write(addon_data); } Send(packet); mCrypt = new PacketCrypt(mKey); mCrypt.Init(); } catch (Exception e) { Log.WriteLine(LogType.Error, e.StackTrace); } }