Files
raton4.0-source/Raton RAT/WpfApp1/FriendsWindow.cs
T

197 lines
6.7 KiB
C#
Raw Normal View History

2026-08-27 11:23:13 -06:00
// Decompiled with JetBrains decompiler
// Type: WpfApp1.FriendsWindow
// 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 DarkModeForms;
using Raton.Classes;
using RatonBack;
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interop;
using System.Windows.Markup;
#nullable disable
namespace WpfApp1;
public partial class FriendsWindow : Window
{
private readonly ObservableCollection<FriendItem> _friends = new ObservableCollection<FriendItem>();
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
public string User { get; set; }
public string DeviceId { get; set; }
[DllImport("dwmapi.dll", CharSet = CharSet.Auto)]
private static extern int DwmSetWindowAttribute(
IntPtr hwnd,
int attr,
ref int attrValue,
int attrSize);
public FriendsWindow()
{
this.InitializeComponent();
this.FriendsList.ItemsSource = (IEnumerable) this._friends;
this.Loaded += new RoutedEventHandler(this.FriendsWindow_Loaded);
}
private async void FriendsWindow_Loaded(object sender, RoutedEventArgs e)
{
FriendsWindow friendsWindow = this;
friendsWindow.ApplyDarkTitle();
string id = await BackendClient.GetID(friendsWindow.DeviceId);
if (!friendsWindow.IsLoaded)
return;
friendsWindow.TbAccountHeader.Text = $"Your friends (Account ID: {id})";
await friendsWindow.LoadFriends();
}
private async Task LoadFriends()
{
(int, string[], string) friends = await BackendClient.GetFriends(this.DeviceId, this.User);
this._friends.Clear();
if (friends.Item2 == null)
return;
foreach (string a in friends.Item2)
{
string str = $"{a} (@{a})";
if (string.Equals(a, "osaka", StringComparison.OrdinalIgnoreCase))
str = "osaka (@Silly)";
this._friends.Add(new FriendItem()
{
Username = a,
DisplayName = str
});
}
if (Application.Current.MainWindow is MainWindow mainWindow)
mainWindow.statFriends.Text = friends.Item1.ToString();
try
{
int num = await BackendClient.ValidateSessionFlags(DeviceManager.GetHWID(), DeviceManager.GetOrCreateId()) ? 1 : 0;
}
catch (Exception ex)
{
int num = (int) MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);
Environment.Exit(0);
}
}
private void TbFriendId_TextChanged(object sender, TextChangedEventArgs e)
{
this.TbPlaceholder.Visibility = string.IsNullOrEmpty(this.TbFriendId.Text) ? Visibility.Visible : Visibility.Collapsed;
}
private async void BtnAdd_Click(object sender, RoutedEventArgs e)
{
string friendDeviceId = this.TbFriendId.Text.Trim();
if (string.IsNullOrWhiteSpace(friendDeviceId))
{
int num1 = (int) Messenger.MessageBox("Please enter a friend ID.", "Missing ID", icon: MessageBoxImage.Exclamation);
}
else
{
try
{
this.BtnAdd.IsEnabled = false;
if (await BackendClient.AddFriend(this.DeviceId, friendDeviceId))
{
this.TbFriendId.Clear();
await this.LoadFriends();
int num2 = (int) Messenger.MessageBox("Friend added successfully.", "Success", icon: MessageBoxImage.Asterisk);
}
else
{
int num3 = (int) Messenger.MessageBox("Failed to add friend.", "Error", icon: MessageBoxImage.Hand);
}
}
catch (Exception ex)
{
int num4 = (int) Messenger.MessageBox(ex.Message, "Backend error", icon: MessageBoxImage.Hand);
}
finally
{
this.BtnAdd.IsEnabled = true;
}
}
}
private async void BtnRemove_Click(object sender, RoutedEventArgs e)
{
if (!(this.FriendsList.SelectedItem is FriendItem selectedItem))
{
int num1 = (int) Messenger.MessageBox("Select a friend first.", "Nothing selected", icon: MessageBoxImage.Exclamation);
}
else
{
try
{
this.BtnRemove.IsEnabled = false;
bool flag = await BackendClient.RemoveFriend(this.DeviceId, this.User, selectedItem.Username);
int num2 = (int) Messenger.MessageBox(flag ? "Friend removed." : "Failed to remove friend.", flag ? "Success" : "Warning", icon: MessageBoxImage.Asterisk);
await this.LoadFriends();
}
catch (Exception ex)
{
int num3 = (int) Messenger.MessageBox(ex.Message, "Backend error", icon: MessageBoxImage.Hand);
}
finally
{
this.BtnRemove.IsEnabled = true;
}
}
}
private async void BtnShareLink_Click(object sender, RoutedEventArgs e)
{
FriendsWindow friendsWindow = this;
ShareLinkDialog shareLinkDialog1 = new ShareLinkDialog();
shareLinkDialog1.Owner = (Window) friendsWindow;
ShareLinkDialog shareLinkDialog2 = shareLinkDialog1;
bool? nullable = shareLinkDialog2.ShowDialog();
bool flag1 = true;
if (!(nullable.GetValueOrDefault() == flag1 & nullable.HasValue))
return;
string str = shareLinkDialog2.LinkText.Trim();
Uri result;
if (!Uri.TryCreate(str, UriKind.Absolute, out result) || !(result.Scheme == Uri.UriSchemeHttp) && !(result.Scheme == Uri.UriSchemeHttps) || !str.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
{
int num1 = (int) Messenger.MessageBox("Only direct .exe links allowed.", "Invalid link", icon: MessageBoxImage.Exclamation);
}
else
{
try
{
friendsWindow.BtnShareLink.IsEnabled = false;
bool flag2 = await BackendClient.SetFriendLink(friendsWindow.DeviceId, friendsWindow.User, str);
int num2 = (int) Messenger.MessageBox(flag2 ? "Share link updated successfully." : "Failed to update link.", flag2 ? "Success" : "Error", icon: flag2 ? MessageBoxImage.Asterisk : MessageBoxImage.Hand);
}
catch (Exception ex)
{
int num3 = (int) Messenger.MessageBox(ex.Message, "Backend error", icon: MessageBoxImage.Hand);
}
finally
{
friendsWindow.BtnShareLink.IsEnabled = true;
}
}
}
private void ApplyDarkTitle()
{
IntPtr handle = new WindowInteropHelper((Window) this).Handle;
int attrValue = 1;
FriendsWindow.DwmSetWindowAttribute(handle, 20, ref attrValue, Marshal.SizeOf(typeof (int)));
}
}