-
Notifications
You must be signed in to change notification settings - Fork 32
/
CharlesKeygen.java
243 lines (206 loc) · 6.68 KB
/
CharlesKeygen.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/* Charles Proxy Keygen */
/* Cracked on 27042020 by @0xduraki via RC5 dec. */
/** usage: */
//$ javac CharlesKeygen.java && java CharlesKeygen "0XDURAKI"
// @see: https://github.com/duraki/charles-keygen
// @see: https://twitter.com/0xduraki
class CharlesKeygen {
public static void main(String[] args) {
if (args.length == 1) {
String name = args[0];
System.out.print("* GENERATED LICENSE:\n [" + name + ":" + calcLicenseKey(name) + "]\n");
return;
}
System.out.print("Charles Proxy - License Key Generator [ALL VERSIONS]\n");
System.out.print("Proudly presented by >> Team 0xCHAOS\n");
System.out.print("**"+"Usage:\n");
System.out.print("$ CharlesKeygen \"TEAM0XCHAOS\"\n\n");
if (args.length != 1) {
System.out.print("Error: Missing License Name ...\n");
return;
}
}
public static String calcLicenseKey(String licenseName) {
int licenseKeyChecksum = 1418211210;
int licenseNameChecksum = licenseNameChecksum(licenseName);
licenseKeyChecksum ^= licenseNameChecksum;
long bLicenseKey = licenseKeyChecksum;
bLicenseKey <<= 32L;
bLicenseKey >>>= 32L;
bLicenseKey <<= 32L;
bLicenseKey |= 0x1CAD6BCL;
int keyEncMin = (int)(bLicenseKey & 0xFFFFFFFFFFFFFFFFL);
int keyEncMax = (int)(bLicenseKey >>> 32L & 0xFFFFFFFFFFFFFFFFL);
int[] keyEnc = new int[2];
keyEnc[0] = keyEncMin;
keyEnc[1] = keyEncMax;
int[] keyDec = new int[2];
RC5 decrypter = new RC5();
decrypter.RC5_SETUP(-334581843, -1259282228);
decrypter.RC5_DECRYPT(keyEnc, keyDec);
long keyDecrypted = (keyDec[1] & 0xFFFFFFFFL) << 32L;
keyDecrypted |= keyDec[0] & 0xFFFFFFFFL;
int xorChecksum = xorChecksum(bLicenseKey);
String finalKey = Integer.toHexString(xorChecksum) + Long.toHexString(keyDecrypted);
finalKey = String.format("%02X", new Object[] { Integer.valueOf(xorChecksum) }) + String.format("%016X", new Object[] { Long.valueOf(keyDecrypted) });
return finalKey;
}
public static int licenseNameChecksum(String licenseName) {
byte[] bArrayName = null;
try {
bArrayName = licenseName.getBytes("UTF-8");
} catch (Exception e) {
System.out.println(e.toString());
}
int nameLen = bArrayName.length;
int n = nameLen + 4;
if (n % 8 != 0)
n += 8 - n % 8;
byte[] arrbChecksum = new byte[n];
System.arraycopy(bArrayName, 0, arrbChecksum, 4, nameLen);
arrbChecksum[0] = (byte)(nameLen >> 24);
arrbChecksum[1] = (byte)(nameLen >> 16);
arrbChecksum[2] = (byte)(nameLen >> 8);
arrbChecksum[3] = (byte)nameLen;
RC5 r = new RC5();
r.RC5_SETUP(1763497072, 2049034577);
byte[] outputArray = r.RC5_EncryptArray(arrbChecksum);
int n3 = 0;
for (byte by : outputArray) {
n3 ^= by;
n3 = n3 << 3 | n3 >>> 29;
}
return n3;
}
private static final int xorChecksum(long l) {
long l2 = 0L;
for (int i = 56; i >= 0; i -= 8)
l2 ^= l >>> i & 0xFFL;
return Math.abs((int)(l2 & 0xFFL));
}
public static byte[] hexToByteArray(String hexstring) {
int len = hexstring.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2)
data[i / 2] = (byte)((Character.digit(hexstring.charAt(i), 16) << 4) + Character.digit(hexstring.charAt(i + 1), 16));
return data;
}
}
class RC5 {
public static final int w = 32;
public static final int r = 12;
public static final int b = 8;
public static final int c = 2;
public static final int t = 26;
public int[] S = new int[26];
public int P = -1209970333;
public int Q = -1640531527;
public byte[] RC5_DecryptArray(byte[] arrby) {
byte[] arrby2 = new byte[arrby.length];
int n = arrby.length;
int n2 = 0;
long l = 0L;
int l1 = 0, l2 = 0;
for (int i = 0; i < n; i++) {
if (l < 4L) {
l1 <<= 8;
l1 |= arrby[i] & 0xFF;
} else {
l2 <<= 8;
l2 |= arrby[i] & 0xFF;
}
l++;
if (++n2 == 8) {
int[] ct = { l2, l1 };
int[] pt = { 0, 0 };
RC5_DECRYPT(ct, pt);
arrby2[i - 7] = (byte)(pt[1] >>> 24);
arrby2[i - 6] = (byte)(pt[1] >>> 16);
arrby2[i - 5] = (byte)(pt[1] >>> 8);
arrby2[i - 4] = (byte)pt[1];
arrby2[i - 3] = (byte)(pt[0] >>> 24);
arrby2[i - 2] = (byte)(pt[0] >>> 16);
arrby2[i - 1] = (byte)(pt[0] >>> 8);
arrby2[i] = (byte)pt[0];
n2 = 0;
l = 0L;
l1 = 0;
l2 = 0;
}
}
return arrby2;
}
public byte[] RC5_EncryptArray(byte[] arrby) {
byte[] arrby2 = new byte[arrby.length];
int n = arrby.length;
int n2 = 0;
long l = 0L;
int l1 = 0, l2 = 0;
for (int i = 0; i < n; i++) {
if (l < 4L) {
l1 <<= 8;
l1 |= arrby[i] & 0xFF;
} else {
l2 <<= 8;
l2 |= arrby[i] & 0xFF;
}
l++;
if (++n2 == 8) {
int[] pt = { l2, l1 };
int[] ct = { 0, 0 };
RC5_ENCRYPT(pt, ct);
arrby2[i - 7] = (byte)(ct[1] >>> 24);
arrby2[i - 6] = (byte)(ct[1] >>> 16);
arrby2[i - 5] = (byte)(ct[1] >>> 8);
arrby2[i - 4] = (byte)ct[1];
arrby2[i - 3] = (byte)(ct[0] >>> 24);
arrby2[i - 2] = (byte)(ct[0] >>> 16);
arrby2[i - 1] = (byte)(ct[0] >>> 8);
arrby2[i] = (byte)ct[0];
n2 = 0;
l = 0L;
l1 = 0;
l2 = 0;
}
}
return arrby2;
}
void RC5_ENCRYPT(int[] pt, int[] ct) {
int A = pt[0] + this.S[0];
int B = pt[1] + this.S[1];
for (int i = 1; i <= 12; i++) {
A = ((A ^ B) << (B & 0x1F) | (A ^ B) >>> 32 - (B & 0x1F)) + this.S[2 * i];
B = ((B ^ A) << (A & 0x1F) | (B ^ A) >>> 32 - (A & 0x1F)) + this.S[2 * i + 1];
}
ct[0] = A;
ct[1] = B;
}
void RC5_DECRYPT(int[] ct, int[] pt) {
int B = ct[1];
int A = ct[0];
for (int i = 12; i > 0; i--) {
B = (B - this.S[2 * i + 1] >>> (A & 0x1F) | B - this.S[2 * i + 1] << 32 - (A & 0x1F)) ^ A;
A = (A - this.S[2 * i] >>> (B & 0x1F) | A - this.S[2 * i] << 32 - (B & 0x1F)) ^ B;
}
pt[1] = B - this.S[1];
pt[0] = A - this.S[0];
}
void RC5_SETUP(int l, int h) {
int u = 4;
int[] L = new int[2];
L[0] = l;
L[1] = h;
int i;
for (this.S[0] = this.P, i = 1; i < 26; i++)
this.S[i] = this.S[i - 1] + this.Q;
int j;
for (int k = 0, B = i = j = k = 0, A = B; k < 78; k++, i = (i + 1) % 26, j = (j + 1) % 2) {
A = this.S[i] = this.S[i] + A + B << 3 | this.S[i] + A + B >>> 29;
B = L[j] = L[j] + A + B << (A + B & 0x1F) | L[j] + A + B >>> 32 - (A + B & 0x1F);
}
System.out.println();
}
public static String hex(int n) {
return String.format("0x%s", new Object[] { Integer.toHexString(n) }).replace(' ', '0');
}
}