JetBrains IDEs

1import java.io.BufferedReader; 2import java.io.ByteArrayOutputStream; 3import java.io.File; 4import java.io.FileInputStream; 5import java.io.FileOutputStream; 6import java.io.IOException; 7import java.io.InputStream; 8import java.io.InputStreamReader; 9import java.io.OutputStream; 10import java.math.BigInteger; 11import java.util.Random; 12import java.util.zip.CRC32; 13import java.util.zip.ZipEntry; 14import java.util.zip.ZipFile; 15import java.util.zip.ZipInputStream; 16import java.util.zip.ZipOutputStream; 17 18/** 19 * Created by rover12421 on 4/6/15. 20 */ 21public class Main { 22 public enum Product { 23 RubyMine(1, "RubyMine", GenericKeyMaker.PRODUCTID_RubyMine, "BB62FBB57F105CD61B47AE2290FCB3CE1179942DE171BEDDF6BAA1A521B9368B735C7C931902EBA8DE6D160711A6ECC40F4A5E766E9FCDEE8A38715DB572AD3D", "7BFADCB153F59E86E69BC1820B4DB72573786E6B00CB824E57AD59BFE915231972746F47C6FBE0D8D88809DA313C1E4BEAD305AD8AFD31AE116ABCB181FF4F21", true), 24 PyCharm(2, "PyCharm", GenericKeyMaker.PRODUCTID_PyCharm, "D57B0596A03949D9A3BB0CD1F7931E405AE27D0E0AF4E562072B487B0DAB7F0874AA982E5383E75FF13D36CA9D8531AC1FA2ED7B11C8858E821C2D5FB48002DD", "406047D02363033D295DB7C0FD8A94DDCD4A6D71B5A622220C8D65DF0DC1409E0BDE26AF66B0AD717406C22FC8BEC3ED88C1B7091BA3443B6BFBA26120DE6A15", true), 25 WebStorm(3, "WebStorm", GenericKeyMaker.PRODUCTID_WebStorm, "BB62FBB57F105CD61B47AE2290FCB3CE1179942DE171BEDDF6BAA1A521B9368B735C7C931902EBA8DE6D160711A6ECC40F4A5E766E9FCDEE8A38715DB572AD3D", "7BFADCB153F59E86E69BC1820B4DB72573786E6B00CB824E57AD59BFE915231972746F47C6FBE0D8D88809DA313C1E4BEAD305AD8AFD31AE116ABCB181FF4F21", true), 26 PhpStorm(4, "PhpStorm", GenericKeyMaker.PRODUCTID_PhpStorm, "BB62FBB57F105CD61B47AE2290FCB3CE1179942DE171BEDDF6BAA1A521B9368B735C7C931902EBA8DE6D160711A6ECC40F4A5E766E9FCDEE8A38715DB572AD3D", "7BFADCB153F59E86E69BC1820B4DB72573786E6B00CB824E57AD59BFE915231972746F47C6FBE0D8D88809DA313C1E4BEAD305AD8AFD31AE116ABCB181FF4F21", true), 27 AppCode(5, "AppCode", GenericKeyMaker.PRODUCTID_AppCode, "F0DD6995C4BD3223641C79C8608D74F32ED54A8BDAE468EB5AC53F1F1C8925E263F82317356BC73B1C82B520630250212416C99CB39A8B7C2611E35552E166B9", "81B5EAEF61A4B584839C26253781D63243CD4F38E3A74FAD3713B3FB7025978538F10E743456F24BB20D5792BFDCB76DB6162C3D5C77DB7B29906CBFC9114EA5", true), 28 Clion(6, "Clion", GenericKeyMaker.PRODUCTID_CLION, "C4AD4C091E08E5688B81B837506EB84D103FB3B2165F62E61C74B345D28C4A0CD0BE2FADF485883D0DDD4E24AAB758716027E84D420DE525B042A70FF8174031", "6FAADD5307E4912C4C993858DFA81DA853A3778993BE50CECA35505C427138D112D75AA22924E9317270C88B164C31C17C5A43B359F21DABFE923A7482DD7401", true), 29 Idea(7, "Idea", GenericKeyMaker.PRODUCTID_IDEA, "430D187DE8BB3F18FB0A986E6B7163BD", "86F71688CDD2612CA117D1F54BDAE029", false),; 30 private int id; 31 private String name; 32 private int productId; 33 private String pubKey; 34 private String privKey; 35 private boolean isRSA; 36 37 Product(int id, String name, int productId, String pubKey, String privKey, boolean isRSA) { 38 this.id = id; 39 this.name = name; 40 this.pubKey = pubKey; 41 this.privKey = privKey; 42 this.productId = productId; 43 this.isRSA = isRSA; 44 } 45 46 public int getId() { 47 return id; 48 } 49 50 public String getName() { 51 return name; 52 } 53 54 public BigInteger getPubKey() { 55 return new BigInteger(pubKey, 16); 56 } 57 58 public BigInteger getPrivKey() { 59 return new BigInteger(privKey, 16); 60 } 61 62 public int getProductId() { 63 return productId; 64 } 65 66 public boolean isRSA() { 67 return isRSA; 68 } 69 70 public static Product valueOf(int id) { 71 for (Product product : Product.values()) { 72 if (product.getId() == id) { 73 return product; 74 } 75 } 76 77 return null; 78 } 79 80 @Override 81 public String toString() { 82 return id + ". " + name; 83 } 84 } 85 86 public static void main(String[] args) throws IOException { 87// System.out.println("Jetbrains's Product Patch or Keygen."); 88// System.out.println("Crack by Rover12421."); 89// System.out.println("Http://Www.Rover12421.Com"); 90// System.out.println("Please support genuine(https://www.jetbrains.com)."); 91// printSelectProduct(); 92// int sel; 93// Product product = null; 94// while (true) { 95// try { 96// sel = Integer.parseInt(readLine()); 97// if ((product = Product.valueOf(sel)) != null) { 98// break; 99// } 100// } catch (Throwable e) { 101// } 102// 103// System.out.println("Enter err!"); 104// printSelectProduct(); 105// } 106// 107// System.out.println("Please enter your username :"); 108// String userName = readLine(); 109 String userName = "cylee"; 110 Product product = Product.Clion; 111 if (product == product.Clion) { 112 System.out.println("Clion need patch"); 113 System.out.println("Please enter your Clion install path or clion.jar path :"); 114// String path = readLine(); 115// while (!ClionPatch.patch(path)) { 116// System.out.println("Clion install path or clion.jar path error!"); 117// System.out.println("Please re-enter!"); 118// path = readLine(); 119// } 120 121 String path = "D:\\Program Files (x86)\\JetBrains\\CLion 2016.1.2"; 122 System.out.println(ClionPatch.patch(path)); 123 } 124 125 System.out.println("---------------------------------------"); 126 127 GenericKeyMaker keyMaker = new GenericKeyMaker(); 128 if (product.isRSA) { 129 System.out.println(keyMaker.generateRSAKey(product.getPrivKey(), product.getPubKey(), GenericKeyMaker.LICENSETYPE_NON_COMMERCIAL, product.getProductId(), 1, 13, userName)); 130 } else { 131 System.out.println(keyMaker.generateNoRSAKey(product.getPrivKey(), product.getPubKey(), GenericKeyMaker.LICENSETYPE_NON_COMMERCIAL, product.getProductId(), 1, 14, userName)); 132 } 133 } 134 135 private static void printSelectProduct() { 136 System.out.println(); 137 System.out.println("Please select product:"); 138 for (Product product : Product.values()) { 139 System.out.println(product); 140 } 141 } 142 143 private static String readLine() throws IOException { 144 InputStreamReader isr = new InputStreamReader(System.in); 145 BufferedReader br = new BufferedReader(isr); 146 return br.readLine(); 147 } 148 149 150 public static class ClionPatch { 151 public static boolean patch(String src) throws IOException { 152 File file = new File(src); 153 if (file.isDirectory()) { 154 File f = new File(file, "lib/clion.jar"); 155 if (f.exists()) { 156 file = f; 157 } else { 158 f = new File(file, "clion.jar"); 159 if (f.exists()) { 160 file = f; 161 } 162 } 163 } 164 165 if (file.isDirectory() || !file.exists()) { 166 System.out.println("Err : Not found clion.jar."); 167 return false; 168 } 169 170 File patch = File.createTempFile("clion", "_patch.jar", file.getParentFile()); 171 172 byte[] srcKey = "8eeb1420b7d8b90aa3b95c7ff73628e46e12c19dc91531be5f517a54b042e99c17445ce7b23834a3ec80d2691b463231be43aab7e897cc334bc9b8bb9f0d55f5".getBytes(); 173 byte[] desKey = "c4ad4c091e08e5688b81b837506eb84d103fb3b2165f62e61c74b345d28c4a0cd0be2fadf485883d0ddd4e24aab758716027e84d420de525b042a70ff8174031".getBytes(); 174 175 boolean isPatch = false; 176 boolean patched = false; 177 try { 178 FileInputStream fis = new FileInputStream(file); 179 ZipInputStream zis = new ZipInputStream(fis); 180 ZipFile zipFile = new ZipFile(file); 181 182 FileOutputStream fos = new FileOutputStream(patch); 183 ZipOutputStream zos = new ZipOutputStream(fos); 184 ZipEntry entry; 185 while ((entry = zis.getNextEntry()) != null) { 186 ZipEntry outEntry = new ZipEntry(entry); 187 try { 188 InputStream is = zipFile.getInputStream(entry); 189 if (entry.getName().endsWith(".class")) { 190 byte[] buff = readInputStream(is); 191 int index = indexOf(buff, srcKey); 192 if (index > 0) { 193 System.out.println("Find Key. Patch..."); 194 System.arraycopy(desKey, 0, buff, index, desKey.length); 195 CRC32 crc32 = new CRC32(); 196 crc32.update(buff); 197 outEntry.setCrc(crc32.getValue()); 198 isPatch = true; 199 } else { 200 if (indexOf(buff, desKey) > 0) { 201 System.out.println("Patched!"); 202 patched = true; 203 break; 204 } 205 } 206 zos.putNextEntry(outEntry); 207 zos.write(buff); 208 zos.closeEntry(); 209 } else { 210 zos.putNextEntry(outEntry); 211 copyStream(is, zos); 212 zos.closeEntry(); 213 } 214 } catch (Exception e) { 215 } 216 } 217 } catch (Exception e) { 218 } 219 if (patched) { 220 patch.delete(); 221 return true; 222 } 223 224 if (isPatch) { 225 file.renameTo(new File(file.getAbsolutePath() + ".bak")); 226 patch.renameTo(file); 227 } else { 228 patch.delete(); 229 } 230 return isPatch; 231 } 232 233 public static void copyStream(InputStream is, OutputStream os) throws IOException { 234 final int BUFFER_SIZE = 8 * 1024; 235 if (is == null || os == null) { 236 throw new IOException("Argument is null."); 237 } 238 239 byte[] bytes = new byte[BUFFER_SIZE]; 240 while (true) { 241 int count = is.read(bytes, 0, BUFFER_SIZE); 242 if (count == -1) { 243 break; 244 } 245 os.write(bytes, 0, count); 246 } 247 } 248 249 public static byte[] readInputStream(InputStream input) { 250 byte[] data = null; 251 try { 252 ByteArrayOutputStream output = new ByteArrayOutputStream(); 253 final byte[] buffer = new byte[1024]; 254 int len = 0; 255 while ((len = input.read(buffer)) != -1) { 256 output.write(buffer, 0, len); 257 } 258 data = output.toByteArray(); 259 output.close(); 260 input.close(); 261 } catch (IOException e) { 262 e.printStackTrace(); 263 } 264 265 return data; 266 } 267 268 /** 269 * Search the data byte array for the first occurrence 270 * of the byte array pattern. 271 */ 272 public static int indexOf(byte[] data, byte[] pattern) { 273 int[] failure = computeFailure(pattern); 274 275 int j = 0; 276 277 for (int i = 0; i < data.length; i++) { 278 while (j > 0 && pattern[j] != data[i]) { 279 j = failure[j - 1]; 280 } 281 if (pattern[j] == data[i]) { 282 j++; 283 } 284 if (j == pattern.length) { 285 return i - pattern.length + 1; 286 } 287 } 288 return -1; 289 } 290 291 /** 292 * Computes the failure function using a boot-strapping process, 293 * where the pattern is matched against itself. 294 */ 295 private static int[] computeFailure(byte[] pattern) { 296 int[] failure = new int[pattern.length]; 297 298 int j = 0; 299 for (int i = 1; i < pattern.length; i++) { 300 while (j > 0 && pattern[j] != pattern[i]) { 301 j = failure[j - 1]; 302 } 303 if (pattern[j] == pattern[i]) { 304 j++; 305 } 306 failure[i] = j; 307 } 308 309 return failure; 310 } 311 312 } 313 314 315 public static class GenericKeyMaker { 316 public static final int LICENSETYPE_NON_COMMERCIAL = 1; 317 public static final int PRODUCTID_IDEA = 1; 318 public static final int PRODUCTID_RubyMine = 4; 319 public static final int PRODUCTID_PyCharm = 5; 320 public static final int PRODUCTID_WebStorm = 6; 321 public static final int PRODUCTID_PhpStorm = 7; 322 public static final int PRODUCTID_AppCode = 8; 323 public static final int PRODUCTID_CLION = 10; 324 325 private Random random = new Random(); 326 327 private String getLicenseId() { 328 return String.format("D%sT", Integer.toString(random.nextInt(90000) + 10000)); 329 } 330 331 private short getCRC(String s, int i, byte bytes[]) { 332 CRC32 crc32 = new CRC32(); 333 if (s != null) { 334 for (int j = 0; j < s.length(); j++) { 335 char c = s.charAt(j); 336 crc32.update(c); 337 } 338 } 339 crc32.update(i); 340 crc32.update(i >> 8); 341 crc32.update(i >> 16); 342 crc32.update(i >> 24); 343 for (int k = 0; k < bytes.length - 2; k++) { 344 byte byte0 = bytes[k]; 345 crc32.update(byte0); 346 } 347 return (short) (int) crc32.getValue(); 348 } 349 350 private byte[] generateKeyBytes14(int licenseType, int productId, 351 int minorVersion, int majorVersion, 352 String userName, int customerId) { 353 byte[] keyBytes = new byte[14]; 354 keyBytes[0] = (byte) ((licenseType << 4) + (productId & 0xFF)); 355 keyBytes[1] = (byte) ((minorVersion << 4) + (majorVersion & 0xFF)); 356 long time = System.currentTimeMillis() >> 16; 357 keyBytes[2] = (byte) (int) (time & 0xFF); 358 keyBytes[3] = (byte) (int) (time >> 8 & 0xFF); 359 keyBytes[4] = (byte) (int) (time >> 16 & 0xFF); 360 keyBytes[5] = (byte) (int) (time >> 24 & 0xFF); 361 long timeDiff = Long.MAX_VALUE; 362 keyBytes[6] = (byte) (int) (timeDiff & 0xFF); 363 keyBytes[7] = (byte) (int) (timeDiff >> 8 & 0xFF); 364 keyBytes[8] = 0; 365 keyBytes[9] = 1; 366 keyBytes[10] = 2; 367 keyBytes[11] = 3; 368 369 int crc32 = getCRC(userName, customerId, keyBytes); 370 keyBytes[12] = (byte) (crc32 & 0xFF); 371 keyBytes[13] = (byte) (crc32 >> 8 & 0xFF); 372 373 return keyBytes; 374 } 375 376 private byte[] generateKeyBytes12(int licenseType, int productId, 377 int minorVersion, int majorVersion, 378 String userName, int customerId) { 379 byte[] keyBytes = new byte[12]; 380 keyBytes[0] = (byte) ((licenseType << 4) + (productId & 0xFF)); 381 keyBytes[1] = (byte) ((minorVersion << 4) + (majorVersion & 0xFF)); 382 long time = System.currentTimeMillis() >> 16; 383 keyBytes[2] = (byte) (int) (time & 0xFF); 384 keyBytes[3] = (byte) (int) (time >> 8 & 0xFF); 385 keyBytes[4] = (byte) (int) (time >> 16 & 0xFF); 386 keyBytes[5] = (byte) (int) (time >> 24 & 0xFF); 387 long timeDiff = Long.MAX_VALUE; 388 keyBytes[6] = (byte) (int) (timeDiff & 0xFF); 389 keyBytes[7] = (byte) (int) (timeDiff >> 8 & 0xFF); 390 keyBytes[8] = 105; 391 keyBytes[9] = -59; 392 393 int crc32 = getCRC(userName, customerId, keyBytes); 394 keyBytes[10] = (byte) (crc32 & 0xFF); 395 keyBytes[11] = (byte) (crc32 >> 8 & 0xFF); 396 397 return keyBytes; 398 } 399 400 /** 401 * @param biginteger 402 * @return String 403 */ 404 public static String encodeGroups(BigInteger biginteger) { 405 BigInteger beginner1 = BigInteger.valueOf(0x39aa400L); 406 StringBuilder sb = new StringBuilder(); 407 for (int i = 0; biginteger.compareTo(BigInteger.ZERO) != 0; i++) { 408 int j = biginteger.mod(beginner1).intValue(); 409 String s1 = encodeGroup(j); 410 if (i > 0) { 411 sb.append("-"); 412 } 413 sb.append(s1); 414 biginteger = biginteger.divide(beginner1); 415 } 416 return sb.toString(); 417 } 418 419 /** 420 * @param i 421 * @return 422 */ 423 public static String encodeGroup(int i) { 424 StringBuilder sb = new StringBuilder(); 425 for (int j = 0; j < 5; j++) { 426 int k = i % 36; 427 char c; 428 if (k < 10) { 429 c = (char) (48 + k); 430 } else { 431 c = (char) ((65 + k) - 10); 432 } 433 sb.append(c); 434 i /= 36; 435 } 436 return sb.toString(); 437 } 438 439 public String generateRSAKey(BigInteger privKey, BigInteger pubKey, 440 int licenseType, int productId, 441 int minorVersion, int majorVersion, 442 String userName) { 443 int customerId = random.nextInt(9000) + 1000; 444 byte[] keyBytes = generateKeyBytes14(licenseType, productId, minorVersion, majorVersion, userName, customerId); 445 RSAEncoder encoder = new RSAEncoder(privKey, pubKey, 64, false); 446 String serial = encoder.encode(keyBytes); 447 serial = "===== LICENSE BEGIN =====\n" + customerId + "-" + getLicenseId() + "\n" + serial + "\n===== LICENSE END ====="; 448 return serial; 449 } 450 451 public String generateNoRSAKey(BigInteger privKey, BigInteger pubKey, 452 int licenseType, int productId, 453 int minorVersion, int majorVersion, 454 String userName) { 455 int customerId = random.nextInt(9000) + 1000; 456 byte[] keyBytes = generateKeyBytes12(licenseType, productId, minorVersion, majorVersion, userName, customerId); 457 458 BigInteger k0 = new BigInteger(keyBytes); 459 BigInteger k1 = k0.modPow(pubKey, privKey); 460 String s0 = Integer.toString(customerId); 461 String sz = "0"; 462 while (s0.length() != 5) { 463 s0 = sz.concat(s0); 464 } 465 s0 = s0.concat("-"); 466 String s1 = encodeGroups(k1); 467 s0 = s0.concat(s1); 468 return s0; 469 } 470 } 471 472 // ================================ // 473 public static class RSAEncoder { 474 private final BigInteger privKey; 475 private final BigInteger pubKey; 476 private final int c; 477 private final int d; 478 private int e = 0; 479 private final BigInteger f; 480 private final boolean g; 481 482 public RSAEncoder(BigInteger privKey, BigInteger pubKey, int len, boolean newLine) { 483 this.privKey = privKey; 484 this.pubKey = pubKey; 485 this.g = newLine; 486 int privKeyLen = privKey.bitLength(); 487 this.f = new BigInteger(String.valueOf(len)); 488 int i = (int) Math.ceil(privKeyLen / Math.log(len) * Math.log(2.0D)); 489 if (i % 5 != 0) { 490 i = (i / 5 + 1) * 5; 491 } 492 this.d = i; 493 this.c = (privKeyLen / 8 - 1); 494 } 495 496 public String encode(byte[] bytes) { 497 int i = bytes.length % this.c; 498 byte[] arrayOfByte = new byte[i == 0 ? bytes.length : bytes.length + this.c - i]; 499 System.arraycopy(bytes, 0, arrayOfByte, this.c - i, bytes.length); 500 501 StringBuffer stringBuffer = new StringBuffer(); 502 for (int j = 0; j < arrayOfByte.length; j += this.c) { 503 encode(arrayOfByte, stringBuffer, j, this.c); 504 } 505 return stringBuffer.toString(); 506 } 507 508 private void encode(byte[] bytes, StringBuffer stringBuffer, int off, int len) { 509 if (len == 0) { 510 return; 511 } 512 byte[] arrayOfByte = new byte[this.c]; 513 System.arraycopy(bytes, off, arrayOfByte, 0, len); 514 BigInteger localBigInteger1 = new BigInteger(1, arrayOfByte); 515 if (localBigInteger1.compareTo(this.pubKey) >= 0) { 516 throw new IllegalArgumentException("result is too long"); 517 } 518 BigInteger localBigInteger2 = localBigInteger1.modPow(this.privKey, this.pubKey); 519 stringBuffer.append(a(a(localBigInteger2))); 520 } 521 522 private String a(String paramString) { 523 StringBuffer localStringBuffer = new StringBuffer(); 524 for (int i = 0; i < paramString.length(); i++) { 525 a(localStringBuffer); 526 localStringBuffer.append(paramString.charAt(i)); 527 } 528 return localStringBuffer.toString(); 529 } 530 531 private String a(BigInteger paramBigInteger) { 532 StringBuffer localStringBuffer = new StringBuffer(); 533 for (int i = 0; i < this.d; i++) { 534 localStringBuffer.insert(0, b(paramBigInteger.mod(this.f))); 535 paramBigInteger = paramBigInteger.divide(this.f); 536 } 537 return localStringBuffer.toString(); 538 } 539 540 private void a(StringBuffer paramStringBuffer) { 541 if ((this.e > 0) && (this.e % 5 == 0)) { 542 if (this.e % 30 == 0) 543 paramStringBuffer.append('\n'); 544 else if (this.g) { 545 paramStringBuffer.append('-'); 546 } 547 } 548 this.e += 1; 549 } 550 551 private static char b(BigInteger paramBigInteger) { 552 int i = paramBigInteger.intValue(); 553 char c1; 554 if (i < 10) { 555 c1 = (char) (48 + i); 556 } else { 557 if (i < 36) { 558 c1 = (char) (65 + i - 10); 559 } else { 560 if (i < 62) 561 c1 = (char) (97 + i - 36); 562 else { 563 c1 = (char) (33 + i - 62); 564 } 565 } 566 } 567 return c1; 568 } 569 } 570}
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )