public override void RequestHash() { Log.outDebug(LogFilter.Warden, "Request hash"); // Create packet structure WardenHashRequest Request = new WardenHashRequest(); Request.Command = WardenOpcodes.Smsg_HashRequest; Request.Seed = _seed; Warden3DataServer packet = new Warden3DataServer(); packet.Data = EncryptData(Request.Write()); _session.SendPacket(packet); }
public void RequestModule() { Log.outDebug(LogFilter.Warden, "Request module"); // Create packet structure WardenModuleUse request = new WardenModuleUse(); request.Command = WardenOpcodes.Smsg_ModuleUse; request.ModuleId = _module.Id; request.ModuleKey = _module.Key; request.Size = _module.CompressedSize; Warden3DataServer packet = new Warden3DataServer(); packet.Data = EncryptData(request.Write()); _session.SendPacket(packet); }
public override void InitializeModule() { Log.outDebug(LogFilter.Warden, "Initialize module"); // Create packet structure WardenInitModuleRequest Request = new WardenInitModuleRequest(); Request.Command1 = WardenOpcodes.Smsg_ModuleInitialize; Request.Size1 = 20; Request.Unk1 = 1; Request.Unk2 = 0; Request.Type = 1; Request.String_library1 = 0; Request.Function1[0] = 0x00024F80; // 0x00400000 + 0x00024F80 SFileOpenFile Request.Function1[1] = 0x000218C0; // 0x00400000 + 0x000218C0 SFileGetFileSize Request.Function1[2] = 0x00022530; // 0x00400000 + 0x00022530 SFileReadFile Request.Function1[3] = 0x00022910; // 0x00400000 + 0x00022910 SFileCloseFile Request.CheckSumm1 = BuildChecksum(BitConverter.GetBytes(Request.Unk1), 20); Request.Command2 = WardenOpcodes.Smsg_ModuleInitialize; Request.Size2 = 8; Request.Unk3 = 4; Request.Unk4 = 0; Request.String_library2 = 0; Request.Function2 = 0x00419D40; // 0x00400000 + 0x00419D40 FrameScript::GetText Request.Function2_set = 1; Request.CheckSumm2 = BuildChecksum(BitConverter.GetBytes(Request.Unk2), 8); Request.Command3 = WardenOpcodes.Smsg_ModuleInitialize; Request.Size3 = 8; Request.Unk5 = 1; Request.Unk6 = 1; Request.String_library3 = 0; Request.Function3 = 0x0046AE20; // 0x00400000 + 0x0046AE20 PerformanceCounter Request.Function3_set = 1; Request.CheckSumm3 = BuildChecksum(BitConverter.GetBytes(Request.Unk5), 8); Warden3DataServer packet = new Warden3DataServer(); packet.Data = EncryptData(Request.Write()); _session.SendPacket(packet); }
public void SendModuleToClient() { Log.outDebug(LogFilter.Warden, "Send module to client"); uint sizeLeft = _module.CompressedSize; int pos = 0; uint burstSize; while (sizeLeft > 0) { WardenModuleTransfer transfer = new WardenModuleTransfer(); burstSize = sizeLeft < 500 ? sizeLeft : 500u; transfer.Command = WardenOpcodes.Smsg_ModuleCache; transfer.DataSize = (ushort)burstSize; Buffer.BlockCopy(_module.CompressedData, pos, transfer.Data, 0, (int)burstSize); sizeLeft -= burstSize; pos += (int)burstSize; Warden3DataServer packet = new Warden3DataServer(); packet.Data = EncryptData(transfer.Write()); _session.SendPacket(packet); } }
public override void RequestData() { Log.outDebug(LogFilter.Warden, "Request data"); // If all checks were done, fill the todo list again if (_memChecksTodo.Empty()) { _memChecksTodo.AddRange(Global.WardenCheckMgr.MemChecksIdPool); } if (_otherChecksTodo.Empty()) { _otherChecksTodo.AddRange(Global.WardenCheckMgr.OtherChecksIdPool); } _serverTicks = GameTime.GetGameTimeMS(); ushort id; WardenCheckType type; WardenCheck wd; _currentChecks.Clear(); // Build check request for (uint i = 0; i < WorldConfig.GetUIntValue(WorldCfg.WardenNumMemChecks); ++i) { // If todo list is done break loop (will be filled on next Update() run) if (_memChecksTodo.Empty()) { break; } // Get check id from the end and remove it from todo id = _memChecksTodo.Last(); _memChecksTodo.Remove(id); // Add the id to the list sent in this cycle _currentChecks.Add(id); } ByteBuffer buffer = new ByteBuffer(); buffer.WriteUInt8((byte)WardenOpcodes.Smsg_CheatChecksRequest); for (uint i = 0; i < WorldConfig.GetUIntValue(WorldCfg.WardenNumOtherChecks); ++i) { // If todo list is done break loop (will be filled on next Update() run) if (_otherChecksTodo.Empty()) { break; } // Get check id from the end and remove it from todo id = _otherChecksTodo.Last(); _otherChecksTodo.Remove(id); // Add the id to the list sent in this cycle _currentChecks.Add(id); wd = Global.WardenCheckMgr.GetWardenDataById(id); switch (wd.Type) { case WardenCheckType.MPQ: case WardenCheckType.LuaStr: case WardenCheckType.Driver: buffer.WriteUInt8((byte)wd.Str.GetByteCount()); buffer.WriteString(wd.Str); break; default: break; } } byte xorByte = _inputKey[0]; // Add TIMING_CHECK buffer.WriteUInt8(0x00); buffer.WriteUInt8((byte)((int)WardenCheckType.Timing ^ xorByte)); byte index = 1; foreach (var checkId in _currentChecks) { wd = Global.WardenCheckMgr.GetWardenDataById(checkId); type = wd.Type; buffer.WriteUInt8((byte)((int)type ^ xorByte)); switch (type) { case WardenCheckType.Memory: { buffer.WriteUInt8(0x00); buffer.WriteUInt32(wd.Address); buffer.WriteUInt8(wd.Length); break; } case WardenCheckType.PageA: case WardenCheckType.PageB: { buffer.WriteBytes(wd.Data.ToByteArray()); buffer.WriteUInt32(wd.Address); buffer.WriteUInt8(wd.Length); break; } case WardenCheckType.MPQ: case WardenCheckType.LuaStr: { buffer.WriteUInt8(index++); break; } case WardenCheckType.Driver: { buffer.WriteBytes(wd.Data.ToByteArray()); buffer.WriteUInt8(index++); break; } case WardenCheckType.Module: { uint seed = RandomHelper.Rand32(); buffer.WriteUInt32(seed); HmacHash hmac = new HmacHash(BitConverter.GetBytes(seed)); hmac.Finish(wd.Str); buffer.WriteBytes(hmac.Digest); break; } /*case PROC_CHECK: * { * buff.append(wd.i.AsByteArray(0, false).get(), wd.i.GetNumBytes()); * buff << uint8(index++); * buff << uint8(index++); * buff << uint32(wd.Address); * buff << uint8(wd.Length); * break; * }*/ default: break; // Should never happen } } buffer.WriteUInt8(xorByte); Warden3DataServer packet = new Warden3DataServer(); packet.Data = EncryptData(buffer.GetData()); _session.SendPacket(packet); _dataSent = true; string stream = "Sent check id's: "; foreach (var checkId in _currentChecks) { stream += checkId + " "; } Log.outDebug(LogFilter.Warden, stream); }