Skip to content

Commit 0c4bfd4

Browse files
authored
Merge pull request #11 from kubune/main
Version 59 update
2 parents c5914ff + 7d821ce commit 0c4bfd4

File tree

6 files changed

+60
-26
lines changed

6 files changed

+60
-26
lines changed

Crypto/PepperCrypto.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ crypto = require("crypto");
44

55
module.exports = class {
66
constructor() {
7-
this.server_public_key = fromHexString("F7C80C59E42D4165A32D5D440A6939D54D18BB7F1B2335E85650673C27AA974F");
7+
this.server_public_key = fromHexString("5C344B84451436796B735CB62EE38DF813A31798D21294F8C05E0F2B4CA4C047");
88
this.client_secret_key = new Uint8Array(crypto.randomBytes(32));
99
this.client_public_key = new Uint8Array(32);
1010
Nacl.lowlevel.crypto_scalarmult_base(this.client_public_key, this.client_secret_key);

DataStream/ByteStream.js

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,57 @@
1+
const zlib = require('zlib');
2+
13
module.exports = class {
24
constructor(obj) {
35
this.payload = new Uint8Array(obj);
46
this.offset = 0;
57
}
8+
69
set(obj) {
710
this.payload = new Uint8Array(obj);
811
}
12+
913
write(a1) {
1014
this.payload[this.offset++] = a1;
1115
}
12-
read() {
13-
return this.payload[this.offset++];
14-
}
16+
1517
writeUInt(a1) {
1618
this.write(a1 & 0xFF);
1719
}
20+
1821
writeByte(a1) {
1922
this.write(a1);
2023
}
24+
2125
writeBoolean(a1) {
22-
this.write(a1 ? 1: 0);
26+
this.write(a1 ? 1 : 0);
2327
}
28+
2429
writeInt(a1) {
2530
this.write((a1 >> 24) & 0xFF);
2631
this.write((a1 >> 16) & 0xFF);
2732
this.write((a1 >> 8) & 0xFF);
2833
this.write(a1 & 0xFF);
2934
}
35+
36+
writeIntLittleEndian(value) {
37+
this.write(value & 0xFF);
38+
this.write((value >> 8) & 0xFF);
39+
this.write((value >> 16) & 0xFF);
40+
this.write((value >> 24) & 0xFF);
41+
}
42+
43+
writeCompressedString(data) {
44+
const compressedText = zlib.deflateSync(Buffer.from(data));
45+
const totalLength = compressedText.length + 4;
46+
this.writeInt(totalLength);
47+
this.writeIntLittleEndian(data.length);
48+
const newPayload = new Uint8Array(this.payload.length + compressedText.length);
49+
newPayload.set(this.payload.slice(0, this.offset));
50+
newPayload.set(compressedText, this.offset);
51+
this.payload = newPayload;
52+
this.offset += compressedText.length;
53+
}
54+
3055
writeString(a1) {
3156
if (!a1) return this.writeInt(-1);
3257
let b = new Uint8Array(Buffer.from(a1));
@@ -35,12 +60,13 @@ module.exports = class {
3560
this.write(b[strOffset]);
3661
}
3762
}
63+
3864
writeVInt(a1) {
39-
let v1 = (((a1 >> 25) & 0x40) | (a1 & 0x3F)),
40-
v2 = ((a1 ^ (a1 >> 31)) >> 6), v3
41-
65+
let v1 = (((a1 >> 25) & 0x40) | (a1 & 0x3F)),
66+
v2 = ((a1 ^ (a1 >> 31)) >> 6), v3;
67+
4268
a1 >>= 6;
43-
if (v2 == 0) {
69+
if (v2 === 0) {
4470
this.writeByte(v1);
4571
} else {
4672
this.writeByte(v1 | 0x80);
@@ -51,7 +77,7 @@ module.exports = class {
5177
}
5278
this.writeByte((a1 & 0x7F) | v3);
5379
a1 >>= 7;
54-
while (v2 != 0) {
80+
while (v2 !== 0) {
5581
v2 >>= 7;
5682
v3 = 0;
5783
if (v2 > 0) {
@@ -62,46 +88,53 @@ module.exports = class {
6288
}
6389
}
6490
}
91+
6592
writeDataReference(a1, a2) {
6693
this.writeVInt(a1);
67-
if (a1 == 0) return;
94+
if (a1 === 0) return;
6895
this.writeVInt(a2);
6996
}
97+
7098
readDataReference() {
7199
let a1 = this.readVInt();
72-
return [a1, a1 == 0 ? 0 : this.readVInt()];
100+
return [a1, a1 === 0 ? 0 : this.readVInt()];
73101
}
102+
74103
readInt() {
75104
return (this.read() << 24 | this.read() << 16 | this.read() << 8 | this.read());
76105
}
106+
77107
readByte() {
78108
return this.read();
79109
}
110+
80111
readBytes(size) {
81112
let result = new Uint8Array(size);
82113
for (let index = 0; index < size; index++) {
83114
result[index] = this.readByte();
84115
}
85116
return result;
86117
}
118+
87119
readBoolean() {
88120
return Boolean(this.read());
89121
}
122+
90123
readString() {
91124
let len = this.readInt();
92-
if (len <= 0 || len == 4294967295) {
125+
if (len <= 0 || len === 4294967295) {
93126
return "";
94127
}
95128
return Buffer.from(this.readBytes(len)).toString();
96129
}
130+
97131
readVInt() {
98-
// this method is discovered by nameless#1347
99132
let result = 0,
100-
shift = 0, b, seventh, msb, n;
133+
shift = 0, b, seventh, msb, n;
101134

102135
while (true) {
103136
b = this.read();
104-
if (shift == 0) {
137+
if (shift === 0) {
105138
seventh = (b & 0x40) >> 6;
106139
msb = (b & 0x80) >> 7;
107140
n = b << 1;
@@ -116,7 +149,8 @@ module.exports = class {
116149
}
117150
return (result >> 1) ^ (-(result & 1));
118151
}
152+
119153
getBytes() {
120154
return this.payload.slice(0, this.offset);
121155
}
122-
}
156+
};

Messaging/Messages/Client/ClientHelloMessage.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ module.exports = class {
66
}
77
encode() {
88
this.ByteStream.writeInt(2); // protocol version
9-
this.ByteStream.writeInt(47); // crypto version
9+
this.ByteStream.writeInt(48); // crypto version
1010
this.ByteStream.writeInt(settings.major); // major version
1111
this.ByteStream.writeInt(settings.build); // build version
1212
this.ByteStream.writeInt(settings.minor); // minor version
1313
this.ByteStream.writeString(settings.hash); // master hash
14-
this.ByteStream.writeInt(0);
15-
this.ByteStream.writeInt(0);
14+
this.ByteStream.writeInt(2);
15+
this.ByteStream.writeInt(2);
1616
}
1717
}

Messaging/Messages/Client/LoginMessage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = class {
3535
this.ByteStream.writeString();
3636
this.ByteStream.writeString();
3737

38-
this.ByteStream.writeString();
38+
this.ByteStream.writeString(); // Supercell ID Session Token, must be compressed with zlib
3939

4040
this.ByteStream.writeBoolean(false);
4141
this.ByteStream.writeString();

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# BrawlStars-Client
2-
client for brawl stars v58 prod server
2+
Client for brawl stars prod server
33

44
# NOTE
55
This content is not affiliated with, endorsed,sponsored, or specifically approved by supercell and supercell is not responsible for it.
@@ -29,7 +29,7 @@ program will gonna use default values 🙃
2929
this project was made by [S.B#0056](https://github.com/HaccerCat) and [risporce#6552](https://github.com/risporce)
3030

3131
# contributors
32-
[@kubune](https://github.com/kubune) - updated client to game version v58
32+
[@kubune](https://github.com/kubune) - updated client to game version v58 and v59
3333

3434
[@RyfterWasTaken](https://github.com/RyfterWasTaken) - updated hash and minor versions for v58
3535

settings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"hash": "ad243357c65ef991993a73261437c2b0f6aa0d4d",
3-
"major": 58,
4-
"minor": 329,
2+
"hash": "86460ad83cb5e3a4ff8474eddb936d23008dfc1f",
3+
"major": 59,
4+
"minor": 212,
55
"build": 1
66
}

0 commit comments

Comments
 (0)