From f8a651b0596712a239e3de5f2559cc4e49ea8c16 Mon Sep 17 00:00:00 2001 From: duckietm Date: Mon, 4 May 2026 13:18:06 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=86=99=20Security=20update=20Info=20stand?= =?UTF-8?q?=20background?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../users/ChangeInfostandBgEvent.java | 62 +++++++++++++++---- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/ChangeInfostandBgEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/ChangeInfostandBgEvent.java index 79283cc2..84262778 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/ChangeInfostandBgEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/ChangeInfostandBgEvent.java @@ -1,26 +1,62 @@ package com.eu.habbo.messages.incoming.users; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.habbohotel.users.HabboInfo; +import com.eu.habbo.habbohotel.users.HabboStats; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer; public class ChangeInfostandBgEvent extends MessageHandler { + private static final String COOLDOWN_KEY = "infostand_bg_cooldown"; + private static final long COOLDOWN_MS = 500L; + private static final int MIN_ID = 0; + private static final int MAX_ID = 9999; + @Override public void handle() throws Exception { - int backgroundImage = this.packet.readInt(); - int backgroundStand = this.packet.readInt(); - int backgroundOverlay = this.packet.readInt(); - int backgroundCard = this.packet.bytesAvailable() >= 4 ? this.packet.readInt() : 0; + Habbo habbo = this.client.getHabbo(); + if (habbo == null) return; - this.client.getHabbo().getHabboInfo().setInfostandBg(backgroundImage); - this.client.getHabbo().getHabboInfo().setInfostandStand(backgroundStand); - this.client.getHabbo().getHabboInfo().setInfostandOverlay(backgroundOverlay); - this.client.getHabbo().getHabboInfo().setInfostandCardBg(backgroundCard); - this.client.getHabbo().getHabboInfo().run(); + HabboInfo info = habbo.getHabboInfo(); + if (info == null) return; - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(this.client.getHabbo()).compose()); + HabboStats stats = habbo.getHabboStats(); + if (stats != null) { + long now = System.currentTimeMillis(); + Object last = stats.cache.get(COOLDOWN_KEY); + if (last instanceof Long && (now - (Long) last) < COOLDOWN_MS) { + return; + } + stats.cache.put(COOLDOWN_KEY, now); + } + + int backgroundImage = sanitize(this.packet.readInt()); + int backgroundStand = sanitize(this.packet.readInt()); + int backgroundOverlay = sanitize(this.packet.readInt()); + int backgroundCard = this.packet.bytesAvailable() >= 4 ? sanitize(this.packet.readInt()) : 0; + + if (info.getInfostandBg() == backgroundImage + && info.getInfostandStand() == backgroundStand + && info.getInfostandOverlay() == backgroundOverlay + && info.getInfostandCardBg() == backgroundCard) { + return; + } + + info.setInfostandBg(backgroundImage); + info.setInfostandStand(backgroundStand); + info.setInfostandOverlay(backgroundOverlay); + info.setInfostandCardBg(backgroundCard); + info.run(); + + if (info.getCurrentRoom() != null) { + info.getCurrentRoom().sendComposer(new RoomUserDataComposer(habbo).compose()); } else { - this.client.sendResponse(new RoomUserDataComposer(this.client.getHabbo())); + this.client.sendResponse(new RoomUserDataComposer(habbo)); } } -} \ No newline at end of file + + private static int sanitize(int value) { + if (value < MIN_ID || value > MAX_ID) return 0; + return value; + } +}