Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Nov 30, 2024
2 parents f0f42dc + d9e10fc commit 4db8fd3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Agent/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 6 additions & 0 deletions Agent/src/main/java/net/lenni0451/authhook/Agent.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public static void premain(final String args, final Instrumentation instrumentat
private static void hook(final Instrumentation instrumentation) {
try {
Map<String, String> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4db8fd3

Please sign in to comment.