2
0

GameGuardReply.java 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.network.clientpackets;
  16. import java.security.MessageDigest;
  17. import java.security.NoSuchAlgorithmException;
  18. import java.util.Arrays;
  19. import java.util.logging.Level;
  20. import java.util.logging.Logger;
  21. import com.l2jserver.gameserver.network.L2GameClient;
  22. /**
  23. * Format: c dddd
  24. *
  25. * @author KenM
  26. */
  27. public class GameGuardReply extends L2GameClientPacket
  28. {
  29. protected static final Logger _log = Logger.getLogger(GameGuardReply.class.getName());
  30. private static final String _C__CA_GAMEGUARDREPLY = "[C] CA GameGuardReply";
  31. private static final byte[] VALID =
  32. {
  33. (byte) 0x88, 0x40, 0x1c, (byte) 0xa7, (byte) 0x83, 0x42, (byte) 0xe9, 0x15,
  34. (byte) 0xde, (byte) 0xc3, 0x68, (byte) 0xf6, 0x2d, 0x23, (byte) 0xf1, 0x3f,
  35. (byte) 0xee, 0x68, 0x5b, (byte) 0xc5,
  36. };
  37. private byte[] _reply = new byte[8];
  38. @Override
  39. protected void readImpl()
  40. {
  41. readB(_reply, 0, 4);
  42. readD();
  43. readB(_reply, 4, 4);
  44. }
  45. @Override
  46. protected void runImpl()
  47. {
  48. L2GameClient client = this.getClient();
  49. try
  50. {
  51. MessageDigest md = MessageDigest.getInstance( "SHA" );
  52. byte[] result = md.digest(_reply);
  53. if (Arrays.equals(result, VALID))
  54. {
  55. client.setGameGuardOk(true);
  56. }
  57. }
  58. catch (NoSuchAlgorithmException e)
  59. {
  60. _log.log(Level.WARNING, "", e);
  61. }
  62. }
  63. @Override
  64. public String getType()
  65. {
  66. return _C__CA_GAMEGUARDREPLY;
  67. }
  68. @Override
  69. protected boolean triggersOnActionRequest()
  70. {
  71. return false;
  72. }
  73. }