-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.cs
executable file
·89 lines (69 loc) · 2.66 KB
/
Plugin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.Mono;
using HarmonyLib;
using System.Text;
using System;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
namespace Marathon;
[BepInPlugin("org.ret2plt.Marathon", "Marathon", "1.0.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static new ManualLogSource Logger;
public class SecureAESInstance : IDisposable
{
private RijndaelManaged _rijndael;
private ICryptoTransform _encryptor;
public SecureAESInstance(byte[] key)
{
this._rijndael = new RijndaelManaged();
this._encryptor = this._rijndael.CreateEncryptor(key, this._rijndael.IV);
key = SymmetricAlgorithm.Create("AES").Key;
}
public void Dispose()
{
_encryptor?.Dispose();
_rijndael?.Dispose();
}
public byte[] Encrypt(byte[] buffer)
{
byte[] second = _encryptor.TransformFinalBlock(buffer, 0, buffer.Length);
return _rijndael.IV.Concat(second).ToArray();
}
}
private void Awake()
{
// Plugin startup logic
Logger = base.Logger;
Logger.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");
var harmony = new Harmony("org.ret2plt.Marathon");
Logger.LogInfo($"Harmony {harmony.Id} is loaded!");
[HarmonyPatch(typeof(EncryptionHelper.SimpleAes), "Encrypt")]
[HarmonyPrefix]
string EncryptPrefix(string input)
{
SecureAESInstance aes = new SecureAESInstance(SymmetricAlgorithm.Create("AES").Key);
return Convert.ToBase64String(aes.Encrypt(Encoding.UTF8.GetBytes(input)));
}
//harmony.Patch(
// typeof(EncryptionHelper.SimpleAes).GetMethod("Encrypt"),
// prefix: new HarmonyMethod(typeof(Plugin).GetMethod("EncryptPrefix"))
//);
Logger.LogInfo("Patched vulnerable Encrypt method");
[HarmonyPatch(typeof(SecurityChecker), "antivirusInstalled")]
[HarmonyPrefix]
bool antivirusInstalledPrefix()
{
return false;
}
//harmony.Patch(
// typeof(SecurityChecker).GetMethod("antivirusInstalled"),
// prefix: new HarmonyMethod(typeof(Plugin).GetMethod("antivirusInstalledPrefix"))
//);
Logger.LogInfo("Patched out antivirusInstalled method");
harmony.PatchAll(Assembly.GetExecutingAssembly());
}
}