GameGuardReply.java 2.1 KB

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