AquaDX/AquaMai/Fix/RemoveEncryption.cs

51 lines
1.5 KiB
C#
Raw Normal View History

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))]
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]
public class EncryptDecrypt
2024-07-09 18:11:06 +08:00
{
public static IEnumerable<MethodBase> TargetMethods()
{
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
}
public static bool Prefix(object[] __args, ref object __result)
2024-07-09 18:11:06 +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
}
}