From 9384d1d96fd78ab839d9606aeb5d89622eec5640 Mon Sep 17 00:00:00 2001 From: Menci Date: Mon, 14 Oct 2024 02:04:26 +0800 Subject: [PATCH] [+] Bypass Cake.dll hash check and SSL pinning (#63) * Bypass Cake.dll hash check and SSL pinning * Move to BasicFix --- AquaMai/Fix/BasicFix.cs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/AquaMai/Fix/BasicFix.cs b/AquaMai/Fix/BasicFix.cs index 54e3d26f..189fbbd9 100644 --- a/AquaMai/Fix/BasicFix.cs +++ b/AquaMai/Fix/BasicFix.cs @@ -1,4 +1,5 @@ -using HarmonyLib; +using System.Net; +using HarmonyLib; using Manager; using Monitor.MusicSelect.ChainList; using Net; @@ -55,11 +56,23 @@ public class BasicFix return false; } - [HarmonyPrefix] - [HarmonyPatch(typeof(NetHttpClient), "CheckServerHash")] - private static bool CheckServerHash(ref bool __result) + [HarmonyPostfix] + [HarmonyPatch(typeof(NetHttpClient), MethodType.Constructor)] + private static void OnNetHttpClientConstructor(NetHttpClient __instance) { - __result = true; - return false; + // Bypass Cake.dll hash check + var tInstance = Traverse.Create(__instance).Field("isTrueDll"); + if (tInstance.FieldExists()) + { + tInstance.SetValue(true); + } + } + + [HarmonyPostfix] + [HarmonyPatch(typeof(NetHttpClient), "Create")] + private static void OnNetHttpClientCreate() + { + // Unset the certificate validation callback (SSL pinning) to restore the default behavior + ServicePointManager.ServerCertificateValidationCallback = null; } }