Jump to content

Flegyas

Members
  • Posts

    12
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Flegyas's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I set a new server, downloaded a new jar etc to send you a clean stuff and... Now it seems to get called also outside the dev environment (I don't know how it is possible). However, I'm still a bit confused about how to patch the method correctly. This time, I'm trying to find the right insert point for the instructions (using @SanAndreasP classes https://github.com/SanAndreasP/SAPManagerPack/tree/master/java/de/sanandrew/core/manpack/transformer, if you'll read this thank you man) but I didn't understand which method I'm going to modify when I add the SortingIndex annotation. Am I patching the deobfuscated class (with "func like" names for methods/fields etc) ? If yes, why do I get an error saying that this needle isn't contained in the method instructions set? InsnList needle = new InsnList(); needle.add(new FrameNode(Opcodes.F_APPEND, 2, new Object[]{"java/lang/String", "net/minecraft/server/management/IPBanEntry"}, 0, null)); needle.add(new VarInsnNode(Opcodes.ALOAD, 3)); needle.add(new InsnNode(Opcodes.ARETURN)); LabelNode l9 = new LabelNode(); needle.add(l9); needle.add(new LineNumberNode(401, l9)); AbstractInsnNode insertPoint = ASMHelper.findLastNodeFromNeedle(method.instructions, needle);
  2. dev -> Working as always. outside -> Not working as always.
  3. This is the patch method now: protected void patchNotObfuscated(ClassNode classNode) { for (MethodNode method : classNode.methods) { String methodName = method.name; if (methodName.equals("func_148542_a") || methodName.equals("allowUserToConnect")) { System.out.println("********** PATCHING METHOD! **********"); InsnList injectList = new InsnList(); LabelNode l42 = new LabelNode(); injectList.add(l42); injectList.add(new LineNumberNode(14, l42)); injectList.add(new FieldInsnNode(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;")); injectList.add(new LdcInsnNode("********** IT'S WORKING **********")); injectList.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false)); method.instructions.insert(injectList); } } } I successfully get the print "********** PATCHING METHOD! **********" but still no changes on the server...
  4. 1. It's the one posted before (in the previous post). 2. I thought I had to patch both environments, I'll try keeping only "patchNotObfuscated" combined with @SortingIndex(1001). 3. I tried with that annotation, it tried to call the "patchNotObfuscated" method, meaning that it found the class "net.minecraft.server.management.ServerConfigurationManager" and not "oi" but where can I find the "func like" matches? I searched in notch-mcp.srg but I found: oi/a (Ljava/net/SocketAddress;Lcom/mojang/authlib/GameProfile;)Ljava/lang/String; net/minecraft/server/management/ServerConfigurationManager/allowUserToConnect (Ljava/net/SocketAddress;Lcom/mojang/authlib/GameProfile;)Ljava/lang/String;
  5. Okay, I tried in this way: ServerConfigurationManagerPatcher: package pnmod.test.skills.asm.patchers; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.*; public class ServerConfigurationManagerPatcher extends Patcher { protected void patchNotObfuscated(ClassNode classNode) { for (MethodNode method : classNode.methods) { String methodName = method.name; if (methodName.equals("allowUserToConnect")) { InsnList injectList = new InsnList(); LabelNode l42 = new LabelNode(); injectList.add(l42); injectList.add(new LineNumberNode(14, l42)); injectList.add(new FieldInsnNode(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;")); injectList.add(new LdcInsnNode("********** IT'S WORKING **********")); injectList.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false)); method.instructions.insert(injectList); /* InsnList needle = new InsnList(); needle.add(new FrameNode(Opcodes.F_APPEND, 2, new Object[]{"java/lang/String", "net/minecraft/server/management/IPBanEntry"}, 0, null)); needle.add(new VarInsnNode(Opcodes.ALOAD, 3)); needle.add(new InsnNode(Opcodes.ARETURN)); LabelNode l9 = new LabelNode(); needle.add(l9); needle.add(new LineNumberNode(401, l9)); AbstractInsnNode insertPoint = ASMHelper.findLastNodeFromNeedle(method.instructions, needle); InsnList injectList = new InsnList(); injectList.add(new FrameNode(Opcodes.F_CHOP, 2, null, 0, null)); injectList.add(new VarInsnNode(Opcodes.ALOAD, 2)); injectList.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "pnmod/test/skills/server/authentication/AuthManager", "requestLogin", "(Lcom/mojang/authlib/GameProfile;)Lpnmod/test/skills/server/authentication/AuthResponse;", false)); injectList.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "pnmod/test/skills/server/authentication/AuthResponse", "getStatus", "()Lpnmod/test/skills/server/authentication/AuthRequestStatus;", false)); injectList.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "pnmod/test/skills/server/authentication/AuthRequestStatus", "isCorrect", "()Z", false)); LabelNode l15 = new LabelNode(); injectList.add(new JumpInsnNode(Opcodes.IFNE, l15)); LabelNode l16 = new LabelNode(); injectList.add(l16); injectList.add(new LdcInsnNode("Phoenix Network Authenticator: login not allowed!")); injectList.add(new InsnNode(Opcodes.ARETURN)); method.instructions.insert(insertPoint, injectList); */ } } } protected void patchObfuscated(ClassNode classNode) { for (MethodNode method : classNode.methods) { String methodName = method.name; if (methodName.equals("a") && method.desc.equals("(Ljava/net/SocketAddress;Lcom/mojang/authlib/GameProfile;)Ljava/lang/String;")) { InsnList injectList = new InsnList(); LabelNode l42 = new LabelNode(); injectList.add(l42); injectList.add(new LineNumberNode(14, l42)); injectList.add(new FieldInsnNode(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;")); injectList.add(new LdcInsnNode("********** IT'S WORKING **********")); injectList.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false)); method.instructions.insert(injectList); } } } } I'm just adding a print to see if the method gets the changes but again it only works in a dev environment, nothing happens when builded.
  6. So, why in the ServerConfigurationManager.patchObfuscated(...) methodName.equals("a") && method.desc.equals("(Ljava/net/SocketAddress;Lcom/mojang/authlib/GameProfile;)Ljava/lang/String;") has true value? Is it called before the FML deobfuscation? Could it be the problem?
  7. I didn't know how to inject only a part of the method so I recreated the class and added the code, then I took the ASM instructions and replaced all (I thought it would be the same result). Ok, now I'll find how to inject only a few instructions. Can you explain this?
  8. The Transformer: public class PNClassTransformer implements IClassTransformer { @Override public byte[] transform(String vanillaClassName, String customClassName, byte[] bytecodeChunk) { if (vanillaClassName.equals("jw")) { bytecodeChunk = new C00PacketLoginStartPatcher().patch(bytecodeChunk, true); } else if (vanillaClassName.equals("net.minecraft.network.login.client.C00PacketLoginStart")) { bytecodeChunk = new C00PacketLoginStartPatcher().patch(bytecodeChunk, false); } else if (vanillaClassName.equals("oi")) { bytecodeChunk = new ServerConfigurationManagerPatcher().patch(bytecodeChunk, true); } else if (vanillaClassName.equals("net.minecraft.server.management.ServerConfigurationManager")) { bytecodeChunk = new ServerConfigurationManagerPatcher().patch(bytecodeChunk, false); } return bytecodeChunk; } } ServerConfigurationManagerPatcher: public class ServerConfigurationManagerPatcher extends Patcher { protected void patchNotObfuscated(ClassNode classNode) { for (MethodNode method : classNode.methods) { String methodName = method.name; if (methodName.equals("allowUserToConnect")) { method.instructions.clear(); method.localVariables.clear(); method.visitCode(); Label l0 = new Label(); method.visitLabel(l0); method.visitLineNumber(324, l0); method.visitVarInsn(Opcodes.ALOAD, 0); method.visitFieldInsn(Opcodes.GETFIELD, "net/minecraft/server/management/ServerConfigurationManager", "bannedPlayers", "Lnet/minecraft/server/management/UserListBans;"); method.visitVarInsn(Opcodes.ALOAD, 2); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/minecraft/server/management/UserListBans", "func_152702_a", "(Lcom/mojang/authlib/GameProfile;)Z", false); Label l1 = new Label(); method.visitJumpInsn(Opcodes.IFEQ, l1); Label l2 = new Label(); method.visitLabel(l2); method.visitLineNumber(325, l2); method.visitVarInsn(Opcodes.ALOAD, 0); method.visitFieldInsn(Opcodes.GETFIELD, "net/minecraft/server/management/ServerConfigurationManager", "bannedPlayers", "Lnet/minecraft/server/management/UserListBans;"); method.visitVarInsn(Opcodes.ALOAD, 2); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/minecraft/server/management/UserListBans", "func_152683_b", "(Ljava/lang/Object;)Lnet/minecraft/server/management/UserListEntry;", false); method.visitTypeInsn(Opcodes.CHECKCAST, "net/minecraft/server/management/UserListBansEntry"); method.visitVarInsn(Opcodes.ASTORE, 4); Label l3 = new Label(); method.visitLabel(l3); method.visitLineNumber(326, l3); method.visitTypeInsn(Opcodes.NEW, "java/lang/StringBuilder"); method.visitInsn(Opcodes.DUP); method.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "()V", false); method.visitLdcInsn("You are banned from this server!\nReason: "); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitVarInsn(Opcodes.ALOAD, 4); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/minecraft/server/management/UserListBansEntry", "getBanReason", "()Ljava/lang/String;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); method.visitVarInsn(Opcodes.ASTORE, 3); Label l4 = new Label(); method.visitLabel(l4); method.visitLineNumber(328, l4); method.visitVarInsn(Opcodes.ALOAD, 4); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/minecraft/server/management/UserListBansEntry", "getBanEndDate", "()Ljava/util/Date;", false); Label l5 = new Label(); method.visitJumpInsn(Opcodes.IFNULL, l5); Label l6 = new Label(); method.visitLabel(l6); method.visitLineNumber(329, l6); method.visitTypeInsn(Opcodes.NEW, "java/lang/StringBuilder"); method.visitInsn(Opcodes.DUP); method.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "()V", false); method.visitVarInsn(Opcodes.ALOAD, 3); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitLdcInsn("\nYour ban will be removed on "); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitFieldInsn(Opcodes.GETSTATIC, "net/minecraft/server/management/ServerConfigurationManager", "dateFormat", "Ljava/text/SimpleDateFormat;"); method.visitVarInsn(Opcodes.ALOAD, 4); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/minecraft/server/management/UserListBansEntry", "getBanEndDate", "()Ljava/util/Date;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/text/SimpleDateFormat", "format", "(Ljava/util/Date;)Ljava/lang/String;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); method.visitVarInsn(Opcodes.ASTORE, 3); method.visitLabel(l5); method.visitLineNumber(332, l5); method.visitFrame(Opcodes.F_APPEND, 2, new Object[]{"java/lang/String", "net/minecraft/server/management/UserListBansEntry"}, 0, null); method.visitVarInsn(Opcodes.ALOAD, 3); method.visitInsn(Opcodes.ARETURN); method.visitLabel(l1); method.visitLineNumber(333, l1); method.visitFrame(Opcodes.F_CHOP, 2, null, 0, null); method.visitVarInsn(Opcodes.ALOAD, 0); method.visitVarInsn(Opcodes.ALOAD, 2); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/minecraft/server/management/ServerConfigurationManager", "func_152607_e", "(Lcom/mojang/authlib/GameProfile;)Z", false); Label l7 = new Label(); method.visitJumpInsn(Opcodes.IFNE, l7); Label l8 = new Label(); method.visitLabel(l8); method.visitLineNumber(334, l8); method.visitLdcInsn("You are not white-listed on this server!"); method.visitInsn(Opcodes.ARETURN); method.visitLabel(l7); method.visitLineNumber(335, l7); method.visitFrame(Opcodes.F_SAME, 0, null, 0, null); method.visitVarInsn(Opcodes.ALOAD, 0); method.visitFieldInsn(Opcodes.GETFIELD, "net/minecraft/server/management/ServerConfigurationManager", "bannedIPs", "Lnet/minecraft/server/management/BanList;"); method.visitVarInsn(Opcodes.ALOAD, 1); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/minecraft/server/management/BanList", "func_152708_a", "(Ljava/net/SocketAddress;)Z", false); Label l9 = new Label(); method.visitJumpInsn(Opcodes.IFEQ, l9); Label l10 = new Label(); method.visitLabel(l10); method.visitLineNumber(336, l10); method.visitVarInsn(Opcodes.ALOAD, 0); method.visitFieldInsn(Opcodes.GETFIELD, "net/minecraft/server/management/ServerConfigurationManager", "bannedIPs", "Lnet/minecraft/server/management/BanList;"); method.visitVarInsn(Opcodes.ALOAD, 1); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/minecraft/server/management/BanList", "func_152709_b", "(Ljava/net/SocketAddress;)Lnet/minecraft/server/management/IPBanEntry;", false); method.visitVarInsn(Opcodes.ASTORE, 4); Label l11 = new Label(); method.visitLabel(l11); method.visitLineNumber(337, l11); method.visitTypeInsn(Opcodes.NEW, "java/lang/StringBuilder"); method.visitInsn(Opcodes.DUP); method.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "()V", false); method.visitLdcInsn("Your IP address is banned from this server!\nReason: "); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitVarInsn(Opcodes.ALOAD, 4); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/minecraft/server/management/IPBanEntry", "getBanReason", "()Ljava/lang/String;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); method.visitVarInsn(Opcodes.ASTORE, 3); Label l12 = new Label(); method.visitLabel(l12); method.visitLineNumber(339, l12); method.visitVarInsn(Opcodes.ALOAD, 4); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/minecraft/server/management/IPBanEntry", "getBanEndDate", "()Ljava/util/Date;", false); Label l13 = new Label(); method.visitJumpInsn(Opcodes.IFNULL, l13); Label l14 = new Label(); method.visitLabel(l14); method.visitLineNumber(340, l14); method.visitTypeInsn(Opcodes.NEW, "java/lang/StringBuilder"); method.visitInsn(Opcodes.DUP); method.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "()V", false); method.visitVarInsn(Opcodes.ALOAD, 3); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitLdcInsn("\nYour ban will be removed on "); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitFieldInsn(Opcodes.GETSTATIC, "net/minecraft/server/management/ServerConfigurationManager", "dateFormat", "Ljava/text/SimpleDateFormat;"); method.visitVarInsn(Opcodes.ALOAD, 4); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "net/minecraft/server/management/IPBanEntry", "getBanEndDate", "()Ljava/util/Date;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/text/SimpleDateFormat", "format", "(Ljava/util/Date;)Ljava/lang/String;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); method.visitVarInsn(Opcodes.ASTORE, 3); method.visitLabel(l13); method.visitLineNumber(343, l13); method.visitFrame(Opcodes.F_APPEND, 2, new Object[]{"java/lang/String", "net/minecraft/server/management/IPBanEntry"}, 0, null); method.visitVarInsn(Opcodes.ALOAD, 3); method.visitInsn(Opcodes.ARETURN); method.visitLabel(l9); method.visitLineNumber(344, l9); method.visitFrame(Opcodes.F_CHOP, 2, null, 0, null); method.visitVarInsn(Opcodes.ALOAD, 2); method.visitMethodInsn(Opcodes.INVOKESTATIC, "pnmod/test/skills/server/authentication/AuthManager", "requestLogin", "(Lcom/mojang/authlib/GameProfile;)Lpnmod/test/skills/server/authentication/AuthResponse;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "pnmod/test/skills/server/authentication/AuthResponse", "getStatus", "()Lpnmod/test/skills/server/authentication/AuthRequestStatus;", false); method.visitFieldInsn(Opcodes.GETSTATIC, "pnmod/test/skills/server/authentication/AuthRequestStatus", "CORRECT", "Lpnmod/test/skills/server/authentication/AuthRequestStatus;"); Label l15 = new Label(); method.visitJumpInsn(Opcodes.IF_ACMPEQ, l15); Label l16 = new Label(); method.visitLabel(l16); method.visitLineNumber(345, l16); method.visitLdcInsn("Login not allowed!"); method.visitInsn(Opcodes.ARETURN); method.visitLabel(l15); method.visitLineNumber(347, l15); method.visitFrame(Opcodes.F_SAME, 0, null, 0, null); method.visitVarInsn(Opcodes.ALOAD, 0); method.visitFieldInsn(Opcodes.GETFIELD, "net/minecraft/server/management/ServerConfigurationManager", "playerEntityList", "Ljava/util/List;"); method.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "size", "()I", true); method.visitVarInsn(Opcodes.ALOAD, 0); method.visitFieldInsn(Opcodes.GETFIELD, "net/minecraft/server/management/ServerConfigurationManager", "maxPlayers", "I"); Label l17 = new Label(); method.visitJumpInsn(Opcodes.IF_ICMPLT, l17); method.visitLdcInsn("The server is full!"); Label l18 = new Label(); method.visitJumpInsn(Opcodes.GOTO, l18); method.visitLabel(l17); method.visitFrame(Opcodes.F_SAME, 0, null, 0, null); method.visitInsn(Opcodes.ACONST_NULL); method.visitLabel(l18); method.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[]{"java/lang/String"}); method.visitInsn(Opcodes.ARETURN); Label l19 = new Label(); method.visitLabel(l19); method.visitLocalVariable("userlistbansentry", "Lnet/minecraft/server/management/UserListBansEntry;", null, l3, l1, 4); method.visitLocalVariable("s", "Ljava/lang/String;", null, l4, l1, 3); method.visitLocalVariable("ipbanentry", "Lnet/minecraft/server/management/IPBanEntry;", null, l11, l9, 4); method.visitLocalVariable("s", "Ljava/lang/String;", null, l12, l9, 3); method.visitLocalVariable("this", "Lnet/minecraft/server/management/ServerConfigurationManager;", null, l0, l19, 0); method.visitLocalVariable("p_148542_1_", "Ljava/net/SocketAddress;", null, l0, l19, 1); method.visitLocalVariable("p_148542_2_", "Lcom/mojang/authlib/GameProfile;", null, l0, l19, 2); method.visitMaxs(3, 5); method.visitEnd(); } } } protected void patchObfuscated(ClassNode classNode) { for (MethodNode method : classNode.methods) { String methodName = method.name; if (methodName.equals("a") && method.desc.equals("(Ljava/net/SocketAddress;Lcom/mojang/authlib/GameProfile;)Ljava/lang/String;")) { method.instructions.clear(); method.localVariables.clear(); method.visitCode(); Label l0 = new Label(); method.visitLabel(l0); method.visitLineNumber(24, l0); method.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;"); method.visitLdcInsn("*********** METHOD CALLED **********"); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); Label l1 = new Label(); method.visitLabel(l1); method.visitLineNumber(26, l1); method.visitVarInsn(Opcodes.ALOAD, 0); method.visitFieldInsn(Opcodes.GETFIELD, "oi", "j", "Lop;"); method.visitVarInsn(Opcodes.ALOAD, 2); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "op", "a", "(Lcom/mojang/authlib/GameProfile;)Z", false); Label l2 = new Label(); method.visitJumpInsn(Opcodes.IFEQ, l2); Label l3 = new Label(); method.visitLabel(l3); method.visitLineNumber(27, l3); method.visitVarInsn(Opcodes.ALOAD, 0); method.visitFieldInsn(Opcodes.GETFIELD, "oi", "j", "Lop;"); method.visitVarInsn(Opcodes.ALOAD, 2); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "op", "b", "(Ljava/lang/Object;)Lol;", false); method.visitTypeInsn(Opcodes.CHECKCAST, "oq"); method.visitVarInsn(Opcodes.ASTORE, 4); Label l4 = new Label(); method.visitLabel(l4); method.visitLineNumber(28, l4); method.visitTypeInsn(Opcodes.NEW, "java/lang/StringBuilder"); method.visitInsn(Opcodes.DUP); method.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "()V", false); method.visitLdcInsn("You are banned from this server!\nReason: "); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitVarInsn(Opcodes.ALOAD, 4); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "oq", "d", "()Ljava/lang/String;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); method.visitVarInsn(Opcodes.ASTORE, 3); Label l5 = new Label(); method.visitLabel(l5); method.visitLineNumber(29, l5); method.visitVarInsn(Opcodes.ALOAD, 4); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "oq", "c", "()Ljava/util/Date;", false); Label l6 = new Label(); method.visitJumpInsn(Opcodes.IFNULL, l6); Label l7 = new Label(); method.visitLabel(l7); method.visitLineNumber(30, l7); method.visitTypeInsn(Opcodes.NEW, "java/lang/StringBuilder"); method.visitInsn(Opcodes.DUP); method.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "()V", false); method.visitVarInsn(Opcodes.ALOAD, 3); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitLdcInsn("\nYour ban will be removed on "); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitFieldInsn(Opcodes.GETSTATIC, "oi", "h", "Ljava/text/SimpleDateFormat;"); method.visitVarInsn(Opcodes.ALOAD, 4); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "oq", "c", "()Ljava/util/Date;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/text/SimpleDateFormat", "format", "(Ljava/util/Date;)Ljava/lang/String;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); method.visitVarInsn(Opcodes.ASTORE, 3); method.visitLabel(l6); method.visitLineNumber(33, l6); method.visitFrame(Opcodes.F_APPEND, 2, new Object[]{"java/lang/String", "oq"}, 0, null); method.visitVarInsn(Opcodes.ALOAD, 3); method.visitInsn(Opcodes.ARETURN); method.visitLabel(l2); method.visitLineNumber(34, l2); method.visitFrame(Opcodes.F_CHOP, 2, null, 0, null); method.visitVarInsn(Opcodes.ALOAD, 0); method.visitVarInsn(Opcodes.ALOAD, 2); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "oi", "e", "(Lcom/mojang/authlib/GameProfile;)Z", false); Label l8 = new Label(); method.visitJumpInsn(Opcodes.IFNE, l8); Label l9 = new Label(); method.visitLabel(l9); method.visitLineNumber(35, l9); method.visitLdcInsn("You are not white-listed on this server!"); method.visitInsn(Opcodes.ARETURN); method.visitLabel(l8); method.visitLineNumber(36, l8); method.visitFrame(Opcodes.F_SAME, 0, null, 0, null); method.visitVarInsn(Opcodes.ALOAD, 0); method.visitFieldInsn(Opcodes.GETFIELD, "oi", "k", "Lnx;"); method.visitVarInsn(Opcodes.ALOAD, 1); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "nx", "a", "(Ljava/net/SocketAddress;)Z", false); Label l10 = new Label(); method.visitJumpInsn(Opcodes.IFEQ, l10); Label l11 = new Label(); method.visitLabel(l11); method.visitLineNumber(37, l11); method.visitVarInsn(Opcodes.ALOAD, 0); method.visitFieldInsn(Opcodes.GETFIELD, "oi", "k", "Lnx;"); method.visitVarInsn(Opcodes.ALOAD, 1); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "nx", "b", "(Ljava/net/SocketAddress;)Lny;", false); method.visitVarInsn(Opcodes.ASTORE, 4); Label l12 = new Label(); method.visitLabel(l12); method.visitLineNumber(38, l12); method.visitTypeInsn(Opcodes.NEW, "java/lang/StringBuilder"); method.visitInsn(Opcodes.DUP); method.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "()V", false); method.visitLdcInsn("Your IP address is banned from this server!\nReason: "); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitVarInsn(Opcodes.ALOAD, 4); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "ny", "d", "()Ljava/lang/String;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); method.visitVarInsn(Opcodes.ASTORE, 3); Label l13 = new Label(); method.visitLabel(l13); method.visitLineNumber(39, l13); method.visitVarInsn(Opcodes.ALOAD, 4); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "ny", "c", "()Ljava/util/Date;", false); Label l14 = new Label(); method.visitJumpInsn(Opcodes.IFNULL, l14); Label l15 = new Label(); method.visitLabel(l15); method.visitLineNumber(40, l15); method.visitTypeInsn(Opcodes.NEW, "java/lang/StringBuilder"); method.visitInsn(Opcodes.DUP); method.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "()V", false); method.visitVarInsn(Opcodes.ALOAD, 3); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitLdcInsn("\nYour ban will be removed on "); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitFieldInsn(Opcodes.GETSTATIC, "oi", "h", "Ljava/text/SimpleDateFormat;"); method.visitVarInsn(Opcodes.ALOAD, 4); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "ny", "c", "()Ljava/util/Date;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/text/SimpleDateFormat", "format", "(Ljava/util/Date;)Ljava/lang/String;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); method.visitVarInsn(Opcodes.ASTORE, 3); method.visitLabel(l14); method.visitLineNumber(43, l14); method.visitFrame(Opcodes.F_APPEND, 2, new Object[]{"java/lang/String", "ny"}, 0, null); method.visitVarInsn(Opcodes.ALOAD, 3); method.visitInsn(Opcodes.ARETURN); method.visitLabel(l10); method.visitLineNumber(44, l10); method.visitFrame(Opcodes.F_CHOP, 2, null, 0, null); method.visitVarInsn(Opcodes.ALOAD, 2); method.visitMethodInsn(Opcodes.INVOKESTATIC, "pnmod/test/skills/server/authentication/AuthManager", "requestLogin", "(Lcom/mojang/authlib/GameProfile;)Lpnmod/test/skills/server/authentication/AuthResponse;", false); method.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "pnmod/test/skills/server/authentication/AuthResponse", "getStatus", "()Lpnmod/test/skills/server/authentication/AuthRequestStatus;", false); method.visitFieldInsn(Opcodes.GETSTATIC, "pnmod/test/skills/server/authentication/AuthRequestStatus", "CORRECT", "Lpnmod/test/skills/server/authentication/AuthRequestStatus;"); Label l16 = new Label(); method.visitJumpInsn(Opcodes.IF_ACMPEQ, l16); Label l17 = new Label(); method.visitLabel(l17); method.visitLineNumber(45, l17); method.visitLdcInsn("Login not allowed!"); method.visitInsn(Opcodes.ARETURN); method.visitLabel(l16); method.visitLineNumber(47, l16); method.visitFrame(Opcodes.F_SAME, 0, null, 0, null); method.visitVarInsn(Opcodes.ALOAD, 0); method.visitFieldInsn(Opcodes.GETFIELD, "oi", "e", "Ljava/util/List;"); method.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "size", "()I", true); method.visitVarInsn(Opcodes.ALOAD, 0); method.visitFieldInsn(Opcodes.GETFIELD, "oi", "f", "I"); Label l18 = new Label(); method.visitJumpInsn(Opcodes.IF_ICMPLT, l18); method.visitLdcInsn("The server is full!"); Label l19 = new Label(); method.visitJumpInsn(Opcodes.GOTO, l19); method.visitLabel(l18); method.visitFrame(Opcodes.F_SAME, 0, null, 0, null); method.visitInsn(Opcodes.ACONST_NULL); method.visitLabel(l19); method.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[]{"java/lang/String"}); method.visitInsn(Opcodes.ARETURN); Label l20 = new Label(); method.visitLabel(l20); method.visitLocalVariable("var5", "Loq;", null, l4, l2, 4); method.visitLocalVariable("var4", "Ljava/lang/String;", null, l5, l2, 3); method.visitLocalVariable("var3", "Lny;", null, l12, l10, 4); method.visitLocalVariable("var4", "Ljava/lang/String;", null, l13, l10, 3); method.visitLocalVariable("this", "Loi;", null, l0, l20, 0); method.visitLocalVariable("var1", "Ljava/net/SocketAddress;", null, l0, l20, 1); method.visitLocalVariable("var2", "Lcom/mojang/authlib/GameProfile;", null, l0, l20, 2); method.visitMaxs(3, 5); method.visitEnd(); } } } } Patcher: public abstract class Patcher { public final byte[] patch(byte[] bytecodeChunk, boolean obfuscated) { ClassNode classNode = new ClassNode(); ClassReader reader = new ClassReader(bytecodeChunk); reader.accept(classNode, ClassReader.EXPAND_FRAMES); if (obfuscated) patchObfuscated(classNode); else patchNotObfuscated(classNode); ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); classNode.accept(cw); return cw.toByteArray(); } protected abstract void patchObfuscated(ClassNode classNode); protected abstract void patchNotObfuscated(ClassNode classNode); }
  9. Hello there! I'm trying to patch the method "allowUserToConnect" of the class "net.minecraft.server.management.ServerConfigurationManager". I'm adding a new level of authentication, in this way: This is the original method: /** * checks ban-lists, then white-lists, then space for the server. Returns null on success, or an error message */ public String allowUserToConnect(SocketAddress p_148542_1_, GameProfile p_148542_2_) { String s; if (this.bannedPlayers.func_152702_a(p_148542_2_)) { UserListBansEntry userlistbansentry = (UserListBansEntry)this.bannedPlayers.func_152683_b(p_148542_2_); s = "You are banned from this server!\nReason: " + userlistbansentry.getBanReason(); if (userlistbansentry.getBanEndDate() != null) { s = s + "\nYour ban will be removed on " + dateFormat.format(userlistbansentry.getBanEndDate()); } return s; } else if (!this.func_152607_e(p_148542_2_)) { return "You are not white-listed on this server!"; } else if (this.bannedIPs.func_152708_a(p_148542_1_)) { IPBanEntry ipbanentry = this.bannedIPs.func_152709_b(p_148542_1_); s = "Your IP address is banned from this server!\nReason: " + ipbanentry.getBanReason(); if (ipbanentry.getBanEndDate() != null) { s = s + "\nYour ban will be removed on " + dateFormat.format(ipbanentry.getBanEndDate()); } return s; } else { return this.playerEntityList.size() >= this.maxPlayers ? "The server is full!" : null; } } This is the modified: /** * checks ban-lists, then white-lists, then space for the server. Returns null on success, or an error message */ public String allowUserToConnect(SocketAddress p_148542_1_, GameProfile p_148542_2_) { String s; if (this.bannedPlayers.func_152702_a(p_148542_2_)) { UserListBansEntry userlistbansentry = (UserListBansEntry) this.bannedPlayers.func_152683_b(p_148542_2_); s = "You are banned from this server!\nReason: " + userlistbansentry.getBanReason(); if (userlistbansentry.getBanEndDate() != null) { s = s + "\nYour ban will be removed on " + dateFormat.format(userlistbansentry.getBanEndDate()); } return s; } else if (!this.func_152607_e(p_148542_2_)) { return "You are not white-listed on this server!"; } else if (this.bannedIPs.func_152708_a(p_148542_1_)) { IPBanEntry ipbanentry = this.bannedIPs.func_152709_b(p_148542_1_); s = "Your IP address is banned from this server!\nReason: " + ipbanentry.getBanReason(); if (ipbanentry.getBanEndDate() != null) { s = s + "\nYour ban will be removed on " + dateFormat.format(ipbanentry.getBanEndDate()); } return s; } /* Here my changes. else if (AuthManager.requestLogin(p_148542_2_).getStatus() != AuthRequestStatus.CORRECT) return "Login not allowed!"; */ else return this.playerEntityList.size() >= this.maxPlayers ? "The server is full!" : null; } This is the not obfuscated method and it's working fine in the dev environment (it gets patched perfectly), the problems come with the obfuscated one, of the class "oi". When my IClassTransformer is called, the oi.class is correctly recognized and his patching method is called but when it's called because of a player login, it seems that it hasn't received the patch, no matter what instruction I patch, it seems the vanilla one. Have you any ideas about this problem?
  10. I don't understand why you can't just answer to the base question, however: Not cracked but Mojang indipendent, users that want to use it must confirm that they have a legal purchased Minecraft account but then they can use it even if the Minecraft auth servers are offline. Because of this feature the server is in offline mode and I need a different auth method for it. It's a symptom of low protection, they can discover where is the enemy camp, where the enemy logged out to kill him etc. The ServerConfigurationManager is responsible of the logins before events or anything else, stopping the login in that moment returns in a more efficient auth, faster and with no delay to exploit.
  11. And you need this new authentication method because...? Because I need to change the authentication method to align it with my launcher credentials. And them seeing the world for a very short time is a problem because...? If someone try to login with another player usename (with wrong credentials) can see where he is in the world. You can cancel the login chat message. Yep, but prevent the login at a lower level seems more "clean".
  12. I'm working with Doctor, the problem is that the patch to the other class is not replaceable with anything (but it's working) and the event is processed too late to prevent the login. If we use ServerConnectionFromClientEvent or PlayerLoggedInEvent the player gets kicked after his login fires in chat and if his connection is very poor, he can see the world for a short time.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.