From df8299b8e747dcb8f25eca642145c8735bea6d9f Mon Sep 17 00:00:00 2001 From: Glavo Date: Thu, 21 Sep 2023 20:38:04 +0800 Subject: [PATCH 1/4] Bump ASM from 9.4 to 9.5 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9a9e0f9..b98c164 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ repositories { } dependencies { - implementation 'org.ow2.asm:asm:9.4' + implementation 'org.ow2.asm:asm:9.5' testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2' } From 2b90fd9816f384932cc16a37709bf613eafd04fa Mon Sep 17 00:00:00 2001 From: Evan Goode Date: Sat, 23 Sep 2023 17:51:33 -0400 Subject: [PATCH 2/4] Include release_time in release JSON manifest For https://github.com/yushijinhun/authlib-injector/issues/219 --- .github/workflows/deploy_release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy_release.yml b/.github/workflows/deploy_release.yml index d10bce4..adfb6ae 100644 --- a/.github/workflows/deploy_release.yml +++ b/.github/workflows/deploy_release.yml @@ -38,6 +38,7 @@ jobs: build_number=$(grep -Pom1 '@@release\.build_number=\K.*(?=@@)' <<< $release_body) version_number=$(grep -Pom1 '@@release\.version_number=\K.*(?=@@)' <<< $release_body) asset_name='${{ github.event.release.assets[0].name }}' + release_published_at='${{ github.event.release.published_at }}' cd ~/deploy git config --local user.name "github-actions[bot]" @@ -49,12 +50,14 @@ jobs: jq -n \ --arg build_number "$build_number" \ --arg version "$version_number" \ + --arg release_time "$release_published_at" \ --arg download_url "https://authlib-injector.yushi.moe/artifact/$build_number/$asset_name" \ --arg sha256 "$sha256" \ ' { "build_number": $build_number|tonumber, "version": $version, + "release_time": $release_time, "download_url": $download_url, "checksums": { "sha256": $sha256 From f6970a51b2b1974b90e43d3786e55dcef04d6a8e Mon Sep 17 00:00:00 2001 From: Haowei Wen Date: Wed, 1 Nov 2023 18:47:45 +0800 Subject: [PATCH 3/4] Fix skin not displayed in Minecraft 1.20.2 --- .../support/YggdrasilKeyTransformUnit.java | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/main/java/moe/yushi/authlibinjector/transform/support/YggdrasilKeyTransformUnit.java b/src/main/java/moe/yushi/authlibinjector/transform/support/YggdrasilKeyTransformUnit.java index 8145491..8212797 100644 --- a/src/main/java/moe/yushi/authlibinjector/transform/support/YggdrasilKeyTransformUnit.java +++ b/src/main/java/moe/yushi/authlibinjector/transform/support/YggdrasilKeyTransformUnit.java @@ -16,16 +16,17 @@ */ package moe.yushi.authlibinjector.transform.support; +import static java.lang.invoke.MethodHandles.publicLookup; +import static java.lang.invoke.MethodType.methodType; import static moe.yushi.authlibinjector.util.IOUtils.asBytes; import static moe.yushi.authlibinjector.util.Logging.Level.DEBUG; import static org.objectweb.asm.Opcodes.ALOAD; import static org.objectweb.asm.Opcodes.ARETURN; import static org.objectweb.asm.Opcodes.ASM9; -import static org.objectweb.asm.Opcodes.GETFIELD; -import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL; import static org.objectweb.asm.Opcodes.IRETURN; import java.io.IOException; import java.io.InputStream; +import java.lang.invoke.MethodHandle; import java.security.GeneralSecurityException; import java.security.InvalidKeyException; import java.security.PrivateKey; @@ -61,7 +62,32 @@ private static PublicKey loadMojangPublicKey() { } @CallbackMethod - public static boolean verifyPropertySignature(String propertyValue, String base64Signature) { + public static boolean verifyPropertySignature(Object propertyObj) { + String base64Signature; + String propertyValue; + + try { + MethodHandle valueHandle; + try { + valueHandle = publicLookup().findVirtual(propertyObj.getClass(), "getValue", methodType(String.class)); + } catch (NoSuchMethodException ignored) { + valueHandle = publicLookup().findVirtual(propertyObj.getClass(), "value", methodType(String.class)); + } + + MethodHandle signatureHandle; + try { + signatureHandle = publicLookup().findVirtual(propertyObj.getClass(), "getSignature", methodType(String.class)); + } catch(NoSuchMethodException ignored) { + signatureHandle = publicLookup().findVirtual(propertyObj.getClass(), "signature", methodType(String.class)); + } + + base64Signature = (String) signatureHandle.invokeWithArguments(propertyObj); + propertyValue = (String) valueHandle.invokeWithArguments(propertyObj); + } catch (Throwable e) { + Logging.log(Level.ERROR, "Failed to get property attributes", e); + return false; + } + byte[] sig = Base64.getDecoder().decode(base64Signature); byte[] data = propertyValue.getBytes(); @@ -145,9 +171,6 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn(GETFIELD, "com/mojang/authlib/properties/Property", "value", "Ljava/lang/String;"); - mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn(GETFIELD, "com/mojang/authlib/properties/Property", "signature", "Ljava/lang/String;"); ctx.invokeCallback(mv, YggdrasilKeyTransformUnit.class, "verifyPropertySignature"); mv.visitInsn(IRETURN); mv.visitMaxs(-1, -1); @@ -170,9 +193,6 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); mv.visitCode(); mv.visitVarInsn(ALOAD, 1); - mv.visitMethodInsn(INVOKEVIRTUAL, "com/mojang/authlib/properties/Property", "getValue", "()Ljava/lang/String;", false); - mv.visitVarInsn(ALOAD, 1); - mv.visitMethodInsn(INVOKEVIRTUAL, "com/mojang/authlib/properties/Property", "getSignature", "()Ljava/lang/String;", false); ctx.invokeCallback(mv, YggdrasilKeyTransformUnit.class, "verifyPropertySignature"); mv.visitInsn(IRETURN); mv.visitMaxs(-1, -1); From 088af7565259a7f41a89186e19183476371ec2ea Mon Sep 17 00:00:00 2001 From: Haowei Wen Date: Wed, 1 Nov 2023 18:52:13 +0800 Subject: [PATCH 4/4] Update dependencies --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index b98c164..e399bf1 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'com.github.johnrengelman.shadow' version '8.1.1' - id 'com.palantir.git-version' version '2.0.0' + id 'com.palantir.git-version' version '3.0.0' id 'java' } @@ -9,8 +9,8 @@ repositories { } dependencies { - implementation 'org.ow2.asm:asm:9.5' - testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2' + implementation 'org.ow2.asm:asm:9.6' + testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0' } tasks.withType(JavaCompile) {