JAVA 268
Untitled Guest on 10th February 2020 09:10:43 PM
  1. /*
  2.  * Copyright © 2004-2019 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.  
  21. import java.security.MessageDigest;
  22. import java.security.NoSuchAlgorithmException;
  23. import java.util.Arrays;
  24. import java.util.logging.Level;
  25.  
  26. import com.l2jserver.gameserver.network.L2GameClient;
  27.  
  28. /**
  29.  * Format: c dddd
  30.  * @author KenM
  31.  */
  32. public class GameGuardReply extends L2GameClientPacket {
  33.         private static final String _C__CB_GAMEGUARDREPLY = "[C] CB GameGuardReply";
  34.        
  35.         private static final byte[] VALID = {
  36.                 (byte) 0x88,
  37.                 0x40,
  38.                 0x1c,
  39.                 (byte) 0xa7,
  40.                 (byte) 0x83,
  41.                 0x42,
  42.                 (byte) 0xe9,
  43.                 0x15,
  44.                 (byte) 0xde,
  45.                 (byte) 0xc3,
  46.                 0x68,
  47.                 (byte) 0xf6,
  48.                 0x2d,
  49.                 0x23,
  50.                 (byte) 0xf1,
  51.                 0x3f,
  52.                 (byte) 0xee,
  53.                 0x68,
  54.                 0x5b,
  55.                 (byte) 0xc5,
  56.         };
  57.        
  58.         private final byte[] _reply = new byte[8];
  59.        
  60.         @Override
  61.         protected void readImpl() {
  62.                 readB(_reply, 0, 4);
  63.                 readD();
  64.                 readB(_reply, 4, 4);
  65.         }
  66.        
  67.         @Override
  68.         protected void runImpl() {
  69.                 L2GameClient client = getClient();
  70.                 try {
  71.                         MessageDigest md = MessageDigest.getInstance("SHA");
  72.                         byte[] result = md.digest(_reply);
  73.                         if (Arrays.equals(result, VALID)) {
  74.                                 client.setGameGuardOk(true);
  75.                         }
  76.                 } catch (NoSuchAlgorithmException e) {
  77.                         _log.log(Level.WARNING, "", e);
  78.                 }
  79.         }
  80.        
  81.         @Override
  82.         public String getType() {
  83.                 return _C__CB_GAMEGUARDREPLY;
  84.         }
  85.        
  86.         @Override
  87.         protected boolean triggersOnActionRequest() {
  88.                 return false;
  89.         }
  90. }
Raw Paste

Login or Register to edit or fork this paste. It's free.