initial commit
This commit is contained in:
@@ -0,0 +1,172 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Raton.RatonForms.BlockWindow
|
||||
// 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.CSharp.RuntimeBinder;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq.Expressions;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media;
|
||||
using WpfApp1;
|
||||
|
||||
#nullable disable
|
||||
namespace Raton.RatonForms;
|
||||
|
||||
public partial class BlockWindow : Window
|
||||
{
|
||||
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
|
||||
private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19;
|
||||
private const string PlaceholderText = "Enter the IP or Username here";
|
||||
|
||||
[DllImport("dwmapi.dll")]
|
||||
private static extern int DwmSetWindowAttribute(
|
||||
IntPtr hwnd,
|
||||
int dwAttribute,
|
||||
ref int pvAttribute,
|
||||
int cbAttribute);
|
||||
|
||||
public BlockWindow() => this.InitializeComponent();
|
||||
|
||||
protected override void OnSourceInitialized(EventArgs e)
|
||||
{
|
||||
base.OnSourceInitialized(e);
|
||||
this.ApplyDarkMode();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e) => this.LoadJson();
|
||||
|
||||
private void Window_Closing(object sender, CancelEventArgs e) => this.SaveJson();
|
||||
|
||||
private void ApplyDarkMode()
|
||||
{
|
||||
IntPtr handle = new WindowInteropHelper((Window) this).Handle;
|
||||
if (handle == IntPtr.Zero)
|
||||
return;
|
||||
int pvAttribute = this.IsWindowsDarkMode() ? 1 : 0;
|
||||
BlockWindow.DwmSetWindowAttribute(handle, 20, ref pvAttribute, 4);
|
||||
BlockWindow.DwmSetWindowAttribute(handle, 19, ref pvAttribute, 4);
|
||||
}
|
||||
|
||||
private bool IsWindowsDarkMode()
|
||||
{
|
||||
using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"))
|
||||
{
|
||||
if (registryKey != null)
|
||||
{
|
||||
if (registryKey.GetValue("AppsUseLightTheme") is int num)
|
||||
return num == 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void TextBox1_GotFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!(this.textBox1.Text == "Enter the IP or Username here"))
|
||||
return;
|
||||
this.textBox1.Text = string.Empty;
|
||||
this.textBox1.Foreground = (Brush) Brushes.White;
|
||||
}
|
||||
|
||||
private void TextBox1_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(this.textBox1.Text))
|
||||
return;
|
||||
this.textBox1.Text = "Enter the IP or Username here";
|
||||
this.textBox1.Foreground = (Brush) new SolidColorBrush(System.Windows.Media.Color.FromRgb((byte) 85, (byte) 85, (byte) 85));
|
||||
}
|
||||
|
||||
private void TextBox1_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key != Key.Return)
|
||||
return;
|
||||
this.AddEntry();
|
||||
}
|
||||
|
||||
private void BtnAdd_Click(object sender, RoutedEventArgs e) => this.AddEntry();
|
||||
|
||||
private void BtnBlock_Click(object sender, RoutedEventArgs e) => this.AddEntry();
|
||||
|
||||
private void BtnUnblock_Click(object sender, RoutedEventArgs e) => this.RemoveSelectedEntry();
|
||||
|
||||
private void ClearAll_Click(object sender, RoutedEventArgs e) => this.listBox1.Items.Clear();
|
||||
|
||||
private void RemoveSelected_Click(object sender, RoutedEventArgs e) => this.RemoveSelectedEntry();
|
||||
|
||||
private void AddEntry()
|
||||
{
|
||||
string newItem = this.textBox1.Text.Trim();
|
||||
if (string.IsNullOrEmpty(newItem) || newItem == "Enter the IP or Username here")
|
||||
return;
|
||||
this.listBox1.Items.Add((object) newItem);
|
||||
this.textBox1.Clear();
|
||||
this.textBox1.Focus();
|
||||
if (!(Application.Current.MainWindow is MainWindow mainWindow))
|
||||
return;
|
||||
object[] objArray = new object[1]
|
||||
{
|
||||
(object) $"USER has blocked a new connection ({newItem})"
|
||||
};
|
||||
mainWindow.AddLog(objArray);
|
||||
}
|
||||
|
||||
private void RemoveSelectedEntry()
|
||||
{
|
||||
if (this.listBox1.SelectedIndex == -1)
|
||||
return;
|
||||
this.listBox1.Items.RemoveAt(this.listBox1.SelectedIndex);
|
||||
}
|
||||
|
||||
private void LoadJson()
|
||||
{
|
||||
string filePath = BlockWindow.GetFilePath();
|
||||
if (!File.Exists(filePath))
|
||||
return;
|
||||
try
|
||||
{
|
||||
JObject json = JObject.Parse(File.ReadAllText(filePath));
|
||||
JArray ipArray = json["IP"] as JArray;
|
||||
if (ipArray != null)
|
||||
{
|
||||
foreach (var item in ipArray)
|
||||
{
|
||||
this.listBox1.Items.Add(item.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void SaveJson()
|
||||
{
|
||||
List<string> stringList = new List<string>();
|
||||
foreach (object obj in (IEnumerable) this.listBox1.Items)
|
||||
stringList.Add(obj.ToString());
|
||||
string contents = JsonConvert.SerializeObject((object) new
|
||||
{
|
||||
IP = stringList
|
||||
}, Formatting.Indented);
|
||||
string filePath = BlockWindow.GetFilePath();
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
|
||||
File.WriteAllText(filePath, contents);
|
||||
}
|
||||
|
||||
private static string GetFilePath() => Path.Combine(MainWindow.appData, "blocked.json");
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Raton.RatonForms.ConsoleTextBox
|
||||
// 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 System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#nullable disable
|
||||
namespace Raton.RatonForms;
|
||||
|
||||
public class ConsoleTextBox : RichTextBox
|
||||
{
|
||||
private int inputStart;
|
||||
|
||||
public string UserID { get; set; }
|
||||
|
||||
public string Username { get; set; }
|
||||
|
||||
public event Action<string> CommandEntered;
|
||||
|
||||
public Func<string, string> AutoCompleteHandler { get; set; }
|
||||
|
||||
public ConsoleTextBox()
|
||||
{
|
||||
this.BorderStyle = BorderStyle.None;
|
||||
this.BackColor = Color.Black;
|
||||
this.ForeColor = Color.Lime;
|
||||
this.Font = new Font("Consolas", 10f);
|
||||
this.DetectUrls = false;
|
||||
this.Multiline = true;
|
||||
this.ScrollBars = RichTextBoxScrollBars.Vertical;
|
||||
this.AcceptsTab = true;
|
||||
this.PreviewKeyDown += new PreviewKeyDownEventHandler(this.Console_PreviewKeyDown);
|
||||
this.KeyDown += new KeyEventHandler(this.Console_KeyDown);
|
||||
this.KeyPress += new KeyPressEventHandler(this.Console_KeyPress);
|
||||
}
|
||||
|
||||
private void Console_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
||||
{
|
||||
if (e.KeyCode != Keys.Tab)
|
||||
return;
|
||||
e.IsInputKey = true;
|
||||
}
|
||||
|
||||
public void ShowPrompt()
|
||||
{
|
||||
string str;
|
||||
if (string.IsNullOrWhiteSpace(this.UserID) || string.IsNullOrWhiteSpace(this.Username))
|
||||
str = "$ ";
|
||||
else
|
||||
str = $"raton@{this.UserID} {this.Username} ~\n$ ";
|
||||
string text = str;
|
||||
this.SelectionStart = this.TextLength;
|
||||
this.SelectionColor = Color.Lime;
|
||||
this.AppendText(text);
|
||||
this.SelectionColor = this.ForeColor;
|
||||
this.inputStart = this.TextLength;
|
||||
this.MoveCaretToEnd();
|
||||
}
|
||||
|
||||
private void Console_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Tab)
|
||||
{
|
||||
e.SuppressKeyPress = true;
|
||||
if (this.AutoCompleteHandler != null)
|
||||
{
|
||||
string str = this.AutoCompleteHandler(this.Text.Substring(this.inputStart));
|
||||
if (!string.IsNullOrEmpty(str))
|
||||
{
|
||||
this.SelectionStart = this.inputStart;
|
||||
this.SelectionLength = this.TextLength - this.inputStart;
|
||||
this.SelectedText = str;
|
||||
}
|
||||
}
|
||||
this.MoveCaretToEnd();
|
||||
}
|
||||
else if (e.KeyCode == Keys.Return)
|
||||
{
|
||||
e.SuppressKeyPress = true;
|
||||
string str = this.Text.Substring(this.inputStart).Trim();
|
||||
this.AppendText(Environment.NewLine);
|
||||
Action<string> commandEntered = this.CommandEntered;
|
||||
if (commandEntered != null)
|
||||
commandEntered(str);
|
||||
this.ShowPrompt();
|
||||
}
|
||||
else if (e.KeyCode == Keys.Back && this.SelectionStart <= this.inputStart && this.SelectionLength == 0)
|
||||
{
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (e.KeyCode != Keys.Left && e.KeyCode != Keys.Home || this.SelectionStart > this.inputStart)
|
||||
return;
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void Console_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
if (this.SelectionStart >= this.inputStart)
|
||||
return;
|
||||
this.MoveCaretToEnd();
|
||||
}
|
||||
|
||||
private void MoveCaretToEnd()
|
||||
{
|
||||
this.SelectionStart = this.TextLength;
|
||||
this.SelectionLength = 0;
|
||||
this.ScrollToCaret();
|
||||
this.Focus();
|
||||
}
|
||||
|
||||
public void WriteLine(string text, Color? color = null)
|
||||
{
|
||||
this.SelectionStart = this.TextLength;
|
||||
this.SelectionColor = color ?? this.ForeColor;
|
||||
this.AppendText(text + Environment.NewLine);
|
||||
this.SelectionColor = this.ForeColor;
|
||||
this.MoveCaretToEnd();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Raton.RatonForms.PluginTextbox
|
||||
// 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 System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#nullable disable
|
||||
namespace Raton.RatonForms;
|
||||
|
||||
public class PluginTextbox : RichTextBox
|
||||
{
|
||||
public PluginTextbox()
|
||||
{
|
||||
this.BorderStyle = BorderStyle.None;
|
||||
this.BackColor = Color.Black;
|
||||
this.ForeColor = Color.Lime;
|
||||
this.Font = new Font("Consolas", 10f);
|
||||
this.DetectUrls = false;
|
||||
this.Multiline = true;
|
||||
this.ScrollBars = RichTextBoxScrollBars.Vertical;
|
||||
this.ReadOnly = true;
|
||||
}
|
||||
|
||||
public void WriteLine(string text, Color? color = null)
|
||||
{
|
||||
Color color1 = color ?? this.ForeColor;
|
||||
string str = "Message";
|
||||
if (color1 == Color.LimeGreen)
|
||||
str = "Success";
|
||||
else if (color1 == Color.Red)
|
||||
str = "Error";
|
||||
else if (color1 == Color.Orange)
|
||||
str = "Critical";
|
||||
else if (color1 == Color.LightSkyBlue)
|
||||
str = "Information";
|
||||
else if (color1 == Color.Gold)
|
||||
str = "Warning";
|
||||
this.SelectionStart = this.TextLength;
|
||||
this.SelectionColor = color1;
|
||||
this.AppendText($"[{DateTime.Now.ToString("HH:mm:ss")}] {str}: {text}\n");
|
||||
this.SelectionColor = this.ForeColor;
|
||||
this.SelectionStart = this.TextLength;
|
||||
this.ScrollToCaret();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user