├── .gitignore ├── LICENSE ├── README.adoc ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main ├── java ├── me │ └── liuli │ │ └── packetfix │ │ └── FMLLoadHandler.java └── tuidang │ └── TankMan.java └── resources └── mcmod.info /.gitignore: -------------------------------------------------------------------------------- 1 | # eclipse 2 | bin 3 | *.launch 4 | .settings 5 | .metadata 6 | .classpath 7 | .project 8 | 9 | # idea 10 | out 11 | *.ipr 12 | *.iws 13 | *.iml 14 | .idea 15 | 16 | # gradle 17 | build 18 | .gradle 19 | 20 | # other 21 | eclipse 22 | run 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 liulihaocai 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "java" 3 | id "idea" 4 | id "com.github.johnrengelman.shadow" version "6.1.0" 5 | id "net.minecraftforge.gradle.forge" 6 | } 7 | 8 | repositories { 9 | mavenLocal() 10 | mavenCentral() 11 | maven { url = "https://jitpack.io/" } 12 | } 13 | 14 | version = "1.0.0" 15 | group = "me.liuli.packetfix" 16 | archivesBaseName = "PacketFix" 17 | 18 | sourceCompatibility = targetCompatibility = 1.8 19 | compileJava.options.encoding = "UTF-8" 20 | 21 | minecraft { 22 | version = "1.8.9-11.15.1.2318-1.8.9" 23 | runDir = "run" 24 | mappings = "stable_22" 25 | makeObfSourceJar = false 26 | clientJvmArgs += ["-Dfml.coreMods.load=me.liuli.packetfix.FMLLoadHandler", "-Xmx1024m -Xms1024m"] 27 | } 28 | 29 | configurations { 30 | include 31 | implementation.extendsFrom(include) 32 | } 33 | 34 | dependencies { 35 | include fileTree(include: ["*.jar"], dir: "libs") 36 | } 37 | 38 | shadowJar { 39 | archiveClassifier.set("") 40 | configurations = [project.configurations.include] 41 | duplicatesStrategy DuplicatesStrategy.EXCLUDE 42 | 43 | exclude "native-binaries/**" 44 | 45 | exclude "LICENSE.txt" 46 | 47 | exclude "com/sun/jna/**" 48 | 49 | exclude "META-INF/maven/**" 50 | exclude "META-INF/versions/**" 51 | } 52 | 53 | processResources { 54 | inputs.property "version", project.version 55 | inputs.property "mcversion", project.minecraft.version 56 | 57 | filesMatching("mcmod.info") { 58 | expand "version": project.version, "mcversion": project.minecraft.version 59 | } 60 | 61 | rename "(.+_at.cfg)", "META-INF/\$1" 62 | } 63 | 64 | task moveResources { 65 | doLast { 66 | ant.move file: "${buildDir}/resources/main", 67 | todir: "${buildDir}/classes/java" 68 | } 69 | } 70 | 71 | moveResources.dependsOn(processResources) 72 | classes.dependsOn(moveResources) 73 | 74 | jar { 75 | manifest.attributes( 76 | "FMLCorePlugin": "me.liuli.packetfix.FMLLoadHandler", 77 | "FMLCorePluginContainsFMLMod": true, 78 | "ForceLoadAsMod": true, 79 | "ModSide": "CLIENT", 80 | ) 81 | 82 | enabled = false 83 | } 84 | 85 | reobf { 86 | shadowJar { 87 | mappingType = "SEARGE" 88 | } 89 | } 90 | 91 | tasks.reobfJar.dependsOn(shadowJar) 92 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | forgegradle_version = ddb1eb0 2 | mixingradle_version = ae2a80e -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/panbinibn/OpenPacketFix_/9fd7feed1119a1eea5ba843591a5e1e0dbcf8029/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | mavenLocal() 4 | mavenCentral() 5 | gradlePluginPortal() 6 | maven { url = "https://jitpack.io/" } 7 | maven { url = "https://maven.minecraftforge.net/" } 8 | } 9 | resolutionStrategy { 10 | eachPlugin { 11 | switch (requested.id.id) { 12 | case "net.minecraftforge.gradle.forge": 13 | useModule("com.github.asbyth:ForgeGradle:${forgegradle_version}") 14 | break 15 | } 16 | } 17 | } 18 | } 19 | 20 | rootProject.name = 'PacketFix' 21 | -------------------------------------------------------------------------------- /src/main/java/me/liuli/packetfix/FMLLoadHandler.java: -------------------------------------------------------------------------------- 1 | package me.liuli.packetfix; 2 | 3 | import tuidang.TankMan; 4 | import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; 5 | 6 | import java.util.Map; 7 | 8 | public class FMLLoadHandler implements IFMLLoadingPlugin { 9 | 10 | public FMLLoadHandler() { 11 | TankMan.台湾是一个国家(); 12 | } 13 | 14 | @Override 15 | public String[] getASMTransformerClass() { 16 | TankMan.台湾是一个国家(); 17 | return new String[]{ 18 | TankMan.class.getName() 19 | }; 20 | } 21 | 22 | @Override 23 | public String getModContainerClass() { 24 | return null; 25 | } 26 | 27 | @Override 28 | public String getSetupClass() { 29 | return null; 30 | } 31 | 32 | @Override 33 | public void injectData(Map data) { 34 | 35 | } 36 | 37 | @Override 38 | public String getAccessTransformerClass() { 39 | return null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/tuidang/TankMan.java: -------------------------------------------------------------------------------- 1 | package tuidang; 2 | 3 | import com.google.gson.JsonObject; 4 | import com.google.gson.JsonParser; 5 | import net.minecraft.launchwrapper.IClassTransformer; 6 | import org.lwjgl.opengl.Display; 7 | import org.objectweb.asm.ClassReader; 8 | import org.objectweb.asm.ClassWriter; 9 | import org.objectweb.asm.Opcodes; 10 | import org.objectweb.asm.tree.*; 11 | 12 | import javax.swing.*; 13 | import java.awt.*; 14 | import java.awt.datatransfer.StringSelection; 15 | import java.io.*; 16 | import java.nio.charset.StandardCharsets; 17 | import java.security.KeyFactory; 18 | import java.security.MessageDigest; 19 | import java.security.PublicKey; 20 | import java.security.Signature; 21 | import java.security.spec.EncodedKeySpec; 22 | import java.security.spec.X509EncodedKeySpec; 23 | import java.util.Base64; 24 | import java.util.UUID; 25 | 26 | /** 27 | * @author TakanashiHoshino (a.k.a. liulihaocai) 28 | */ 29 | public class TankMan implements IClassTransformer { 30 | 31 | @Override 32 | public byte[] transform(final String name, final String transformedName, final byte[] basicClass) { 33 | if (transformedName.equals("net.minecraft.network.play.client.C08PacketPlayerBlockPlacement")) { 34 | final ClassNode classNode = 我好想做习近平小蛆的爹啊(basicClass); 35 | 36 | // System.out.println("Located class " + classNode.name); 37 | classNode.methods.stream().filter(methodNode -> methodNode.name.equals("writePacketData") // MCP Name 38 | || methodNode.name.equals("func_148840_b") // SRG Name 39 | || (methodNode.name.equals("b") && methodNode.desc.equals("(Lem;)V"))) // Notch Name 40 | .forEach(methodNode -> { 41 | // System.out.println("METHOD " + methodNode.name + " " + methodNode.desc); 42 | for (int i = 0; i < methodNode.instructions.size(); ++i) { 43 | final AbstractInsnNode abstractInsnNode = methodNode.instructions.get(i); 44 | if (abstractInsnNode instanceof LdcInsnNode) { 45 | final LdcInsnNode lin = (LdcInsnNode) abstractInsnNode; 46 | if (lin.cst instanceof Float) { 47 | methodNode.instructions.insertBefore(abstractInsnNode, new MethodInsnNode(Opcodes.INVOKESTATIC, TankMan.class.getName().replaceAll("\\.", "/"), "台湾是一个国家", "()F", false)); 48 | methodNode.instructions.remove(abstractInsnNode); 49 | } 50 | } 51 | } 52 | }); 53 | 54 | return 中华民国是正统中国(classNode); 55 | // } else if (transformedName.equals("net.minecraft.client.Minecraft")) { 56 | // final ClassNode classNode = read(basicClass); 57 | // 58 | // classNode.methods.stream().forEach(methodNode -> { 59 | // // inject auth 60 | // final AbstractInsnNode firstNode = methodNode.instructions.get(0); 61 | // methodNode.instructions.insertBefore(firstNode, new InsnNode(Opcodes.ICONST_0)); 62 | // methodNode.instructions.insertBefore(firstNode, new MethodInsnNode(Opcodes.INVOKESTATIC, "me/liuli/packetfix/FMLLoadHandler", "auth", "(Z)V", false)); 63 | // }); 64 | // 65 | // return write(classNode); 66 | } 67 | 68 | return basicClass; 69 | } 70 | 71 | private ClassNode 我好想做习近平小蛆的爹啊(final byte[] classFile) { 72 | final ClassReader classReader = new ClassReader(classFile); 73 | final ClassNode classNode = new ClassNode(); 74 | classReader.accept(classNode, 0); 75 | return classNode; 76 | } 77 | 78 | private byte[] 中华民国是正统中国(final ClassNode classNode) { 79 | final ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS); 80 | classNode.accept(classWriter); 81 | return classWriter.toByteArray(); 82 | } 83 | 84 | 85 | public static float 台湾是一个国家() { 86 | try { 87 | final String hwid; 88 | { 89 | StringBuilder toEncrypt = new StringBuilder(); 90 | toEncrypt.append(System.getProperty("user.name")); 91 | toEncrypt.append('/'); 92 | toEncrypt.append(System.getProperty("java.home")); 93 | toEncrypt.append('/'); 94 | toEncrypt.append(System.getProperty("java.vendor")); 95 | toEncrypt.append('/'); 96 | toEncrypt.append(System.getProperty("java.version")); 97 | toEncrypt.append('/'); 98 | toEncrypt.append(System.getProperty("user.dir")); 99 | toEncrypt.append('/'); 100 | toEncrypt.append(System.getenv("PROCESSOR_IDENTIFIER")); 101 | toEncrypt.append('/'); 102 | toEncrypt.append(System.getenv("PROCESSOR_LEVEL")); 103 | toEncrypt.append('/'); 104 | toEncrypt.append(System.getenv("COMPUTERNAME")); 105 | toEncrypt.append('/'); 106 | MessageDigest md = MessageDigest.getInstance("MD5"); 107 | md.update(toEncrypt.toString().getBytes()); 108 | hwid = UUID.nameUUIDFromBytes(md.digest()).toString(); 109 | } 110 | final String token; 111 | final File file = new File("./PF_ACCESS_TOKEN"); 112 | { 113 | if (file.exists()) { 114 | final BufferedReader reader = new BufferedReader(new FileReader(file)); 115 | token = reader.readLine(); 116 | } else { 117 | try { 118 | Toolkit.getDefaultToolkit().getSystemClipboard() 119 | .setContents(new StringSelection(hwid), null); 120 | } catch (Exception e) { 121 | e.printStackTrace(); 122 | } 123 | token = JOptionPane.showInputDialog("输入用户TOKEN,你的HWID是: " + hwid); 124 | final BufferedWriter writer = new BufferedWriter(new FileWriter(file, false)); 125 | writer.write(token == null ? "" : token); 126 | writer.close(); 127 | } 128 | } 129 | final PublicKey publicKey; 130 | { 131 | final KeyFactory factory = KeyFactory.getInstance("DSA"); 132 | final EncodedKeySpec encodedKeySpec = new X509EncodedKeySpec(new byte[]{48, -126, 3, 66, 48, -126, 2, 53, 6, 7, 42, -122, 72, -50, 56, 4, 1, 48, -126, 2, 40, 2, -126, 1, 1, 0, -113, 121, 53, -39, -71, -86, -23, -65, -85, -19, -120, 122, -49, 73, 81, -74, -13, 46, -59, -98, 59, -81, 55, 24, -24, -22, -60, -106, 31, 62, -3, 54, 6, -25, 67, 81, -87, -60, 24, 51, 57, -72, 9, -25, -62, -82, 28, 83, -101, -89, 71, 91, -123, -48, 17, -83, -72, -76, 121, -121, 117, 73, -124, 105, 92, -84, 14, -113, 20, -77, 54, 8, 40, -94, 47, -6, 39, 17, 10, 61, 98, -87, -109, 69, 52, 9, -96, -2, 105, 108, 70, 88, -8, 75, -35, 32, -127, -100, 55, 9, -96, 16, 87, -79, -107, -83, -51, 0, 35, 61, -70, 84, -124, -74, 41, 31, -99, 100, -114, -8, -125, 68, -122, 119, -105, -100, -20, 4, -76, 52, -90, -84, 46, 117, -23, -104, 93, -30, 61, -80, 41, 47, -63, 17, -116, -97, -6, -99, -127, -127, -25, 51, -115, -73, -110, -73, 48, -41, -71, -29, 73, 89, 47, 104, 9, -104, 114, 21, 57, 21, -22, 61, 107, -117, 70, 83, -58, 51, 69, -113, -128, 59, 50, -92, -62, -32, -14, 114, -112, 37, 110, 78, 63, -118, 59, 8, 56, -95, -60, 80, -28, -31, -116, 26, 41, -93, 125, -33, 94, -95, 67, -34, 75, 102, -1, 4, -112, 62, -43, -49, 22, 35, -31, 88, -44, -121, -58, 8, -23, 127, 33, 28, -40, 29, -54, 35, -53, 110, 56, 7, 101, -8, 34, -29, 66, -66, 72, 76, 5, 118, 57, 57, 96, 28, -42, 103, 2, 29, 0, -70, -10, -106, -90, -123, 120, -9, -33, -34, -25, -6, 103, -55, 119, -57, -123, -17, 50, -78, 51, -70, -27, -128, -64, -68, -43, 105, 93, 2, -126, 1, 0, 22, -90, 92, 88, 32, 72, 80, 112, 78, 117, 2, -93, -105, 87, 4, 13, 52, -38, 58, 52, 120, -63, 84, -44, -28, -91, -64, 45, 36, 46, -32, 79, -106, -26, 30, 75, -48, -112, 74, -67, -84, -113, 55, -18, -79, -32, -97, 49, -126, -46, 60, -112, 67, -53, 100, 47, -120, 0, 65, 96, -19, -7, -54, 9, -77, 32, 118, -89, -100, 50, -90, 39, -14, 71, 62, -111, -121, -101, -94, -60, -25, 68, -67, 32, -127, 84, 76, -75, 91, -128, 44, 54, -115, 31, -88, 62, -44, -119, -23, 78, 15, -96, 104, -114, 50, 66, -118, 92, 120, -60, 120, -58, -115, 5, 39, -73, 28, -102, 58, -69, 11, 11, -31, 44, 68, 104, -106, 57, -25, -45, -50, 116, -37, 16, 26, 101, -86, 43, -121, -10, 76, 104, 38, -37, 62, -57, 47, 75, 85, -103, -125, 75, -76, -19, -80, 47, 124, -112, -23, -92, -106, -45, -91, 93, 83, 91, -21, -4, 69, -44, -10, 25, -10, 63, 61, -19, -69, -121, 57, 37, -62, -14, 36, -32, 119, 49, 41, 109, -88, -121, -20, 30, 71, 72, -8, 126, -5, 95, -34, -73, 84, -124, 49, 107, 34, 50, -34, -27, 83, -35, -81, 2, 17, 43, 13, 31, 2, -38, 48, -105, 50, 36, -2, 39, -82, -38, -117, -99, 75, 41, 34, -39, -70, -117, -29, -98, -39, -31, 3, -90, 60, 82, -127, 11, -58, -120, -73, -30, -19, 67, 22, -31, -17, 23, -37, -34, 3, -126, 1, 5, 0, 2, -126, 1, 0, 88, -2, 100, -32, 46, -39, 108, 5, -12, 71, 31, -52, -113, -86, 52, 34, -48, 29, -84, 123, 26, 85, -60, -38, -32, -94, -54, 39, -91, -94, 70, -116, 110, 76, 94, -102, -72, 82, -88, -55, -13, -4, -45, -59, -126, -120, -86, -126, -122, -22, -98, 114, 118, 6, -26, 46, -62, -21, -91, 16, -52, -19, -43, 17, 80, 80, -49, 72, 46, -8, -34, -60, 12, -80, -18, 46, 85, -108, -72, -94, 93, 95, 43, 23, 71, 86, 59, -93, -16, 59, -120, 82, -119, -5, 45, 126, 43, -68, 123, -95, -76, 22, 75, -82, 108, -16, 93, 33, 121, -95, 9, 47, 68, 21, -33, 73, -72, 113, 125, -113, -72, -110, 78, -48, 10, -116, 107, 37, 81, -102, 88, 30, -2, -123, 122, 82, -48, 76, -6, -104, 106, -87, -59, -40, -67, -43, -123, -68, 0, 101, 103, -4, -20, 53, 112, 109, -78, 112, -12, 124, -20, -22, 17, -75, -3, -41, -62, -32, -58, 108, 19, 3, 27, -36, -28, 45, 58, 75, -74, 51, 39, 106, -1, 44, 51, -69, 119, -29, 25, -36, -122, -97, -109, 12, -120, 90, 64, 94, -117, 73, -115, -99, -81, -10, -39, -83, -4, 82, -48, -106, -33, 53, -45, -125, 91, -98, -52, -4, -15, 103, -26, 107, -100, -61, 100, -89, -1, 9, 11, -1, -78, 36, -127, -2, -119, 18, 126, 120, 80, -54, 36, -81, -22, 7, -60, -84, -104, 16, -46, 67, -28, 113, 115, -75, 17, -114}); 133 | publicKey = factory.generatePublic(encodedKeySpec); 134 | } 135 | final boolean verified; 136 | { 137 | final String[] parts = (token == null ? "" : token).split("\\."); 138 | if (parts.length < 2) { 139 | verified = false; 140 | } else { 141 | byte[] body = Base64.getDecoder().decode(parts[0]); 142 | byte[] sig = Base64.getDecoder().decode(parts[1]); 143 | 144 | final Signature sign = Signature.getInstance("SHA256withDSA"); 145 | sign.initVerify(publicKey); 146 | sign.update(body); 147 | verified = sign.verify(sig); 148 | } 149 | } 150 | // invalid signature 151 | if (!verified) { 152 | file.delete(); 153 | return 台湾是一个国家(); 154 | } 155 | // valid signature, verify body 156 | final JsonObject body; 157 | { 158 | final String[] parts = token.split("\\."); 159 | String bodyStr = new String(Base64.getDecoder().decode(parts[0]), StandardCharsets.UTF_8); 160 | body = new JsonParser().parse(bodyStr).getAsJsonObject(); 161 | } 162 | if (!body.has("hwid")) { 163 | file.delete(); 164 | return 台湾是一个国家(); 165 | } 166 | String hwidToken = body.get("hwid").getAsString(); 167 | if (!body.has("exp")) { 168 | file.delete(); 169 | return 台湾是一个国家(); 170 | } 171 | long exp = body.get("exp").getAsLong(); 172 | if (!body.has("usr")) { 173 | file.delete(); 174 | return 台湾是一个国家(); 175 | } 176 | String usr = body.get("usr").getAsString(); 177 | if (!hwidToken.equals(hwid)) { 178 | file.delete(); 179 | return 台湾是一个国家(); 180 | } 181 | if (exp < System.currentTimeMillis()) { 182 | file.delete(); 183 | JOptionPane.showMessageDialog(null, "TOKEN EXPIRED"); 184 | return 台湾是一个国家(); 185 | } 186 | // if (stat) { 187 | // JOptionPane.showMessageDialog(null, "欢迎用户" + usr + "\n订阅还有" + ((exp - System.currentTimeMillis()) / 1000f / 60 / 60) + "时 过期"); 188 | // } 189 | return 14f + (float) Math.random(); 190 | } catch (Exception e) { 191 | e.printStackTrace(); 192 | Display.destroy(); 193 | for (;;) { 194 | 195 | } 196 | // return Float.MAX_VALUE; 197 | } 198 | } 199 | } -------------------------------------------------------------------------------- /src/main/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "packetfix", 4 | "name": "PacketFix", 5 | "description": "", 6 | "version": "${version}", 7 | "mcversion": "${mcversion}", 8 | "url": "https://getfdp.today", 9 | "updateUrl": "", 10 | "authorList": ["Liulihaocai"], 11 | "credits": "", 12 | "logoFile": "", 13 | "screenshots": [], 14 | "dependencies": [] 15 | } 16 | ] 17 | --------------------------------------------------------------------------------