Verify usernameHash and serverKey match

Signed-off-by: Graham <gpe@openrs2.org>
Graham 1 year ago
parent 6d43e0392e
commit e3a73291a9
  1. 13
      game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt

@ -49,6 +49,7 @@ import org.openrs2.protocol.login.upstream.GameLoginPayload
import org.openrs2.protocol.login.upstream.LoginRequest import org.openrs2.protocol.login.upstream.LoginRequest
import org.openrs2.protocol.world.downstream.WorldListDownstream import org.openrs2.protocol.world.downstream.WorldListDownstream
import org.openrs2.protocol.world.downstream.WorldListResponse import org.openrs2.protocol.world.downstream.WorldListResponse
import org.openrs2.util.Base37
import java.time.DateTimeException import java.time.DateTimeException
import java.time.LocalDate import java.time.LocalDate
@ -141,6 +142,18 @@ public class LoginChannelHandler @Inject constructor(
return return
} }
val usernameHash = ((Base37.encode(msg.username) shr 16) and 0x1F).toInt()
if (this.usernameHash != usernameHash) {
ctx.write(LoginResponse.InvalidLoginPacket).addListener(ChannelFutureListener.CLOSE)
return
}
val serverKey = (msg.key.k2.toLong() shl 32) or (msg.key.k3.toLong() and 0xFFFFFFFF)
if (this.serverKey != serverKey) {
ctx.write(LoginResponse.InvalidLoginPacket).addListener(ChannelFutureListener.CLOSE)
return
}
// TODO // TODO
} }

Loading…
Cancel
Save