Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. case 1: //here's where we get the username and password
  2. boolean hd = false;
  3. @SuppressWarnings("unused")
  4. int loginType = -1, loginPacketSize = -1;
  5. if (3 <= in.remaining()) {
  6. loginType = in.get() & 0xff; //should be 16 or 18
  7. loginPacketSize = in.getUnsignedShort();
  8. //Logger.log("loginType="+loginType);
  9. } else {
  10. in.rewind();
  11. return false;
  12. }
  13. if (loginPacketSize <= in.remaining()) {
  14. byte[] payload = new byte[loginPacketSize];
  15. in.get(payload);
  16. Packet p = new Packet(session, -1, payload);
  17. @SuppressWarnings("unused")
  18. int loginEncryptPacketSize = loginPacketSize - (36 + 1 + 1 + 2); // can't be negative
  19. int clientVersion = p.readInt();
  20. if (clientVersion != 562) {
  21. Logger.getInstance().error("Invalid ver : " + clientVersion);
  22. session.close();
  23. return true;
  24. }
  25. p.skip(30);
  26. p.readRS2String(); // settings string?
  27. p.skip(127);
  28. long clientSessionKey = p.readLong();
  29. long serverSessionKey = p.readLong();
  30. long l = p.readLong();
  31. int hash = (int) (31 & l >> 16);
  32. if (hash != (Integer) session.getAttribute("NAME_HASH")) {
  33. // invalid name hash (possibly a bot attacking)
  34. session.close();
  35. return true;
  36. }
  37. String user = Misc.longToPlayerName(l), //given username
  38. pass = p.readRS2String(); //given password
  39. int sessionKey[] = new int[4];
  40. sessionKey[0] = (int) (clientSessionKey >> 32);
  41. sessionKey[1] = (int) clientSessionKey;
  42. sessionKey[2] = (int) (serverSessionKey >> 32);
  43. sessionKey[3] = (int) serverSessionKey;
  44.  
  45. // set in ISAAC
  46. for (int i = 0; i < 4; i++) sessionKey[i] += 50;
  47. // set out ISAAC
  48.  
  49. session.removeAttribute("LOGIN_STAGE");
  50. session.removeAttribute("NAME_HASH");
  51.  
  52. /**
  53. * Here's where we add the user to the login queue, and if the login is
  54. * accepted, we change their session filter to a standard RS2ProtocolCodec.
  55. */
  56. logger.debug("Login request: [username=" + user + ",password=" + pass + "].");
  57.  
  58. PlayerDetails d = new PlayerDetails(user, pass, session, hd);
  59. workerThread.loadPlayer(d);
  60.  
  61. session.setIdleTime(IdleStatus.BOTH_IDLE, Constants.SESSION_IDLE_TIME);
  62.  
  63. session.getFilterChain().remove("protocolFilter");
  64. session.getFilterChain().addLast("protocolFilter", new ProtocolCodecFilter(new CodecFactory()));
  65.  
  66. return true;
  67. } else {
  68. in.rewind();
  69. return false;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement