Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. public class RequestAuthLogin extends L2LoginClientPacket
  2. {
  3. private static Logger _log = Logger.getLogger(RequestAuthLogin.class.getName());
  4.  
  5. private byte[] _raw = new byte[128];
  6.  
  7. private String _user;
  8. private String _password;
  9. private int _ncotp;
  10.  
  11. /**
  12. * @return
  13. */
  14. public String getPassword()
  15. {
  16. return _password;
  17. }
  18.  
  19. /**
  20. * @return
  21. */
  22. public String getUser()
  23. {
  24. return _user;
  25. }
  26.  
  27. public int getOneTimePassword()
  28. {
  29. return _ncotp;
  30. }
  31.  
  32. @Override
  33. public boolean readImpl()
  34. {
  35. if (super._buf.remaining() >= 128)
  36. {
  37. readB(_raw);
  38. return true;
  39. }
  40. else
  41. {
  42. return false;
  43. }
  44. }
  45.  
  46. @Override
  47. public void run()
  48. {
  49. byte[] decrypted = null;
  50. try
  51. {
  52. Cipher rsaCipher = Cipher.getInstance("RSA/ECB/nopadding");
  53. rsaCipher.init(Cipher.DECRYPT_MODE, getClient().getRSAPrivateKey());
  54. decrypted = rsaCipher.doFinal(_raw, 0x00, 0x80 );
  55. }
  56. catch (GeneralSecurityException e)
  57. {
  58. e.printStackTrace();
  59. return;
  60. }
  61.  
  62. _user = new String(decrypted, 0x5E, 14 ).trim();
  63. _user = _user.toLowerCase();
  64. _password = new String(decrypted, 0x6C, 16).trim();
  65. _ncotp = decrypted[0x7c];
  66. _ncotp |= decrypted[0x7d] << 8;
  67. _ncotp |= decrypted[0x7e] << 16;
  68. _ncotp |= decrypted[0x7f] << 24;
  69.  
  70. LoginController lc = LoginController.getInstance();
  71. L2LoginClient client = getClient();
  72. try
  73. {
  74. AuthLoginResult result = lc.tryAuthLogin(_user, _password, client);
  75.  
  76. switch (result)
  77. {
  78. case AUTH_SUCCESS:
  79. client.setAccount(_user);
  80. client.setState(LoginClientState.AUTHED_LOGIN);
  81. client.setSessionKey(lc.assignSessionKeyToClient(_user, client));
  82. if (Config.SECURITY_CARD_LOGIN)
  83.  
  84. client.sendPacket(new LoginFail(LoginFailReason.REASON_INVALID_SECURITY_CARD_NO));
  85.  
  86. else if (Config.SHOW_LICENCE)
  87. {
  88. client.sendPacket(new LoginOk(client.getSessionKey()));
  89. }
  90. else
  91. {
  92. client.sendPacket(new ServerList(client));
  93. }
  94. break;
  95. case INVALID_PASSWORD:
  96. client.close(LoginFailReason.REASON_USER_OR_PASS_WRONG);
  97. break;
  98. case ACCOUNT_BANNED:
  99. client.close(new AccountKicked(AccountKickedReason.REASON_PERMANENTLY_BANNED));
  100. break;
  101. case ALREADY_ON_LS:
  102. L2LoginClient oldClient;
  103. if ((oldClient = lc.getAuthedClient(_user)) != null)
  104. {
  105. // kick the other client
  106. oldClient.close(LoginFailReason.REASON_ACCOUNT_IN_USE);
  107. lc.removeAuthedLoginClient(_user);
  108. }
  109. // kick also current client
  110. client.close(LoginFailReason.REASON_ACCOUNT_IN_USE);
  111. break;
  112. case ALREADY_ON_GS:
  113. GameServerInfo gsi;
  114. if ((gsi = lc.getAccountOnGameServer(_user)) != null)
  115. {
  116. client.close(LoginFailReason.REASON_ACCOUNT_IN_USE);
  117.  
  118. // kick from there
  119. if (gsi.isAuthed())
  120. {
  121. gsi.getGameServerThread().kickPlayer(_user);
  122. }
  123. }
  124. break;
  125. }
  126. }
  127. catch (HackingException e)
  128. {
  129. InetAddress address = client.getConnection().getInetAddress();
  130. lc.addBanForAddress(address, Config.LOGIN_BLOCK_AFTER_BAN*1000);
  131. _log.info("Banned ("+address+") for "+Config.LOGIN_BLOCK_AFTER_BAN+" seconds, due to "+e.getConnects()+" incorrect login attempts.");
  132. }
  133. }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement