fix(housekeeping): enforce target rank ceiling

This commit is contained in:
simoleo89
2026-06-14 14:09:10 +02:00
parent 87e1ef94f7
commit 9ac50600f6
13 changed files with 124 additions and 0 deletions
@@ -41,6 +41,11 @@ public class HousekeepingBanUserEvent extends MessageHandler {
return;
}
if (!HousekeepingTargetRankGuard.canTargetUser(this.client.getHabbo(), userId)) {
this.client.sendResponse(new HousekeepingActionResultComposer(ACTION_KEY, false, 0, "housekeeping.error.rank_too_high"));
return;
}
long durationLong = (long) hours * SECONDS_IN_HOUR;
int duration = durationLong > MAX_DURATION_SECONDS ? MAX_DURATION_SECONDS : (int) durationLong;
@@ -40,6 +40,11 @@ public class HousekeepingForceDisconnectUserEvent extends MessageHandler {
return;
}
if (!HousekeepingTargetRankGuard.canTargetUser(this.client.getHabbo(), userId)) {
this.client.sendResponse(new HousekeepingActionResultComposer(ACTION_KEY, false, 0, "housekeeping.error.rank_too_high"));
return;
}
if (reason != null && !reason.isEmpty()) {
target.alert(reason);
}
@@ -33,6 +33,11 @@ public class HousekeepingGiveCreditsEvent extends MessageHandler {
return;
}
if (!HousekeepingTargetRankGuard.canTargetUser(this.client.getHabbo(), userId)) {
this.client.sendResponse(new HousekeepingActionResultComposer(ACTION_KEY, false, 0, "housekeeping.error.rank_too_high"));
return;
}
Habbo online = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
if (online != null) {
@@ -42,6 +42,11 @@ public class HousekeepingGiveCurrencyEvent extends MessageHandler {
return;
}
if (!HousekeepingTargetRankGuard.canTargetUser(this.client.getHabbo(), userId)) {
this.client.sendResponse(new HousekeepingActionResultComposer(actionKey, false, 0, "housekeeping.error.rank_too_high"));
return;
}
Habbo online = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
if (online != null) {
@@ -40,6 +40,11 @@ public class HousekeepingGrantItemEvent extends MessageHandler {
return;
}
if (!HousekeepingTargetRankGuard.canTargetUser(this.client.getHabbo(), userId)) {
this.client.sendResponse(new HousekeepingActionResultComposer(ACTION_KEY, false, 0, "housekeeping.error.rank_too_high"));
return;
}
if (quantity > MAX_QUANTITY_PER_CALL) {
quantity = MAX_QUANTITY_PER_CALL;
}
@@ -42,6 +42,11 @@ public class HousekeepingKickUserEvent extends MessageHandler {
return;
}
if (!HousekeepingTargetRankGuard.canTargetUser(this.client.getHabbo(), userId)) {
this.client.sendResponse(new HousekeepingActionResultComposer(ACTION_KEY, false, 0, "housekeeping.error.rank_too_high"));
return;
}
if (target.hasPermission(Permission.ACC_UNKICKABLE)) {
this.client.sendResponse(new HousekeepingActionResultComposer(ACTION_KEY, false, 0, "housekeeping.error.target_unkickable"));
return;
@@ -44,6 +44,11 @@ public class HousekeepingMuteUserEvent extends MessageHandler {
return;
}
if (!HousekeepingTargetRankGuard.canTargetUser(this.client.getHabbo(), userId)) {
this.client.sendResponse(new HousekeepingActionResultComposer(ACTION_KEY, false, 0, "housekeeping.error.rank_too_high"));
return;
}
target.mute(minutes * SECONDS_IN_MINUTE, false);
if (reason != null && !reason.isEmpty()) {
@@ -46,6 +46,11 @@ public class HousekeepingResetUserPasswordEvent extends MessageHandler {
return;
}
if (!HousekeepingTargetRankGuard.canTargetUser(this.client.getHabbo(), userId)) {
this.client.sendResponse(new HousekeepingActionResultComposer(ACTION_KEY, false, 0, "housekeeping.error.rank_too_high"));
return;
}
String plain = randomPassword();
String hash;
@@ -38,6 +38,11 @@ public class HousekeepingSetHcSubscriptionEvent extends MessageHandler {
return;
}
if (!HousekeepingTargetRankGuard.canTargetUser(this.client.getHabbo(), userId)) {
this.client.sendResponse(new HousekeepingActionResultComposer(ACTION_KEY, false, 0, "housekeeping.error.rank_too_high"));
return;
}
int now = Emulator.getIntUnixTimestamp();
int newExpire;
@@ -0,0 +1,23 @@
package com.eu.habbo.messages.incoming.housekeeping;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
final class HousekeepingTargetRankGuard {
private HousekeepingTargetRankGuard() {
}
static boolean canTargetUser(Habbo operator, int targetUserId) {
if (operator == null || targetUserId <= 0) {
return false;
}
HabboInfo targetInfo = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(targetUserId);
if (targetInfo == null) {
return true;
}
return targetInfo.getRank().getId() < operator.getHabboInfo().getRank().getId();
}
}
@@ -43,6 +43,11 @@ public class HousekeepingTradeLockUserEvent extends MessageHandler {
return;
}
if (!HousekeepingTargetRankGuard.canTargetUser(this.client.getHabbo(), userId)) {
this.client.sendResponse(new HousekeepingActionResultComposer(ACTION_KEY, false, 0, "housekeeping.error.rank_too_high"));
return;
}
long durationLong = (long) hours * SECONDS_IN_HOUR;
int duration = durationLong > MAX_DURATION_SECONDS ? MAX_DURATION_SECONDS : (int) durationLong;
int lockedUntil = Emulator.getIntUnixTimestamp() + duration;
@@ -34,6 +34,11 @@ public class HousekeepingUnbanUserEvent extends MessageHandler {
return;
}
if (!HousekeepingTargetRankGuard.canTargetUser(this.client.getHabbo(), userId)) {
this.client.sendResponse(new HousekeepingActionResultComposer(ACTION_KEY, false, 0, "housekeeping.error.rank_too_high"));
return;
}
// ModToolManager.unban only takes a username; the SQL UPDATE
// happens against active bans (ban_expire > now), so calling it
// on a never-banned user is a benign no-op that returns false.