DevWilliams

Guard System

Mar 27th, 2023
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.89 KB | None | 0 0
  1. diff --git a/L2jOne_C6_Interlude/config/server.properties b/L2jOne_C6_Interlude/config/server.properties
  2. index 1673b7c..42b8b90 100644
  3. --- a/L2jOne_C6_Interlude/config/server.properties
  4. +++ b/L2jOne_C6_Interlude/config/server.properties
  5. @@ -23,6 +23,11 @@
  6. # /!\ Don't edit this value and reload config while the server is running. It would lead to all connected clients to become unresponsive (waiting de/crypted packets, but receiving the versus).
  7. UseBlowfishCipher = True
  8.  
  9. +# Guard System Encryption keys
  10. +# ATTENTION: Don't change this if you don't know what are you doing
  11. +ClientKey = ffeeddccbbaa99887766554433221100ffeeddccbbaa99887766554433221100
  12. +ServerKey = 00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff
  13. +
  14. # ================================================================
  15. # Database informations
  16. # ================================================================
  17. diff --git a/L2jOne_C6_Interlude/java/guard/GuardSystem.java b/L2jOne_C6_Interlude/java/guard/GuardSystem.java
  18. new file mode 100644
  19. index 0000000..cca1121
  20. --- /dev/null
  21. +++ b/L2jOne_C6_Interlude/java/guard/GuardSystem.java
  22. @@ -0,0 +1,117 @@
  23. +package guard;
  24. +
  25. +import java.sql.Connection;
  26. +import java.sql.PreparedStatement;
  27. +import java.sql.ResultSet;
  28. +import java.sql.SQLException;
  29. +import java.util.List;
  30. +import java.util.concurrent.CopyOnWriteArrayList;
  31. +
  32. +import net.sf.l2j.commons.logging.CLogger;
  33. +import net.sf.l2j.commons.pool.ConnectionPool;
  34. +
  35. +import net.sf.l2j.Config;
  36. +import net.sf.l2j.gameserver.model.actor.Player;
  37. +import net.sf.l2j.gameserver.network.GameClient;
  38. +
  39. +public class GuardSystem
  40. +{
  41. + private static final CLogger LOGGER = new CLogger(GuardSystem.class.getName());
  42. +
  43. + private static final String LOAD_bans = "SELECT `hwid` FROM `banned_hwids`";
  44. + private static final String ADD_TO_bans = "INSERT INTO `banned_hwids` VALUES (?)";
  45. + private static final String REMOVE_FROM_bans = "DELETE FROM `banned_hwids` WHERE `hwid` = ?";
  46. +
  47. + private List<String> _bans = new CopyOnWriteArrayList<>();
  48. +
  49. + public GuardSystem()
  50. + {
  51. + _bans.clear();
  52. + try (Connection conn = ConnectionPool.getConnection())
  53. + {
  54. + try (PreparedStatement ps = conn.prepareStatement(LOAD_bans))
  55. + {
  56. + try (ResultSet rs = ps.executeQuery())
  57. + {
  58. + while (rs.next())
  59. + _bans.add(rs.getString(1));
  60. + }
  61. + }
  62. + }
  63. + catch (SQLException ex)
  64. + {
  65. + LOGGER.warn("Failed to load banned HWIDs from DB.", ex);
  66. + }
  67. +
  68. + LOGGER.info("Loaded {} banned HWIDs from DB.", _bans.size());
  69. + }
  70. +
  71. + public void ban(Player player)
  72. + {
  73. + if (player == null || Config.ALLOWED_GUARD_SYSTEM)
  74. + return;
  75. +
  76. + final GameClient client = player.getClient();
  77. + if (client == null)
  78. + return;
  79. +
  80. + _bans.add(client.getHwid());
  81. +
  82. + try (Connection conn = ConnectionPool.getConnection())
  83. + {
  84. + try (PreparedStatement ps = conn.prepareStatement(ADD_TO_bans))
  85. + {
  86. + ps.setString(1, client.getHwid());
  87. + ps.executeUpdate();
  88. + }
  89. + }
  90. + catch (SQLException ex)
  91. + {
  92. + LOGGER.warn("Failed to store banned HWID in DB.", ex);
  93. + }
  94. + }
  95. +
  96. + public void unban(String hwid)
  97. + {
  98. + if (hwid == null || Config.ALLOWED_GUARD_SYSTEM)
  99. + return;
  100. +
  101. + if (_bans.contains(hwid))
  102. + {
  103. + _bans.remove(hwid);
  104. + try (Connection conn = ConnectionPool.getConnection())
  105. + {
  106. + try (PreparedStatement ps = conn.prepareStatement(REMOVE_FROM_bans))
  107. + {
  108. + ps.setString(1, hwid);
  109. + ps.executeUpdate();
  110. + }
  111. + }
  112. + catch (SQLException ex)
  113. + {
  114. + LOGGER.warn("Failed to remove banned HWID from DB.", ex);
  115. + }
  116. + }
  117. + }
  118. +
  119. + public boolean isBanned(String hwid)
  120. + {
  121. + return _bans.contains(hwid);
  122. + }
  123. +
  124. + public boolean isBanned(Player player)
  125. + {
  126. + final GameClient client = player.getClient();
  127. + return client != null && isBanned(client.getHwid());
  128. + }
  129. +
  130. + public static GuardSystem getInstance()
  131. + {
  132. + return SingletonHolder.INSTANCE;
  133. + }
  134. +
  135. + private static class SingletonHolder
  136. + {
  137. + protected static final GuardSystem INSTANCE = new GuardSystem();
  138. + }
  139. +}
  140. \ No newline at end of file
  141. diff --git a/L2jOne_C6_Interlude/java/guard/crypt/LameCrypt.java b/L2jOne_C6_Interlude/java/guard/crypt/LameCrypt.java
  142. new file mode 100644
  143. index 0000000..9f9e14b
  144. --- /dev/null
  145. +++ b/L2jOne_C6_Interlude/java/guard/crypt/LameCrypt.java
  146. @@ -0,0 +1,38 @@
  147. +package guard.crypt;
  148. +
  149. +import net.sf.l2j.Config;
  150. +
  151. +public class LameCrypt
  152. +{
  153. + private boolean _enabled;
  154. +
  155. + private VMPC _c;
  156. + private VMPC _s;
  157. +
  158. + public LameCrypt()
  159. + {
  160. + _c = new VMPC();
  161. + _s = new VMPC();
  162. + }
  163. +
  164. + public void init(byte[] iv)
  165. + {
  166. + iv = LameKey.expandKey(iv);
  167. + _c.setup(LameKey.expandKey(Config.CLIENT_KEY.getBytes()), iv);
  168. + _s.setup(LameKey.expandKey(Config.SERVER_KEY.getBytes()), iv);
  169. + }
  170. +
  171. + public void decrypt(final byte[] raw, final int offset, final int size)
  172. + {
  173. + if (_enabled)
  174. + _c.crypt(raw, offset, size);
  175. + }
  176. +
  177. + public void encrypt(final byte[] raw, final int offset, final int size)
  178. + {
  179. + if (!_enabled)
  180. + _enabled = true;
  181. + else
  182. + _s.crypt(raw, offset, size);
  183. + }
  184. +}
  185. \ No newline at end of file
  186. diff --git a/L2jOne_C6_Interlude/java/guard/crypt/LameKey.java b/L2jOne_C6_Interlude/java/guard/crypt/LameKey.java
  187. new file mode 100644
  188. index 0000000..72a7d4d
  189. --- /dev/null
  190. +++ b/L2jOne_C6_Interlude/java/guard/crypt/LameKey.java
  191. @@ -0,0 +1,55 @@
  192. +package guard.crypt;
  193. +
  194. +public class LameKey
  195. +{
  196. + private static final byte[] TKBOX =
  197. + {
  198. + -112, 22, 124, -93, 68, -116, -19, -125, -4, 101, -62, 5, 70, 25,
  199. + 29, 81, 65, -86, 79, -69, 2, 97, -108, -11, -84, -56, 17, 7, 31, 52, -34, -41, -110, -60, 57, -5, -6, -24,
  200. + 98, -100, 23, 4, -74, -37, 1, 6, -2, -14, -77, 12, -7, 3, -29, -17, -75, 49, 44, -78, 94, 21, 0, 35, -18,
  201. + 83, 9, -42, 60, 93, 54, 20, -49, 114, 106, -82, 113, -90, 86, -124, -73, -81, 90, 121, 115, 125, 47, 24,
  202. + -28, 73, 56, -31, 8, 71, 122, 58, -33, 108, -111, 102, -118, -103, -122, 88, 28, -76, 67, -115, -67, 78, 36,
  203. + 117, -8, -25, -97, 107, -91, -50, -53, -52, 111, -114, -58, -128, 84, -98, 63, 74, 10, 41, -32,
  204. + 126, 69, -68, 11, -119, -44, -39, -107, -40, 85, -87, 61, 91, -1, 50, -72, -117, 15, 55, -51, 43, 87, 105,
  205. + 120, -88, 116, 80, -48, -123, -127, -105, -22, 76, 109, 19, -46, -30, 112, 16, -10, 45, -63, -47, 123, -106,
  206. + 27, 38, 104, -70, -79, 18, -99, -16, -85, -23, 30, -66, 48, -89, -61, -113, -12, 51, -95, -15, 32, -9, 62,
  207. + -38, 14, -45, -80, 66, 100, 103, -104, -27, -43, 110, -83, -26, -101, 46, -120, -54, 37, 42, 13, 75, 82,
  208. + -109, 26, -94, -57, -64, 119, 53, 39, -13, -121, 33, 72, -126, -65, -36, -71, 118, -35, 92, 96, 89, 64, 34,
  209. + -20, -96, 77, 40, 127, -21, 59, -55, -102, 95, -3, 99, -59, -92
  210. + };
  211. +
  212. + private static final byte[] MGBOX =
  213. + {
  214. + -14, -108, 90, 75, 15, 115, -38, -37, -125, 29, -77, 9, -4, 54,
  215. + -72, 70, 65, -44, -48, 85, -13, -121, 118, -102, 40, 53, 113, -5, -9, 28, 3, 125, 21, -124, 10, 67, -6, -98,
  216. + 96, -105, -104, 126, -93, 82, -47, 41, -91, 89, -59, 122, 47, 37, -31, 59, 56, 12, -112, -58, -39, -10, -40,
  217. + -49, 22, -107, 33, -89, 109, 31, 88, 81, 72, 42, -66, -85, -15, 93, -101, -7, -128, -19, -27, -90,
  218. + -11, 111, 49, -70, 121, 79, -123, -127, -79, 35, -28, 114, -22, 44, -54, 107, 106, 30, 92, 4, -43, -82, -78,
  219. + -26, -61, 57, 77, 95, 58, 69, -76, 103, -56, 78, 26, -92, 48, -32, -52, 16, -67, 51, -50, -73, -29, 52, -60,
  220. + -118, -1, -80, 63, 2, 124, -36, -65, 8, -33, -115, -3, 108, -21, 18, 110, 36, -51, 46, -103, 94, 20, -114,
  221. + 80, 127, -86, 19, -119, -113, 68, -25, -120, -71, 32, 38, -95, -57, 5, 7, 105, -17, -34, -81, 24,
  222. + -74, -35, 100, 1, -46, -94, 43, 13, 17, -87, 11, -69, -62, -126, -63, -64, -23, -97, 27, -18, -53, 84, 0,
  223. + -106, -83, 39, 116, 91, 104, 14, -24, -42, 34, -88, -84, 62, 61, -2, 112, 23, 119, 73, 6, -122, 55, -99,
  224. + -41, 83, 99, 60, 87, 45, 120, -55, 117, -117, 98, 123, -8, 76, -16, -30, 64, -96, -109, -75, 25, 101, -110,
  225. + 86, 50, 71, -12, 74, -100, -116, -68, 66, -20, -45, 102, -111, 97
  226. + };
  227. +
  228. + public static byte[] expandKey(byte[] key)
  229. + {
  230. + short i;
  231. + byte t, m;
  232. + byte[] P = new byte[64];
  233. +
  234. + for (i = 0; i < 64; i++)
  235. + P[i] = key[i % key.length];
  236. +
  237. + for (i = 0; i < 256; i++)
  238. + {
  239. + t = P[i % 64];
  240. + m = (byte) (MGBOX[MGBOX[t & 0xFF] & 0xFF] & 0xFF ^ TKBOX[TKBOX[i] & 0xFF] & 0xFF);
  241. + P[i % 64] = TKBOX[m & 0xFF];
  242. + }
  243. +
  244. + return P;
  245. + }
  246. +}
  247. \ No newline at end of file
  248. diff --git a/L2jOne_C6_Interlude/java/guard/crypt/VMPC.java b/L2jOne_C6_Interlude/java/guard/crypt/VMPC.java
  249. new file mode 100644
  250. index 0000000..6be832f
  251. --- /dev/null
  252. +++ b/L2jOne_C6_Interlude/java/guard/crypt/VMPC.java
  253. @@ -0,0 +1,54 @@
  254. +package guard.crypt;
  255. +
  256. +public class VMPC
  257. +{
  258. + private byte _n, _s;
  259. + private byte[] _P = new byte[256];
  260. +
  261. + private void ksa(byte[] key)
  262. + {
  263. + byte temp;
  264. + for (short i = 0; i < 768; i++)
  265. + {
  266. + _s = _P[(_s + _P[i & 0xff] + key[i % key.length]) & 0xff];
  267. +
  268. + temp = _P[i & 0xff];
  269. + _P[i & 0xff] = _P[_s & 0xff];
  270. + _P[_s & 0xff] = temp;
  271. + }
  272. + }
  273. +
  274. + public void setup(byte[] key, byte[] iv)
  275. + {
  276. + _n = 0;
  277. + _s = 0;
  278. +
  279. + for (short i = 0; i < 256; i++)
  280. + _P[i] = (byte) i;
  281. +
  282. + ksa(key);
  283. +
  284. + if (iv != null && iv.length > 0)
  285. + {
  286. + ksa(iv);
  287. + ksa(key);
  288. + }
  289. + }
  290. +
  291. + public void crypt(byte[] raw, int offset, int size)
  292. + {
  293. + byte z, temp;
  294. + for (int i = 0; i < size; i++)
  295. + {
  296. + _s = _P[(_s + _P[_n & 0xff]) & 0xff];
  297. + z = _P[(_P[_P[_s & 0xff] & 0xff] + 1) & 0xff];
  298. +
  299. + temp = _P[_n & 0xff];
  300. + _P[_n & 0xff] = _P[_s & 0xff];
  301. + _P[_s & 0xff] = temp;
  302. + _n = (byte) ((_n + 1) & 0xff);
  303. +
  304. + raw[offset + i] = (byte) (raw[offset + i] ^ z);
  305. + }
  306. + }
  307. +}
  308. \ No newline at end of file
  309. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/Config.java b/L2jOne_C6_Interlude/java/net/sf/l2j/Config.java
  310. index 2f080f7..af15f83 100644
  311. --- a/L2jOne_C6_Interlude/java/net/sf/l2j/Config.java
  312. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/Config.java
  313. @@ -500,6 +500,11 @@
  314. public static boolean ACCEPT_ALTERNATE_ID;
  315. public static boolean USE_BLOWFISH_CIPHER;
  316.  
  317. + /** Guard System */
  318. + public static boolean ALLOWED_GUARD_SYSTEM;
  319. + public static String CLIENT_KEY;
  320. + public static String SERVER_KEY;
  321. +
  322. /** Access to database */
  323. public static String DATABASE_URL;
  324. public static String DATABASE_LOGIN;
  325. @@ -1175,6 +1180,10 @@
  326. ACCEPT_ALTERNATE_ID = server.getProperty("AcceptAlternateID", true);
  327. USE_BLOWFISH_CIPHER = server.getProperty("UseBlowfishCipher", true);
  328.  
  329. + ALLOWED_GUARD_SYSTEM = server.getProperty("AllowGuardSystem", false);
  330. + CLIENT_KEY = server.getProperty("ClientKey", "");
  331. + SERVER_KEY = server.getProperty("ServerKey", "");
  332. +
  333. DATABASE_URL = server.getProperty("URL", "jdbc:mariadb://localhost/acis");
  334. DATABASE_LOGIN = server.getProperty("Login", "root");
  335. DATABASE_PASSWORD = server.getProperty("Password", "");
  336. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/GameServer.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/GameServer.java
  337. index a7f3bc5..31b577b 100644
  338. --- a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/GameServer.java
  339. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/GameServer.java
  340. @@ -99,6 +99,8 @@
  341. import net.sf.l2j.util.DeadLockDetector;
  342. import net.sf.l2j.util.IPv4Filter;
  343.  
  344. +import guard.GuardSystem;
  345. +
  346. public class GameServer
  347. {
  348. private static final CLogger LOGGER = new CLogger(GameServer.class.getName());
  349. @@ -268,6 +270,9 @@
  350. LOGGER.info("Loaded {} target handlers.", TargetHandler.getInstance().size());
  351. LOGGER.info("Loaded {} user command handlers.", UserCommandHandler.getInstance().size());
  352.  
  353. + StringUtil.printSection("Guard System");
  354. + GuardSystem.getInstance();
  355. +
  356. StringUtil.printSection("System");
  357. Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
  358.  
  359. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/BlowFishKeygen.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/BlowFishKeygen.java
  360. index 8507b86..4289560 100644
  361. --- a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/BlowFishKeygen.java
  362. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/BlowFishKeygen.java
  363. @@ -2,6 +2,8 @@
  364.  
  365. import net.sf.l2j.commons.random.Rnd;
  366.  
  367. +import net.sf.l2j.Config;
  368. +
  369. public class BlowFishKeygen
  370. {
  371. private static final int CRYPT_KEYS_SIZE = 20;
  372. @@ -44,6 +46,6 @@
  373. */
  374. public static byte[] getRandomKey()
  375. {
  376. - return Rnd.get(CRYPT_KEYS);
  377. + return Config.ALLOWED_GUARD_SYSTEM ? Rnd.nextBytes(16) : Rnd.get(CRYPT_KEYS);
  378. }
  379. }
  380. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/GameClient.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/GameClient.java
  381. index 7089d2b..c738f97 100644
  382. --- a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/GameClient.java
  383. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/GameClient.java
  384. @@ -24,6 +24,7 @@
  385. import net.sf.l2j.gameserver.model.World;
  386. import net.sf.l2j.gameserver.model.actor.Player;
  387. import net.sf.l2j.gameserver.model.pledge.Clan;
  388. +import net.sf.l2j.gameserver.network.serverpackets.GameGuardQuery;
  389. import net.sf.l2j.gameserver.network.serverpackets.L2GameServerPacket;
  390. import net.sf.l2j.gameserver.network.serverpackets.ServerClose;
  391.  
  392. @@ -70,6 +71,7 @@
  393. private final ReentrantLock _activeCharLock = new ReentrantLock();
  394.  
  395. private final GameCrypt _crypt;
  396. + private String _hwid;
  397. private final long _connectionStartTime;
  398.  
  399. public GameClientState _state;
  400. @@ -90,6 +92,7 @@
  401. super(con);
  402.  
  403. _state = GameClientState.CONNECTED;
  404. + _hwid = null;
  405. _connectionStartTime = System.currentTimeMillis();
  406. _crypt = new GameCrypt();
  407.  
  408. @@ -174,7 +177,17 @@
  409. {
  410. LOGGER.debug("{} disconnected abnormally.", toString());
  411. }
  412. -
  413. +
  414. + public String getHwid()
  415. + {
  416. + return _hwid;
  417. + }
  418. +
  419. + public void setHwid(String hwid)
  420. + {
  421. + _hwid = hwid;
  422. + }
  423. +
  424. public byte[] enableCrypt()
  425. {
  426. byte[] key = BlowFishKeygen.getRandomKey();
  427. @@ -225,6 +238,7 @@
  428. public void setAccountName(String pAccountName)
  429. {
  430. _accountName = pAccountName;
  431. + sendPacket(new GameGuardQuery());
  432. }
  433.  
  434. public String getAccountName()
  435. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/GameCrypt.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/GameCrypt.java
  436. index 562853e..92bd7f7 100644
  437. --- a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/GameCrypt.java
  438. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/GameCrypt.java
  439. @@ -1,22 +1,42 @@
  440. package net.sf.l2j.gameserver.network;
  441.  
  442. +import java.util.Arrays;
  443. +
  444. import net.sf.l2j.Config;
  445.  
  446. +import guard.crypt.LameCrypt;
  447. +
  448. public class GameCrypt
  449. {
  450. + private boolean _enabled;
  451. private final byte[] _inKey = new byte[16];
  452. private final byte[] _outKey = new byte[16];
  453. - private boolean _isEnabled;
  454. + private LameCrypt _lameCrypt;
  455. +
  456. + public GameCrypt()
  457. + {
  458. + if (Config.ALLOWED_GUARD_SYSTEM)
  459. + _lameCrypt = new LameCrypt();
  460. + }
  461.  
  462. public void setKey(byte[] key)
  463. {
  464. System.arraycopy(key, 0, _inKey, 0, 16);
  465. System.arraycopy(key, 0, _outKey, 0, 16);
  466. +
  467. + if (Config.ALLOWED_GUARD_SYSTEM)
  468. + _lameCrypt.init(Arrays.copyOfRange(key, 0, 8));
  469. }
  470.  
  471. public void decrypt(byte[] raw, final int offset, final int size)
  472. {
  473. - if (!Config.USE_BLOWFISH_CIPHER || !_isEnabled)
  474. + if (Config.ALLOWED_GUARD_SYSTEM)
  475. + {
  476. + _lameCrypt.decrypt(raw, offset, size);
  477. + return;
  478. + }
  479. +
  480. + if (!Config.USE_BLOWFISH_CIPHER || !_enabled)
  481. return;
  482.  
  483. int temp = 0;
  484. @@ -42,9 +62,15 @@
  485.  
  486. public void encrypt(byte[] raw, final int offset, final int size)
  487. {
  488. - if (!_isEnabled)
  489. + if (Config.ALLOWED_GUARD_SYSTEM)
  490. {
  491. - _isEnabled = Config.USE_BLOWFISH_CIPHER;
  492. + _lameCrypt.encrypt(raw, offset, size);
  493. + return;
  494. + }
  495. +
  496. + if (!_enabled)
  497. + {
  498. + _enabled = Config.USE_BLOWFISH_CIPHER;
  499. return;
  500. }
  501.  
  502. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/GamePacketHandler.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/GamePacketHandler.java
  503. index 143b4b1..fc5b0a8 100644
  504. --- a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/GamePacketHandler.java
  505. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/GamePacketHandler.java
  506. @@ -76,6 +76,9 @@
  507. case 0x68:
  508. msg = new RequestPledgeCrest();
  509. break;
  510. + case 0xca:
  511. + msg = new GameGuardReply();
  512. + break;
  513. default:
  514. printDebug(opcode, buf, state, client);
  515. break;
  516. @@ -649,9 +652,6 @@
  517. case 0xc8:
  518. msg = new PetitionVote();
  519. break;
  520. - case 0xCA:
  521. - msg = new GameGuardReply();
  522. - break;
  523. case 0xcc:
  524. msg = new RequestSendL2FriendSay();
  525. break;
  526. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/clientpackets/GameGuardReply.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/clientpackets/GameGuardReply.java
  527. index 4622e37..3d18237 100644
  528. --- a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/clientpackets/GameGuardReply.java
  529. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/network/clientpackets/GameGuardReply.java
  530. @@ -1,17 +1,39 @@
  531. package net.sf.l2j.gameserver.network.clientpackets;
  532.  
  533. +import net.sf.l2j.Config;
  534. import net.sf.l2j.gameserver.model.actor.Player;
  535.  
  536. +import guard.GuardSystem;
  537. +
  538. public class GameGuardReply extends L2GameClientPacket
  539. {
  540. + private byte[] _hwid = new byte[16];
  541. +
  542. @Override
  543. protected void readImpl()
  544. {
  545. + readB(_hwid);
  546. }
  547.  
  548. @Override
  549. protected void runImpl()
  550. {
  551. + if (Config.ALLOWED_GUARD_SYSTEM)
  552. + {
  553. + String hwid = null;
  554. +
  555. + // convert HWID from byte array to string.
  556. + StringBuilder sb = new StringBuilder(_hwid.length * 2);
  557. + for(final byte b: _hwid)
  558. + sb.append(String.format("%02X", b));
  559. +
  560. + hwid = sb.toString();
  561. + if (GuardSystem.getInstance().isBanned(hwid))
  562. + getClient().closeNow();
  563. + else
  564. + getClient().setHwid(hwid);
  565. + }
  566. +
  567. final Player player = getClient().getPlayer();
  568. if (player == null)
  569. return;
Advertisement
Add Comment
Please, Sign In to add comment