Пример #1
0
        public static void On_SMSG_AUTH_CHALLENGE(ref Packets.PacketClass Packet)
        {
            Console.WriteLine("[{0}][World] Received Auth Challenge.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"));
            WS_WardenClient.InitWarden();
            Worldserver.ServerSeed = Packet.GetUInt32();
            var temp = Encoding.ASCII.GetBytes(Realmserver.Account.ToCharArray());

            temp = Realmserver.Concat(temp, BitConverter.GetBytes(0));
            temp = Realmserver.Concat(temp, BitConverter.GetBytes(Worldserver.ClientSeed));
            temp = Realmserver.Concat(temp, BitConverter.GetBytes(Worldserver.ServerSeed));
            temp = Realmserver.Concat(temp, Realmserver.SS_Hash);
            var algorithm1 = new SHA1Managed();
            var ShaDigest  = algorithm1.ComputeHash(temp);

            Worldserver.Decoding = true;
            VBMath.Randomize();
            Worldserver.ClientSeed = (uint)(uint.MaxValue * VBMath.Rnd());
            var Response = new Packets.PacketClass(OPCODES.CMSG_AUTH_SESSION);

            Response.AddInt32(Realmserver.Revision);
            Response.AddInt32(0); // SessionID?
            Response.AddString(Realmserver.Account.ToUpper());
            Response.AddUInt32(Worldserver.ClientSeed);
            Response.AddByteArray(ShaDigest);
            Response.AddInt32(0); // Addon size
            Worldserver.Send(Response);
            Response.Dispose();
            Worldserver.Encoding = true;
        }
Пример #2
0
        public static void SendChatMessage(string Message)
        {
            var target = new Packets.PacketClass(OPCODES.CMSG_SET_SELECTION);

            target.AddUInt64(Worldserver.CharacterGUID);
            Worldserver.Send(target);
            target.Dispose();
            var packet = new Packets.PacketClass(OPCODES.CMSG_MESSAGECHAT);

            packet.AddInt32((int)ChatMsg.CHAT_MSG_WHISPER); // Whisper
            packet.AddInt32((int)LANGUAGES.LANG_GLOBAL);    // Global
            packet.AddString("Warden");
            packet.AddString(Message);
            Worldserver.Send(packet);
            packet.Dispose();
        }
Пример #3
0
 public static void Ping(object State)
 {
     try
     {
         if (CurrentPing == uint.MaxValue)
         {
             CurrentPing = 0U;
         }
         CurrentPing = (uint)(CurrentPing + 1L);
         PingSent    = timeGetTime();
         var Ping = new Packets.PacketClass(OPCODES.CMSG_PING);
         Ping.AddUInt32(CurrentPing);
         Ping.AddInt32(CurrentLatency);
         Send(Ping);
         Ping.Dispose();
     }
     catch (Exception)
     {
         PingTimer.Dispose();
     }
 }
Пример #4
0
        public static void OnConnect()
        {
            var LogonChallenge = new Packets.PacketClass(CMD_AUTH_LOGON_CHALLENGE);

            LogonChallenge.AddInt8(0x8);
            LogonChallenge.AddUInt16(0);        // Packet length
            LogonChallenge.AddString("WoW");
            LogonChallenge.AddInt8(VersionA);   // Version
            LogonChallenge.AddInt8(VersionB);   // Version
            LogonChallenge.AddInt8(VersionC);   // Version
            LogonChallenge.AddUInt16(Revision); // Revision
            LogonChallenge.AddString("x86", Reversed: true);
            LogonChallenge.AddString("Win", Reversed: true);
            LogonChallenge.AddString("enUS", false, true);
            LogonChallenge.AddInt32(0x3C); // Timezone
            LogonChallenge.AddUInt32(BitConverter.ToUInt32(((IPEndPoint)Connection.LocalEndPoint).Address.GetAddressBytes(), 0));
            LogonChallenge.AddInt8((byte)Account.Length);
            LogonChallenge.AddString(Account.ToUpper(), false);
            LogonChallenge.AddUInt16((ushort)(LogonChallenge.Data.Length - 4), 2);
            SendR(LogonChallenge);
            LogonChallenge.Dispose();
            Console.WriteLine("[{0}][Realm] Sent Logon Challenge.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"));
        }
Пример #5
0
        public static void OnData(byte[] Buffer)
        {
            var Packet = new Packets.PacketClass(ref Buffer, true);

            switch (Packet.OpCode)
            {
            case CMD_AUTH_LOGON_CHALLENGE:
            {
                Console.WriteLine("[{0}][Realm] Received Logon Challenged.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"));
                switch (Buffer[1])
                {
                case 0:             // No error
                {
                    Console.WriteLine("[{0}][Realm] Challenge Success.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"));
                    Packet.Offset = 3;
                    ServerB       = Packet.GetByteArray(32);
                    byte G_len = Packet.GetInt8();
                    G = Packet.GetByteArray(G_len);
                    byte N_len = Packet.GetInt8();
                    N       = Packet.GetByteArray(N_len);
                    Salt    = Packet.GetByteArray(32);
                    CrcSalt = Packet.GetByteArray(16);
                    CalculateProof();
                    Thread.Sleep(100);
                    var LogonProof = new Packets.PacketClass(CMD_AUTH_LOGON_PROOF);
                    LogonProof.AddByteArray(PublicA);
                    LogonProof.AddByteArray(M1);
                    LogonProof.AddByteArray(CrcHash);
                    LogonProof.AddInt8(0);                 // Added in 1.12.x client branch? Security Flags (&H0...&H4)?
                    SendR(LogonProof);
                    LogonProof.Dispose();
                    break;
                }

                case 4:
                case 5:             // Bad user
                {
                    Console.WriteLine("[{0}][Realm] Bad account information, the account did not exist.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"));
                    Connection.Close();
                    break;
                }

                case 9:             // Bad version
                {
                    Console.WriteLine("[{0}][Realm] Bad client version (the server does not allow our version).", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"));
                    Connection.Close();
                    break;
                }

                default:
                {
                    Console.WriteLine("[{0}][Realm] Unknown challenge error [{1}].", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"), Buffer[1]);
                    Connection.Close();
                    break;
                }
                }

                break;
            }

            case CMD_AUTH_LOGON_PROOF:
            {
                Console.WriteLine("[{0}][Realm] Received Logon Proof.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"));
                switch (Buffer[1])
                {
                case 0:             // No error
                {
                    Console.WriteLine("[{0}][Realm] Proof Success.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"));
                    var RealmList = new Packets.PacketClass(CMD_AUTH_REALMLIST);
                    RealmList.AddInt32(0);
                    SendR(RealmList);
                    RealmList.Dispose();
                    break;
                }

                case 4:
                case 5:             // Bad user
                {
                    Console.WriteLine("[{0}][Realm] Bad account information, your password was incorrect.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"));
                    Connection.Close();
                    break;
                }

                case 9:             // Bad version
                {
                    Console.WriteLine("[{0}][Realm] Bad client version (the crc files are either too old or to new for this server).", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"));
                    Connection.Close();
                    break;
                }

                default:
                {
                    Console.WriteLine("[{0}][Realm] Unknown proof error [{1}].", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"), Buffer[1]);
                    Connection.Close();
                    break;
                }
                }

                break;
            }

            case CMD_AUTH_REALMLIST:
            {
                Console.WriteLine("[{0}][Realm] Received Realm List.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"));
                Packet.Offset = 7;
                int RealmCount = Packet.GetInt8();
                if (RealmCount > 0)
                {
                    for (int i = 1, loopTo = RealmCount; i <= loopTo; i++)
                    {
                        byte   RealmType       = Packet.GetInt8();
                        byte   RealmLocked     = Packet.GetInt8();
                        byte   Unk1            = Packet.GetInt8();
                        byte   Unk2            = Packet.GetInt8();
                        byte   RealmStatus     = Packet.GetInt8();
                        string RealmName       = Packet.GetString();
                        string RealmIP         = Packet.GetString();
                        float  RealmPopulation = Packet.GetFloat();
                        byte   RealmCharacters = Packet.GetInt8();
                        byte   RealmTimezone   = Packet.GetInt8();
                        byte   Unk3            = Packet.GetInt8();
                        Console.WriteLine("[{0}][Realm] Connecting to realm [{1}][{2}].", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"), RealmName, RealmIP);
                        if (Strings.InStr(RealmIP, ":") > 0)
                        {
                            var SplitIP = Strings.Split(RealmIP, ":");
                            if (SplitIP.Length == 2)
                            {
                                if (Information.IsNumeric(SplitIP[1]))
                                {
                                    Worldserver.ConnectToServer(SplitIP[0], Conversions.ToInteger(SplitIP[1]));
                                }
                                else
                                {
                                    Console.WriteLine("[{0}][Realm] Invalid IP in realmlist [{1}].", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"), RealmIP);
                                }
                            }
                            else
                            {
                                Console.WriteLine("[{0}][Realm] Invalid IP in realmlist [{1}].", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"), RealmIP);
                            }
                        }
                        else
                        {
                            Console.WriteLine("[{0}][Realm] Invalid IP in realmlist [{1}].", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"), RealmIP);
                        }

                        break;
                    }
                }
                else
                {
                    Console.WriteLine("[{0}][Realm] No realms were found.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"));
                }

                break;
            }

            default:
            {
                Console.WriteLine("[{0}][Realm] Unknown opcode [{1}].", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"), Packet.OpCode);
                break;
            }
            }
        }