-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #175 from yushijinhun/develop
Release v1.2.1
- Loading branch information
Showing
3 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...n/java/moe/yushi/authlibinjector/transform/support/BungeeCordProfileKeyTransformUnit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (C) 2022 Haowei Wen <[email protected]> and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package moe.yushi.authlibinjector.transform.support; | ||
|
||
import static org.objectweb.asm.Opcodes.ASM9; | ||
import static org.objectweb.asm.Opcodes.ICONST_1; | ||
import static org.objectweb.asm.Opcodes.IRETURN; | ||
import java.util.Optional; | ||
import org.objectweb.asm.ClassVisitor; | ||
import org.objectweb.asm.MethodVisitor; | ||
import moe.yushi.authlibinjector.transform.TransformContext; | ||
import moe.yushi.authlibinjector.transform.TransformUnit; | ||
|
||
/** | ||
* Hacks BungeeCord to bypass profile key signature validation. | ||
* See https://github.com/SpigotMC/BungeeCord/commit/78ca16dfe3bf9a21d5c054a1884d4f5f198a62bc . | ||
*/ | ||
public class BungeeCordProfileKeyTransformUnit implements TransformUnit { | ||
|
||
@Override | ||
public Optional<ClassVisitor> transform(ClassLoader classLoader, String className, ClassVisitor writer, TransformContext ctx) { | ||
if ("net.md_5.bungee.EncryptionUtil".equals(className)) { | ||
return Optional.of(new ClassVisitor(ASM9, writer) { | ||
@Override | ||
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { | ||
if ("check".equals(name) && "(Lnet/md_5/bungee/protocol/PlayerPublicKey;Ljava/util/UUID;)Z".equals(descriptor)) { | ||
ctx.markModified(); | ||
|
||
MethodVisitor mv = super.visitMethod(access, name, descriptor, signature, exceptions); | ||
mv.visitCode(); | ||
mv.visitInsn(ICONST_1); | ||
mv.visitInsn(IRETURN); | ||
mv.visitMaxs(-1, -1); | ||
mv.visitEnd(); | ||
|
||
return null; | ||
} else { | ||
return super.visitMethod(access, name, descriptor, signature, exceptions); | ||
} | ||
} | ||
}); | ||
} else { | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "BungeeCord Profile Key Transformer"; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...ain/java/moe/yushi/authlibinjector/transform/support/VelocityProfileKeyTransformUnit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (C) 2022 Haowei Wen <[email protected]> and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package moe.yushi.authlibinjector.transform.support; | ||
|
||
import static org.objectweb.asm.Opcodes.ARETURN; | ||
import static org.objectweb.asm.Opcodes.ASM9; | ||
import static org.objectweb.asm.Opcodes.GETSTATIC; | ||
import java.util.Optional; | ||
import org.objectweb.asm.ClassVisitor; | ||
import org.objectweb.asm.MethodVisitor; | ||
import moe.yushi.authlibinjector.transform.TransformContext; | ||
import moe.yushi.authlibinjector.transform.TransformUnit; | ||
|
||
/** | ||
* Hacks Velocity to bypass profile key signature validation. | ||
* See https://github.com/PaperMC/Velocity/commit/1a3fba4250553702d9dcd05731d04347bfc24c9f . | ||
*/ | ||
public class VelocityProfileKeyTransformUnit implements TransformUnit { | ||
|
||
@Override | ||
public Optional<ClassVisitor> transform(ClassLoader classLoader, String className, ClassVisitor writer, TransformContext ctx) { | ||
if ("com.velocitypowered.proxy.crypto.IdentifiedKeyImpl".equals(className)) { | ||
return Optional.of(new ClassVisitor(ASM9, writer) { | ||
@Override | ||
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { | ||
if ("validateData".equals(name) && "(Ljava/util/UUID;)Ljava/lang/Boolean;".equals(descriptor)) { | ||
ctx.markModified(); | ||
|
||
MethodVisitor mv = super.visitMethod(access, name, descriptor, signature, exceptions); | ||
mv.visitCode(); | ||
mv.visitFieldInsn(GETSTATIC, "java/lang/Boolean", "TRUE", "Ljava/lang/Boolean;"); | ||
mv.visitInsn(ARETURN); | ||
mv.visitMaxs(-1, -1); | ||
mv.visitEnd(); | ||
|
||
return null; | ||
} else { | ||
return super.visitMethod(access, name, descriptor, signature, exceptions); | ||
} | ||
} | ||
}); | ||
} else { | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Velocity Profile Key Transformer"; | ||
} | ||
} |