Advertisement
VANPER

Protect Hwid

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