GameGuardReply.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 com.l2jserver.gameserver.network.L2GameClient;
  20. /**
  21. * Format: c dddd
  22. *
  23. * @author KenM
  24. */
  25. public class GameGuardReply extends L2GameClientPacket
  26. {
  27. private static final String _C__CA_GAMEGUARDREPLY = "[C] CA GameGuardReply";
  28. private static final byte[] VALID =
  29. {
  30. (byte) 0x88, 0x40, 0x1c, (byte) 0xa7, (byte) 0x83, 0x42, (byte) 0xe9, 0x15,
  31. (byte) 0xde, (byte) 0xc3, 0x68, (byte) 0xf6, 0x2d, 0x23, (byte) 0xf1, 0x3f,
  32. (byte) 0xee, 0x68, 0x5b, (byte) 0xc5,
  33. };
  34. private byte[] _reply = new byte[8];
  35. @Override
  36. protected void readImpl()
  37. {
  38. readB(_reply, 0, 4);
  39. readD();
  40. readB(_reply, 4, 4);
  41. }
  42. @Override
  43. protected void runImpl()
  44. {
  45. L2GameClient client = this.getClient();
  46. try
  47. {
  48. MessageDigest md = MessageDigest.getInstance( "SHA" );
  49. byte[] result = md.digest(_reply);
  50. if (Arrays.equals(result, VALID))
  51. {
  52. client.setGameGuardOk(true);
  53. }
  54. }
  55. catch (NoSuchAlgorithmException e)
  56. {
  57. e.printStackTrace();
  58. }
  59. }
  60. @Override
  61. public String getType()
  62. {
  63. return _C__CA_GAMEGUARDREPLY;
  64. }
  65. @Override
  66. protected boolean triggersOnActionRequest()
  67. {
  68. return false;
  69. }
  70. }