Example #1
0
        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();
        }
Example #2
0
    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);

        Thread.Sleep(1000);
        try
        {
            mSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
            mSocket.Connect(ep);
            Debug.LogWarning("Successfully connected to WorldServer at: " + realm.Address);
        }
        catch (SocketException ex)
        {
            Debug.LogWarning("Failed to connect to realm: " + ex.Message);
            //Exchange.Disconnect();
            return;
        }

        byte[] nullA = new byte[24];
        mCrypt = new PacketCrypt(nullA);
        Global.showNotifyBox("Connected.", "Cancel");
        HandlerDefinitions.InitializePacketHandler();
        Ping.Elapsed += new ElapsedEventHandler(pingLoop);
        Ping.Interval = 30000;
        Ping.Enabled  = true;
        Ping_Seq      = 1;
        Latency       = 1;
    }
Example #3
0
        public override void OnAccept(Socket newSocket)
        {
            base.OnAccept(newSocket);

            ulong key = PacketCrypt.GetKeyFromAuthBuildAndMessage();

            encryption = new PacketCrypt(key);
        }
        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);
            }
        }
Example #5
0
        protected override void Dispatch(InPacket inPacket)
        {
            try
            {
                PacketCrypt pd = new PacketCrypt(0);

                byte[] ii;
                if (inPacket.Array[0] == 0xAA && inPacket.Array[1] == 0x55)
                {
                    ii = inPacket.Array;
                }
                else
                {
                    ii = pd.Decrypt(inPacket.Array);
                }

                InPacket ip = new InPacket(ii);

                if (ip.OperationCode == (ushort)ClientOpcode.SERVER)
                {
                    var Header = ip.ReadShort();
#if DEBUG
                    Log.Hex("Received (0x{0:X2}) packet from {1}: ", ip.Content, Header, this.Title);
#endif
                    switch (Header)
                    {
                    case 0x0C:
                        FriendPacket.FriendList(this);
                        break;
                    }
                }
            }
            catch (HackException e)
            {
                // TODO: Register offense using the exception's message.
                Log.Warn("Hack exception from {0}: \n{1}", this.Title, e.ToString());
            }
            catch (Exception e)
            {
                Log.Error("Unhandled exception from {0}: \n{1}", this.Title, e.ToString());
            }
        }
Example #6
0
        public void SetEncryptionKey(byte[] sessionKey)
        {
            ulong key = PacketCrypt.GetKeyFromTicket(sessionKey);

            encryption = new PacketCrypt(key);
        }
Example #7
0
 public WorldClass()
 {
     DataBuffer  = new byte[8192];
     PacketQueue = new Queue();
     Crypt       = new PacketCrypt();
 }
Example #8
0
        protected override void Dispatch(InPacket inPacket)
        {
            try
            {
                //Log.Hex("Received packet from {0}: ", inPacket.Array, this.Title);
                PacketCrypt pd = new PacketCrypt(SessionID);

                byte[] ii;
                if (inPacket.Array[0] == 0x4D && inPacket.Array[1] == 0x0)
                {
                    ii = inPacket.Array;
                }
                else
                {
                    ii = pd.Decrypt(inPacket.Array);
                }
                InPacket ip = new InPacket(ii);

                if (ip.OperationCode == (ushort)ClientOpcode.SERVER)
                {
                    GameServerHandler.ServerHandlerReceive(ip, this);
                }
            }
            catch (HackException e)
            {
                if (this.Character != null)
                {
                    // TODO: Register offense points in the database (?).

                    //Log.Warn("Taking Hack Action of {0} against {1}: \n{2}", e.Action, this.Character.Name, e.Message);

                    switch (e.Action)
                    {
                    case HackAction.Disconnection:
                    {
                        this.Dispose();
                    }
                    break;

                    case HackAction.ThirthyDays:
                    {
                    }
                    break;

                    case HackAction.NinetyDays:
                    {
                    }
                    break;

                    case HackAction.Permanent:
                    {
                    }
                    break;
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error("Unhandled Packet Exception from {0}: \n{1}", this.Title, e.ToString());
            }
        }
Example #9
0
 public WorldSession()
 {
     ReceiveBuffer = new byte[ushort.MaxValue];
     PacketQueue   = new Queue();
     Crypt         = new PacketCrypt();
 }