From e3795eb503c80e13afc4efb20305155877709064 Mon Sep 17 00:00:00 2001 From: Lenni0451 <20379977+Lenni0451@users.noreply.github.com> Date: Sat, 30 Nov 2024 21:11:52 +0100 Subject: [PATCH 1/2] Inform user about invalid secret key --- Agent/src/main/java/net/lenni0451/authhook/Agent.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Agent/src/main/java/net/lenni0451/authhook/Agent.java b/Agent/src/main/java/net/lenni0451/authhook/Agent.java index 1691f0d..4326e02 100644 --- a/Agent/src/main/java/net/lenni0451/authhook/Agent.java +++ b/Agent/src/main/java/net/lenni0451/authhook/Agent.java @@ -16,6 +16,12 @@ public static void premain(final String args, final Instrumentation instrumentat private static void hook(final Instrumentation instrumentation) { try { Map config = Config.load(); + if (config.get(Config.SECRET_KEY).contains(" ")) { + System.err.println("Please set a valid secret key in the auth_hook.properties file"); + System.err.println("It is automatically generated by ViaProxy if you have the AuthHook plugin installed"); + System.exit(-1); + } + instrumentation.addTransformer(new URLRedirector(config), true); } catch (Throwable t) { System.err.println("An error occurred while starting AuthHook"); From d9e10fc967a7463db2f36a015b880466c90cf2ff Mon Sep 17 00:00:00 2001 From: Lenni0451 <20379977+Lenni0451@users.noreply.github.com> Date: Sat, 30 Nov 2024 21:26:29 +0100 Subject: [PATCH 2/2] Compile agent using java 8 --- Agent/build.gradle | 4 ++++ Agent/src/main/java/net/lenni0451/authhook/URLRedirector.java | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Agent/build.gradle b/Agent/build.gradle index eb066f6..3532df7 100644 --- a/Agent/build.gradle +++ b/Agent/build.gradle @@ -1,3 +1,7 @@ +base { + java.toolchain.languageVersion = JavaLanguageVersion.of(8) +} + dependencies { include "org.ow2.asm:asm:9.7.1" include "org.ow2.asm:asm-tree:9.7.1" diff --git a/Agent/src/main/java/net/lenni0451/authhook/URLRedirector.java b/Agent/src/main/java/net/lenni0451/authhook/URLRedirector.java index b4bc2ee..8ecbaec 100644 --- a/Agent/src/main/java/net/lenni0451/authhook/URLRedirector.java +++ b/Agent/src/main/java/net/lenni0451/authhook/URLRedirector.java @@ -38,7 +38,9 @@ public byte[] transform(ClassLoader loader, String className, Class classBein boolean modified = false; for (MethodNode method : node.methods) { for (AbstractInsnNode insn : method.instructions) { - if (insn instanceof LdcInsnNode ldc && ldc.cst instanceof String str) { + if (insn instanceof LdcInsnNode && ((LdcInsnNode) insn).cst instanceof String) { + LdcInsnNode ldc = (LdcInsnNode) insn; + String str = (String) ldc.cst; if (str.startsWith(URL)) { str = str.substring(URL.length()); str = this.targetAddress + "/" + this.secretKey + str;