L2-Irrelevant

Hwid for L2jFrozen

Jun 15th, 2021 (edited)
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 111.99 KB | None | 0 0
  1.  
  2. Index: head-src/Hwid/+Hwid.java
  3. ===================================================================
  4. /*
  5. * This program is free software: you can redistribute it and/or modify it under
  6. * the terms of the GNU General Public License as published by the Free Software
  7. * Foundation, either version 3 of the License, or (at your option) any later
  8. * version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  13. * details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. package Hwid;
  19.  
  20. import Hwid.crypt.Manager;
  21. import Hwid.hwidmanager.HWIDBan;
  22. import Hwid.hwidmanager.HWIDManager;
  23. import Hwid.utils.Util;
  24.  
  25. import java.io.IOException;
  26. import java.nio.ByteBuffer;
  27. import java.util.concurrent.ConcurrentHashMap;
  28. import java.util.logging.Logger;
  29.  
  30. import com.l2jfrozen.crypt.BlowfishEngine;
  31. import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  32.  
  33. import com.l2jfrozen.gameserver.network.L2GameClient;
  34. import com.l2jfrozen.gameserver.network.serverpackets.ServerClose;
  35.  
  36. public class Hwid
  37. {
  38. protected static Logger _log = Logger.getLogger(Hwid.class.getName());
  39. private static byte[] _key = new byte[16];
  40. static byte version = 11;
  41. protected static ConcurrentHashMap<String, Manager.InfoSet> _objects = new ConcurrentHashMap<>();
  42.  
  43. public static void Init()
  44. {
  45. HwidConfig.load();
  46. if (isProtectionOn())
  47. {
  48. HWIDBan.getInstance();
  49. HWIDManager.getInstance();
  50. Manager.getInstance();
  51. }
  52. }
  53.  
  54. public static boolean isProtectionOn()
  55. {
  56. if (HwidConfig.ALLOW_GUARD_SYSTEM)
  57. return true;
  58. return false;
  59. }
  60.  
  61. public static byte[] getKey(byte[] key)
  62. {
  63. // byte[] bfkey = FirstKey.SKBOX;
  64. byte[] bfkey =
  65. {
  66. 110,
  67. 36,
  68. 2,
  69. 15,
  70. -5,
  71. 17,
  72. 24,
  73. 23,
  74. 18,
  75. 45,
  76. 1,
  77. 21,
  78. 122,
  79. 16,
  80. -5,
  81. 12
  82. };
  83. try
  84. {
  85. BlowfishEngine bf = new BlowfishEngine();
  86. bf.init(true, bfkey);
  87. bf.processBlock(key, 0, _key, 0);
  88. bf.processBlock(key, 8, _key, 8);
  89. }
  90. catch (IOException e)
  91. {
  92. _log.info("Bad key!!!");
  93. }
  94. return _key;
  95. }
  96.  
  97. public static void addPlayer(L2GameClient client)
  98. {
  99. if (isProtectionOn() && client != null)
  100. Manager.getInstance().addPlayer(client);
  101. }
  102.  
  103. public static void removePlayer(L2GameClient client)
  104. {
  105. if (isProtectionOn() && client != null)
  106. Manager.removePlayer(client.getPlayerName());
  107. }
  108.  
  109. public static boolean checkVerfiFlag(L2GameClient client, int flag)
  110. {
  111. boolean result = true;
  112. int fl = Integer.reverseBytes(flag);
  113. if (fl == -1)
  114. // Log.add("Error Verify Flag|" client.toString(), _logFile);
  115. return false;
  116. else if (fl == 1342177280)
  117. // Log.add("Error get net data client|" client.toString() "|DEBUG INFO:" fl, _logFile);
  118. return false;
  119. else
  120. {
  121. if ((fl & 1) != 0)
  122. // Log.add("Sniffer detect |" client.toString() "|DEBUG INFO:" fl, _logFile);
  123. result = false;
  124.  
  125. // Console CMD
  126. if ((fl & 16) != 0)
  127. // Log.add("Sniffer detect2 |" client.toString() "|DEBUG INFO:" fl, _logFile);
  128. result = false;
  129.  
  130. if ((fl & 268435456) != 0)
  131. // Log.add("L2ext detect |" client.toString() "|DEBUG INFO:" fl, _logFile);
  132. result = false;
  133.  
  134. return result;
  135. }
  136. }
  137.  
  138. public static int dumpData(int _id, int position, L2GameClient pi)
  139. {
  140. int value = 0;
  141. position = position > 4 ? 5 : position;
  142. boolean isIdZero = false;
  143. if (_id == 0)
  144. isIdZero = true;
  145. // Log.add("Cannot read DumpId|Target:" _positionName[position] "|" pi.toString() "|DEBUG INFO:" _id, _logFile);
  146. switch (position)
  147. {
  148. case 0:
  149. // IG
  150. if (_id != 1435233386)
  151. {
  152. if (!isIdZero)
  153. {
  154. // Log.add(_positionName[position] " was found|" pi.toString() "|DEBUG INFO:" _id, _logFile);
  155. }
  156. value = 1/* HwidConfig.PROTECT_PENALTY_IG */;
  157. }
  158. break;
  159. case 1:
  160. // Console CMD
  161. if (_id != 16)
  162. {
  163. if (!isIdZero)
  164. {
  165. // Log.add(_positionName[position] " was found|" pi.toString() "|DEBUG INFO:" _id, _logFile);
  166. }
  167. value = 2/* HwidConfig.PROTECT_PENALTY_CONSOLE_CMD */;
  168. }
  169. break;
  170. case 2:
  171. case 3:
  172. case 4:
  173. // check debuger (0xСС) or hook (0xE9)
  174. int code = _id & 0xFF000000;
  175. if (code == 0xCC)
  176. {
  177. // Log.add("Attempts!!! Debuger was found|" pi.toString() "|DEBUG INFO:" _id, _logFile);
  178. }
  179. // L2phx (connect, send, recv)
  180. if (code == 0xE9)
  181. // Log.add(_positionName[position] " was found|" pi.toString() "|DEBUG INFO:" _id, _logFile);
  182. value = 3/* HwidConfig.PROTECT_PENALTY_L2PHX */;
  183. break;
  184. default:
  185. value = 0;
  186. break;
  187. }
  188. return value;
  189. }
  190.  
  191. public static int calcPenalty(byte[] data, L2GameClient pi)
  192. {
  193. int sum = -1;
  194. if (Util.verifyChecksum(data, 0, data.length))
  195. {
  196. ByteBuffer buf = ByteBuffer.wrap(data, 0, data.length - 4);
  197. sum = 0;
  198. int lenPenalty = (data.length - 4) / 4;
  199. for (int i = 0; i < lenPenalty; i++)
  200. sum = Hwid.dumpData(buf.getInt(), i, pi);
  201. }
  202. return sum;
  203. }
  204.  
  205. public static boolean CheckHWIDs(L2GameClient client, int LastError1, int LastError2)
  206. {
  207. boolean resultHWID = false;
  208. boolean resultLastError = false;
  209. String HWID = client.getHWID();
  210.  
  211. if (HWID.equalsIgnoreCase("fab800b1cc9de379c8046519fa841e6"))
  212. // Log.add("HWID:" HWID "|is empty, account:" client.getLoginName() "|IP: " client.toString(), _logFile);
  213. if (HwidConfig.PROTECT_KICK_WITH_EMPTY_HWID)
  214. {
  215. resultHWID = true;
  216. }
  217. if (LastError1 != 0)
  218. {
  219. // Log.add("LastError(HWID):" LastError1 "|" Util.LastErrorConvertion(Integer.valueOf(LastError1)) "|isn\'t empty, " client.toString(), _logFile);
  220. if (HwidConfig.PROTECT_KICK_WITH_LASTERROR_HWID)
  221. {
  222. resultLastError = true;
  223. }
  224. }
  225. return resultHWID || resultLastError;
  226. }
  227.  
  228. public static String fillHex(int data, int digits)
  229. {
  230. String number = Integer.toHexString(data);
  231.  
  232. for (int i = number.length(); i < digits; i++)
  233. number = "0" +number;
  234.  
  235. return number;
  236. }
  237.  
  238. public static String ExtractHWID(byte[] _data)
  239. {
  240. if (!Util.verifyChecksum(_data, 0, _data.length))
  241. return null;
  242. StringBuilder resultHWID = new StringBuilder();
  243.  
  244. for (int i = 0; i < _data.length - 8; i++)
  245. resultHWID.append(fillHex(_data[i] & 255, 2));
  246.  
  247. return resultHWID.toString();
  248. }
  249.  
  250. public static boolean doAuthLogin(L2GameClient client, byte[] data, String loginName)
  251. {
  252. if (!isProtectionOn())
  253. return true;
  254. client.setLoginName(loginName);
  255. String fullHWID = ExtractHWID(data);
  256.  
  257. if (fullHWID == null)
  258. {
  259. _log.info("AuthLogin CRC Check Fail! May be BOT or unprotected client! Client IP: " + client.toString());
  260. client.close(ServerClose.STATIC_PACKET);
  261. return false;
  262. }
  263.  
  264. int LastError1 = ByteBuffer.wrap(data, 16, 4).getInt();
  265. if (CheckHWIDs(client, LastError1, 0))
  266. {
  267. _log.info("HWID error, look protection_logs.txt file, from IP: " + client.toString());
  268. client.close(ServerClose.STATIC_PACKET);
  269. return false;
  270. }
  271. if (HWIDBan.getInstance().checkFullHWIDBanned(client))
  272. {
  273. _log.info("Client " + client + " is banned. Kicked! |HWID: " + client.getHWID() + " IP: " + client.toString());
  274. client.close(ServerClose.STATIC_PACKET);
  275. }
  276.  
  277. int VerfiFlag = ByteBuffer.wrap(data, 40, 4).getInt();
  278. if (!checkVerfiFlag(client, VerfiFlag))
  279. return false;
  280. return true;
  281. }
  282.  
  283. public static void doDisconection(L2GameClient client)
  284. {
  285. removePlayer(client);
  286. }
  287.  
  288. public static boolean checkPlayerWithHWID(L2GameClient client, int playerID, String playerName)
  289. {
  290. if (!isProtectionOn())
  291. return true;
  292.  
  293. client.setPlayerName(playerName);
  294. client.setPlayerId(playerID);
  295.  
  296. if (HwidConfig.PROTECT_WINDOWS_COUNT != 0)
  297. {
  298. final int count = Manager.getCountByHWID(client.getHWID());
  299. if (count > HwidConfig.PROTECT_WINDOWS_COUNT && count > HWIDManager.getAllowedWindowsCount(client))
  300. {
  301. _log.info("Multi windows: " + client.toString());
  302. client.close(ServerClose.STATIC_PACKET);
  303. return false;
  304. }
  305. }
  306. addPlayer(client);
  307. return true;
  308.  
  309. }
  310.  
  311. public static void nopath(L2GameClient client)
  312. {
  313. _log.info("Client " + client + " is no have path kick: " + client.getHWID() + " IP: " + client.toString());
  314. client.close(ServerClose.STATIC_PACKET);
  315. }
  316.  
  317. public static void enterlog(L2PcInstance player, L2GameClient client)
  318. {
  319. if (HwidConfig.ALLOW_GUARD_SYSTEM && HwidConfig.ENABLE_CONSOLE_LOG)
  320. _log.info("HWID : [" + client.getHWID() + "], character: [" + player.getName() + "] PlayerId: [" + player.getObjectId() + " ]");
  321. }
  322.  
  323. public static void waitSecs(int i)
  324. {
  325. try
  326. {
  327. Thread.sleep(i * 1000);
  328. }
  329. catch (InterruptedException ie)
  330. {
  331. ie.printStackTrace();
  332. }
  333. }
  334. }
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344. Index: head-src/Hwid/+HwidConfig.java
  345. ===================================================================
  346. /*
  347. * This program is free software: you can redistribute it and/or modify it under
  348. * the terms of the GNU General Public License as published by the Free Software
  349. * Foundation, either version 3 of the License, or (at your option) any later
  350. * version.
  351. *
  352. * This program is distributed in the hope that it will be useful, but WITHOUT
  353. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  354. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  355. * details.
  356. *
  357. * You should have received a copy of the GNU General Public License along with
  358. * this program. If not, see <http://www.gnu.org/licenses/>.
  359. */
  360. package Hwid;
  361.  
  362. import Hwid.crypt.FirstKey;
  363.  
  364. import java.io.File;
  365. import java.io.FileInputStream;
  366. import java.io.InputStream;
  367. import java.util.Properties;
  368. import java.util.logging.Logger;
  369.  
  370. public class HwidConfig
  371. {
  372. protected static Logger _log = Logger.getLogger(HwidConfig.class.getName());
  373. public static final String D_GUARD_FILE = "./config/Hwid.properties";
  374. public static final boolean PROTECT_DEBUG = false;
  375. public static final boolean PROTECT_ENABLE_HWID_LOCK = false;
  376. public static byte[] GUARD_CLIENT_CRYPT_KEY;
  377. public static byte[] GUARD_CLIENT_CRYPT;
  378. public static byte[] GUARD_SERVER_CRYPT_KEY;
  379. public static byte[] GUARD_SERVER_CRYPT;
  380. public static byte FST_KEY;
  381. public static byte SCN_KEY;
  382. public static byte ANP_KEY;
  383. public static byte ULT_KEY;
  384. public static int NPROTECT_KEY = -1;
  385. public static String NPROTECT_USERNAME;
  386. public static int SITE_01;
  387. public static final boolean ALLOW_DUALBOX1 = true;
  388.  
  389. public static boolean ALLOW_GUARD_SYSTEM;
  390. public static int PROTECT_WINDOWS_COUNT;
  391.  
  392. public static int GET_CLIENT_HWID;
  393. public static boolean ALLOW_SEND_GG_REPLY;
  394. public static boolean ENABLE_CONSOLE_LOG;
  395. public static long TIME_SEND_GG_REPLY;
  396. public static boolean PROTECT_KICK_WITH_EMPTY_HWID;
  397. public static boolean PROTECT_KICK_WITH_LASTERROR_HWID;
  398.  
  399. public static String MESSAGE_GOOD;
  400. public static String MESSAGE_ERROR;
  401.  
  402. public static final void load()
  403. {
  404. File fp = new File(D_GUARD_FILE);
  405. ALLOW_GUARD_SYSTEM = fp.exists();
  406.  
  407. if (ALLOW_GUARD_SYSTEM)
  408. try
  409. {
  410. Properties guardSettings = new Properties();
  411. InputStream is = new FileInputStream(fp);
  412. guardSettings.load(is);
  413. is.close();
  414.  
  415. _log.info("- Loading Protection Configs");
  416. ALLOW_GUARD_SYSTEM = getBooleanProperty(guardSettings, "AllowGuardSystem", true);
  417. PROTECT_WINDOWS_COUNT = getIntProperty(guardSettings, "AllowedWindowsCount", 1);
  418. NPROTECT_USERNAME = guardSettings.getProperty("UserName", "");
  419. SITE_01 = getIntProperty(guardSettings, "Prtctn", 1);
  420.  
  421. FST_KEY = getByteProperty(guardSettings, "FstKey", 110);
  422. SCN_KEY = getByteProperty(guardSettings, "ScnKey", 36);
  423. ANP_KEY = getByteProperty(guardSettings, "AnpKey", -5);
  424. ULT_KEY = getByteProperty(guardSettings, "UltKey", 12);
  425.  
  426. GET_CLIENT_HWID = getIntProperty(guardSettings, "UseClientHWID", 2);
  427. ENABLE_CONSOLE_LOG = getBooleanProperty(guardSettings, "EnableConsoleLog", false);
  428. PROTECT_KICK_WITH_EMPTY_HWID = getBooleanProperty(guardSettings, "KickWithEmptyHWID", false);
  429. PROTECT_KICK_WITH_LASTERROR_HWID = getBooleanProperty(guardSettings, "KickWithLastErrorHWID", false);
  430.  
  431. MESSAGE_GOOD = guardSettings.getProperty("ServerKey", "");
  432. MESSAGE_ERROR = guardSettings.getProperty("ClientKey", "");
  433.  
  434. String key_client = "GOGX2_RB(]Slnjt15~EgyqTv%[$YR]!1E~ayK?$9[R%%m4{zoMF$D?f:zvS2q&>~";
  435. String key_server = "b*qR43<9J1pD>Q4Uns6FsKao~VbU0H]y`A0ytTveiWn)SuSYsM?m*eblL!pwza!t";
  436. byte[] keyS = key_server.getBytes();
  437. byte[] tmpS = new byte[32];
  438.  
  439. byte[] keyC = key_client.getBytes();
  440. byte[] tmpC = new byte[32];
  441.  
  442. System.arraycopy(keyC, 0, tmpC, 0, 32);
  443. GUARD_CLIENT_CRYPT_KEY = FirstKey.expandKey(tmpC, 32);
  444. System.arraycopy(keyC, 32, tmpC, 0, 32);
  445. GUARD_CLIENT_CRYPT = FirstKey.expandKey(tmpC, 32);
  446.  
  447. System.arraycopy(keyS, 0, tmpS, 0, 32);
  448. GUARD_SERVER_CRYPT_KEY = FirstKey.expandKey(tmpS, 32);
  449. System.arraycopy(keyS, 32, tmpS, 0, 32);
  450. GUARD_SERVER_CRYPT = FirstKey.expandKey(tmpS, 32);
  451. }
  452. catch (Exception e)
  453. {
  454. e.printStackTrace();
  455. }
  456. }
  457.  
  458. protected static Properties getSettings(String CONFIGURATION_FILE) throws Exception
  459. {
  460. Properties serverSettings = new Properties();
  461. InputStream is = new FileInputStream(new File(CONFIGURATION_FILE));
  462. serverSettings.load(is);
  463. is.close();
  464. return serverSettings;
  465. }
  466.  
  467. protected static String getProperty(Properties prop, String name)
  468. {
  469. return prop.getProperty(name.trim(), null);
  470. }
  471.  
  472. protected static String getProperty(Properties prop, String name, String _default)
  473. {
  474. String s = getProperty(prop, name);
  475. return s == null ? _default : s;
  476. }
  477.  
  478. protected static int getIntProperty(Properties prop, String name, int _default)
  479. {
  480. String s = getProperty(prop, name);
  481. return s == null ? _default : Integer.parseInt(s.trim());
  482. }
  483.  
  484. protected static int getIntHexProperty(Properties prop, String name, int _default)
  485. {
  486. return (int) getLongHexProperty(prop, name, _default);
  487. }
  488.  
  489. protected static long getLongProperty(Properties prop, String name, long _default)
  490. {
  491. String s = getProperty(prop, name);
  492. return s == null ? _default : Long.parseLong(s.trim());
  493. }
  494.  
  495. protected static long getLongHexProperty(Properties prop, String name, long _default)
  496. {
  497. String s = getProperty(prop, name);
  498. if (s == null)
  499. return _default;
  500. s = s.trim();
  501. if (!s.startsWith("0x"))
  502. s = "0x" + s;
  503. return Long.decode(s).longValue();
  504. }
  505.  
  506. protected static byte getByteProperty(Properties prop, String name, byte _default)
  507. {
  508. String s = getProperty(prop, name);
  509. return s == null ? _default : Byte.parseByte(s.trim());
  510. }
  511.  
  512. protected static byte getByteProperty(Properties prop, String name, int _default)
  513. {
  514. return getByteProperty(prop, name, (byte) _default);
  515. }
  516.  
  517. protected static boolean getBooleanProperty(Properties prop, String name, boolean _default)
  518. {
  519. String s = getProperty(prop, name);
  520. return s == null ? _default : Boolean.parseBoolean(s.trim());
  521. }
  522.  
  523. protected static float getFloatProperty(Properties prop, String name, float _default)
  524. {
  525. String s = getProperty(prop, name);
  526. return s == null ? _default : Float.parseFloat(s.trim());
  527. }
  528.  
  529. protected static float getFloatProperty(Properties prop, String name, double _default)
  530. {
  531. return getFloatProperty(prop, name, (float) _default);
  532. }
  533.  
  534. protected static double getDoubleProperty(Properties prop, String name, double _default)
  535. {
  536. String s = getProperty(prop, name);
  537. return s == null ? _default : Double.parseDouble(s.trim());
  538. }
  539.  
  540. protected static int[] getIntArray(Properties prop, String name, int[] _default)
  541. {
  542. String s = getProperty(prop, name);
  543. return s == null ? _default : parseCommaSeparatedIntegerArray(s.trim());
  544. }
  545.  
  546. protected static float[] getFloatArray(Properties prop, String name, float[] _default)
  547. {
  548. String s = getProperty(prop, name);
  549. return s == null ? _default : parseCommaSeparatedFloatArray(s.trim());
  550. }
  551.  
  552. protected static String[] getStringArray(Properties prop, String name, String[] _default, String delimiter)
  553. {
  554. String s = getProperty(prop, name);
  555. return s == null ? _default : s.split(delimiter);
  556. }
  557.  
  558. protected static String[] getStringArray(Properties prop, String name, String[] _default)
  559. {
  560. return getStringArray(prop, name, _default, ",");
  561. }
  562.  
  563. protected static float[] parseCommaSeparatedFloatArray(String s)
  564. {
  565. if (s.isEmpty())
  566. return new float[0];
  567.  
  568. String[] tmp = s.replaceAll(",", ";").split(";");
  569. float[] ret = new float[tmp.length];
  570.  
  571. for (int i = 0; i < tmp.length; i++)
  572. ret[i] = Float.parseFloat(tmp[i]);
  573. return ret;
  574. }
  575.  
  576. protected static int[] parseCommaSeparatedIntegerArray(String s)
  577. {
  578. if (s.isEmpty())
  579. return new int[0];
  580.  
  581. String[] tmp = s.replaceAll(",", ";").split(";");
  582. int[] ret = new int[tmp.length];
  583. for (int i = 0; i < tmp.length; i++)
  584. ret[i] = Integer.parseInt(tmp[i]);
  585.  
  586. return ret;
  587. }
  588. }
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595. Index: Head-src/Hwid/crypt/+BlowfishEngine.java
  596. ===================================================================
  597. /*
  598. * This program is free software: you can redistribute it and/or modify it under
  599. * the terms of the GNU General Public License as published by the Free Software
  600. * Foundation, either version 3 of the License, or (at your option) any later
  601. * version.
  602. *
  603. * This program is distributed in the hope that it will be useful, but WITHOUT
  604. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  605. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  606. * details.
  607. *
  608. * You should have received a copy of the GNU General Public License along with
  609. * this program. If not, see <http://www.gnu.org/licenses/>.
  610. */
  611. package Hwid;
  612.  
  613. import java.io.IOException;
  614.  
  615. public class BlowfishEngine
  616. {
  617. private final static int[] KP =
  618. {
  619. 0x243F6A88,
  620. 0x85A308D3,
  621. 0x13198A2E,
  622. 0x03707344,
  623. 0xA4093822,
  624. 0x299F31D0,
  625. 0x082EFA98,
  626. 0xEC4E6C89,
  627. 0x452821E6,
  628. 0x38D01377,
  629. 0xBE5466CF,
  630. 0x34E90C6C,
  631. 0xC0AC29B7,
  632. 0xC97C50DD,
  633. 0x3F84D5B5,
  634. 0xB5470917,
  635. 0x9216D5D9,
  636. 0x8979FB1B
  637.  
  638. }, KS0 =
  639. {
  640. 0xD1310BA6,
  641. 0x98DFB5AC,
  642. 0x2FFD72DB,
  643. 0xD01ADFB7,
  644. 0xB8E1AFED,
  645. 0x6A267E96,
  646. 0xBA7C9045,
  647. 0xF12C7F99,
  648. 0x24A19947,
  649. 0xB3916CF7,
  650. 0x0801F2E2,
  651. 0x858EFC16,
  652. 0x636920D8,
  653. 0x71574E69,
  654. 0xA458FEA3,
  655. 0xF4933D7E,
  656. 0x0D95748F,
  657. 0x728EB658,
  658. 0x718BCD58,
  659. 0x82154AEE,
  660. 0x7B54A41D,
  661. 0xC25A59B5,
  662. 0x9C30D539,
  663. 0x2AF26013,
  664. 0xC5D1B023,
  665. 0x286085F0,
  666. 0xCA417918,
  667. 0xB8DB38EF,
  668. 0x8E79DCB0,
  669. 0x603A180E,
  670. 0x6C9E0E8B,
  671. 0xB01E8A3E,
  672. 0xD71577C1,
  673. 0xBD314B27,
  674. 0x78AF2FDA,
  675. 0x55605C60,
  676. 0xE65525F3,
  677. 0xAA55AB94,
  678. 0x57489862,
  679. 0x63E81440,
  680. 0x55CA396A,
  681. 0x2AAB10B6,
  682. 0xB4CC5C34,
  683. 0x1141E8CE,
  684. 0xA15486AF,
  685. 0x7C72E993,
  686. 0xB3EE1411,
  687. 0x636FBC2A,
  688. 0x2BA9C55D,
  689. 0x741831F6,
  690. 0xCE5C3E16,
  691. 0x9B87931E,
  692. 0xAFD6BA33,
  693. 0x6C24CF5C,
  694. 0x7A325381,
  695. 0x28958677,
  696. 0x3B8F4898,
  697. 0x6B4BB9AF,
  698. 0xC4BFE81B,
  699. 0x66282193,
  700. 0x61D809CC,
  701. 0xFB21A991,
  702. 0x487CAC60,
  703. 0x5DEC8032,
  704. 0xEF845D5D,
  705. 0xE98575B1,
  706. 0xDC262302,
  707. 0xEB651B88,
  708. 0x23893E81,
  709. 0xD396ACC5,
  710. 0x0F6D6FF3,
  711. 0x83F44239,
  712. 0x2E0B4482,
  713. 0xA4842004,
  714. 0x69C8F04A,
  715. 0x9E1F9B5E,
  716. 0x21C66842,
  717. 0xF6E96C9A,
  718. 0x670C9C61,
  719. 0xABD388F0,
  720. 0x6A51A0D2,
  721. 0xD8542F68,
  722. 0x960FA728,
  723. 0xAB5133A3,
  724. 0x6EEF0B6C,
  725. 0x137A3BE4,
  726. 0xBA3BF050,
  727. 0x7EFB2A98,
  728. 0xA1F1651D,
  729. 0x39AF0176,
  730. 0x66CA593E,
  731. 0x82430E88,
  732. 0x8CEE8619,
  733. 0x456F9FB4,
  734. 0x7D84A5C3,
  735. 0x3B8B5EBE,
  736. 0xE06F75D8,
  737. 0x85C12073,
  738. 0x401A449F,
  739. 0x56C16AA6,
  740. 0x4ED3AA62,
  741. 0x363F7706,
  742. 0x1BFEDF72,
  743. 0x429B023D,
  744. 0x37D0D724,
  745. 0xD00A1248,
  746. 0xDB0FEAD3,
  747. 0x49F1C09B,
  748. 0x075372C9,
  749. 0x80991B7B,
  750. 0x25D479D8,
  751. 0xF6E8DEF7,
  752. 0xE3FE501A,
  753. 0xB6794C3B,
  754. 0x976CE0BD,
  755. 0x04C006BA,
  756. 0xC1A94FB6,
  757. 0x409F60C4,
  758. 0x5E5C9EC2,
  759. 0x196A2463,
  760. 0x68FB6FAF,
  761. 0x3E6C53B5,
  762. 0x1339B2EB,
  763. 0x3B52EC6F,
  764. 0x6DFC511F,
  765. 0x9B30952C,
  766. 0xCC814544,
  767. 0xAF5EBD09,
  768. 0xBEE3D004,
  769. 0xDE334AFD,
  770. 0x660F2807,
  771. 0x192E4BB3,
  772. 0xC0CBA857,
  773. 0x45C8740F,
  774. 0xD20B5F39,
  775. 0xB9D3FBDB,
  776. 0x5579C0BD,
  777. 0x1A60320A,
  778. 0xD6A100C6,
  779. 0x402C7279,
  780. 0x679F25FE,
  781. 0xFB1FA3CC,
  782. 0x8EA5E9F8,
  783. 0xDB3222F8,
  784. 0x3C7516DF,
  785. 0xFD616B15,
  786. 0x2F501EC8,
  787. 0xAD0552AB,
  788. 0x323DB5FA,
  789. 0xFD238760,
  790. 0x53317B48,
  791. 0x3E00DF82,
  792. 0x9E5C57BB,
  793. 0xCA6F8CA0,
  794. 0x1A87562E,
  795. 0xDF1769DB,
  796. 0xD542A8F6,
  797. 0x287EFFC3,
  798. 0xAC6732C6,
  799. 0x8C4F5573,
  800. 0x695B27B0,
  801. 0xBBCA58C8,
  802. 0xE1FFA35D,
  803. 0xB8F011A0,
  804. 0x10FA3D98,
  805. 0xFD2183B8,
  806. 0x4AFCB56C,
  807. 0x2DD1D35B,
  808. 0x9A53E479,
  809. 0xB6F84565,
  810. 0xD28E49BC,
  811. 0x4BFB9790,
  812. 0xE1DDF2DA,
  813. 0xA4CB7E33,
  814. 0x62FB1341,
  815. 0xCEE4C6E8,
  816. 0xEF20CADA,
  817. 0x36774C01,
  818. 0xD07E9EFE,
  819. 0x2BF11FB4,
  820. 0x95DBDA4D,
  821. 0xAE909198,
  822. 0xEAAD8E71,
  823. 0x6B93D5A0,
  824. 0xD08ED1D0,
  825. 0xAFC725E0,
  826. 0x8E3C5B2F,
  827. 0x8E7594B7,
  828. 0x8FF6E2FB,
  829. 0xF2122B64,
  830. 0x8888B812,
  831. 0x900DF01C,
  832. 0x4FAD5EA0,
  833. 0x688FC31C,
  834. 0xD1CFF191,
  835. 0xB3A8C1AD,
  836. 0x2F2F2218,
  837. 0xBE0E1777,
  838. 0xEA752DFE,
  839. 0x8B021FA1,
  840. 0xE5A0CC0F,
  841. 0xB56F74E8,
  842. 0x18ACF3D6,
  843. 0xCE89E299,
  844. 0xB4A84FE0,
  845. 0xFD13E0B7,
  846. 0x7CC43B81,
  847. 0xD2ADA8D9,
  848. 0x165FA266,
  849. 0x80957705,
  850. 0x93CC7314,
  851. 0x211A1477,
  852. 0xE6AD2065,
  853. 0x77B5FA86,
  854. 0xC75442F5,
  855. 0xFB9D35CF,
  856. 0xEBCDAF0C,
  857. 0x7B3E89A0,
  858. 0xD6411BD3,
  859. 0xAE1E7E49,
  860. 0x00250E2D,
  861. 0x2071B35E,
  862. 0x226800BB,
  863. 0x57B8E0AF,
  864. 0x2464369B,
  865. 0xF009B91E,
  866. 0x5563911D,
  867. 0x59DFA6AA,
  868. 0x78C14389,
  869. 0xD95A537F,
  870. 0x207D5BA2,
  871. 0x02E5B9C5,
  872. 0x83260376,
  873. 0x6295CFA9,
  874. 0x11C81968,
  875. 0x4E734A41,
  876. 0xB3472DCA,
  877. 0x7B14A94A,
  878. 0x1B510052,
  879. 0x9A532915,
  880. 0xD60F573F,
  881. 0xBC9BC6E4,
  882. 0x2B60A476,
  883. 0x81E67400,
  884. 0x08BA6FB5,
  885. 0x571BE91F,
  886. 0xF296EC6B,
  887. 0x2A0DD915,
  888. 0xB6636521,
  889. 0xE7B9F9B6,
  890. 0xFF34052E,
  891. 0xC5855664,
  892. 0x53B02D5D,
  893. 0xA99F8FA1,
  894. 0x08BA4799,
  895. 0x6E85076A
  896. }, KS1 =
  897. {
  898. 0x4B7A70E9,
  899. 0xB5B32944,
  900. 0xDB75092E,
  901. 0xC4192623,
  902. 0xAD6EA6B0,
  903. 0x49A7DF7D,
  904. 0x9CEE60B8,
  905. 0x8FEDB266,
  906. 0xECAA8C71,
  907. 0x699A17FF,
  908. 0x5664526C,
  909. 0xC2B19EE1,
  910. 0x193602A5,
  911. 0x75094C29,
  912. 0xA0591340,
  913. 0xE4183A3E,
  914. 0x3F54989A,
  915. 0x5B429D65,
  916. 0x6B8FE4D6,
  917. 0x99F73FD6,
  918. 0xA1D29C07,
  919. 0xEFE830F5,
  920. 0x4D2D38E6,
  921. 0xF0255DC1,
  922. 0x4CDD2086,
  923. 0x8470EB26,
  924. 0x6382E9C6,
  925. 0x021ECC5E,
  926. 0x09686B3F,
  927. 0x3EBAEFC9,
  928. 0x3C971814,
  929. 0x6B6A70A1,
  930. 0x687F3584,
  931. 0x52A0E286,
  932. 0xB79C5305,
  933. 0xAA500737,
  934. 0x3E07841C,
  935. 0x7FDEAE5C,
  936. 0x8E7D44EC,
  937. 0x5716F2B8,
  938. 0xB03ADA37,
  939. 0xF0500C0D,
  940. 0xF01C1F04,
  941. 0x0200B3FF,
  942. 0xAE0CF51A,
  943. 0x3CB574B2,
  944. 0x25837A58,
  945. 0xDC0921BD,
  946. 0xD19113F9,
  947. 0x7CA92FF6,
  948. 0x94324773,
  949. 0x22F54701,
  950. 0x3AE5E581,
  951. 0x37C2DADC,
  952. 0xC8B57634,
  953. 0x9AF3DDA7,
  954. 0xA9446146,
  955. 0x0FD0030E,
  956. 0xECC8C73E,
  957. 0xA4751E41,
  958. 0xE238CD99,
  959. 0x3BEA0E2F,
  960. 0x3280BBA1,
  961. 0x183EB331,
  962. 0x4E548B38,
  963. 0x4F6DB908,
  964. 0x6F420D03,
  965. 0xF60A04BF,
  966. 0x2CB81290,
  967. 0x24977C79,
  968. 0x5679B072,
  969. 0xBCAF89AF,
  970. 0xDE9A771F,
  971. 0xD9930810,
  972. 0xB38BAE12,
  973. 0xDCCF3F2E,
  974. 0x5512721F,
  975. 0x2E6B7124,
  976. 0x501ADDE6,
  977. 0x9F84CD87,
  978. 0x7A584718,
  979. 0x7408DA17,
  980. 0xBC9F9ABC,
  981. 0xE94B7D8C,
  982. 0xEC7AEC3A,
  983. 0xDB851DFA,
  984. 0x63094366,
  985. 0xC464C3D2,
  986. 0xEF1C1847,
  987. 0x3215D908,
  988. 0xDD433B37,
  989. 0x24C2BA16,
  990. 0x12A14D43,
  991. 0x2A65C451,
  992. 0x50940002,
  993. 0x133AE4DD,
  994. 0x71DFF89E,
  995. 0x10314E55,
  996. 0x81AC77D6,
  997. 0x5F11199B,
  998. 0x043556F1,
  999. 0xD7A3C76B,
  1000. 0x3C11183B,
  1001. 0x5924A509,
  1002. 0xF28FE6ED,
  1003. 0x97F1FBFA,
  1004. 0x9EBABF2C,
  1005. 0x1E153C6E,
  1006. 0x86E34570,
  1007. 0xEAE96FB1,
  1008. 0x860E5E0A,
  1009. 0x5A3E2AB3,
  1010. 0x771FE71C,
  1011. 0x4E3D06FA,
  1012. 0x2965DCB9,
  1013. 0x99E71D0F,
  1014. 0x803E89D6,
  1015. 0x5266C825,
  1016. 0x2E4CC978,
  1017. 0x9C10B36A,
  1018. 0xC6150EBA,
  1019. 0x94E2EA78,
  1020. 0xA5FC3C53,
  1021. 0x1E0A2DF4,
  1022. 0xF2F74EA7,
  1023. 0x361D2B3D,
  1024. 0x1939260F,
  1025. 0x19C27960,
  1026. 0x5223A708,
  1027. 0xF71312B6,
  1028. 0xEBADFE6E,
  1029. 0xEAC31F66,
  1030. 0xE3BC4595,
  1031. 0xA67BC883,
  1032. 0xB17F37D1,
  1033. 0x018CFF28,
  1034. 0xC332DDEF,
  1035. 0xBE6C5AA5,
  1036. 0x65582185,
  1037. 0x68AB9802,
  1038. 0xEECEA50F,
  1039. 0xDB2F953B,
  1040. 0x2AEF7DAD,
  1041. 0x5B6E2F84,
  1042. 0x1521B628,
  1043. 0x29076170,
  1044. 0xECDD4775,
  1045. 0x619F1510,
  1046. 0x13CCA830,
  1047. 0xEB61BD96,
  1048. 0x0334FE1E,
  1049. 0xAA0363CF,
  1050. 0xB5735C90,
  1051. 0x4C70A239,
  1052. 0xD59E9E0B,
  1053. 0xCBAADE14,
  1054. 0xEECC86BC,
  1055. 0x60622CA7,
  1056. 0x9CAB5CAB,
  1057. 0xB2F3846E,
  1058. 0x648B1EAF,
  1059. 0x19BDF0CA,
  1060. 0xA02369B9,
  1061. 0x655ABB50,
  1062. 0x40685A32,
  1063. 0x3C2AB4B3,
  1064. 0x319EE9D5,
  1065. 0xC021B8F7,
  1066. 0x9B540B19,
  1067. 0x875FA099,
  1068. 0x95F7997E,
  1069. 0x623D7DA8,
  1070. 0xF837889A,
  1071. 0x97E32D77,
  1072. 0x11ED935F,
  1073. 0x16681281,
  1074. 0x0E358829,
  1075. 0xC7E61FD6,
  1076. 0x96DEDFA1,
  1077. 0x7858BA99,
  1078. 0x57F584A5,
  1079. 0x1B227263,
  1080. 0x9B83C3FF,
  1081. 0x1AC24696,
  1082. 0xCDB30AEB,
  1083. 0x532E3054,
  1084. 0x8FD948E4,
  1085. 0x6DBC3128,
  1086. 0x58EBF2EF,
  1087. 0x34C6FFEA,
  1088. 0xFE28ED61,
  1089. 0xEE7C3C73,
  1090. 0x5D4A14D9,
  1091. 0xE864B7E3,
  1092. 0x42105D14,
  1093. 0x203E13E0,
  1094. 0x45EEE2B6,
  1095. 0xA3AAABEA,
  1096. 0xDB6C4F15,
  1097. 0xFACB4FD0,
  1098. 0xC742F442,
  1099. 0xEF6ABBB5,
  1100. 0x654F3B1D,
  1101. 0x41CD2105,
  1102. 0xD81E799E,
  1103. 0x86854DC7,
  1104. 0xE44B476A,
  1105. 0x3D816250,
  1106. 0xCF62A1F2,
  1107. 0x5B8D2646,
  1108. 0xFC8883A0,
  1109. 0xC1C7B6A3,
  1110. 0x7F1524C3,
  1111. 0x69CB7492,
  1112. 0x47848A0B,
  1113. 0x5692B285,
  1114. 0x095BBF00,
  1115. 0xAD19489D,
  1116. 0x1462B174,
  1117. 0x23820E00,
  1118. 0x58428D2A,
  1119. 0x0C55F5EA,
  1120. 0x1DADF43E,
  1121. 0x233F7061,
  1122. 0x3372F092,
  1123. 0x8D937E41,
  1124. 0xD65FECF1,
  1125. 0x6C223BDB,
  1126. 0x7CDE3759,
  1127. 0xCBEE7460,
  1128. 0x4085F2A7,
  1129. 0xCE77326E,
  1130. 0xA6078084,
  1131. 0x19F8509E,
  1132. 0xE8EFD855,
  1133. 0x61D99735,
  1134. 0xA969A7AA,
  1135. 0xC50C06C2,
  1136. 0x5A04ABFC,
  1137. 0x800BCADC,
  1138. 0x9E447A2E,
  1139. 0xC3453484,
  1140. 0xFDD56705,
  1141. 0x0E1E9EC9,
  1142. 0xDB73DBD3,
  1143. 0x105588CD,
  1144. 0x675FDA79,
  1145. 0xE3674340,
  1146. 0xC5C43465,
  1147. 0x713E38D8,
  1148. 0x3D28F89E,
  1149. 0xF16DFF20,
  1150. 0x153E21E7,
  1151. 0x8FB03D4A,
  1152. 0xE6E39F2B,
  1153. 0xDB83ADF7
  1154. }, KS2 =
  1155. {
  1156. 0xE93D5A68,
  1157. 0x948140F7,
  1158. 0xF64C261C,
  1159. 0x94692934,
  1160. 0x411520F7,
  1161. 0x7602D4F7,
  1162. 0xBCF46B2E,
  1163. 0xD4A20068,
  1164. 0xD4082471,
  1165. 0x3320F46A,
  1166. 0x43B7D4B7,
  1167. 0x500061AF,
  1168. 0x1E39F62E,
  1169. 0x97244546,
  1170. 0x14214F74,
  1171. 0xBF8B8840,
  1172. 0x4D95FC1D,
  1173. 0x96B591AF,
  1174. 0x70F4DDD3,
  1175. 0x66A02F45,
  1176. 0xBFBC09EC,
  1177. 0x03BD9785,
  1178. 0x7FAC6DD0,
  1179. 0x31CB8504,
  1180. 0x96EB27B3,
  1181. 0x55FD3941,
  1182. 0xDA2547E6,
  1183. 0xABCA0A9A,
  1184. 0x28507825,
  1185. 0x530429F4,
  1186. 0x0A2C86DA,
  1187. 0xE9B66DFB,
  1188. 0x68DC1462,
  1189. 0xD7486900,
  1190. 0x680EC0A4,
  1191. 0x27A18DEE,
  1192. 0x4F3FFEA2,
  1193. 0xE887AD8C,
  1194. 0xB58CE006,
  1195. 0x7AF4D6B6,
  1196. 0xAACE1E7C,
  1197. 0xD3375FEC,
  1198. 0xCE78A399,
  1199. 0x406B2A42,
  1200. 0x20FE9E35,
  1201. 0xD9F385B9,
  1202. 0xEE39D7AB,
  1203. 0x3B124E8B,
  1204. 0x1DC9FAF7,
  1205. 0x4B6D1856,
  1206. 0x26A36631,
  1207. 0xEAE397B2,
  1208. 0x3A6EFA74,
  1209. 0xDD5B4332,
  1210. 0x6841E7F7,
  1211. 0xCA7820FB,
  1212. 0xFB0AF54E,
  1213. 0xD8FEB397,
  1214. 0x454056AC,
  1215. 0xBA489527,
  1216. 0x55533A3A,
  1217. 0x20838D87,
  1218. 0xFE6BA9B7,
  1219. 0xD096954B,
  1220. 0x55A867BC,
  1221. 0xA1159A58,
  1222. 0xCCA92963,
  1223. 0x99E1DB33,
  1224. 0xA62A4A56,
  1225. 0x3F3125F9,
  1226. 0x5EF47E1C,
  1227. 0x9029317C,
  1228. 0xFDF8E802,
  1229. 0x04272F70,
  1230. 0x80BB155C,
  1231. 0x05282CE3,
  1232. 0x95C11548,
  1233. 0xE4C66D22,
  1234. 0x48C1133F,
  1235. 0xC70F86DC,
  1236. 0x07F9C9EE,
  1237. 0x41041F0F,
  1238. 0x404779A4,
  1239. 0x5D886E17,
  1240. 0x325F51EB,
  1241. 0xD59BC0D1,
  1242. 0xF2BCC18F,
  1243. 0x41113564,
  1244. 0x257B7834,
  1245. 0x602A9C60,
  1246. 0xDFF8E8A3,
  1247. 0x1F636C1B,
  1248. 0x0E12B4C2,
  1249. 0x02E1329E,
  1250. 0xAF664FD1,
  1251. 0xCAD18115,
  1252. 0x6B2395E0,
  1253. 0x333E92E1,
  1254. 0x3B240B62,
  1255. 0xEEBEB922,
  1256. 0x85B2A20E,
  1257. 0xE6BA0D99,
  1258. 0xDE720C8C,
  1259. 0x2DA2F728,
  1260. 0xD0127845,
  1261. 0x95B794FD,
  1262. 0x647D0862,
  1263. 0xE7CCF5F0,
  1264. 0x5449A36F,
  1265. 0x877D48FA,
  1266. 0xC39DFD27,
  1267. 0xF33E8D1E,
  1268. 0x0A476341,
  1269. 0x992EFF74,
  1270. 0x3A6F6EAB,
  1271. 0xF4F8FD37,
  1272. 0xA812DC60,
  1273. 0xA1EBDDF8,
  1274. 0x991BE14C,
  1275. 0xDB6E6B0D,
  1276. 0xC67B5510,
  1277. 0x6D672C37,
  1278. 0x2765D43B,
  1279. 0xDCD0E804,
  1280. 0xF1290DC7,
  1281. 0xCC00FFA3,
  1282. 0xB5390F92,
  1283. 0x690FED0B,
  1284. 0x667B9FFB,
  1285. 0xCEDB7D9C,
  1286. 0xA091CF0B,
  1287. 0xD9155EA3,
  1288. 0xBB132F88,
  1289. 0x515BAD24,
  1290. 0x7B9479BF,
  1291. 0x763BD6EB,
  1292. 0x37392EB3,
  1293. 0xCC115979,
  1294. 0x8026E297,
  1295. 0xF42E312D,
  1296. 0x6842ADA7,
  1297. 0xC66A2B3B,
  1298. 0x12754CCC,
  1299. 0x782EF11C,
  1300. 0x6A124237,
  1301. 0xB79251E7,
  1302. 0x06A1BBE6,
  1303. 0x4BFB6350,
  1304. 0x1A6B1018,
  1305. 0x11CAEDFA,
  1306. 0x3D25BDD8,
  1307. 0xE2E1C3C9,
  1308. 0x44421659,
  1309. 0x0A121386,
  1310. 0xD90CEC6E,
  1311. 0xD5ABEA2A,
  1312. 0x64AF674E,
  1313. 0xDA86A85F,
  1314. 0xBEBFE988,
  1315. 0x64E4C3FE,
  1316. 0x9DBC8057,
  1317. 0xF0F7C086,
  1318. 0x60787BF8,
  1319. 0x6003604D,
  1320. 0xD1FD8346,
  1321. 0xF6381FB0,
  1322. 0x7745AE04,
  1323. 0xD736FCCC,
  1324. 0x83426B33,
  1325. 0xF01EAB71,
  1326. 0xB0804187,
  1327. 0x3C005E5F,
  1328. 0x77A057BE,
  1329. 0xBDE8AE24,
  1330. 0x55464299,
  1331. 0xBF582E61,
  1332. 0x4E58F48F,
  1333. 0xF2DDFDA2,
  1334. 0xF474EF38,
  1335. 0x8789BDC2,
  1336. 0x5366F9C3,
  1337. 0xC8B38E74,
  1338. 0xB475F255,
  1339. 0x46FCD9B9,
  1340. 0x7AEB2661,
  1341. 0x8B1DDF84,
  1342. 0x846A0E79,
  1343. 0x915F95E2,
  1344. 0x466E598E,
  1345. 0x20B45770,
  1346. 0x8CD55591,
  1347. 0xC902DE4C,
  1348. 0xB90BACE1,
  1349. 0xBB8205D0,
  1350. 0x11A86248,
  1351. 0x7574A99E,
  1352. 0xB77F19B6,
  1353. 0xE0A9DC09,
  1354. 0x662D09A1,
  1355. 0xC4324633,
  1356. 0xE85A1F02,
  1357. 0x09F0BE8C,
  1358. 0x4A99A025,
  1359. 0x1D6EFE10,
  1360. 0x1AB93D1D,
  1361. 0x0BA5A4DF,
  1362. 0xA186F20F,
  1363. 0x2868F169,
  1364. 0xDCB7DA83,
  1365. 0x573906FE,
  1366. 0xA1E2CE9B,
  1367. 0x4FCD7F52,
  1368. 0x50115E01,
  1369. 0xA70683FA,
  1370. 0xA002B5C4,
  1371. 0x0DE6D027,
  1372. 0x9AF88C27,
  1373. 0x773F8641,
  1374. 0xC3604C06,
  1375. 0x61A806B5,
  1376. 0xF0177A28,
  1377. 0xC0F586E0,
  1378. 0x006058AA,
  1379. 0x30DC7D62,
  1380. 0x11E69ED7,
  1381. 0x2338EA63,
  1382. 0x53C2DD94,
  1383. 0xC2C21634,
  1384. 0xBBCBEE56,
  1385. 0x90BCB6DE,
  1386. 0xEBFC7DA1,
  1387. 0xCE591D76,
  1388. 0x6F05E409,
  1389. 0x4B7C0188,
  1390. 0x39720A3D,
  1391. 0x7C927C24,
  1392. 0x86E3725F,
  1393. 0x724D9DB9,
  1394. 0x1AC15BB4,
  1395. 0xD39EB8FC,
  1396. 0xED545578,
  1397. 0x08FCA5B5,
  1398. 0xD83D7CD3,
  1399. 0x4DAD0FC4,
  1400. 0x1E50EF5E,
  1401. 0xB161E6F8,
  1402. 0xA28514D9,
  1403. 0x6C51133C,
  1404. 0x6FD5C7E7,
  1405. 0x56E14EC4,
  1406. 0x362ABFCE,
  1407. 0xDDC6C837,
  1408. 0xD79A3234,
  1409. 0x92638212,
  1410. 0x670EFA8E,
  1411. 0x406000E0
  1412. }, KS3 =
  1413. {
  1414. 0x3A39CE37,
  1415. 0xD3FAF5CF,
  1416. 0xABC27737,
  1417. 0x5AC52D1B,
  1418. 0x5CB0679E,
  1419. 0x4FA33742,
  1420. 0xD3822740,
  1421. 0x99BC9BBE,
  1422. 0xD5118E9D,
  1423. 0xBF0F7315,
  1424. 0xD62D1C7E,
  1425. 0xC700C47B,
  1426. 0xB78C1B6B,
  1427. 0x21A19045,
  1428. 0xB26EB1BE,
  1429. 0x6A366EB4,
  1430. 0x5748AB2F,
  1431. 0xBC946E79,
  1432. 0xC6A376D2,
  1433. 0x6549C2C8,
  1434. 0x530FF8EE,
  1435. 0x468DDE7D,
  1436. 0xD5730A1D,
  1437. 0x4CD04DC6,
  1438. 0x2939BBDB,
  1439. 0xA9BA4650,
  1440. 0xAC9526E8,
  1441. 0xBE5EE304,
  1442. 0xA1FAD5F0,
  1443. 0x6A2D519A,
  1444. 0x63EF8CE2,
  1445. 0x9A86EE22,
  1446. 0xC089C2B8,
  1447. 0x43242EF6,
  1448. 0xA51E03AA,
  1449. 0x9CF2D0A4,
  1450. 0x83C061BA,
  1451. 0x9BE96A4D,
  1452. 0x8FE51550,
  1453. 0xBA645BD6,
  1454. 0x2826A2F9,
  1455. 0xA73A3AE1,
  1456. 0x4BA99586,
  1457. 0xEF5562E9,
  1458. 0xC72FEFD3,
  1459. 0xF752F7DA,
  1460. 0x3F046F69,
  1461. 0x77FA0A59,
  1462. 0x80E4A915,
  1463. 0x87B08601,
  1464. 0x9B09E6AD,
  1465. 0x3B3EE593,
  1466. 0xE990FD5A,
  1467. 0x9E34D797,
  1468. 0x2CF0B7D9,
  1469. 0x022B8B51,
  1470. 0x96D5AC3A,
  1471. 0x017DA67D,
  1472. 0xD1CF3ED6,
  1473. 0x7C7D2D28,
  1474. 0x1F9F25CF,
  1475. 0xADF2B89B,
  1476. 0x5AD6B472,
  1477. 0x5A88F54C,
  1478. 0xE029AC71,
  1479. 0xE019A5E6,
  1480. 0x47B0ACFD,
  1481. 0xED93FA9B,
  1482. 0xE8D3C48D,
  1483. 0x283B57CC,
  1484. 0xF8D56629,
  1485. 0x79132E28,
  1486. 0x785F0191,
  1487. 0xED756055,
  1488. 0xF7960E44,
  1489. 0xE3D35E8C,
  1490. 0x15056DD4,
  1491. 0x88F46DBA,
  1492. 0x03A16125,
  1493. 0x0564F0BD,
  1494. 0xC3EB9E15,
  1495. 0x3C9057A2,
  1496. 0x97271AEC,
  1497. 0xA93A072A,
  1498. 0x1B3F6D9B,
  1499. 0x1E6321F5,
  1500. 0xF59C66FB,
  1501. 0x26DCF319,
  1502. 0x7533D928,
  1503. 0xB155FDF5,
  1504. 0x03563482,
  1505. 0x8ABA3CBB,
  1506. 0x28517711,
  1507. 0xC20AD9F8,
  1508. 0xABCC5167,
  1509. 0xCCAD925F,
  1510. 0x4DE81751,
  1511. 0x3830DC8E,
  1512. 0x379D5862,
  1513. 0x9320F991,
  1514. 0xEA7A90C2,
  1515. 0xFB3E7BCE,
  1516. 0x5121CE64,
  1517. 0x774FBE32,
  1518. 0xA8B6E37E,
  1519. 0xC3293D46,
  1520. 0x48DE5369,
  1521. 0x6413E680,
  1522. 0xA2AE0810,
  1523. 0xDD6DB224,
  1524. 0x69852DFD,
  1525. 0x09072166,
  1526. 0xB39A460A,
  1527. 0x6445C0DD,
  1528. 0x586CDECF,
  1529. 0x1C20C8AE,
  1530. 0x5BBEF7DD,
  1531. 0x1B588D40,
  1532. 0xCCD2017F,
  1533. 0x6BB4E3BB,
  1534. 0xDDA26A7E,
  1535. 0x3A59FF45,
  1536. 0x3E350A44,
  1537. 0xBCB4CDD5,
  1538. 0x72EACEA8,
  1539. 0xFA6484BB,
  1540. 0x8D6612AE,
  1541. 0xBF3C6F47,
  1542. 0xD29BE463,
  1543. 0x542F5D9E,
  1544. 0xAEC2771B,
  1545. 0xF64E6370,
  1546. 0x740E0D8D,
  1547. 0xE75B1357,
  1548. 0xF8721671,
  1549. 0xAF537D5D,
  1550. 0x4040CB08,
  1551. 0x4EB4E2CC,
  1552. 0x34D2466A,
  1553. 0x0115AF84,
  1554. 0xE1B00428,
  1555. 0x95983A1D,
  1556. 0x06B89FB4,
  1557. 0xCE6EA048,
  1558. 0x6F3F3B82,
  1559. 0x3520AB82,
  1560. 0x011A1D4B,
  1561. 0x277227F8,
  1562. 0x611560B1,
  1563. 0xE7933FDC,
  1564. 0xBB3A792B,
  1565. 0x344525BD,
  1566. 0xA08839E1,
  1567. 0x51CE794B,
  1568. 0x2F32C9B7,
  1569. 0xA01FBAC9,
  1570. 0xE01CC87E,
  1571. 0xBCC7D1F6,
  1572. 0xCF0111C3,
  1573. 0xA1E8AAC7,
  1574. 0x1A908749,
  1575. 0xD44FBD9A,
  1576. 0xD0DADECB,
  1577. 0xD50ADA38,
  1578. 0x0339C32A,
  1579. 0xC6913667,
  1580. 0x8DF9317C,
  1581. 0xE0B12B4F,
  1582. 0xF79E59B7,
  1583. 0x43F5BB3A,
  1584. 0xF2D519FF,
  1585. 0x27D9459C,
  1586. 0xBF97222C,
  1587. 0x15E6FC2A,
  1588. 0x0F91FC71,
  1589. 0x9B941525,
  1590. 0xFAE59361,
  1591. 0xCEB69CEB,
  1592. 0xC2A86459,
  1593. 0x12BAA8D1,
  1594. 0xB6C1075E,
  1595. 0xE3056A0C,
  1596. 0x10D25065,
  1597. 0xCB03A442,
  1598. 0xE0EC6E0E,
  1599. 0x1698DB3B,
  1600. 0x4C98A0BE,
  1601. 0x3278E964,
  1602. 0x9F1F9532,
  1603. 0xE0D392DF,
  1604. 0xD3A0342B,
  1605. 0x8971F21E,
  1606. 0x1B0A7441,
  1607. 0x4BA3348C,
  1608. 0xC5BE7120,
  1609. 0xC37632D8,
  1610. 0xDF359F8D,
  1611. 0x9B992F2E,
  1612. 0xE60B6F47,
  1613. 0x0FE3F11D,
  1614. 0xE54CDA54,
  1615. 0x1EDAD891,
  1616. 0xCE6279CF,
  1617. 0xCD3E7E6F,
  1618. 0x1618B166,
  1619. 0xFD2C1D05,
  1620. 0x848FD2C5,
  1621. 0xF6FB2299,
  1622. 0xF523F357,
  1623. 0xA6327623,
  1624. 0x93A83531,
  1625. 0x56CCCD02,
  1626. 0xACF08162,
  1627. 0x5A75EBB5,
  1628. 0x6E163697,
  1629. 0x88D273CC,
  1630. 0xDE966292,
  1631. 0x81B949D0,
  1632. 0x4C50901B,
  1633. 0x71C65614,
  1634. 0xE6C6C7BD,
  1635. 0x327A140A,
  1636. 0x45E1D006,
  1637. 0xC3F27B9A,
  1638. 0xC9AA53FD,
  1639. 0x62A80F00,
  1640. 0xBB25BFE2,
  1641. 0x35BDD2F6,
  1642. 0x71126905,
  1643. 0xB2040222,
  1644. 0xB6CBCF7C,
  1645. 0xCD769C2B,
  1646. 0x53113EC0,
  1647. 0x1640E3D3,
  1648. 0x38ABBD60,
  1649. 0x2547ADF0,
  1650. 0xBA38209C,
  1651. 0xF746CE76,
  1652. 0x77AFA1C5,
  1653. 0x20756060,
  1654. 0x85CBFE4E,
  1655. 0x8AE88DD8,
  1656. 0x7AAAF9B0,
  1657. 0x4CF9AA7E,
  1658. 0x1948C25C,
  1659. 0x02FB8A8C,
  1660. 0x01C36AE4,
  1661. 0xD6EBE1F9,
  1662. 0x90D4F869,
  1663. 0xA65CDEA0,
  1664. 0x3F09252D,
  1665. 0xC208E69F,
  1666. 0xB74E6132,
  1667. 0xCE77E25B,
  1668. 0x578FDFE3,
  1669. 0x3AC372E6
  1670. };
  1671.  
  1672. private static final int ROUNDS = 16;
  1673. private static final int BLOCK_SIZE = 8;
  1674. private static final int SBOX_SK = 256;
  1675. private static final int P_SZ = ROUNDS + 2;
  1676. private final int[] S0, S1, S2, S3;
  1677. private final int[] P;
  1678. private boolean encrypting = false;
  1679. private byte[] workingKey = null;
  1680.  
  1681. public BlowfishEngine()
  1682. {
  1683. S0 = new int[SBOX_SK];
  1684. S1 = new int[SBOX_SK];
  1685. S2 = new int[SBOX_SK];
  1686. S3 = new int[SBOX_SK];
  1687. P = new int[P_SZ];
  1688. }
  1689.  
  1690. public void init(boolean pEncrypting, byte[] key)
  1691. {
  1692. encrypting = pEncrypting;
  1693. workingKey = key;
  1694. setKey(workingKey);
  1695. }
  1696.  
  1697. public String getAlgorithmName()
  1698. {
  1699. return "Blowfish";
  1700. }
  1701.  
  1702. public final int processBlock(byte[] in, int inOff, byte[] out, int outOff) throws IOException
  1703. {
  1704. if (workingKey == null)
  1705. throw new IllegalStateException("Blowfish not initialised");
  1706. if (inOff + BLOCK_SIZE > in.length)
  1707. throw new IOException("input buffer too short");
  1708. if (outOff + BLOCK_SIZE > out.length)
  1709. throw new IOException("output buffer too short");
  1710. if (encrypting)
  1711. encryptBlock(in, inOff, out, outOff);
  1712. else
  1713. decryptBlock(in, inOff, out, outOff);
  1714. return BLOCK_SIZE;
  1715. }
  1716.  
  1717. public void reset()
  1718. {
  1719. }
  1720.  
  1721. public int getBlockSize()
  1722. {
  1723. return BLOCK_SIZE;
  1724. }
  1725.  
  1726. private int F(int x)
  1727. {
  1728. return (S0[x >>> 24] + S1[x >>> 16 & 0xff] ^ S2[x >>> 8 & 0xff]) + S3[x & 0xff];
  1729. }
  1730.  
  1731. private void processTable(int xl, int xr, int[] table)
  1732. {
  1733. int size = table.length;
  1734. for (int s = 0; s < size; s += 2)
  1735. {
  1736. xl ^= P[0];
  1737. for (int i = 1; i < ROUNDS; i += 2)
  1738. {
  1739. xr ^= F(xl) ^ P[i];
  1740. xl ^= F(xr) ^ P[i + 1];
  1741. }
  1742. xr ^= P[ROUNDS + 1];
  1743. table[s] = xr;
  1744. table[s + 1] = xl;
  1745. xr = xl;
  1746. xl = table[s];
  1747. }
  1748. }
  1749.  
  1750. private void setKey(byte[] key)
  1751. {
  1752. System.arraycopy(KS0, 0, S0, 0, SBOX_SK);
  1753. System.arraycopy(KS1, 0, S1, 0, SBOX_SK);
  1754. System.arraycopy(KS2, 0, S2, 0, SBOX_SK);
  1755. System.arraycopy(KS3, 0, S3, 0, SBOX_SK);
  1756. System.arraycopy(KP, 0, P, 0, P_SZ);
  1757.  
  1758. int keyLength = key.length;
  1759. int keyIndex = 0;
  1760. for (int i = 0; i < P_SZ; i++)
  1761. {
  1762. int data = 0x0000000;
  1763. for (int j = 0; j < 4; j++)
  1764. {
  1765. data = data << 8 | key[keyIndex++] & 0xff;
  1766. if (keyIndex >= keyLength)
  1767. keyIndex = 0;
  1768. }
  1769. P[i] ^= data;
  1770. }
  1771. processTable(0, 0, P);
  1772. processTable(P[P_SZ - 2], P[P_SZ - 1], S0);
  1773. processTable(S0[SBOX_SK - 2], S0[SBOX_SK - 1], S1);
  1774. processTable(S1[SBOX_SK - 2], S1[SBOX_SK - 1], S2);
  1775. processTable(S2[SBOX_SK - 2], S2[SBOX_SK - 1], S3);
  1776. }
  1777.  
  1778. public void encryptBlock(byte[] src, int srcIndex, byte[] dst, int dstIndex)
  1779. {
  1780. int xl = BytesTo32bits(src, srcIndex);
  1781. int xr = BytesTo32bits(src, srcIndex + 4);
  1782. xl ^= P[0];
  1783. for (int i = 1; i < ROUNDS; i += 2)
  1784. {
  1785. xr ^= F(xl) ^ P[i];
  1786. xl ^= F(xr) ^ P[i + 1];
  1787. }
  1788. xr ^= P[ROUNDS + 1];
  1789. Bits32ToBytes(xr, dst, dstIndex);
  1790. Bits32ToBytes(xl, dst, dstIndex + 4);
  1791. }
  1792.  
  1793. public void decryptBlock(byte[] src, int srcIndex, byte[] dst, int dstIndex)
  1794. {
  1795. int xl = BytesTo32bits(src, srcIndex);
  1796. int xr = BytesTo32bits(src, srcIndex + 4);
  1797. xl ^= P[ROUNDS + 1];
  1798. for (int i = ROUNDS; i > 0; i -= 2)
  1799. {
  1800. xr ^= F(xl) ^ P[i];
  1801. xl ^= F(xr) ^ P[i - 1];
  1802. }
  1803. xr ^= P[0];
  1804. Bits32ToBytes(xr, dst, dstIndex);
  1805. Bits32ToBytes(xl, dst, dstIndex + 4);
  1806. }
  1807.  
  1808. private static int BytesTo32bits(byte[] b, int i)
  1809. {
  1810. return (b[i + 3] & 0xff) << 24 | (b[i + 2] & 0xff) << 16 | (b[i + 1] & 0xff) << 8 | b[i] & 0xff;
  1811. }
  1812.  
  1813. private static void Bits32ToBytes(int in, byte[] b, int offset)
  1814. {
  1815. b[offset] = (byte) in;
  1816. b[offset + 1] = (byte) (in >> 8);
  1817. b[offset + 2] = (byte) (in >> 16);
  1818. b[offset + 3] = (byte) (in >> 24);
  1819. }
  1820. }
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828. Index: Head-src/Hwid/crypt/+FirstKey.java
  1829. ===================================================================
  1830. /*
  1831. * This program is free software: you can redistribute it and/or modify it under
  1832. * the terms of the GNU General Public License as published by the Free Software
  1833. * Foundation, either version 3 of the License, or (at your option) any later
  1834. * version.
  1835. *
  1836. * This program is distributed in the hope that it will be useful, but WITHOUT
  1837. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1838. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1839. * details.
  1840. *
  1841. * You should have received a copy of the GNU General Public License along with
  1842. * this program. If not, see <http://www.gnu.org/licenses/>.
  1843. */
  1844. package Hwid.crypt;
  1845.  
  1846. import Hwid.HwidConfig;
  1847.  
  1848. import java.util.logging.Logger;
  1849.  
  1850. public class FirstKey
  1851. {
  1852. protected static Logger _log = Logger.getLogger(FirstKey.class.getName());
  1853.  
  1854. private static final byte[] TKBOX =
  1855. {
  1856. -112,
  1857. 22,
  1858. 124,
  1859. -93,
  1860. 68,
  1861. -116,
  1862. -19,
  1863. -125,
  1864. -4,
  1865. 101,
  1866. -62,
  1867. 5,
  1868. 70,
  1869. 25,
  1870. 29,
  1871. 81,
  1872. 65,
  1873. -86,
  1874. 79,
  1875. -69,
  1876. 2,
  1877. 97,
  1878. -108,
  1879. -11,
  1880. -84,
  1881. -56,
  1882. 17,
  1883. 7,
  1884. 31,
  1885. 52,
  1886. -34,
  1887. -41,
  1888. -110,
  1889. -60,
  1890. 57,
  1891. -5,
  1892. -6,
  1893. -24,
  1894. 98,
  1895. -100,
  1896. 23,
  1897. 4,
  1898. -74,
  1899. -37,
  1900. 1,
  1901. 6,
  1902. -2,
  1903. -14,
  1904. -77,
  1905. 12,
  1906. -7,
  1907. 3,
  1908. -29,
  1909. -17,
  1910. -75,
  1911. 49,
  1912. 44,
  1913. -78,
  1914. 94,
  1915. 21,
  1916. 0,
  1917. 35,
  1918. -18,
  1919. 83,
  1920. 9,
  1921. -42,
  1922. 60,
  1923. 93,
  1924. 54,
  1925. 20,
  1926. -49,
  1927. 114,
  1928. 106,
  1929. -82,
  1930. 113,
  1931. -90,
  1932. 86,
  1933. -124,
  1934. -73,
  1935. -81,
  1936. 90,
  1937. 121,
  1938. 115,
  1939. 125,
  1940. 47,
  1941. 24,
  1942. -28,
  1943. 73,
  1944. 56,
  1945. -31,
  1946. 8,
  1947. 71,
  1948. 122,
  1949. 58,
  1950. -33,
  1951. 108,
  1952. -111,
  1953. 102,
  1954. -118,
  1955. -103,
  1956. -122,
  1957. 88,
  1958. 28,
  1959. -76,
  1960. 67,
  1961. -115,
  1962. -67,
  1963. 78,
  1964. 36,
  1965. 117,
  1966. -8,
  1967. -25,
  1968. -97,
  1969. 107,
  1970. -91,
  1971. -50,
  1972. -53,
  1973. -52,
  1974. 111,
  1975. -114,
  1976. -58,
  1977. -128,
  1978. 84,
  1979. -98,
  1980. 63,
  1981. 74,
  1982. 10,
  1983. 41,
  1984. -32,
  1985. 126,
  1986. 69,
  1987. -68,
  1988. 11,
  1989. -119,
  1990. -44,
  1991. -39,
  1992. -107,
  1993. -40,
  1994. 85,
  1995. -87,
  1996. 61,
  1997. 91,
  1998. -1,
  1999. 50,
  2000. -72,
  2001. -117,
  2002. 15,
  2003. 55,
  2004. -51,
  2005. 43,
  2006. 87,
  2007. 105,
  2008. 120,
  2009. -88,
  2010. 116,
  2011. 80,
  2012. -48,
  2013. -123,
  2014. -127,
  2015. -105,
  2016. -22,
  2017. 76,
  2018. 109,
  2019. 19,
  2020. -46,
  2021. -30,
  2022. 112,
  2023. 16,
  2024. -10,
  2025. 45,
  2026. -63,
  2027. -47,
  2028. 123,
  2029. -106,
  2030. 27,
  2031. 38,
  2032. 104,
  2033. -70,
  2034. -79,
  2035. 18,
  2036. -99,
  2037. -16,
  2038. -85,
  2039. -23,
  2040. 30,
  2041. -66,
  2042. 48,
  2043. -89,
  2044. -61,
  2045. -113,
  2046. -12,
  2047. 51,
  2048. -95,
  2049. -15,
  2050. 32,
  2051. -9,
  2052. 62,
  2053. -38,
  2054. 14,
  2055. -45,
  2056. -80,
  2057. 66,
  2058. 100,
  2059. 103,
  2060. -104,
  2061. -27,
  2062. -43,
  2063. 110,
  2064. -83,
  2065. -26,
  2066. -101,
  2067. 46,
  2068. -120,
  2069. -54,
  2070. 37,
  2071. 42,
  2072. 13,
  2073. 75,
  2074. 82,
  2075. -109,
  2076. 26,
  2077. -94,
  2078. -57,
  2079. -64,
  2080. 119,
  2081. 53,
  2082. 39,
  2083. -13,
  2084. -121,
  2085. 33,
  2086. 72,
  2087. -126,
  2088. -65,
  2089. -36,
  2090. -71,
  2091. 118,
  2092. -35,
  2093. 92,
  2094. 96,
  2095. 89,
  2096. 64,
  2097. 34,
  2098. -20,
  2099. -96,
  2100. 77,
  2101. 40,
  2102. 127,
  2103. -21,
  2104. 59,
  2105. -55,
  2106. -102,
  2107. 95,
  2108. -3,
  2109. 99,
  2110. -59,
  2111. -92
  2112. };
  2113. private static final byte[] MGBOX =
  2114. {
  2115. -14,
  2116. -108,
  2117. 90,
  2118. 75,
  2119. 15,
  2120. 115,
  2121. -38,
  2122. -37,
  2123. -125,
  2124. 29,
  2125. -77,
  2126. 9,
  2127. -4,
  2128. 54,
  2129. -72,
  2130. 70,
  2131. 65,
  2132. -44,
  2133. -48,
  2134. 85,
  2135. -13,
  2136. -121,
  2137. 118,
  2138. -102,
  2139. 40,
  2140. 53,
  2141. 113,
  2142. -5,
  2143. -9,
  2144. 28,
  2145. 3,
  2146. 125,
  2147. 21,
  2148. -124,
  2149. 10,
  2150. 67,
  2151. -6,
  2152. -98,
  2153. 96,
  2154. -105,
  2155. -104,
  2156. 126,
  2157. -93,
  2158. 82,
  2159. -47,
  2160. 41,
  2161. -91,
  2162. 89,
  2163. -59,
  2164. 122,
  2165. 47,
  2166. 37,
  2167. -31,
  2168. 59,
  2169. 56,
  2170. 12,
  2171. -112,
  2172. -58,
  2173. -39,
  2174. -10,
  2175. -40,
  2176. -49,
  2177. 22,
  2178. -107,
  2179. 33,
  2180. -89,
  2181. 109,
  2182. 31,
  2183. 88,
  2184. 81,
  2185. 72,
  2186. 42,
  2187. -66,
  2188. -85,
  2189. -15,
  2190. 93,
  2191. -101,
  2192. -7,
  2193. -128,
  2194. -19,
  2195. -27,
  2196. -90,
  2197. -11,
  2198. 111,
  2199. 49,
  2200. -70,
  2201. 121,
  2202. 79,
  2203. -123,
  2204. -127,
  2205. -79,
  2206. 35,
  2207. -28,
  2208. 114,
  2209. -22,
  2210. 44,
  2211. -54,
  2212. 107,
  2213. 106,
  2214. 30,
  2215. 92,
  2216. 4,
  2217. -43,
  2218. -82,
  2219. -78,
  2220. -26,
  2221. -61,
  2222. 57,
  2223. 77,
  2224. 95,
  2225. 58,
  2226. 69,
  2227. -76,
  2228. 103,
  2229. -56,
  2230. 78,
  2231. 26,
  2232. -92,
  2233. 48,
  2234. -32,
  2235. -52,
  2236. 16,
  2237. -67,
  2238. 51,
  2239. -50,
  2240. -73,
  2241. -29,
  2242. 52,
  2243. -60,
  2244. -118,
  2245. -1,
  2246. -80,
  2247. 63,
  2248. 2,
  2249. 124,
  2250. -36,
  2251. -65,
  2252. 8,
  2253. -33,
  2254. -115,
  2255. -3,
  2256. 108,
  2257. -21,
  2258. 18,
  2259. 110,
  2260. 36,
  2261. -51,
  2262. 46,
  2263. -103,
  2264. 94,
  2265. 20,
  2266. -114,
  2267. 80,
  2268. 127,
  2269. -86,
  2270. 19,
  2271. -119,
  2272. -113,
  2273. 68,
  2274. -25,
  2275. -120,
  2276. -71,
  2277. 32,
  2278. 38,
  2279. -95,
  2280. -57,
  2281. 5,
  2282. 7,
  2283. 105,
  2284. -17,
  2285. -34,
  2286. -81,
  2287. 24,
  2288. -74,
  2289. -35,
  2290. 100,
  2291. 1,
  2292. -46,
  2293. -94,
  2294. 43,
  2295. 13,
  2296. 17,
  2297. -87,
  2298. 11,
  2299. -69,
  2300. -62,
  2301. -126,
  2302. -63,
  2303. -64,
  2304. -23,
  2305. -97,
  2306. 27,
  2307. -18,
  2308. -53,
  2309. 84,
  2310. 0,
  2311. -106,
  2312. -83,
  2313. 39,
  2314. 116,
  2315. 91,
  2316. 104,
  2317. 14,
  2318. -24,
  2319. -42,
  2320. 34,
  2321. -88,
  2322. -84,
  2323. 62,
  2324. 61,
  2325. -2,
  2326. 112,
  2327. 23,
  2328. 119,
  2329. 73,
  2330. 6,
  2331. -122,
  2332. 55,
  2333. -99,
  2334. -41,
  2335. 83,
  2336. 99,
  2337. 60,
  2338. 87,
  2339. 45,
  2340. 120,
  2341. -55,
  2342. 117,
  2343. -117,
  2344. 98,
  2345. 123,
  2346. -8,
  2347. 76,
  2348. -16,
  2349. -30,
  2350. 64,
  2351. -96,
  2352. -109,
  2353. -75,
  2354. 25,
  2355. 101,
  2356. -110,
  2357. 86,
  2358. 50,
  2359. 71,
  2360. -12,
  2361. 74,
  2362. -100,
  2363. -116,
  2364. -68,
  2365. 66,
  2366. -20,
  2367. -45,
  2368. 102,
  2369. -111,
  2370. 97
  2371. };
  2372. public static final byte[] SKBOX =
  2373. {
  2374. HwidConfig.FST_KEY,
  2375. HwidConfig.SCN_KEY,
  2376. 2,
  2377. 15,
  2378. -5,
  2379. 17,
  2380. 24,
  2381. 23,
  2382. 18,
  2383. 45,
  2384. 1,
  2385. 21,
  2386. 122,
  2387. 16,
  2388. HwidConfig.ANP_KEY,
  2389. HwidConfig.ULT_KEY
  2390. };
  2391.  
  2392. public static byte[] expandKey(byte[] key, int size)
  2393. {
  2394. byte[] P = new byte[64];
  2395.  
  2396. for (int i = 0; i < 64; i++)
  2397. P[i] = key[i % size];
  2398.  
  2399. for (int i = 0; i < 256; i++)
  2400. {
  2401. byte t = P[i % 64];
  2402. byte m = (byte) (MGBOX[MGBOX[t & 0xFF] & 0xFF] & 0xFF ^ TKBOX[TKBOX[i] & 0xFF] & 0xFF);
  2403. P[i % 64] = TKBOX[m & 0xFF];
  2404. }
  2405.  
  2406. return P;
  2407. }
  2408.  
  2409. }
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415.  
  2416.  
  2417. Index: Head-src/Hwid/crypt/+GameCrypt.java
  2418. ===================================================================
  2419. /*
  2420. * This program is free software: you can redistribute it and/or modify it under
  2421. * the terms of the GNU General Public License as published by the Free Software
  2422. * Foundation, either version 3 of the License, or (at your option) any later
  2423. * version.
  2424. *
  2425. * This program is distributed in the hope that it will be useful, but WITHOUT
  2426. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  2427. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  2428. * details.
  2429. *
  2430. * You should have received a copy of the GNU General Public License along with
  2431. * this program. If not, see <http://www.gnu.org/licenses/>.
  2432. */
  2433. package Hwid.crypt;
  2434.  
  2435. import Hwid.HwidConfig;
  2436. import Hwid.crypt.impl.L2Client;
  2437. import Hwid.crypt.impl.L2Server;
  2438. import Hwid.crypt.impl.VMPC;
  2439.  
  2440. public class GameCrypt
  2441. {
  2442. private ProtectionCrypt _client;
  2443. private ProtectionCrypt _server;
  2444. private boolean _isEnabled = false;
  2445. private boolean _isProtected = false;
  2446.  
  2447. public void setProtected(boolean state)
  2448. {
  2449. _isProtected = state;
  2450. }
  2451.  
  2452. public void setKey(byte[] key)
  2453. {
  2454. if (_isProtected)
  2455. {
  2456. _client = new VMPC();
  2457. _client.setup(key, HwidConfig.GUARD_CLIENT_CRYPT);
  2458. _server = new L2Server();
  2459. _server.setup(key, null);
  2460. _server = new VMPC();
  2461. _server.setup(key, HwidConfig.GUARD_SERVER_CRYPT);
  2462. }
  2463. else
  2464. {
  2465. _client = new L2Client();
  2466. _client.setup(key, null);
  2467. _server = new L2Server();
  2468. _server.setup(key, null);
  2469. }
  2470. }
  2471.  
  2472. public void decrypt(byte[] raw, int offset, int size)
  2473. {
  2474. if (_isEnabled)
  2475. _client.crypt(raw, offset, size);
  2476. }
  2477.  
  2478. public void encrypt(byte[] raw, int offset, int size)
  2479. {
  2480. if (_isEnabled)
  2481. _server.crypt(raw, offset, size);
  2482. else
  2483. _isEnabled = true;
  2484. }
  2485. }
  2486.  
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493. Index: head-src/Hwid/crypt/+Manager.java
  2494. ===================================================================
  2495. /*
  2496. * This program is free software: you can redistribute it and/or modify it under
  2497. * the terms of the GNU General Public License as published by the Free Software
  2498. * Foundation, either version 3 of the License, or (at your option) any later
  2499. * version.
  2500. *
  2501. * This program is distributed in the hope that it will be useful, but WITHOUT
  2502. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  2503. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  2504. * details.
  2505. *
  2506. * You should have received a copy of the GNU General Public License along with
  2507. * this program. If not, see <http://www.gnu.org/licenses/>.
  2508. */
  2509. package Hwid.crypt;
  2510.  
  2511. import Hwid.hwidmanager.HWIDManager;
  2512.  
  2513. import java.util.Iterator;
  2514. import java.util.concurrent.ConcurrentHashMap;
  2515. import java.util.concurrent.ScheduledFuture;
  2516. import java.util.logging.Logger;
  2517.  
  2518. import com.l2jfrozen.Config;
  2519. import com.l2jfrozen.gameserver.network.L2GameClient;
  2520.  
  2521. public final class Manager
  2522. {
  2523. protected static Logger _log = Logger.getLogger(Manager.class.getName());
  2524.  
  2525. protected static String _logFile = "Manager";
  2526. protected static String _logMainFile = "hwid_logs";
  2527. protected static Manager _instance;
  2528. protected static ScheduledFuture<?> _GGTask = null;
  2529. protected static ConcurrentHashMap<String, Manager.InfoSet> _objects = new ConcurrentHashMap<>();
  2530.  
  2531. public Manager()
  2532. {
  2533. //
  2534. }
  2535.  
  2536. public static Manager getInstance()
  2537. {
  2538. if (_instance == null)
  2539. {
  2540. System.out.println("- HWID Manager read successfully...");
  2541. _instance = new Manager();
  2542. }
  2543.  
  2544. return _instance;
  2545. }
  2546.  
  2547. public class InfoSet
  2548. {
  2549. public String _playerName = "";
  2550. public long _lastGGSendTime;
  2551. public long _lastGGRecvTime;
  2552. public int _attempts;
  2553. public String _HWID = "";
  2554.  
  2555. public InfoSet(String name, String HWID)
  2556. {
  2557. _playerName = name;
  2558. _lastGGSendTime = System.currentTimeMillis();
  2559. _lastGGRecvTime = _lastGGSendTime;
  2560. _attempts = 0;
  2561. _HWID = HWID;
  2562. }
  2563. }
  2564.  
  2565. public void addPlayer(L2GameClient client)
  2566. {
  2567. int i = 1;
  2568. HWIDManager.updateHWIDInfo(client, i);
  2569. _objects.put(client.getPlayerName(), new Manager.InfoSet(client.getPlayerName(), client.getHWID()));
  2570. }
  2571.  
  2572. public static void removePlayer(String name)
  2573. {
  2574. if (!_objects.containsKey(name))
  2575. {
  2576. if (Config.DEBUG)
  2577. _log.warning("trying to remove player that non exists");
  2578. }
  2579. else
  2580. _objects.remove(name);
  2581. }
  2582.  
  2583. public static int getCountByHWID(String HWID)
  2584. {
  2585. int result = 0;
  2586. Iterator<InfoSet> var3 = _objects.values().iterator();
  2587.  
  2588. while (var3.hasNext())
  2589. {
  2590. Manager.InfoSet object = var3.next();
  2591.  
  2592. if (object._HWID.equals(HWID))
  2593. result++;
  2594. }
  2595.  
  2596. return result;
  2597. }
  2598.  
  2599. }
  2600.  
  2601.  
  2602.  
  2603.  
  2604.  
  2605. Index: head-src/Hwid/crypt/+ProtectionCrypt.java
  2606. ===================================================================
  2607. /*
  2608. * This program is free software: you can redistribute it and/or modify it under
  2609. * the terms of the GNU General Public License as published by the Free Software
  2610. * Foundation, either version 3 of the License, or (at your option) any later
  2611. * version.
  2612. *
  2613. * This program is distributed in the hope that it will be useful, but WITHOUT
  2614. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  2615. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  2616. * details.
  2617. *
  2618. * You should have received a copy of the GNU General Public License along with
  2619. * this program. If not, see <http://www.gnu.org/licenses/>.
  2620. */
  2621. package Hwid.crypt;
  2622.  
  2623. public abstract interface ProtectionCrypt
  2624. {
  2625. public abstract void setup(byte[] rnd_key, byte[] client_server_key);
  2626.  
  2627. public abstract void crypt(byte[] raw, int offset, int size);
  2628. }
  2629.  
  2630.  
  2631.  
  2632. Index: head-src/Hwid/crypt/+ProtectionPackets.java
  2633. ===================================================================
  2634. /*
  2635. * This program is free software: you can redistribute it and/or modify it under
  2636. * the terms of the GNU General Public License as published by the Free Software
  2637. * Foundation, either version 3 of the License, or (at your option) any later
  2638. * version.
  2639. *
  2640. * This program is distributed in the hope that it will be useful, but WITHOUT
  2641. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  2642. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  2643. * details.
  2644. *
  2645. * You should have received a copy of the GNU General Public License along with
  2646. * this program. If not, see <http://www.gnu.org/licenses/>.
  2647. */
  2648. package Hwid.crypt;
  2649.  
  2650. import Hwid.utils.Rnd;
  2651.  
  2652. public class ProtectionPackets
  2653. {
  2654. public static int readB(byte[] raw, int offset, byte[] data, int size)
  2655. {
  2656. for (int i = 0; i < size; i++)
  2657. {
  2658. data[i] = (byte) (raw[offset] ^ raw[0]);
  2659. offset += raw[offset + 1] & 0xFF;
  2660. }
  2661.  
  2662. return offset;
  2663. }
  2664.  
  2665. public static int readS(byte[] raw, int offset, byte[] data, int size)
  2666. {
  2667. for (int i = 0; i < size; i++)
  2668. {
  2669. data[i] = (byte) (raw[offset] ^ raw[0]);
  2670. offset += raw[offset + 1] & 0xFF;
  2671.  
  2672. if (data[i] == 0)
  2673. break;
  2674. }
  2675. return offset;
  2676. }
  2677.  
  2678. public static int writeB(byte[] raw, int offset, byte[] data, int size)
  2679. {
  2680. for (int i = 0; i < size; i++)
  2681. {
  2682. raw[offset] = (byte) (data[i] ^ raw[0]);
  2683. raw[offset + 1] = (byte) (2 + Rnd.nextInt(10));
  2684. offset += raw[offset + 1] & 0xFF;
  2685. }
  2686.  
  2687. return offset;
  2688. }
  2689.  
  2690. public static byte ck(byte[] raw, int offset, int size)
  2691. {
  2692. byte c = -1;
  2693.  
  2694. for (int i = 0; i < size; i++)
  2695. c = (byte) (c ^ raw[offset + i]);
  2696. return c;
  2697. }
  2698. }
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704. Index: head-src/Hwid/crypt/+impl/+L2Client.java
  2705. ===================================================================
  2706. /*
  2707. * This program is free software: you can redistribute it and/or modify it under
  2708. * the terms of the GNU General Public License as published by the Free Software
  2709. * Foundation, either version 3 of the License, or (at your option) any later
  2710. * version.
  2711. *
  2712. * This program is distributed in the hope that it will be useful, but WITHOUT
  2713. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  2714. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  2715. * details.
  2716. *
  2717. * You should have received a copy of the GNU General Public License along with
  2718. * this program. If not, see <http://www.gnu.org/licenses/>.
  2719. */
  2720. package Hwid.crypt.impl;
  2721.  
  2722. import Hwid.crypt.ProtectionCrypt;
  2723.  
  2724. public class L2Client implements ProtectionCrypt
  2725. {
  2726. private ProtectionCrypt _client;
  2727. private final byte[] _key = new byte[16];
  2728. private byte[] _iv = null;
  2729.  
  2730. @Override
  2731. public void setup(byte[] key, byte[] iv)
  2732. {
  2733. System.arraycopy(key, 0, _key, 0, 16);
  2734. _iv = iv;
  2735. }
  2736.  
  2737. @Override
  2738. public void crypt(byte[] raw, int offset, int size)
  2739. {
  2740. if (_iv != null)
  2741. {
  2742. _client = new VMPC();
  2743. _client.setup(_key, _iv);
  2744. _client.crypt(raw, offset, size);
  2745. }
  2746. int temp = 0;
  2747. int temp2 = 0;
  2748. for (int i = 0; i < size; i++)
  2749. {
  2750. temp2 = raw[offset + i] & 0xFF;
  2751. raw[offset + i] = (byte) (temp2 ^ _key[i & 0xF] ^ temp);
  2752. temp = temp2;
  2753. }
  2754.  
  2755. int old = _key[8] & 0xFF;
  2756. old |= _key[9] << 8 & 0xFF00;
  2757. old |= _key[10] << 16 & 0xFF0000;
  2758. old |= _key[11] << 24 & 0xFF000000;
  2759.  
  2760. old += size;
  2761.  
  2762. _key[8] = (byte) (old & 0xFF);
  2763. _key[9] = (byte) (old >> 8 & 0xFF);
  2764. _key[10] = (byte) (old >> 16 & 0xFF);
  2765. _key[11] = (byte) (old >> 24 & 0xFF);
  2766. }
  2767. }
  2768.  
  2769.  
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775. Index: head-src/Hwid/crypt/impl/+L2Server.java
  2776. ===================================================================
  2777. /*
  2778. * This program is free software: you can redistribute it and/or modify it under
  2779. * the terms of the GNU General Public License as published by the Free Software
  2780. * Foundation, either version 3 of the License, or (at your option) any later
  2781. * version.
  2782. *
  2783. * This program is distributed in the hope that it will be useful, but WITHOUT
  2784. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  2785. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  2786. * details.
  2787. *
  2788. * You should have received a copy of the GNU General Public License along with
  2789. * this program. If not, see <http://www.gnu.org/licenses/>.
  2790. */
  2791. package Hwid.crypt.impl;
  2792.  
  2793. import Hwid.crypt.ProtectionCrypt;
  2794.  
  2795. public class L2Server implements ProtectionCrypt
  2796. {
  2797. private final byte[] _key = new byte[16];
  2798. private byte[] _iv = null;
  2799. private ProtectionCrypt _server;
  2800.  
  2801. @Override
  2802. public void setup(byte[] key, byte[] iv)
  2803. {
  2804. System.arraycopy(key, 0, _key, 0, 16);
  2805. _iv = iv;
  2806. }
  2807.  
  2808. @Override
  2809. public void crypt(byte[] raw, int offset, int size)
  2810. {
  2811. int temp = 0;
  2812. for (int i = 0; i < size; i++)
  2813. {
  2814. int temp2 = raw[offset + i] & 0xFF;
  2815. temp = temp2 ^ _key[i & 0xF] ^ temp;
  2816. raw[offset + i] = (byte) temp;
  2817. }
  2818.  
  2819. int old = _key[8] & 0xFF;
  2820. old |= _key[9] << 8 & 0xFF00;
  2821. old |= _key[10] << 16 & 0xFF0000;
  2822. old |= _key[11] << 24 & 0xFF000000;
  2823.  
  2824. old += size;
  2825.  
  2826. _key[8] = (byte) (old & 0xFF);
  2827. _key[9] = (byte) (old >> 8 & 0xFF);
  2828. _key[10] = (byte) (old >> 16 & 0xFF);
  2829. _key[11] = (byte) (old >> 24 & 0xFF);
  2830.  
  2831. if (_iv != null)
  2832. {
  2833. _server = new VMPC();
  2834. _server.setup(_key, _iv);
  2835. _server.crypt(raw, offset, size);
  2836. }
  2837. }
  2838. }
  2839.  
  2840.  
  2841.  
  2842.  
  2843.  
  2844.  
  2845. Index: head-src/Hwid/crypt/impl/+VMPC.java
  2846. ===================================================================
  2847. /*
  2848. * This program is free software: you can redistribute it and/or modify it under
  2849. * the terms of the GNU General Public License as published by the Free Software
  2850. * Foundation, either version 3 of the License, or (at your option) any later
  2851. * version.
  2852. *
  2853. * This program is distributed in the hope that it will be useful, but WITHOUT
  2854. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  2855. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  2856. * details.
  2857. *
  2858. * You should have received a copy of the GNU General Public License along with
  2859. * this program. If not, see <http://www.gnu.org/licenses/>.
  2860. */
  2861. package Hwid.crypt.impl;
  2862.  
  2863. import Hwid.crypt.ProtectionCrypt;
  2864.  
  2865. public class VMPC implements ProtectionCrypt
  2866. {
  2867. private byte _n = 0;
  2868. private final byte[] _P = new byte[256];
  2869. private byte _s = 0;
  2870.  
  2871. @Override
  2872. public void setup(byte[] key, byte[] iv)
  2873. {
  2874. _s = 0;
  2875.  
  2876. for (int i = 0; i < 256; i++)
  2877. _P[i] = (byte) (i & 0xFF);
  2878.  
  2879. for (int m = 0; m < 768; m++)
  2880. {
  2881. _s = _P[_s + _P[m & 0xFF] + key[m % 64] & 0xFF];
  2882. byte temp = _P[m & 0xFF];
  2883. _P[m & 0xFF] = _P[_s & 0xFF];
  2884. _P[_s & 0xFF] = temp;
  2885. }
  2886.  
  2887. for (int m = 0; m < 768; m++)
  2888. {
  2889. _s = _P[_s + _P[m & 0xFF] + iv[m % 64] & 0xFF];
  2890. byte temp = _P[m & 0xFF];
  2891. _P[m & 0xFF] = _P[_s & 0xFF];
  2892. _P[_s & 0xFF] = temp;
  2893. }
  2894.  
  2895. for (int m = 0; m < 768; m++)
  2896. {
  2897. _s = _P[_s + _P[m & 0xFF] + key[m % 64] & 0xFF];
  2898. byte temp = _P[m & 0xFF];
  2899. _P[m & 0xFF] = _P[_s & 0xFF];
  2900. _P[_s & 0xFF] = temp;
  2901. }
  2902.  
  2903. _n = 0;
  2904. }
  2905.  
  2906. @Override
  2907. public void crypt(byte[] raw, int offset, int size)
  2908. {
  2909. for (int i = 0; i < size; i++)
  2910. {
  2911. _s = _P[_s + _P[_n & 0xFF] & 0xFF];
  2912. byte z = _P[_P[_P[_s & 0xFF] & 0xFF] + 1 & 0xFF];
  2913. byte temp = _P[_n & 0xFF];
  2914. _P[_n & 0xFF] = _P[_s & 0xFF];
  2915. _P[_s & 0xFF] = temp;
  2916. _n = (byte) (_n + 1 & 0xFF);
  2917. raw[offset + i] = (byte) (raw[offset + i] ^ z);
  2918. }
  2919. }
  2920. }
  2921.  
  2922.  
  2923.  
  2924.  
  2925.  
  2926.  
  2927. Index: head-src/Hwid/hwidmanager/+HWIDAdminBan.java
  2928. ===================================================================
  2929. /*
  2930. * This program is free software: you can redistribute it and/or modify it under
  2931. * the terms of the GNU General Public License as published by the Free Software
  2932. * Foundation, either version 3 of the License, or (at your option) any later
  2933. * version.
  2934. *
  2935. * This program is distributed in the hope that it will be useful, but WITHOUT
  2936. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  2937. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  2938. * details.
  2939. *
  2940. * You should have received a copy of the GNU General Public License along with
  2941. * this program. If not, see <http://www.gnu.org/licenses/>.
  2942. */
  2943. package Hwid.hwidmanager;
  2944.  
  2945. import Hwid.HwidConfig;
  2946.  
  2947. import com.l2jfrozen.gameserver.handler.IAdminCommandHandler;
  2948. import com.l2jfrozen.gameserver.model.L2Object;
  2949. import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  2950.  
  2951. public class HWIDAdminBan implements IAdminCommandHandler
  2952. {
  2953. private static final String[] ADMIN_COMMANDS =
  2954. {
  2955. "admin_ban_hwid"
  2956. };
  2957.  
  2958. @Override
  2959. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  2960. {
  2961. if (!HwidConfig.ALLOW_GUARD_SYSTEM)
  2962. return false;
  2963.  
  2964. if (activeChar == null)
  2965. return false;
  2966.  
  2967. if (command.startsWith("admin_ban_hwid"))
  2968. {
  2969. L2Object playerTarger = activeChar.getTarget();
  2970.  
  2971. if (playerTarger != null && !playerTarger.equals(activeChar))
  2972. {
  2973. activeChar.sendMessage("Target is empty");
  2974. return false;
  2975. }
  2976.  
  2977. if (playerTarger == null && activeChar.equals(""))
  2978. {
  2979. activeChar.sendMessage("Usage: //ban_hwid <account_name> (if none, target char's account gets banned).");
  2980. return false;
  2981. }
  2982.  
  2983. L2PcInstance target = (L2PcInstance) playerTarger;
  2984. if (target != null)
  2985. {
  2986. HWIDBan.addHWIDBan(target.getClient());
  2987. activeChar.sendMessage(target.getName() + " banned in HWID");
  2988. }
  2989. }
  2990.  
  2991. return true;
  2992. }
  2993.  
  2994. @Override
  2995. public String[] getAdminCommandList()
  2996. {
  2997. return ADMIN_COMMANDS;
  2998. }
  2999. }
  3000.  
  3001.  
  3002.  
  3003.  
  3004.  
  3005.  
  3006. Index: head-src/Hwid/hwidmanager/+HWIDBan.java
  3007. ===================================================================
  3008. /*
  3009. * This program is free software: you can redistribute it and/or modify it under
  3010. * the terms of the GNU General Public License as published by the Free Software
  3011. * Foundation, either version 3 of the License, or (at your option) any later
  3012. * version.
  3013. *
  3014. * This program is distributed in the hope that it will be useful, but WITHOUT
  3015. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  3016. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  3017. * details.
  3018. *
  3019. * You should have received a copy of the GNU General Public License along with
  3020. * this program. If not, see <http://www.gnu.org/licenses/>.
  3021. */
  3022. package Hwid.hwidmanager;
  3023.  
  3024. import java.sql.Connection;
  3025. import java.sql.PreparedStatement;
  3026. import java.sql.ResultSet;
  3027. import java.util.HashMap;
  3028. import java.util.Map;
  3029. import java.util.logging.Logger;
  3030.  
  3031. import com.l2jfrozen.util.database.L2DatabaseFactory;
  3032. import com.l2jfrozen.gameserver.network.L2GameClient;
  3033.  
  3034.  
  3035. public class HWIDBan
  3036. {
  3037. protected static Logger _log = Logger.getLogger(HWIDBan.class.getName());
  3038. private static HWIDBan _instance;
  3039. private static Map<Integer, HWIDBanList> _lists;
  3040.  
  3041. public HWIDBan()
  3042. {
  3043. _lists = new HashMap<>();
  3044. load();
  3045. System.out.println("- HWID Ban: Loaded " + _lists.size() + " HWIDs");
  3046. }
  3047.  
  3048. public static HWIDBan getInstance()
  3049. {
  3050. if (_instance == null)
  3051. _instance = new HWIDBan();
  3052. return _instance;
  3053. }
  3054.  
  3055. private static void load()
  3056. {
  3057. String HWID = "";
  3058. int counterHWIDBan = 0;
  3059. try
  3060. {
  3061. Connection con = L2DatabaseFactory.getInstance().getConnection();
  3062. Throwable localThrowable2 = null;
  3063. try
  3064. {
  3065. PreparedStatement statement = con.prepareStatement("SELECT * FROM hwid_bans");
  3066. ResultSet rset = statement.executeQuery();
  3067. while (rset.next())
  3068. {
  3069. HWID = rset.getString("HWID");
  3070. HWIDBanList hb = new HWIDBanList(counterHWIDBan);
  3071. hb.setHWIDBan(HWID);
  3072. _lists.put(Integer.valueOf(counterHWIDBan), hb);
  3073. counterHWIDBan++;
  3074. }
  3075. }
  3076. catch (Throwable localThrowable1)
  3077. {
  3078. localThrowable2 = localThrowable1;
  3079. throw localThrowable1;
  3080. }
  3081. finally
  3082. {
  3083. if (con != null)
  3084. if (localThrowable2 != null)
  3085. try
  3086. {
  3087. con.close();
  3088. }
  3089. catch (Throwable x2)
  3090. {
  3091. localThrowable2.addSuppressed(x2);
  3092. }
  3093. else
  3094. con.close();
  3095. }
  3096. }
  3097. catch (Exception e)
  3098. {
  3099. e.printStackTrace();
  3100. }
  3101. }
  3102.  
  3103. public static void reload()
  3104. {
  3105. _instance = new HWIDBan();
  3106. }
  3107.  
  3108. public boolean checkFullHWIDBanned(L2GameClient client)
  3109. {
  3110. if (_lists.size() == 0)
  3111. return false;
  3112. for (int i = 0; i < _lists.size(); i++)
  3113. if (_lists.get(Integer.valueOf(i)).getHWID().equals(client.getHWID()))
  3114. return true;
  3115. return false;
  3116. }
  3117.  
  3118. public static int getCountHWIDBan()
  3119. {
  3120. return _lists.size();
  3121. }
  3122.  
  3123. public static void addHWIDBan(L2GameClient client)
  3124. {
  3125. String HWID = client.getHWID();
  3126. int counterHwidBan = _lists.size();
  3127. HWIDBanList hb = new HWIDBanList(counterHwidBan);
  3128. hb.setHWIDBan(HWID);
  3129. _lists.put(Integer.valueOf(counterHwidBan), hb);
  3130. try
  3131. {
  3132. Connection con = L2DatabaseFactory.getInstance().getConnection();
  3133. Throwable localThrowable2 = null;
  3134. try
  3135. {
  3136. PreparedStatement statement = con.prepareStatement("INSERT INTO hwid_bans SET HWID=?");
  3137. statement.setString(1, HWID);
  3138. statement.execute();
  3139. }
  3140. catch (Throwable localThrowable1)
  3141. {
  3142. localThrowable2 = localThrowable1;
  3143. throw localThrowable1;
  3144. }
  3145. finally
  3146. {
  3147. if (con != null)
  3148. if (localThrowable2 != null)
  3149. try
  3150. {
  3151. con.close();
  3152. }
  3153. catch (Throwable x2)
  3154. {
  3155. localThrowable2.addSuppressed(x2);
  3156. }
  3157. else
  3158. con.close();
  3159. }
  3160. }
  3161. catch (Exception e)
  3162. {
  3163. e.printStackTrace();
  3164. }
  3165. }
  3166. }
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174. Index: head-src/Hwid/hwidmanager/+HWIDBanList.java
  3175. ===================================================================
  3176. /*
  3177. * This program is free software: you can redistribute it and/or modify it under
  3178. * the terms of the GNU General Public License as published by the Free Software
  3179. * Foundation, either version 3 of the License, or (at your option) any later
  3180. * version.
  3181. *
  3182. * This program is distributed in the hope that it will be useful, but WITHOUT
  3183. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  3184. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  3185. * details.
  3186. *
  3187. * You should have received a copy of the GNU General Public License along with
  3188. * this program. If not, see <http://www.gnu.org/licenses/>.
  3189. */
  3190. package Hwid.hwidmanager;
  3191.  
  3192. public class HWIDBanList
  3193. {
  3194. private final int _id;
  3195. private String HWID;
  3196.  
  3197. public HWIDBanList(int id)
  3198. {
  3199. _id = id;
  3200. }
  3201.  
  3202. public int getId()
  3203. {
  3204. return _id;
  3205. }
  3206.  
  3207. public String getHWID()
  3208. {
  3209. return HWID;
  3210. }
  3211.  
  3212. public void setHWIDBan(String hwid1)
  3213. {
  3214. HWID = hwid1;
  3215. }
  3216. }
  3217.  
  3218.  
  3219.  
  3220.  
  3221.  
  3222. Index: head-src/Hwid/hwidmanager/+HWIDInfoList.java
  3223. ===================================================================
  3224. /*
  3225. * This program is free software: you can redistribute it and/or modify it under
  3226. * the terms of the GNU General Public License as published by the Free Software
  3227. * Foundation, either version 3 of the License, or (at your option) any later
  3228. * version.
  3229. *
  3230. * This program is distributed in the hope that it will be useful, but WITHOUT
  3231. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  3232. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  3233. * details.
  3234. *
  3235. * You should have received a copy of the GNU General Public License along with
  3236. * this program. If not, see <http://www.gnu.org/licenses/>.
  3237. */
  3238. package Hwid.hwidmanager;
  3239.  
  3240. public class HWIDInfoList
  3241. {
  3242. private final int _id;
  3243. private String HWID;
  3244. private int count;
  3245. private int playerID;
  3246. private String login;
  3247. private LockType lockType;
  3248.  
  3249. public static enum LockType
  3250. {
  3251. PLAYER_LOCK,
  3252. ACCOUNT_LOCK,
  3253. NONE
  3254. }
  3255.  
  3256. public HWIDInfoList(int id)
  3257. {
  3258. _id = id;
  3259. }
  3260.  
  3261. public int get_id()
  3262. {
  3263. return _id;
  3264. }
  3265.  
  3266. public void setHwids(String hwid)
  3267. {
  3268. HWID = hwid;
  3269. count = 1;
  3270. }
  3271.  
  3272. public String getHWID()
  3273. {
  3274. return HWID;
  3275. }
  3276.  
  3277. public void setHWID(String HWID)
  3278. {
  3279. this.HWID = HWID;
  3280. }
  3281.  
  3282. public int getPlayerID()
  3283. {
  3284. return playerID;
  3285. }
  3286.  
  3287. public void setPlayerID(int playerID)
  3288. {
  3289. this.playerID = playerID;
  3290. }
  3291.  
  3292. public String getLogin()
  3293. {
  3294. return login;
  3295. }
  3296.  
  3297. public void setLogin(String login)
  3298. {
  3299. this.login = login;
  3300. }
  3301.  
  3302. public LockType getLockType()
  3303. {
  3304. return lockType;
  3305. }
  3306.  
  3307. public void setLockType(LockType lockType)
  3308. {
  3309. this.lockType = lockType;
  3310. }
  3311.  
  3312. public int getCount()
  3313. {
  3314. return count;
  3315. }
  3316.  
  3317. public void setCount(int count)
  3318. {
  3319. this.count = count;
  3320. }
  3321. }
  3322.  
  3323.  
  3324.  
  3325.  
  3326.  
  3327. Index: head-src/Hwid/hwidmanager/+HWIDManager.java
  3328. ===================================================================
  3329. /*
  3330. * This program is free software: you can redistribute it and/or modify it under
  3331. * the terms of the GNU General Public License as published by the Free Software
  3332. * Foundation, either version 3 of the License, or (at your option) any later
  3333. * version.
  3334. *
  3335. * This program is distributed in the hope that it will be useful, but WITHOUT
  3336. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  3337. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  3338. * details.
  3339. *
  3340. * You should have received a copy of the GNU General Public License along with
  3341. * this program. If not, see <http://www.gnu.org/licenses/>.
  3342. */
  3343. package Hwid.hwidmanager;
  3344.  
  3345. import java.sql.Connection;
  3346. import java.sql.PreparedStatement;
  3347. import java.sql.ResultSet;
  3348. import java.util.HashMap;
  3349. import java.util.Map;
  3350. import java.util.logging.Logger;
  3351.  
  3352. import com.l2jfrozen.util.database.L2DatabaseFactory;
  3353. import com.l2jfrozen.gameserver.network.L2GameClient;
  3354.  
  3355. public class HWIDManager
  3356. {
  3357. protected static Logger _log = Logger.getLogger(HWIDManager.class.getName());
  3358. private static HWIDManager _instance;
  3359. public static Map<Integer, HWIDInfoList> _listHWID;
  3360. public static Map<Integer, Integer> _sessions;
  3361.  
  3362. public HWIDManager()
  3363. {
  3364. _listHWID = new HashMap<>();
  3365. load();
  3366. System.out.println("- HWID Info: Loaded " + _listHWID.size() + " HWIDs");
  3367. }
  3368.  
  3369. public static HWIDManager getInstance()
  3370. {
  3371. if (_instance == null)
  3372. _instance = new HWIDManager();
  3373.  
  3374. return _instance;
  3375. }
  3376.  
  3377. private static void load()
  3378. {
  3379. try
  3380. {
  3381. Connection con = L2DatabaseFactory.getInstance().getConnection();
  3382. Throwable localThrowable2 = null;
  3383. try
  3384. {
  3385. PreparedStatement statement = con.prepareStatement("SELECT * FROM hwid_info");
  3386. ResultSet rset = statement.executeQuery();
  3387. int counterHWIDInfo = 0;
  3388. while (rset.next())
  3389. {
  3390. HWIDInfoList hInfo = new HWIDInfoList(counterHWIDInfo);
  3391. hInfo.setHwids(rset.getString("HWID"));
  3392. hInfo.setCount(rset.getInt("WindowsCount"));
  3393. hInfo.setLogin(rset.getString("Account"));
  3394. hInfo.setPlayerID(rset.getInt("PlayerID"));
  3395. hInfo.setLockType(HWIDInfoList.LockType.valueOf(rset.getString("LockType")));
  3396. _listHWID.put(Integer.valueOf(counterHWIDInfo), hInfo);
  3397. counterHWIDInfo++;
  3398. }
  3399. }
  3400. catch (Throwable localThrowable1)
  3401. {
  3402. localThrowable2 = localThrowable1;
  3403. throw localThrowable1;
  3404. }
  3405. finally
  3406. {
  3407. if (con != null)
  3408. if (localThrowable2 != null)
  3409. try
  3410. {
  3411. con.close();
  3412. }
  3413. catch (Throwable x2)
  3414. {
  3415. localThrowable2.addSuppressed(x2);
  3416. }
  3417. else
  3418. con.close();
  3419. }
  3420. }
  3421. catch (Exception e)
  3422. {
  3423. e.printStackTrace();
  3424. }
  3425. }
  3426.  
  3427. public static int getAllowedWindowsCount(final L2GameClient pi)
  3428. {
  3429. if (_listHWID.size() == 0)
  3430. return -1;
  3431.  
  3432. for (int i = 0; i < _listHWID.size(); i++)
  3433. if (_listHWID.get(i).getHWID().equals(pi.getHWID()))
  3434. {
  3435. if (_listHWID.get(i).getHWID().equals(""))
  3436. return -1;
  3437.  
  3438. return _listHWID.get(i).getCount();
  3439. }
  3440. return -1;
  3441. }
  3442.  
  3443. public static void reload()
  3444. {
  3445. _instance = new HWIDManager();
  3446. }
  3447.  
  3448. public static void updateHWIDInfo(L2GameClient client, int windowscount)
  3449. {
  3450. updateHWIDInfo(client, windowscount, HWIDInfoList.LockType.NONE);
  3451. }
  3452.  
  3453. public static void updateHwidInfo(final L2GameClient client, final HWIDInfoList.LockType lockType)
  3454. {
  3455. updateHWIDInfo(client, 1, lockType);
  3456. }
  3457.  
  3458. public static void updateHWIDInfo(L2GameClient client, int windowsCount, HWIDInfoList.LockType lockType)
  3459. {
  3460. int counterHwidInfo = _listHWID.size();
  3461. boolean isFound = false;
  3462.  
  3463. for (int i = 0; i < _listHWID.size(); i++)
  3464. if (_listHWID.get(i).getHWID().equals(client.getHWID()))
  3465. {
  3466. isFound = true;
  3467. counterHwidInfo = i;
  3468. break;
  3469. }
  3470.  
  3471. final HWIDInfoList hInfo = new HWIDInfoList(counterHwidInfo);
  3472. hInfo.setHwids(client.getHWID());
  3473. hInfo.setCount(windowsCount);
  3474. hInfo.setLogin(client.getAccountName());
  3475. hInfo.setPlayerID(client.getPlayerId());
  3476. hInfo.setLockType(lockType);
  3477. _listHWID.put(Integer.valueOf(counterHwidInfo), hInfo);
  3478.  
  3479. if (isFound)
  3480. try
  3481. {
  3482. Connection con = L2DatabaseFactory.getInstance().getConnection();
  3483. Throwable localThrowable3 = null;
  3484. try
  3485. {
  3486. PreparedStatement statement = con.prepareStatement("UPDATE hwid_info SET WindowsCount=?,Account=?,PlayerID=?,LockType=? WHERE HWID=?");
  3487. statement.setInt(1, windowsCount);
  3488. statement.setString(2, client.getPlayerName());
  3489. statement.setInt(3, client.getPlayerId());
  3490. statement.setString(4, lockType.toString());
  3491. statement.setString(5, client.getHWID());
  3492. statement.execute();
  3493. }
  3494. catch (Throwable localThrowable1)
  3495. {
  3496. localThrowable3 = localThrowable1;
  3497. throw localThrowable1;
  3498. }
  3499. finally
  3500. {
  3501. if (con != null)
  3502. if (localThrowable3 != null)
  3503. try
  3504. {
  3505. con.close();
  3506. }
  3507. catch (Throwable x2)
  3508. {
  3509. localThrowable3.addSuppressed(x2);
  3510. }
  3511. else
  3512. con.close();
  3513. }
  3514. }
  3515. catch (Exception e)
  3516. {
  3517. e.printStackTrace();
  3518. }
  3519. else
  3520. try
  3521. {
  3522. Connection con = L2DatabaseFactory.getInstance().getConnection();
  3523. Throwable localThrowable3 = null;
  3524. try
  3525. {
  3526. PreparedStatement statement = con.prepareStatement("INSERT INTO hwid_info (HWID, WindowsCount, Account, PlayerID, LockType) values (?,?,?,?,?)");
  3527. statement.setString(1, client.getHWID());
  3528. statement.setInt(2, windowsCount);
  3529. statement.setString(3, client.getPlayerName());// .getAccountName());
  3530. statement.setInt(4, client.getPlayerId());
  3531. statement.setString(5, lockType.toString());
  3532. statement.execute();
  3533. }
  3534. catch (Throwable localThrowable2)
  3535. {
  3536. localThrowable3 = localThrowable2;
  3537. throw localThrowable2;
  3538. }
  3539. finally
  3540. {
  3541. if (con != null)
  3542. if (localThrowable3 != null)
  3543. try
  3544. {
  3545. con.close();
  3546. }
  3547. catch (Throwable x2)
  3548. {
  3549. localThrowable3.addSuppressed(x2);
  3550. }
  3551. else
  3552. con.close();
  3553. }
  3554. }
  3555. catch (Exception e)
  3556. {
  3557. e.printStackTrace();
  3558. }
  3559. }
  3560.  
  3561. public static void updateHWIDInfo(L2GameClient client, HWIDInfoList.LockType lockType)
  3562. {
  3563. updateHWIDInfo(client, 1, lockType);
  3564. }
  3565.  
  3566. public static int getCountHwidInfo()
  3567. {
  3568. return _listHWID.size();
  3569. }
  3570. }
  3571.  
  3572.  
  3573.  
  3574.  
  3575.  
  3576.  
  3577.  
  3578.  
  3579. Index: head-src/Hwid/utils/+Rnd.java
  3580. ===================================================================
  3581. /*
  3582. * This program is free software: you can redistribute it and/or modify it under
  3583. * the terms of the GNU General Public License as published by the Free Software
  3584. * Foundation, either version 3 of the License, or (at your option) any later
  3585. * version.
  3586. *
  3587. * This program is distributed in the hope that it will be useful, but WITHOUT
  3588. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  3589. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  3590. * details.
  3591. *
  3592. * You should have received a copy of the GNU General Public License along with
  3593. * this program. If not, see <http://www.gnu.org/licenses/>.
  3594. */
  3595. package Hwid.utils;
  3596.  
  3597. import java.util.Random;
  3598.  
  3599. public class Rnd
  3600. {
  3601. private static final Random random = new Random();
  3602.  
  3603. public static int nextInt(int n)
  3604. {
  3605. if (n < 0)
  3606. return random.nextInt(-n) * -1;
  3607. if (n == 0)
  3608. return 0;
  3609. return random.nextInt(n);
  3610. }
  3611.  
  3612. public static byte[] nextBytes(byte[] array)
  3613. {
  3614. random.nextBytes(array);
  3615. return array;
  3616. }
  3617. }
  3618.  
  3619.  
  3620. Index: head-src/Hwid.utils;Util.java
  3621. ===================================================================
  3622. /*
  3623. * This program is free software: you can redistribute it and/or modify it under
  3624. * the terms of the GNU General Public License as published by the Free Software
  3625. * Foundation, either version 3 of the License, or (at your option) any later
  3626. * version.
  3627. *
  3628. * This program is distributed in the hope that it will be useful, but WITHOUT
  3629. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  3630. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  3631. * details.
  3632. *
  3633. * You should have received a copy of the GNU General Public License along with
  3634. * this program. If not, see <http://www.gnu.org/licenses/>.
  3635. */
  3636. package Hwid.utils;
  3637.  
  3638. public class Util
  3639. {
  3640. public Util()
  3641. {
  3642. }
  3643.  
  3644. public static void intToBytes(int value, byte[] array, int offset)
  3645. {
  3646. array[offset++] = (byte) (value & 255);
  3647. array[offset++] = (byte) (value >> 8 & 255);
  3648. array[offset++] = (byte) (value >> 16 & 255);
  3649. array[offset++] = (byte) (value >> 24 & 255);
  3650. }
  3651.  
  3652. public static String LastErrorConvertion(Integer LastError)
  3653. {
  3654. return LastError.toString();
  3655. }
  3656.  
  3657. public static final String asHex(byte[] raw)
  3658. {
  3659. return asHex(raw, 0, raw.length);
  3660. }
  3661.  
  3662. public static final String asHex(byte[] raw, int offset, int size)
  3663. {
  3664. StringBuffer strbuf = new StringBuffer(raw.length * 2);
  3665.  
  3666. for (int i = 0; i < size; ++i)
  3667. {
  3668. if ((raw[offset + i] & 255) < 16)
  3669. strbuf.append("0");
  3670.  
  3671. strbuf.append(Long.toString(raw[offset + i] & 255, 16));
  3672. }
  3673.  
  3674. return strbuf.toString();
  3675. }
  3676.  
  3677. public static int bytesToInt(byte[] array, int offset)
  3678. {
  3679. return array[offset++] & 255 | (array[offset++] & 255) << 8 | (array[offset++] & 255) << 16 | (array[offset++] & 255) << 24;
  3680. }
  3681.  
  3682. public static String asHwidString(String hex)
  3683. {
  3684. byte[] buf = asByteArray(hex);
  3685. return asHex(buf);
  3686. }
  3687.  
  3688. public static byte[] asByteArray(String hex)
  3689. {
  3690. byte[] buf = new byte[hex.length() / 2];
  3691.  
  3692. for (int i = 0; i < hex.length(); i += 2)
  3693. {
  3694. int j = Integer.parseInt(hex.substring(i, i + 2), 16);
  3695. buf[i / 2] = (byte) (j & 255);
  3696. }
  3697.  
  3698. return buf;
  3699. }
  3700.  
  3701. public static boolean verifyChecksum(byte[] raw, int offset, int size)
  3702. {
  3703. if ((size & 3) == 0 && size > 4)
  3704. {
  3705. long chksum = 0L;
  3706. int count = size - 4;
  3707.  
  3708. for (int i1 = offset; i1 < count; i1 += 4)
  3709. chksum ^= bytesToInt(raw, i1);
  3710.  
  3711. long check = bytesToInt(raw, count);
  3712. return check == chksum;
  3713. }
  3714. return false;
  3715. }
  3716.  
  3717. /*
  3718. * public static byte[] asByteArray(String hex) { byte[] buf = new byte[hex.length() / 2]; for (int i = 0; i < hex.length(); i += 2) { int j = Integer.parseInt(hex.substring(i, i + 2), 16); buf[(i / 2)] = (byte)(j & 0xFF); } return buf; } public static String asHwidString(String hex) { byte[]
  3719. * buf = asByteArray(hex); return asHex(buf); } public static final String asHex(byte[] raw, int offset, int size) { StringBuffer strbuf = new StringBuffer(raw.length * 2); for (int i = 0; i < size; i++) { if ((raw[(offset + i)] & 0xFF) < 16) { strbuf.append("0"); }
  3720. * strbuf.append(Long.toString(raw[(offset + i)] & 0xFF, 16)); } return strbuf.toString(); } public static final String asHex(byte[] raw) { return asHex(raw, 0, raw.length); }
  3721. */
  3722. }
  3723.  
  3724.  
  3725.  
  3726.  
  3727.  
  3728.  
  3729. Index: com.l2jfrozen.gameserver.GameServer.java
  3730. ===================================================================
  3731. + import Hwid.Hwid;
  3732.  
  3733.  
  3734. @@
  3735.  
  3736.  
  3737. + Util.printSection("Hwid Manager");
  3738. + Hwid.Init();
  3739.  
  3740. Util.printSection("Custom Mods");
  3741.  
  3742. if (Config.L2JMOD_ALLOW_WEDDING || Config.ALLOW_AWAY_STATUS || Config.PCB_ENABLE || Config.POWERPAK_ENABLED )
  3743. {
  3744. if (Config.L2JMOD_ALLOW_WEDDING)
  3745. CoupleManager.getInstance();
  3746.  
  3747. if (Config.ALLOW_AWAY_STATUS)
  3748. AwayManager.getInstance();
  3749.  
  3750.  
  3751. Index: com.l2jfrozen.gameserver.handler.AdminCommandHandler.java
  3752. ===================================================================
  3753. import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminGeodata;
  3754. import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminGetOlympiadStat;
  3755. import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminGm;
  3756. import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminGmChat;
  3757. import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminHeal;
  3758. import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminHelpPage;
  3759. + import Hwid.hwidmanager.HWIDAdminBan;
  3760.  
  3761.  
  3762. @@
  3763.  
  3764. registerAdminCommandHandler(new AdminAugment());
  3765. registerAdminCommandHandler(new AdminAio());
  3766. registerAdminCommandHandler(new AdminCharSupervision());
  3767. registerAdminCommandHandler(new AdminInventory());
  3768. registerAdminCommandHandler(new AdminGetOlympiadStat());
  3769. registerAdminCommandHandler(new AdminSendDonate());
  3770. registerAdminCommandHandler(new AdminEditOlympiadStat());
  3771. registerAdminCommandHandler(new AdminCustom());
  3772. + registerAdminCommandHandler(new HWIDAdminBan());
  3773.  
  3774.  
  3775.  
  3776.  
  3777. Index: com.l2jfrozen.gameserver.network.L2GameClient.java
  3778. ===================================================================
  3779. --- package net.sf.l2j.gameserver.network;GameClient.java (revision 84)
  3780. +++ package net.sf.l2j.gameserver.network;GameClient.java (working copy)
  3781. import com.l2jfrozen.util.CloseUtil;
  3782. import com.l2jfrozen.util.OlympiadLogger;
  3783. import com.l2jfrozen.util.database.DatabaseUtils;
  3784. import com.l2jfrozen.util.database.L2DatabaseFactory;
  3785. import Dev.Tournament.properties.ArenaTask;
  3786. + import Hwid.Hwid;
  3787.  
  3788.  
  3789.  
  3790. @@
  3791.  
  3792. public byte[] enableCrypt()
  3793. {
  3794. byte[] key = BlowFishKeygen.getRandomKey();
  3795. _crypt.setKey(key);
  3796.  
  3797. + if (Hwid.isProtectionOn())
  3798. + key = Hwid.getKey(key);
  3799.  
  3800. return key;
  3801. }
  3802.  
  3803.  
  3804. @@
  3805.  
  3806. private boolean cancelCleanup()
  3807. {
  3808. final Future<?> task = _cleanupTask;
  3809. if (task != null)
  3810. {
  3811. _cleanupTask = null;
  3812. return task.cancel(true);
  3813. }
  3814.  
  3815. return false;
  3816. }
  3817.  
  3818. + // Hwid Protection
  3819. + private String _playerName = "";
  3820. + private String _loginName = "";
  3821. + private int _playerId = 0;
  3822. + private String _hwid = "";
  3823. + private int revision = 0;
  3824. +
  3825. + public final String getPlayerName()
  3826. + {
  3827. + return _playerName;
  3828. + }
  3829. +
  3830. + public void setPlayerName(String name)
  3831. + {
  3832. + _playerName = name;
  3833. + }
  3834. +
  3835. + public void setPlayerId(int plId)
  3836. + {
  3837. + _playerId = plId;
  3838. + }
  3839. +
  3840. + public int getPlayerId()
  3841. + {
  3842. + return _playerId;
  3843. + }
  3844. +
  3845. + public final String getHWID()
  3846. + {
  3847. + return _hwid;
  3848. + }
  3849. +
  3850. + public void setHWID(String hwid)
  3851. + {
  3852. + _hwid = hwid;
  3853. + }
  3854. +
  3855. + public void setRevision(int revision)
  3856. + {
  3857. + this.revision = revision;
  3858. + }
  3859. +
  3860. + public int getRevision()
  3861. + {
  3862. + return this.revision;
  3863. + }
  3864. +
  3865. + public final String getLoginName()
  3866. + {
  3867. + return _loginName;
  3868. + }
  3869. +
  3870. + public void setLoginName(String name)
  3871. + {
  3872. + _loginName = name;
  3873. + }
  3874. +
  3875. + public synchronized boolean BanedHwid(String hwidban)
  3876. + {
  3877. + boolean result = true;
  3878. + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  3879. + {
  3880. + PreparedStatement statement = con.prepareStatement("SELECT hwid FROM banned_hwid WHERE hwid=?");
  3881. + statement.setString(1, hwidban);
  3882. + ResultSet rset = statement.executeQuery();
  3883. + result = rset.next();
  3884. + rset.close();
  3885. + statement.close();
  3886. + }
  3887. + catch (Exception e)
  3888. + {
  3889. + LOGGER.warn("HWIDReload: " + e.getMessage(), e);
  3890. + //LOGGER.log(Level.WARN, "HWIDReload: " + e.getMessage(), e);
  3891. + }
  3892. + return result;
  3893. + }
  3894. +
  3895.  
  3896. Index: com.l2jfrozen.gameserver.network.clientpackets.AuthLogin.java
  3897. ===================================================================
  3898. import com.l2jfrozen.gameserver.network.L2GameClient;
  3899. + import Hwid.Hwid;
  3900.  
  3901.  
  3902. private int _loginKey1;
  3903. private int _loginKey2;
  3904. + private final byte[] _data = new byte[48];
  3905.  
  3906. @Override
  3907. protected void runImpl()
  3908. {
  3909. final SessionKey key = new SessionKey(_loginKey1, _loginKey2, _playKey1, _playKey2);
  3910.  
  3911. + if (Hwid.isProtectionOn())
  3912. + {
  3913. + if (!Hwid.doAuthLogin(getClient(), _data, _loginName))
  3914. + return;
  3915. + }
  3916.  
  3917.  
  3918. com.l2jfrozen.gameserver.network.clientpackets.EnterWorld.java
  3919. ===================================================================
  3920. import com.l2jfrozen.gameserver.communitybbs.Manager.RegionBBSManager;
  3921. import com.l2jfrozen.gameserver.controllers.GameTimeController;
  3922. import com.l2jfrozen.gameserver.datatables.CharSchemesTable;
  3923. import com.l2jfrozen.gameserver.datatables.GmListTable;
  3924. + import Hwid.Hwid;
  3925.  
  3926.  
  3927. @Override
  3928. protected void runImpl()
  3929. {
  3930. final L2PcInstance activeChar = getClient().getActiveChar();
  3931.  
  3932. + // Means that it's not ok multiBox situation, so logout
  3933. + Hwid.enterlog(activeChar, getClient());
  3934.  
  3935.  
  3936. com.l2jfrozen.gameserver.network.clientpackets.GameGuardReply.java
  3937. ===================================================================
  3938. import com.l2jfrozen.Config;
  3939. import com.l2jfrozen.crypt.nProtect;
  3940. +import com.l2jfrozen.gameserver.network.serverpackets.KeyPacket;
  3941.  
  3942. +import Hwid.Hwid;
  3943. +import Hwid.HwidConfig;
  3944.  
  3945.  
  3946. + private int _version;
  3947. + private byte _data[];
  3948. + private String _hwidHdd = "NoHWID-HD";
  3949. + private String _hwidMac = "NoHWID-MAC";
  3950. + private String _hwidCPU = "NoHWID-CPU";
  3951.  
  3952. @Override
  3953. protected void readImpl()
  3954. {
  3955.  
  3956. + _version = readD();
  3957. + if (Hwid.isProtectionOn())
  3958. + {
  3959. + if (_buf.remaining() > 260)
  3960. + {
  3961. + _data = new byte[260];
  3962. + readB(_data);
  3963. + if (Hwid.isProtectionOn())
  3964. + {
  3965. + _hwidHdd = readS();
  3966. + _hwidMac = readS();
  3967. + _hwidCPU = readS();
  3968. + }
  3969. + }
  3970. + }
  3971. + else if (Hwid.isProtectionOn())
  3972. + {
  3973. + getClient().close(new KeyPacket(getClient().enableCrypt()));
  3974. + }
  3975. }
  3976.  
  3977. @Override
  3978. protected void runImpl()
  3979. {
  3980. + if (_version == -2)
  3981. + {
  3982. + getClient().close((L2GameServerPacket) null);
  3983. + }
  3984. + else if (_version < Config.MIN_PROTOCOL_REVISION || _version > Config.MAX_PROTOCOL_REVISION)
  3985. + {
  3986. + LOGGER.info("Client: " + getClient().toString() + " -> Protocol Revision: " + _version + " is invalid. Minimum and maximum allowed are: " + Config.MIN_PROTOCOL_REVISION + " and " + Config.MAX_PROTOCOL_REVISION + ". Closing connection.");
  3987. + getClient().close((L2GameServerPacket) null);
  3988. + }
  3989. + else
  3990. + {
  3991. + getClient().sendPacket(new KeyPacket(getClient().enableCrypt()));
  3992. + }
  3993. + if (Hwid.isProtectionOn())
  3994. + {
  3995. + if (_hwidHdd.equals("NoGuard") && _hwidMac.equals("NoGuard") && _hwidCPU.equals("NoGuard"))
  3996. + {
  3997. + LOGGER.info("HWID Status: No Client side dlls");
  3998. + getClient().close(new KeyPacket(getClient().enableCrypt()));
  3999. + }
  4000. +
  4001. + switch (HwidConfig.GET_CLIENT_HWID)
  4002. + {
  4003. + case 1:
  4004. + getClient().setHWID(_hwidHdd);
  4005. + break;
  4006. + case 2:
  4007. + getClient().setHWID(_hwidMac);
  4008. + break;
  4009. + case 3:
  4010. + getClient().setHWID(_hwidCPU);
  4011. + break;
  4012. + }
  4013. + }
  4014.  
  4015. // TODO: clean nProtect System
  4016. if (!nProtect.getInstance().checkGameGuardRepy(getClient(), _reply))
  4017. return;
  4018.  
  4019.  
  4020.  
  4021.  
  4022. com.l2jfrozen.gameserver.network.clientpackets.ProtocolVersion.java
  4023. ===================================================================
  4024. import com.l2jfrozen.gameserver.network.serverpackets.SendStatus;
  4025.  
  4026. +import Hwid.Hwid;
  4027. +import Hwid.HwidConfig;
  4028.  
  4029. @@
  4030.  
  4031. static Logger LOGGER = Logger.getLogger(ProtocolVersion.class);
  4032. private int _version;
  4033. + private byte _data[];
  4034. + private String
  4035. + _hwidHdd = "NoHWID-HD";
  4036. + private String _hwidMac = "NoHWID-MAC";
  4037. + private String _hwidCPU = "NoHWID-CPU";
  4038. + L2PcInstance player;
  4039.  
  4040. @Override
  4041. protected void readImpl()
  4042. {
  4043. _version = readH();
  4044. + if (Hwid.isProtectionOn())
  4045. + {
  4046. + if (_buf.remaining() > 260)
  4047. + {
  4048. + _data = new byte[260];
  4049. + readB(_data);
  4050. + if (Hwid.isProtectionOn())
  4051. + {
  4052. + _hwidHdd = readS();
  4053. + _hwidMac = readS();
  4054. + _hwidCPU = readS();
  4055. + }
  4056. + }
  4057. + }
  4058. + else if (Hwid.isProtectionOn())
  4059. + {
  4060. + getClient().close(new KeyPacket(getClient().enableCrypt()));
  4061. + }
  4062. }
  4063.  
  4064. @@
  4065.  
  4066.  
  4067. protected void runImpl()
  4068. {
  4069. + if (Hwid.isProtectionOn())
  4070. + {
  4071. + if (_hwidHdd.equals("NoGuard") && _hwidMac.equals("NoGuard") && _hwidCPU.equals("NoGuard"))
  4072. + {
  4073. + LOGGER.info("HWID Status: No Client side dlls");
  4074. + getClient().close(new KeyPacket(getClient().enableCrypt()));
  4075. + }
  4076. +
  4077. + switch (HwidConfig.GET_CLIENT_HWID)
  4078. + {
  4079. + case 1:
  4080. + getClient().setHWID(_hwidHdd);
  4081. + break;
  4082. + case 2:
  4083. + getClient().setHWID(_hwidMac);
  4084. + break;
  4085. + case 3:
  4086. + getClient().setHWID(_hwidCPU);
  4087. + break;
  4088. + }
  4089. + }
  4090.  
  4091. // this packet is never encrypted
  4092. if (_version == 65534 || _version == -2) // Ping
  4093.  
  4094. Index: com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance.java
  4095. ===================================================================
  4096.  
  4097. + private String _hwid = "";
  4098. +
  4099. + public final String getHWID()
  4100. + {
  4101. + return _hwid;
  4102. + }
  4103. +
  4104. + public void setHWID(String hwid)
  4105. + {
  4106. + _hwid = hwid;
  4107. + }
  4108. +
  4109. + /**
  4110. + * This is a multitype HWID function it worked with L2JGuard, catsguard and used in all scoria pack. some here - simple
  4111. + * @return
  4112. + */
  4113. + public String gethwid()
  4114. + { // cats reflect method
  4115. + if (getClient().getHWID() != null)
  4116. + return getClient().getHWID();
  4117. + else if (getClient().getHWID() != null)
  4118. + return getClient().getHWID();
  4119. + else
  4120. + return null;
  4121. + }
  4122. +
  4123. + public String getHWid()
  4124. + {
  4125. + return getClient().getHWID();
  4126. + }
  4127.  
  4128. Index: hwid_bans.sql
  4129. ===================================================================
  4130.  
  4131.  
  4132. DROP TABLE IF EXISTS `hwid_bans`;
  4133. CREATE TABLE `hwid_bans` (
  4134. `HWID` varchar(32) DEFAULT NULL,
  4135. `HWIDSecond` varchar(32) DEFAULT NULL,
  4136. `expiretime` int(11) NOT NULL DEFAULT '0',
  4137. `comments` varchar(255) DEFAULT '',
  4138. UNIQUE KEY `HWID` (`HWID`)
  4139. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  4140.  
  4141. Index: hwid_info.sql
  4142. ===================================================================
  4143.  
  4144.  
  4145. DROP TABLE IF EXISTS `hwid_info`;
  4146. CREATE TABLE `hwid_info` (
  4147. `HWID` varchar(32) NOT NULL DEFAULT '',
  4148. `WindowsCount` int(10) unsigned NOT NULL DEFAULT '1',
  4149. `Account` varchar(45) NOT NULL DEFAULT '',
  4150. `PlayerID` int(10) unsigned NOT NULL DEFAULT '0',
  4151. `LockType` enum('PLAYER_LOCK','ACCOUNT_LOCK','NONE') NOT NULL DEFAULT 'NONE',
  4152. PRIMARY KEY (`HWID`)
  4153. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  4154.  
  4155.  
  4156.  
  4157. Admin_commands_rights.sql
  4158. ===================================================================
  4159.  
  4160.  
  4161. INSERT INTO `admin_command_access_rights` VALUES('admin_ban_hwid','1');
  4162.  
  4163.  
  4164.  
  4165. config/Hwid.properties
  4166. ===============================================================
  4167.  
  4168. # Allow Guard Protection System
  4169. AllowGuardSystem = True
  4170.  
  4171. # Licence Key
  4172. UserName =
  4173.  
  4174. # =================================================================
  4175. # Protection 2.0 - Key Configurations - Not Change
  4176. # Range of versions of protection client modules
  4177. FstKey = 112
  4178. ScnKey = 56
  4179. AnpKey = -5
  4180. UltKey = 12
  4181.  
  4182. # Not Change values
  4183. ServerKey = aHR0cDovL3RzLnZvdGUtZ2FtZXMuY29tL25HdWFyZDIvbnBnbXVwLnBocA==
  4184. ClientKey = aHR0cDovL3ZndWFyZC5wcm8vbkd1YXJkMi9ucGdtdXAucGhw
  4185. # =================================================================
  4186. # Installing client HWID
  4187. # 1 = HWID HDD
  4188. # 2 = HWID MAC
  4189. # 3 = HWID CPU
  4190. UseClientHWID = 2
  4191. KickWithEmptyHWID = False
  4192. KickWithLastErrorHWID = False
  4193.  
  4194. # Configure the number of open windows client
  4195. # If 0 = Unlimited
  4196. # 1 = 2 players for HWID, 2 = 3 players for HWID
  4197. AllowedWindowsCount = 10
  4198.  
  4199.  
  4200. # Dont use in Interlude only Freya/H5
  4201. EnableHWIDLock = False
  4202. # =================================================================
  4203. # LOGS
  4204. # Enable log on Console Server - Player, HWID, NAME, ID
  4205. EnableConsoleLog = False
  4206.  
  4207. EnableHWIDBans = True
  4208. EnableHWIDBonus = False
  4209. StoreHWID = True
  4210. LogHWIDs = True
  4211.  
  4212. #=============================================
  4213. #EDIT PROTOCOL revision in : config/functions/developer
  4214. #=============================================
  4215. #BETTER NOT EDIT!!
Add Comment
Please, Sign In to add comment