// 初始化hook public static void init(MCCSAPI api) { mcapi = api; // 改写原始代码数据 if (api.VERSION == "1.16.100.4") { byte[] jmp_expplaycheck = { 0xeb, 0x07, 0xF6, 0x00, 0x04, 0xeb, 0x00, 0xeb, 0x00 }; // IDA jmp short + 7 if (api.writeHardMemory(0x0AC36F9, jmp_expplaycheck, 9)) { Console.WriteLine("[C# hack] JS 引擎实验性验证已跳过。"); } else { Console.WriteLine("[C# hack] Some hardcode err excption."); } } // 初始化RVA,或可远程获取 ArrayList al = new ArrayList(new int[] { 0x00B9D4C0, 0x00429850, 0x004ECFD0 }); RVAs["1.16.1.2"] = al; ArrayList a2 = new ArrayList(new int[] { 0x00B9D100, 0x00429820, 0x004ECFA0 }); RVAs["1.16.10.2"] = a2; ArrayList a3 = new ArrayList(new int[] { 0x00BA3560, 0x0042D250, 0x004F0920 }); RVAs["1.16.20.3"] = a3; ArrayList a4 = new ArrayList(new int[] { 0x00BA1200, 0x0042D260, 0x004F0930 }); RVAs["1.16.40.2"] = a4; try { ArrayList rval = null; if (RVAs.TryGetValue(api.VERSION, out rval)) { if (rval != null && rval.Count > 0) { IntPtr tmpCrtorg = IntPtr.Zero; api.cshook((int)rval[0], // IDA ServerScoreboard::onPlayerJoined Marshal.GetFunctionPointerForDelegate(cs_crthookptr), out tmpCrtorg); _CS_ONCREATEPLAYER_org = tmpCrtorg; tmpCrtorg = IntPtr.Zero; api.cshook((int)rval[1], // IDA CommandRegistry::registerCommand Marshal.GetFunctionPointerForDelegate(cs_reghookptr), out tmpCrtorg); _CS_REGISTERCOMMAND_org = tmpCrtorg; } } } catch (Exception e) { Console.WriteLine(e.StackTrace); } }
public static void init(MCCSAPI api) { mapi = api; // 高版本,函数被优化,使用汇编机器码方式直接改写源程序机器码 switch (api.VERSION) { case "1.16.100.4": case "1.16.101.1": { //byte[] orgdata = {0xF6, 0x00, 0x04, 0x0F, 0x84, 0x47, 0x01, 0x00, 0x00}; // IDA test XX, jz XX //byte[] loaded = api.readHardMemory(0x0AC36F9, 9); //if (string.Compare(Convert.ToBase64String(orgdata), Convert.ToBase64String(loaded)) == 0) { // // 特征码测试通过 // Console.WriteLine("explay check readHardMemory OK"); //} byte[] jmp_explaycheckcode = { 0xeb, 0x07, 0, 0, 0, 0, 0, 0, 0 }; // IDA jmp short + 7, hex data if (api.writeHardMemory(0x0AC36F9, jmp_explaycheckcode, 9)) // IDA MinecraftServerScriptEngine::onServerThreadStarted + 0x69 // JS 引擎对实验性玩法的验证通过汇编码跳过 { const int symregcmd = 0x00A1E8E0; // IDA CommandRegistry::registerCommand nocheat(symregcmd); } } break; case "1.16.200.2": case "1.16.201.2": case "1.16.201.3": { byte[] jmp_explaycheckcode = { 0xeb, 0x07, 0, 0, 0, 0, 0, 0, 0 }; if (api.writeHardMemory(0x0CB1379, jmp_explaycheckcode, 9)) { const int symregcmd = 0x00C0D650; nocheat(symregcmd); } } break; case "1.16.210.05": case "1.16.210.06": case "1.16.220.02": case "1.16.221.01": case "1.17.0.03": case "1.17.1.01": case "1.17.2.01": case "1.17.10.04": { Hashtable rva_sestart = new Hashtable(); rva_sestart["1.16.210.05"] = 0x0B325C1; rva_sestart["1.16.210.06"] = 0x00B21710 + 0x61; rva_sestart["1.16.220.02"] = 0x00BF6090 + 0x61; rva_sestart["1.16.221.01"] = 0x00BF6220 + 0x61; rva_sestart["1.17.0.03"] = 0x00E59380 + 0x61; rva_sestart["1.17.1.01"] = 0x00E58E20 + 0x61; rva_sestart["1.17.2.01"] = 0x00E58E60 + 0x61; rva_sestart["1.17.10.04"] = 0x00E4A030 + 0x61; Hashtable rva_regcmd = new Hashtable(); rva_regcmd["1.16.210.05"] = 0x00612040; rva_regcmd["1.16.210.06"] = 0x006112B0; rva_regcmd["1.16.220.02"] = 0x00683AC0; rva_regcmd["1.16.221.01"] = 0x00683A90; rva_regcmd["1.17.0.03"] = 0x0075F9F0; rva_regcmd["1.17.1.01"] = 0x0075F610; rva_regcmd["1.17.2.01"] = 0x0075F620; rva_regcmd["1.17.10.04"] = 0x00793530; byte[] jmp_explaycheckcode = { 0xeb, 0x06, 0, 0, 0, 0, 0, 0 }; if (api.writeHardMemory((int)rva_sestart[api.VERSION], jmp_explaycheckcode, 8)) { int symregcmd = (int)rva_regcmd[api.VERSION]; nocheat(symregcmd); } } break; } // 初始化RVA,或可远程获取,早期版本 var a1 = new ArrayList(new int[] { 0x00A7F9C0, 0x004CD7D0, 0x0042D250 }); RVAs["1.16.20.3"] = a1; var a2 = new ArrayList(new int[] { 0x00A7D660, 0x004CD7E0, 0x0042D260 }); RVAs["1.16.40.2"] = a2; try { ArrayList rval = null; if (RVAs.TryGetValue(api.VERSION, out rval)) { if (rval != null && rval.Count > 0) { bool ret = api.cshook((int)rval[1], // IDA MinecraftServerScriptEngine::onServerThreadStarted Marshal.GetFunctionPointerForDelegate(jsonpen), out jsorg); ret = ret && api.cshook((int)rval[2], // IDA CommandRegistry::registerCommand Marshal.GetFunctionPointerForDelegate(cmdnocheat), out cregorg); if (ret) { Console.WriteLine("[UnlockScripting] Addons脚本引擎+作弊指令已强开。"); } } } } catch (Exception e) { Console.WriteLine(e.StackTrace); } }