2024-07-09 18:11:06 +08:00
|
|
|
|
using System.Collections.Generic;
|
2024-09-11 01:35:17 +08:00
|
|
|
|
using System.Linq;
|
2024-07-09 18:11:06 +08:00
|
|
|
|
using System.Reflection;
|
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using Net.Packet;
|
|
|
|
|
|
|
|
|
|
namespace AquaMai.Fix;
|
|
|
|
|
|
|
|
|
|
public class RemoveEncryption
|
|
|
|
|
{
|
|
|
|
|
[HarmonyPrefix]
|
2024-09-11 01:35:17 +08:00
|
|
|
|
[HarmonyPatch(typeof(Packet), "Obfuscator", typeof(string))]
|
2024-10-13 21:35:13 +08:00
|
|
|
|
public static bool PreObfuscator(string srcStr, ref string __result)
|
2024-07-09 18:11:06 +08:00
|
|
|
|
{
|
|
|
|
|
__result = srcStr.Replace("MaimaiExp", "").Replace("MaimaiChn", "");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HarmonyPatch]
|
2024-10-13 21:35:13 +08:00
|
|
|
|
public class EncryptDecrypt
|
2024-07-09 18:11:06 +08:00
|
|
|
|
{
|
|
|
|
|
public static IEnumerable<MethodBase> TargetMethods()
|
|
|
|
|
{
|
2024-10-13 21:35:13 +08:00
|
|
|
|
var methods = AccessTools.TypeByName("Net.CipherAES").GetMethods();
|
|
|
|
|
return
|
|
|
|
|
[
|
|
|
|
|
methods.FirstOrDefault(it => it.Name == "Encrypt" && it.IsPublic),
|
|
|
|
|
methods.FirstOrDefault(it => it.Name == "Decrypt" && it.IsPublic)
|
|
|
|
|
];
|
2024-07-09 18:11:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-10-13 21:35:13 +08:00
|
|
|
|
public static bool Prefix(object[] __args, ref object __result)
|
2024-07-09 18:11:06 +08:00
|
|
|
|
{
|
2024-10-13 21:35:13 +08:00
|
|
|
|
if (__args.Length == 1)
|
|
|
|
|
{
|
|
|
|
|
// public static byte[] Encrypt(byte[] data)
|
|
|
|
|
// public static byte[] Decrypt(byte[] encryptData)
|
|
|
|
|
__result = __args[0];
|
|
|
|
|
}
|
|
|
|
|
else if (__args.Length == 2)
|
|
|
|
|
{
|
|
|
|
|
// public static bool Encrypt(byte[] data, out byte[] encryptData)
|
|
|
|
|
// public static bool Decrypt(byte[] encryptData, out byte[] plainData)
|
|
|
|
|
__args[1] = __args[0];
|
|
|
|
|
__result = true;
|
|
|
|
|
}
|
2024-09-11 01:35:17 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-07-09 18:11:06 +08:00
|
|
|
|
}
|
|
|
|
|
}
|