public void MaievResult(ref WS_PlayerData.CharacterObject objCharacter, ref Packets.PacketClass Packet) { ushort bufLen = Packet.GetUInt16(); uint checkSum = Packet.GetUInt32(); int tmpOffset = Packet.Offset; byte[] data = Packet.GetByteArray(); Packet.Offset = tmpOffset; if (!ControlChecksum(checkSum, data)) { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.CRITICAL, "[WARDEN] Failed checkSum at result packet. Cheater?"); objCharacter.CommandResponse("[WARDEN] Pack your bags cheater, you're going!"); return; } WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[WARDEN] Result bufLen:{0} checkSum:{1:X}", bufLen, checkSum); objCharacter.WardenData.Scan.HandleResponse(ref Packet); }
public void On_CMSG_SET_ACTION_BUTTON(ref Packets.PacketClass packet, ref WS_Network.ClientClass client) { if (checked (packet.Data.Length - 1) < 10) { return; } packet.GetInt16(); var button = packet.GetInt8(); var action = packet.GetUInt16(); var actionMisc = packet.GetInt8(); var actionType = packet.GetInt8(); if (action == 0) { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] MSG_SET_ACTION_BUTTON [Remove action from button {2}]", client.IP, client.Port, button); client.Character.ActionButtons.Remove(button); } else { switch (actionType) { case 64: WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_SET_ACTION_BUTTON [Added Macro {2} into button {3}]", client.IP, client.Port, action, button); break; case 128: WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_SET_ACTION_BUTTON [Added Item {2} into button {3}]", client.IP, client.Port, action, button); break; default: WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_SET_ACTION_BUTTON [Added Action {2}:{4}:{5} into button {3}]", client.IP, client.Port, action, button, actionType, actionMisc); break; } } client.Character.ActionButtons[button] = new WS_PlayerHelper.TActionButton(action, actionType, actionMisc); }
public static void On_SMSG_WARDEN_DATA(ref Packets.PacketClass Packet) { // START Warden Decryption var b = new byte[(Packet.Data.Length - 4)]; Buffer.BlockCopy(Packet.Data, 4, b, 0, b.Length); RC4.Crypt(ref b, Maiev.KeyIn); Buffer.BlockCopy(b, 0, Packet.Data, 4, b.Length); // END var WardenData = new byte[(Packet.Data.Length - 4)]; Buffer.BlockCopy(Packet.Data, 4, WardenData, 0, WardenData.Length); MaievOpcode Opcode = (MaievOpcode)Packet.GetInt8(); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("SMSG_WARDEN_DATA [{0}]", Opcode); Console.ForegroundColor = ConsoleColor.White; switch (Opcode) { case MaievOpcode.MAIEV_MODULE_INFORMATION: { var Name = Packet.GetByteArray(16); var Key = Packet.GetByteArray(16); var Size = Packet.GetUInt32(); Maiev.ModuleName = BitConverter.ToString(Name).Replace("-", ""); Maiev.ModuleKey = Key; ModuleLength = (int)Size; Maiev.ModuleData = Array.Empty <byte>(); if (File.Exists(@"modules\" + Maiev.ModuleName + ".mod") == false) { Console.WriteLine("[{0}][WARDEN] Module is missing.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss")); Packets.PacketClass response = new(OPCODES.CMSG_WARDEN_DATA); response.AddInt8((byte)MaievResponse.MAIEV_RESPONSE_FAILED_OR_MISSING); SendWardenPacket(ref response); response.Dispose(); } else { Console.WriteLine("[{0}][WARDEN] Module is initiated.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss")); Maiev.ModuleData = File.ReadAllBytes(@"modules\" + Maiev.ModuleName + ".mod"); if (Maiev.LoadModule(Maiev.ModuleName, ref Maiev.ModuleData, Maiev.ModuleKey)) { Console.WriteLine("[{0}][WARDEN] Successfully loaded the module.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss")); Packets.PacketClass response = new(OPCODES.CMSG_WARDEN_DATA); response.AddInt8((byte)MaievResponse.MAIEV_RESPONSE_SUCCESS); SendWardenPacket(ref response); response.Dispose(); } else { Packets.PacketClass response = new(OPCODES.CMSG_WARDEN_DATA); response.AddInt8((byte)MaievResponse.MAIEV_RESPONSE_FAILED_OR_MISSING); SendWardenPacket(ref response); response.Dispose(); } } break; } case MaievOpcode.MAIEV_MODULE_TRANSFER: { var Size = Packet.GetUInt16(); var Data = Packet.GetByteArray(Size); Maiev.ModuleData = Realmserver.Concat(Maiev.ModuleData, Data); ModuleLength -= Size; if (ModuleLength <= 0) { Console.WriteLine("[{0}][WARDEN] Module is fully transfered.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss")); if (Directory.Exists("modules") == false) { Directory.CreateDirectory("modules"); } File.WriteAllBytes(@"modules\" + Maiev.ModuleName + ".mod", Maiev.ModuleData); if (Maiev.LoadModule(Maiev.ModuleName, ref Maiev.ModuleData, Maiev.ModuleKey)) { Console.WriteLine("[{0}][WARDEN] Successfully loaded the module.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss")); Packets.PacketClass response = new(OPCODES.CMSG_WARDEN_DATA); response.AddInt8((byte)MaievResponse.MAIEV_RESPONSE_SUCCESS); SendWardenPacket(ref response); response.Dispose(); } } else { Console.WriteLine("[{0}][WARDEN] Module transfer. Bytes left: {1}", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"), ModuleLength); } break; } case MaievOpcode.MAIEV_MODULE_RUN: { Console.WriteLine("[{0}][WARDEN] Requesting a scan.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss")); // TODO: Encrypt? Maiev.ReadKeys2(); RC4.Crypt(ref WardenData, Maiev.ModKeyIn); var HandledBytes = Maiev.HandlePacket(WardenData); if (HandledBytes <= 0) { return; } var thePacket = Maiev.ReadPacket(); if (thePacket.Length == 0) { return; } RC4.Crypt(ref WardenData, Maiev.ModKeyOut); // TODO: Decrypt? Packets.DumpPacket(thePacket); Packets.PacketClass response = new(OPCODES.CMSG_WARDEN_DATA); response.AddByteArray(thePacket); SendWardenPacket(ref response); response.Dispose(); break; } case MaievOpcode.MAIEV_MODULE_UNK: { // TODO: Encrypt? Maiev.ReadKeys2(); RC4.Crypt(ref WardenData, Maiev.ModKeyIn); var HandledBytes = Maiev.HandlePacket(WardenData); if (HandledBytes <= 0) { return; } var thePacket = Maiev.ReadPacket(); if (thePacket.Length == 0) { return; } RC4.Crypt(ref WardenData, Maiev.ModKeyOut); // TODO: Decrypt? Packets.DumpPacket(thePacket); Packets.PacketClass response = new(OPCODES.CMSG_WARDEN_DATA); response.AddByteArray(thePacket); SendWardenPacket(ref response); response.Dispose(); break; } case MaievOpcode.MAIEV_MODULE_SEED: { Maiev.GenerateNewRC4Keys(Realmserver.SS_Hash); var HandledBytes = Maiev.HandlePacket(WardenData); if (HandledBytes <= 0) { return; } var thePacket = Maiev.ReadPacket(); Maiev.ModKeyIn = new byte[258]; Maiev.ModKeyOut = new byte[258]; Packets.PacketClass response = new(OPCODES.CMSG_WARDEN_DATA); response.AddByteArray(thePacket); SendWardenPacket(ref response); response.Dispose(); Maiev.ReadKeys(); break; } default: { Console.WriteLine("[{0}][WARDEN] Unhandled Opcode [{1}] 0x{2:X}", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"), Opcode, Conversions.ToInteger(Opcode)); break; } } }