Skip to content

Commit

Permalink
添加 Keygen 代码
Browse files Browse the repository at this point in the history
  • Loading branch information
lx0758 committed Jul 12, 2021
1 parent 9904a0e commit 2a60478
Show file tree
Hide file tree
Showing 13 changed files with 398 additions and 64 deletions.
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# Charles 破解工具本地版
# Charles Tools

支持 Charles 最新版本的破解,自定义注册名称
## Crack
支持 Charles 最新版本的破解,自定义注册名称。

## 使用原来的网络版本
[立即使用](https://www.zzzmode.com/mytools/charles/)
> [使用原来的网络版本](https://www.zzzmode.com/mytools/charles/)

## 运行

```gradle
### 运行
```bash
gradle run
```

## 更新
### 更新
* 2020-12-02 重写为本地自适应版, 不需要配置文件
* 2020-11-16 Charles 4.6.1
* 2020-01-19 Charles 4.5.6
Expand All @@ -25,5 +23,13 @@ gradle run
* 2018-06-25 Charles 4.2.6
* 2018-04-08 Charles 4.2.5

## License
## Keygen
支持 Charles 激活码生成。

### 运行
```bash
gradle run
```

# License
GPL v3.0
50 changes: 0 additions & 50 deletions build.gradle

This file was deleted.

21 changes: 21 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
group = "com.liux.java.charles"
version = "1.1.0-SNAPSHOT"

allprojects {
buildscript {
repositories {
maven {
setUrl("https://maven.aliyun.com/repository/public/")
}
mavenCentral()
mavenLocal()
}
}
repositories {
maven {
setUrl("https://maven.aliyun.com/repository/public/")
}
mavenCentral()
mavenLocal()
}
}
41 changes: 41 additions & 0 deletions crack/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("java")
id("application")
id("org.jetbrains.kotlin.jvm") version "1.5.20"
}

group = rootProject.group
version = rootProject.version
java.sourceCompatibility = JavaVersion.VERSION_1_8

dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("commons-io:commons-io:2.10.0")
implementation("org.javassist:javassist:3.28.0-GA")
}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}

tasks.withType<Test> {
useJUnitPlatform()
}

val fatJar = task("fatJar", type = Jar::class) {
manifest {
attributes["Main-Class"] = "com.liux.java.charles.crack.Main"
}
from(configurations.compileClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
with(tasks["jar"] as CopySpec)
}
tasks {
"build" {
dependsOn(fatJar)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@file:JvmName("Main")

package com.liux.java.charles
package com.liux.java.charles.crack

import javassist.ClassPool
import javassist.CtClass
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
41 changes: 41 additions & 0 deletions keygen/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("java")
id("application")
id("org.jetbrains.kotlin.jvm") version "1.5.20"
}

group = rootProject.group
version = rootProject.version
java.sourceCompatibility = JavaVersion.VERSION_1_8

dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

testImplementation("org.junit.jupiter:junit-jupiter:5.7.0")
}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}

tasks.withType<Test> {
useJUnitPlatform()
}

val fatJar = task("fatJar", type = Jar::class) {
manifest {
attributes["Main-Class"] = "com.liux.java.charles.keygen.CharlesKeygenUI"
}
from(configurations.compileClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
with(tasks["jar"] as CopySpec)
}
tasks {
"build" {
dependsOn(fatJar)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.liux.java.charles.keygen;

import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.util.Formatter;
import java.util.Random;

public class CharlesKeygen {

private static final Random RANDOM = new SecureRandom();

static final long RC5KEY_NAME = 0x7a21c951691cd470L;

static final long RC5KEY_KEY = 0xb4f0e0ccec0eafadL;

/**
* magic by worked / banned key
*/
static final int NAME_PREFIX = 0x54882f8a;

private CharlesKeygen() {

}

static int calcPrefix(String name) {
final byte[] bytes = name.replaceAll("[  \u180e     ]", " ").getBytes(StandardCharsets.UTF_8);
int length = bytes.length + 4;
int padded = ((~length + 1) & (8 - 1)) + length;
ByteBuffer input = ByteBuffer.allocate(padded).putInt(bytes.length).put(bytes);
input.rewind();

SimpleRC5 rc5 = new SimpleRC5(RC5KEY_NAME);
ByteBuffer output = ByteBuffer.allocate(padded);
while (input.hasRemaining()) {
output.putLong(rc5.encrypt(input.getLong()));
}
output.rewind();

int n = 0;
for (byte b : output.array()) {
n = rc5.rotateLeft(n ^ b, 0x3);
}
return n;
}

static int xor(final long n) {
long n2 = 0L;
for (int i = 56; i >= 0; i -= 8) {
n2 ^= ((n >>> i) & 0xffL);
}
return Math.abs((int) (n2 & 0xffL));
}

static String key(int prefix, int suffix) {
long in = ((long) prefix << 32);
switch (suffix >> 16) {
case 0x0401: // user - v4
case 0x0402: // site - v4
case 0x0403: // multi-site - v4
in |= suffix;
break;
default:
in |= (0x01000000 | (suffix & 0xffffff));
break;
}
long out = new SimpleRC5(RC5KEY_KEY).decrypt(in);
return new Formatter().format("%02x%016x", xor(in), out).toString();
}

public static String keygen(String name) {
return keygen(name, RANDOM.nextInt());
}

public static String keygen(String name, int suffix) {
int prefix = calcPrefix(name) ^ NAME_PREFIX;
return key(prefix, suffix);
}

public static void main(String[] names) {
if (names.length == 0) {
System.err.println("Usage: java -jar charles-keygen.jar name [,...]");
CharlesKeygenUI.main(names);
} else {
for (String name : names) {
System.out.format("Name: %s, Key: %s%n", name, keygen(name));
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.liux.java.charles.keygen;

import java.awt.*;

import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

public class CharlesKeygenUI extends JFrame implements DocumentListener {
private final JTextField textFieldName;
private final JTextField textFieldKey;

public CharlesKeygenUI() {
setSize(310, 120);
setTitle("Charles Keygen");
setResizable(false);
final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setLocation(screenSize.width / 2 - getSize().width / 2, screenSize.height / 2 - getSize().height / 2);

JLabel labelName = new JLabel("Name: ", JLabel.TRAILING);
labelName.setBounds(10, 10, 50, 30);
JLabel labelKey = new JLabel("Key: ", JLabel.TRAILING);
labelKey.setBounds(10, 50, 50, 30);

textFieldName = new JTextField("Cracked", 20);
textFieldName.setBounds(60, 10, 240, 30);
textFieldName.getDocument().addDocumentListener(this);
labelName.setLabelFor(textFieldName);

textFieldKey = new JTextField(20);
textFieldKey.setEditable(false);
textFieldKey.setSize(300, 40);
textFieldKey.setBounds(60, 50, 240, 30);
int fontSize = textFieldKey.getFont().getSize();
textFieldKey.setFont(new Font(Font.MONOSPACED, Font.PLAIN, fontSize));
labelKey.setLabelFor(textFieldKey);

setLayout(null);
Container contentPane = getContentPane();
contentPane.add(labelName);
contentPane.add(textFieldName);
contentPane.add(labelKey);
contentPane.add(textFieldKey);

setDefaultCloseOperation(EXIT_ON_CLOSE);
updateKey();
}

@Override
public void insertUpdate(DocumentEvent e) {
updateKey();
}

@Override
public void removeUpdate(DocumentEvent e) {
updateKey();
}

@Override
public void changedUpdate(DocumentEvent e) {
updateKey();
}

private void updateKey() {
String text = textFieldName.getText();
if (text.isEmpty()) {
textFieldKey.setText("");
} else {
textFieldKey.setText(CharlesKeygen.keygen(text));
}
}

public static void main(String[] arguments) {
if (arguments.length > 0) {
CharlesKeygen.main(arguments);
} else {
new CharlesKeygenUI().setVisible(true);
}
}

}
Loading

0 comments on commit 2a60478

Please sign in to comment.