mirror of
https://github.com/yushijinhun/authlib-injector.git
synced 2024-06-03 00:59:00 +02:00
Compare commits
10 commits
Author | SHA1 | Date | |
---|---|---|---|
cf9248bdbf | |||
18d708d62c | |||
da910956ea | |||
0fe9beb63b | |||
c7670af3d4 | |||
088af75652 | |||
f6970a51b2 | |||
2b90fd9816 | |||
acef784f82 | |||
df8299b8e7 |
3
.github/workflows/deploy_release.yml
vendored
3
.github/workflows/deploy_release.yml
vendored
|
@ -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
|
||||
|
|
|
@ -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.4'
|
||||
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) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Haowei Wen <yushijinhun@gmail.com> and contributors
|
||||
* Copyright (C) 2024 Haowei Wen <yushijinhun@gmail.com> 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
|
||||
|
@ -49,12 +49,15 @@ public class QueryUUIDsFilter implements URLFilter {
|
|||
|
||||
@Override
|
||||
public boolean canHandle(String domain) {
|
||||
return domain.equals("api.mojang.com");
|
||||
return domain.equals("api.mojang.com") || domain.equals("api.minecraftservices.com");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Response> handle(String domain, String path, IHTTPSession session) throws IOException {
|
||||
if (domain.equals("api.mojang.com") && path.equals("/profiles/minecraft") && session.getMethod().equals("POST")) {
|
||||
if (
|
||||
(domain.equals("api.mojang.com") && path.equals("/profiles/minecraft") && session.getMethod().equals("POST")) ||
|
||||
(domain.equals("api.minecraftservices.com") && path.equals("/minecraft/profile/lookup/bulk/byname") && session.getMethod().equals("POST"))
|
||||
) {
|
||||
Set<String> request = new LinkedHashSet<>();
|
||||
asJsonArray(parseJson(asString(asBytes(session.getInputStream()))))
|
||||
.forEach(element -> request.add(asJsonString(element)));
|
||||
|
|
|
@ -188,7 +188,7 @@ public class URLProcessor {
|
|||
conn.setDoOutput(clientIn != null);
|
||||
requestHeaders.forEach(conn::setRequestProperty);
|
||||
|
||||
if (clientIn != null) {
|
||||
if (clientIn != null && !method.equalsIgnoreCase("GET") && !method.equalsIgnoreCase("HEAD")) {
|
||||
try (OutputStream upstreamOut = conn.getOutputStream()) {
|
||||
transfer(clientIn, upstreamOut);
|
||||
}
|
||||
|
|
|
@ -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 @@ public class YggdrasilKeyTransformUnit implements TransformUnit {
|
|||
}
|
||||
|
||||
@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 class YggdrasilKeyTransformUnit implements TransformUnit {
|
|||
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 class YggdrasilKeyTransformUnit implements TransformUnit {
|
|||
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);
|
||||
|
|
Loading…
Reference in a new issue