Skip to content

Commit

Permalink
fix: Re-added tinydec offset arg
Browse files Browse the repository at this point in the history
It was removed by the ConstantArg transformer
  • Loading branch information
Pazaz committed Mar 3, 2024
1 parent ade26c5 commit 7ca848c
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions client/src/main/java/ClanChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void leave() {
public static void join(@OriginalArg(0) String arg0) {
if (!arg0.equals("")) {
Protocol.writeOpcode(ClientProt.PACKET_64);
Protocol.outboundBuffer.p1(Packet.calcPjstrLen(arg0));
Protocol.outboundBuffer.p1(Packet.pjstrlen(arg0));
Protocol.outboundBuffer.pjstr(arg0);
}
}
Expand All @@ -35,7 +35,7 @@ public static void join(@OriginalArg(0) String arg0) {
public static void kick(@OriginalArg(1) String arg0) {
if (members != null) {
Protocol.writeOpcode(ClientProt.PACKET_15);
Protocol.outboundBuffer.p1(Packet.calcPjstrLen(arg0));
Protocol.outboundBuffer.p1(Packet.pjstrlen(arg0));
Protocol.outboundBuffer.pjstr(arg0);
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/CreateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public static void createAccount(@OriginalArg(0) String password, @OriginalArg(2
rsaBuffer.rsaenc(Protocol.EXPONENT, Protocol.MODULUS);
@Pc(118) Packet xteaBuffer = new Packet(350);
xteaBuffer.pjstr(email);
@Pc(131) int padding = 8 - Packet.calcPjstrLen(email) % 8;
@Pc(131) int padding = 8 - Packet.pjstrlen(email) % 8;
for (@Pc(133) int i = 0; i < padding; i++) {
xteaBuffer.p1((int) (Math.random() * 255.0D));
}
Expand Down
6 changes: 3 additions & 3 deletions client/src/main/java/FriendsList.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void remove(@OriginalArg(1) String arg0) {
}
Static53.anInt3971 = InterfaceList.transmitTimer;
Protocol.writeOpcode(ClientProt.PACKET_53);
Protocol.outboundBuffer.p1(Packet.calcPjstrLen(arg0));
Protocol.outboundBuffer.p1(Packet.pjstrlen(arg0));
Protocol.outboundBuffer.pjstr(arg0);
return;
}
Expand Down Expand Up @@ -116,15 +116,15 @@ public static void add(@OriginalArg(0) String arg0) {
Chat.add(Static122.aClass79_54.getLocalized(client.language));
} else {
Protocol.writeOpcode(ClientProt.PACKET_18);
Protocol.outboundBuffer.p1(Packet.calcPjstrLen(arg0));
Protocol.outboundBuffer.p1(Packet.pjstrlen(arg0));
Protocol.outboundBuffer.pjstr(arg0);
}
}

@OriginalMember(owner = "client!jt", name = "a", descriptor = "(IILjava/lang/String;)V")
public static void setRank(@OriginalArg(0) int arg0, @OriginalArg(2) String arg1) {
Protocol.writeOpcode(ClientProt.PACKET_49);
Protocol.outboundBuffer.p1(Packet.calcPjstrLen(arg1) + 1);
Protocol.outboundBuffer.p1(Packet.pjstrlen(arg1) + 1);
Protocol.outboundBuffer.p1_alt1(arg0);
Protocol.outboundBuffer.pjstr(arg1);
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/main/java/IgnoreList.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void remove(@OriginalArg(0) String arg0) {
}
Static53.anInt3971 = InterfaceList.transmitTimer;
Protocol.writeOpcode(ClientProt.PACKET_24);
Protocol.outboundBuffer.p1(Packet.calcPjstrLen(arg0));
Protocol.outboundBuffer.p1(Packet.pjstrlen(arg0));
Protocol.outboundBuffer.pjstr(arg0);
break;
}
Expand Down Expand Up @@ -91,7 +91,7 @@ public static void add(@OriginalArg(0) String arg0, @OriginalArg(1) boolean arg1
Chat.add(Static47.aClass79_27.getLocalized(client.language));
} else {
Protocol.writeOpcode(ClientProt.PACKET_16);
Protocol.outboundBuffer.p1(Packet.calcPjstrLen(arg0) + 1);
Protocol.outboundBuffer.p1(Packet.pjstrlen(arg0) + 1);
Protocol.outboundBuffer.pjstr(arg0);
Protocol.outboundBuffer.p1(arg1 ? 1 : 0);
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/Js5.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private boolean unpackGroup(@OriginalArg(1) int arg0, @OriginalArg(2) int arg1,
} else {
local128 = ByteArray.unwrap(true, this.packed[arg1]);
@Pc(133) Packet local133 = new Packet(local128);
local133.tinydec(arg2, local133.data.length);
local133.tinydec(5, arg2, local133.data.length);
}
@Pc(157) byte[] local157;
try {
Expand Down
26 changes: 13 additions & 13 deletions client/src/main/java/Packet.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// legend:
// "p" prefix - put value
// "g" prefix - get value
// "i" prefix - inverse (little-endian)
// byte suffix - size/data type
// "i" prefix - inverse (little-endian) dealing with other libraries (i.e. audio or OpenGL)
// byte suffix - size/data type - b means "byte" (signed -128 to 127) and s means signed (for its data type)
// "alt" suffix - packet obfuscation type (alt read/write methods)

// alt methods can appear to be "missing" as the *original* obfuscator will remove unused methods
Expand Down Expand Up @@ -71,7 +71,7 @@ public Packet(@OriginalArg(0) byte[] src) {

// calculate size of pjstr output
@OriginalMember(owner = "client!bk", name = "a", descriptor = "(BLjava/lang/String;)I")
public static int calcPjstrLen(@OriginalArg(1) String str) {
public static int pjstrlen(@OriginalArg(1) String str) {
return str.length() + 1;
}

Expand Down Expand Up @@ -103,7 +103,7 @@ public void gdata(@OriginalArg(0) byte[] src, @OriginalArg(2) int length) {
}
}

// get, 2 bytes, signed, alt method 2
// get, 2 bytes signed, alt method 2
@OriginalMember(owner = "client!bt", name = "c", descriptor = "(I)I")
public int g2s_alt2() {
this.pos += 2;
Expand Down Expand Up @@ -231,7 +231,7 @@ public int g1() {
return this.data[this.pos++] & 0xFF;
}

// get, 2 bytes, signed, alt method 3
// get, 2 bytes signed, alt method 3
@OriginalMember(owner = "client!bt", name = "f", descriptor = "(B)I")
public int g2s_alt3() {
this.pos += 2;
Expand All @@ -242,14 +242,14 @@ public int g2s_alt3() {
return value;
}

// get, smart
// get, smart (range of 0 to 32767)
@OriginalMember(owner = "client!bt", name = "g", descriptor = "(B)I")
public int gsmart() {
@Pc(16) int value = this.data[this.pos] & 0xFF;
return value >= 128 ? this.g2() - 32768 : this.g1();
}

// get, smart, signed
// get, smart signed (range of -16384 to 16383)
@OriginalMember(owner = "client!bt", name = "h", descriptor = "(B)I")
public int gsmarts() {
@Pc(19) int value = this.data[this.pos] & 0xFF;
Expand All @@ -264,8 +264,8 @@ public void p1_alt3(@OriginalArg(0) int value) {

// (extended) tiny (encryption algorithm) (XTEA), decrypt
@OriginalMember(owner = "client!bt", name = "a", descriptor = "(II[II)V")
public void tinydec(@OriginalArg(2) int[] key, @OriginalArg(3) int len) {
@Pc(25) int blocks = (len - 5) / 8;
public void tinydec(@OriginalArg(0) int off, @OriginalArg(2) int[] key, @OriginalArg(3) int len) {
@Pc(25) int blocks = (len - off) / 8;
@Pc(16) int start = this.pos;
this.pos = 5;

Expand Down Expand Up @@ -301,7 +301,7 @@ public void pjstr(@OriginalArg(0) String str) {
this.data[this.pos++] = 0;
}

// get, 2 bytes, signed
// get, 2 bytes signed
@OriginalMember(owner = "client!bt", name = "i", descriptor = "(B)I")
public int g2s() {
this.pos += 2;
Expand Down Expand Up @@ -460,7 +460,7 @@ public void p4_alt2(@OriginalArg(1) int value) {
this.data[this.pos++] = (byte) (value >> 16);
}

// get, 1 byte, signed, alt method 3
// get, 1 byte signed, alt method 3
@OriginalMember(owner = "client!bt", name = "j", descriptor = "(I)B")
public byte g1b_alt3() {
return (byte) (128 - this.data[this.pos++]);
Expand Down Expand Up @@ -528,7 +528,7 @@ public void pVarInt(@OriginalArg(1) int value) {
this.p1(value & 0x7F);
}

// get, 2 bytes, signed, alt method 1
// get, 2 bytes signed, alt method 1
@OriginalMember(owner = "client!bt", name = "m", descriptor = "(B)I")
public int g2s_alt1() {
this.pos += 2;
Expand Down Expand Up @@ -564,7 +564,7 @@ public int g2_alt3() {
(this.data[this.pos - 2] - 128 & 0xFF);
}

// get, 1 byte, signed, alt method 1
// get, 1 byte signed, alt method 1
@OriginalMember(owner = "client!bt", name = "o", descriptor = "(B)B")
public byte g1b_alt1() {
return (byte) (this.data[this.pos++] - 128);
Expand Down
4 changes: 2 additions & 2 deletions client/src/main/java/ScriptRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -2874,7 +2874,7 @@ private static void runScript10000(@OriginalArg(0) int opcode, @OriginalArg(1) b
local81 = local81.substring(0, 80);
}
Protocol.writeOpcode(ClientProt.BUG_REPORT);
Protocol.outboundBuffer.p1(Packet.calcPjstrLen(local75) + Packet.calcPjstrLen(local81) + 2);
Protocol.outboundBuffer.p1(Packet.pjstrlen(local75) + Packet.pjstrlen(local81) + 2);
Protocol.outboundBuffer.pjstr(local75);
Protocol.outboundBuffer.p1(local89 - 1);
Protocol.outboundBuffer.p1(local95);
Expand Down Expand Up @@ -3680,7 +3680,7 @@ private static void runScript10000(@OriginalArg(0) int opcode, @OriginalArg(1) b
local81 = stringStack[ssp + 1];
local89 = intStack[--isp];
Protocol.writeOpcode(ClientProt.URL_REQUEST);
Protocol.outboundBuffer.p1(Packet.calcPjstrLen(local75) + Packet.calcPjstrLen(local81) + 1);
Protocol.outboundBuffer.p1(Packet.pjstrlen(local75) + Packet.pjstrlen(local81) + 1);
Protocol.outboundBuffer.pjstr(local75);
Protocol.outboundBuffer.pjstr(local81);
Protocol.outboundBuffer.p1(local89);
Expand Down

0 comments on commit 7ca848c

Please sign in to comment.