Files
raton4.0-source/Raton RAT/Raton/Classes/DeviceManager.cs
T
2026-08-27 11:23:13 -06:00

70 lines
1.9 KiB
C#

// Decompiled with JetBrains decompiler
// Type: Raton.Classes.DeviceManager
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
using Microsoft.Win32;
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using WpfApp1;
#nullable disable
namespace Raton.Classes;
public static class DeviceManager
{
private static readonly string DeviceFile = Path.Combine(MainWindow.appData, "device.id");
public static string GetHWID()
{
try
{
using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Cryptography"))
{
if (registryKey != null)
{
object obj = registryKey.GetValue("MachineGuid");
if (obj != null)
return DeviceManager.Sha256(obj.ToString());
}
}
}
catch
{
}
return $"HWID-{Environment.MachineName}-{Environment.UserName}";
}
public static string GetOrCreateId()
{
try
{
if (File.Exists(DeviceManager.DeviceFile))
return File.ReadAllText(DeviceManager.DeviceFile).Trim();
string contents = Guid.NewGuid().ToString("N");
Directory.CreateDirectory(Path.GetDirectoryName(DeviceManager.DeviceFile));
File.WriteAllText(DeviceManager.DeviceFile, contents);
return contents;
}
catch
{
return Guid.NewGuid().ToString("N");
}
}
private static string Sha256(string input)
{
using (SHA256 shA256 = SHA256.Create())
{
byte[] hash = shA256.ComputeHash(Encoding.UTF8.GetBytes(input));
StringBuilder stringBuilder = new StringBuilder();
foreach (byte num in hash)
stringBuilder.Append(num.ToString("x2"));
return stringBuilder.ToString();
}
}
}