Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case 1: //here's where we get the username and password
- boolean hd = false;
- @SuppressWarnings("unused")
- int loginType = -1, loginPacketSize = -1;
- if (3 <= in.remaining()) {
- loginType = in.get() & 0xff; //should be 16 or 18
- loginPacketSize = in.getUnsignedShort();
- //Logger.log("loginType="+loginType);
- } else {
- in.rewind();
- return false;
- }
- if (loginPacketSize <= in.remaining()) {
- byte[] payload = new byte[loginPacketSize];
- in.get(payload);
- Packet p = new Packet(session, -1, payload);
- @SuppressWarnings("unused")
- int loginEncryptPacketSize = loginPacketSize - (36 + 1 + 1 + 2); // can't be negative
- int clientVersion = p.readInt();
- if (clientVersion != 562) {
- Logger.getInstance().error("Invalid ver : " + clientVersion);
- session.close();
- return true;
- }
- p.skip(30);
- p.readRS2String(); // settings string?
- p.skip(127);
- long clientSessionKey = p.readLong();
- long serverSessionKey = p.readLong();
- long l = p.readLong();
- int hash = (int) (31 & l >> 16);
- if (hash != (Integer) session.getAttribute("NAME_HASH")) {
- // invalid name hash (possibly a bot attacking)
- session.close();
- return true;
- }
- String user = Misc.longToPlayerName(l), //given username
- pass = p.readRS2String(); //given password
- int sessionKey[] = new int[4];
- sessionKey[0] = (int) (clientSessionKey >> 32);
- sessionKey[1] = (int) clientSessionKey;
- sessionKey[2] = (int) (serverSessionKey >> 32);
- sessionKey[3] = (int) serverSessionKey;
- // set in ISAAC
- for (int i = 0; i < 4; i++) sessionKey[i] += 50;
- // set out ISAAC
- session.removeAttribute("LOGIN_STAGE");
- session.removeAttribute("NAME_HASH");
- /**
- * Here's where we add the user to the login queue, and if the login is
- * accepted, we change their session filter to a standard RS2ProtocolCodec.
- */
- logger.debug("Login request: [username=" + user + ",password=" + pass + "].");
- PlayerDetails d = new PlayerDetails(user, pass, session, hd);
- workerThread.loadPlayer(d);
- session.setIdleTime(IdleStatus.BOTH_IDLE, Constants.SESSION_IDLE_TIME);
- session.getFilterChain().remove("protocolFilter");
- session.getFilterChain().addLast("protocolFilter", new ProtocolCodecFilter(new CodecFactory()));
- return true;
- } else {
- in.rewind();
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement