mirror of
https://github.com/SpaceTimee/Sheas-Cealer.git
synced 2025-07-13 21:02:08 +08:00
1.1.0 更新
This commit is contained in:
parent
0e5ed26581
commit
714a4d2c5b
5
App.xaml
5
App.xaml
@ -1,12 +1,13 @@
|
||||
<Application x:Class="Sheas_Cealer.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
DispatcherUnhandledException="App_DispatcherUnhandledException">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<materialDesign:BundledTheme BaseTheme="Light" PrimaryColor="Red" SecondaryColor="Orange" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="CommonWindow" TargetType="{x:Type Window}">
|
||||
|
@ -1,9 +1,16 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace Sheas_Cealer
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
protected override void OnStartup(StartupEventArgs e) => new MainWindow(e.Args).Show();
|
||||
|
||||
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||
{
|
||||
MessageBox.Show("Error: " + e.Exception.Message);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using SheasCore;
|
||||
|
||||
namespace Sheas_Cealer
|
||||
{
|
||||
internal class Clash : Proc
|
||||
{
|
||||
internal Clash() : base("Cealing-Clash.exe")
|
||||
{
|
||||
}
|
||||
|
||||
public override void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
|
||||
{
|
||||
}
|
||||
public override void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e)
|
||||
{
|
||||
}
|
||||
public override void Process_Exited(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
21
README.md
21
README.md
@ -3,7 +3,7 @@
|
||||
</br>
|
||||
|
||||
## 自我介绍
|
||||
**Sheas Cealer**: 一只基于 **WPF(.Net5)** 的 SNI 伪造工具
|
||||
**Sheas Cealer**: 一只基于 **WPF(.Net8)** 的 SNI 伪造工具
|
||||
|
||||
* 适用平台: Windows x64
|
||||
|
||||
@ -11,13 +11,12 @@
|
||||
**[Sheas Cealer Dictionary](https://github.com/SpaceTimee/Sheas-Cealer/wiki/Sheas-Cealer-Dictionary)**
|
||||
|
||||
## 注意事项
|
||||
1. 最新的 **Cealing-Host.json** 内置伪造规则可在 [Cealing Host 存储库](https://github.com/SpaceTimee/Cealing-Host) 获取
|
||||
2. 其他所有配置文件的获取请参考 [Sheas Cealer Archive](https://github.com/SpaceTimee/Sheas-Cealer/wiki/Sheas-Cealer-Archive)
|
||||
3. 自动更新时不会覆盖已有的 **Cealing-Host.json** 和 **config.yaml** 配置文件,如有需要应**手动覆盖或修改**
|
||||
4. 本项目仅供**学习参考**,无意绕过任何审查设备的审查
|
||||
5. 为避免不必要的麻烦,食用前请先阅读**注意事项**和**用户协议**
|
||||
6. Sheas Cealer 仍处于**开发阶段**,但每个正式版发布前会尽量确保其**稳定可用**
|
||||
7. Github Release 中会保留目前能够使用的**所有版本**,但强烈推荐使用**最新版**
|
||||
1. **Cealing-Host.json** 内置伪造规则在 [Cealing Host 存储库](https://github.com/SpaceTimee/Cealing-Host) 持续更新
|
||||
2. Sheas Cealer 更新时不会覆盖已有的 **Cealing-Host.json** 配置文件,如需与上游同步,需点击**更新规则**按钮 (>= 1.1.0),或**手动修改覆盖**
|
||||
3. 本项目仅供**学习参考**,无意绕过任何审查设备的审查
|
||||
4. 为避免不必要的麻烦,食用前请先阅读**注意事项**和**用户协议**
|
||||
5. Sheas Cealer 仍处于**开发阶段**,但每个正式版发布前会尽量确保其**稳定可用**
|
||||
6. Github Release 中会保留目前能够使用的**所有版本**,但强烈推荐使用**最新版**
|
||||
|
||||
## 用户协议
|
||||
1. [隐私政策](https://thoughts.teambition.com/share/6264eda98adeb10041b92fda#title=Sheas_Cealer_隐私政策)
|
||||
@ -43,14 +42,14 @@
|
||||
## 致谢名单
|
||||
* **kit: 为本项目提供全部的原理基础**
|
||||
* **NiceBowl: 为本项目提供详细的原理说明**
|
||||
* **Clash: 为本项目解决 SSL 证书匹配问题**
|
||||
* **Clash: 为本项目解决过一段时间的 SSL 证书匹配问题**
|
||||
|
||||
## 开发者
|
||||
**Space Time**
|
||||
|
||||
## 联系方式
|
||||
1. **新 QQ 群 (主群): 338919498**
|
||||
2. 新 TG 群 (分群) (宽松管理): [PixCealerChat](https://t.me/PixCealerChat)
|
||||
1. **QQ 群 (主群): 338919498**
|
||||
2. TG 群 (分群) (宽松管理): [PixCealerChat](https://t.me/PixCealerChat)
|
||||
3. **邮箱: Zeus6_6@163.com**
|
||||
|
||||
## 许可证
|
||||
|
@ -8,10 +8,10 @@
|
||||
<PackageReleaseNotes>Just Ceal It</PackageReleaseNotes>
|
||||
<Authors>Space Time</Authors>
|
||||
<Company>Space Time</Company>
|
||||
<AssemblyVersion>1.0.5</AssemblyVersion>
|
||||
<Version>1.0.5</Version>
|
||||
<FileVersion>1.0.5</FileVersion>
|
||||
<InformationalVersion>1.0.5</InformationalVersion>
|
||||
<AssemblyVersion>1.1.0</AssemblyVersion>
|
||||
<Version>1.1.0</Version>
|
||||
<FileVersion>1.1.0</FileVersion>
|
||||
<InformationalVersion>1.1.0</InformationalVersion>
|
||||
<PackageTags>Tool;Sheas;Cealer;Sni</PackageTags>
|
||||
<ApplicationIcon>Sheas-Cealer-Logo.ico</ApplicationIcon>
|
||||
<PackageIcon>Sheas Cealer Logo.png</PackageIcon>
|
||||
@ -21,7 +21,7 @@
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<Copyright>Copyright © 2077</Copyright>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net5.0-windows10.0.22000.0</TargetFramework>
|
||||
<TargetFramework>net8.0-windows10.0.22000.0</TargetFramework>
|
||||
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
|
||||
<RootNamespace>Sheas_Cealer</RootNamespace>
|
||||
<Nullable>enable</Nullable>
|
||||
@ -30,7 +30,7 @@
|
||||
<IsPublishable>True</IsPublishable>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<ErrorReport>none</ErrorReport>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<NoWin32Manifest>true</NoWin32Manifest>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
@ -55,7 +55,6 @@
|
||||
<ItemGroup>
|
||||
<None Remove=".gitattributes" />
|
||||
<None Remove=".gitignore" />
|
||||
<None Remove="app.manifest" />
|
||||
<None Remove="README.md" />
|
||||
<None Remove="Sheas-Cealer-Logo.ico" />
|
||||
</ItemGroup>
|
||||
@ -73,17 +72,16 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MaterialDesignThemes" Version="4.5.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
||||
<PackageReference Include="MaterialDesignThemes" Version="5.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Ona-Core">
|
||||
<HintPath>..\Ona-Core\bin\Release\net5.0-windows10.0.22000.0\Ona-Core.dll</HintPath>
|
||||
<HintPath>..\Ona-Core\bin\Release\net8.0-windows10.0.22000.0\Ona-Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Sheas-Core">
|
||||
<HintPath>D:\Git-Repository\Sheas-Core\bin\Release\Sheas-Core.dll</HintPath>
|
||||
<HintPath>..\Sheas-Core\bin\Release\Sheas-Core.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -4,9 +4,9 @@ using SheasCore;
|
||||
|
||||
namespace Sheas_Cealer
|
||||
{
|
||||
internal class Cmd : Proc
|
||||
internal class Command : Proc
|
||||
{
|
||||
internal Cmd() : base("Cmd.exe")
|
||||
internal Command() : base("Cmd.exe")
|
||||
{
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using System.Windows.Interop;
|
||||
namespace Sheas_Cealer
|
||||
{
|
||||
//定义IconRemover
|
||||
internal static class IconRemover
|
||||
internal static partial class IconRemover
|
||||
{
|
||||
private const int GWL_EXSTYLE = -20;
|
||||
private const int WS_EX_DLGMODALFRAME = 0x0001;
|
||||
@ -16,14 +16,15 @@ namespace Sheas_Cealer
|
||||
private const int SWP_FRAMECHANGED = 0x0020;
|
||||
private const uint WM_SETICON = 0x0080;
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int GetWindowLong(IntPtr hwnd, int index);
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle);
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, int x, int y, int width, int height, uint flags);
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr SendMessage(IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam);
|
||||
[LibraryImport("user32.dll", EntryPoint = "GetWindowLongW")]
|
||||
private static partial int GetWindowLong(IntPtr hwnd, int index);
|
||||
[LibraryImport("user32.dll", EntryPoint = "SetWindowLongW")]
|
||||
private static partial int SetWindowLong(IntPtr hwnd, int index, int newStyle);
|
||||
[LibraryImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static partial bool SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, int x, int y, int width, int height, uint flags);
|
||||
[LibraryImport("user32.dll", EntryPoint = "SendMessageW")]
|
||||
private static partial IntPtr SendMessage(IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
internal static void RemoveIcon(Window window)
|
||||
{
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@ -16,8 +15,6 @@ namespace Sheas_Cealer
|
||||
private void AboutWin_Loaded(object sender, RoutedEventArgs e) => UpdateButton.Content = "版本号: " + Assembly.GetExecutingAssembly().GetName().Version!.ToString()[0..^2];
|
||||
|
||||
private void AboutButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sender == UpdateButton)
|
||||
MessageBox.Show("密码: 3wnj");
|
||||
@ -25,10 +22,8 @@ namespace Sheas_Cealer
|
||||
ProcessStartInfo processStartInfo = new(sender == EmailButton ? "mailto:" : string.Empty + ((Button)sender).ToolTip) { UseShellExecute = true };
|
||||
Process.Start(processStartInfo);
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
}
|
||||
|
||||
private void AboutWin_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||
private void AboutWin_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
Close();
|
||||
|
@ -18,30 +18,21 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox x:Name="ShowBox" Text="(填入任意以 Chromium 为内核的浏览器的路径)" Foreground="#FFBFCDDB" Grid.Column="0" Margin="0,0,10,0" VerticalContentAlignment="Center" GotFocus="ShowBox_GotFocus" LostFocus="ShowBox_LostFocus" TextChanged="ShowBox_TextChanged" PreviewDragOver="MainWin_DragEnter" />
|
||||
<Button x:Name="ViewButton" Grid.Column="2" Content="浏览" Click="ViewButton_Click" />
|
||||
<TextBox x:Name="PathBox" Text="(填入任意以 Chromium 为内核的浏览器的路径)" Foreground="#FFBFCDDB" Grid.Column="0" Margin="0,0,10,0" VerticalContentAlignment="Center" GotFocus="PathBox_GotFocus" LostFocus="PathBox_LostFocus" TextChanged="PathBox_TextChanged" PreviewDragOver="MainWin_DragEnter" />
|
||||
<Button x:Name="BrowseButton" Grid.Column="2" Content="浏览" Click="BrowseButton_Click" />
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1" Margin="0,5,0,5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button x:Name="ClashButton" Content="启动代理" Grid.Column="0" Margin="5,0,5,0" Click="ClashButton_Click" />
|
||||
<Button x:Name="OpenButton" Content="启动伪造" Grid.Column="1" Margin="5,0,5,0" IsDefault="True" IsEnabled="False" Click="OpenButton_Click" />
|
||||
</Grid>
|
||||
<Button x:Name="StartButton" Content="启动伪造" Grid.Row="1" Margin="5" IsDefault="True" IsEnabled="False" Click="StartButton_Click" />
|
||||
|
||||
<Grid Grid.Row="2" Margin="0,5,0,5">
|
||||
<Grid Grid.Row="2" Margin="0,5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button x:Name="ConfigButton" Content="代理规则" Grid.Column="0" Margin="5,0,5,0" Click="ConfigOpenButton_Click" />
|
||||
<Button x:Name="HostMenuButton" Content="伪造规则🔺" Grid.Column="1" Margin="5,0,5,0" Panel.ZIndex="1" MouseEnter="HostMenuButton_MouseEnter" MouseLeave="HostMenuButton_MouseLeave" Click="HostMenuButton_Click" />
|
||||
<Button x:Name="HostOpenButton" Content="打开伪造规则" Grid.Column="1" Margin="5,0,5,0" Background="Orange" MouseEnter="HostMenuButton_MouseEnter" MouseLeave="HostMenuButton_MouseLeave" Click="HostOpenButton_Click" />
|
||||
<Button x:Name="HostUpdateButton" Content="更新伪造规则" Grid.Column="1" Margin="5,0,5,0" Background="Orange" MouseEnter="HostMenuButton_MouseEnter" MouseLeave="HostMenuButton_MouseLeave" Click="HostUpdateButton_Click" />
|
||||
<Button x:Name="AboutButton" Content="关于项目" Grid.Column="2" Margin="5,0,5,0" Click="AboutButton_Click" Cursor="Hand" />
|
||||
<Button x:Name="HostEditButton" Content="编辑规则" Grid.Column="0" Margin="5,0" Click="HostEditButton_Click" />
|
||||
<Button x:Name="HostUpdateButton" Content="更新规则" Grid.Column="1" Margin="5,0" Click="HostUpdateButton_Click" />
|
||||
<Button x:Name="AboutButton" Content="关于项目" Grid.Column="2" Margin="5,0" Click="AboutButton_Click" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
@ -1,19 +1,19 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Threading;
|
||||
using IWshRuntimeLibrary;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OnaCore;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
using File = System.IO.File;
|
||||
|
||||
namespace Sheas_Cealer
|
||||
@ -22,144 +22,87 @@ namespace Sheas_Cealer
|
||||
{
|
||||
private readonly HttpClient MAIN_CLIENT = new(); //当前窗口使用的唯一的 HttpClient
|
||||
private static readonly FileSystemWatcher CEALING_HOST_WATCHER = new(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host.json") { EnableRaisingEvents = true, NotifyFilter = NotifyFilters.LastWrite };
|
||||
private static readonly DispatcherTimer MONITOR_TIMER = new() { Interval = new TimeSpan(1000000) }; //0.1s
|
||||
[GeneratedRegex(@"\r")] private static partial Regex HOST_REGEX();
|
||||
private static string? CEALING_ARGUMENT;
|
||||
private static bool IS_HOST_MENU_OPENED;
|
||||
|
||||
internal MainWindow(string[] args)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
try
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
MONITOR_TIMER.Tick += MONITOR_TIMER_Tick;
|
||||
MONITOR_TIMER.Start();
|
||||
|
||||
if (args.Length > 0)
|
||||
Dispatcher.Invoke(() => ShowBox.Text = args[0]);
|
||||
Dispatcher.Invoke(() => PathBox.Text = args[0]);
|
||||
else if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.BrowserPath))
|
||||
Dispatcher.Invoke(() => ShowBox.Text = Properties.Settings.Default.BrowserPath);
|
||||
Dispatcher.Invoke(() => PathBox.Text = Properties.Settings.Default.BrowserPath);
|
||||
|
||||
CEALING_HOST_WATCHER.Changed += CEALING_HOST_WATCHER_Changed;
|
||||
CEALING_HOST_WATCHER_Changed(null!, null!);
|
||||
});
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); }
|
||||
}
|
||||
private void MainWin_Loaded(object sender, RoutedEventArgs e) => ShowBox.Focus();
|
||||
private void MainWin_Closing(object sender, System.ComponentModel.CancelEventArgs e) => Environment.Exit(0);
|
||||
private void MainWin_Loaded(object sender, RoutedEventArgs e) => PathBox.Focus();
|
||||
private void MainWin_Closing(object sender, CancelEventArgs e) => Environment.Exit(0);
|
||||
|
||||
private void ShowBox_GotFocus(object sender, RoutedEventArgs e)
|
||||
private void PathBox_GotFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (ShowBox.Foreground != Foreground)
|
||||
if (PathBox.Foreground != Foreground)
|
||||
{
|
||||
//PlaceHold状态
|
||||
ShowBox.Text = string.Empty;
|
||||
ShowBox.Foreground = Foreground;
|
||||
PathBox.Text = string.Empty;
|
||||
PathBox.Foreground = Foreground;
|
||||
}
|
||||
}
|
||||
private void ShowBox_LostFocus(object sender, RoutedEventArgs e)
|
||||
private void PathBox_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ShowBox.Text))
|
||||
if (string.IsNullOrEmpty(PathBox.Text))
|
||||
{
|
||||
ShowBox.Text = "(填入任意以 Chromium 为内核的浏览器的路径)";
|
||||
ShowBox.Foreground = new SolidColorBrush(Color.FromRgb(191, 205, 219));
|
||||
PathBox.Text = "(填入任意以 Chromium 为内核的浏览器的路径)";
|
||||
PathBox.Foreground = new SolidColorBrush(Color.FromRgb(191, 205, 219));
|
||||
}
|
||||
}
|
||||
private void ShowBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
|
||||
private void PathBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (OpenButton == null)
|
||||
if (StartButton == null)
|
||||
return;
|
||||
|
||||
if (File.Exists(ShowBox.Text) && Path.GetFileName(ShowBox.Text).EndsWith(".exe"))
|
||||
if (File.Exists(PathBox.Text) && Path.GetFileName(PathBox.Text).EndsWith(".exe"))
|
||||
{
|
||||
OpenButton.IsEnabled = true;
|
||||
StartButton.IsEnabled = true;
|
||||
|
||||
Properties.Settings.Default.BrowserPath = ShowBox.Text;
|
||||
Properties.Settings.Default.BrowserPath = PathBox.Text;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
else
|
||||
OpenButton.IsEnabled = false;
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
StartButton.IsEnabled = false;
|
||||
}
|
||||
|
||||
private void MainWin_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
e.Handled = true;
|
||||
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
e.Effects = DragDropEffects.Link;
|
||||
else
|
||||
e.Effects = DragDropEffects.None;
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
private void MainWin_Drop(object sender, DragEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
ShowBox.Text = ((string[])e.Data.GetData(DataFormats.FileDrop))[0];
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
PathBox.Text = ((string[])e.Data.GetData(DataFormats.FileDrop))[0];
|
||||
}
|
||||
|
||||
private void ViewButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
private void BrowseButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OpenFileDialog openFileDialog = new() { Filter = "浏览器 (*.exe)|*.exe" };
|
||||
|
||||
if (openFileDialog.ShowDialog() == true)
|
||||
{
|
||||
ShowBox.Focus();
|
||||
ShowBox.Text = openFileDialog.FileName;
|
||||
PathBox.Focus();
|
||||
PathBox.Text = openFileDialog.FileName;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
}
|
||||
|
||||
private void ClashButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
RegistryKey proxyKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true)!;
|
||||
if (ClashButton.Content.ToString() == "启动代理")
|
||||
{
|
||||
YamlStream configStream = new();
|
||||
YamlMappingNode configMap;
|
||||
try
|
||||
{
|
||||
configStream.Load(File.OpenText(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Cealing-Config.yaml")));
|
||||
configMap = (YamlMappingNode)configStream.Documents[0].RootNode;
|
||||
}
|
||||
catch { throw new Exception("规则无法识别,请检查代理规则是否含有语法错误"); }
|
||||
|
||||
proxyKey.SetValue("ProxyEnable", 1);
|
||||
proxyKey.SetValue("ProxyServer", "127.0.0.1:" + configMap["mixed-port"]);
|
||||
|
||||
new Clash().ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"-f .\Cealing-Config.yaml");
|
||||
}
|
||||
else
|
||||
{
|
||||
proxyKey.SetValue("ProxyEnable", 0);
|
||||
|
||||
foreach (Process clashProcess in Process.GetProcessesByName("Cealing-Clash"))
|
||||
clashProcess.Kill();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
}
|
||||
private void OpenButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
private void StartButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(CEALING_ARGUMENT))
|
||||
throw new Exception("规则无法识别,请检查伪造规则是否含有语法错误");
|
||||
@ -167,129 +110,77 @@ namespace Sheas_Cealer
|
||||
return;
|
||||
|
||||
IWshShortcut uncealedBrowserShortcut = (IWshShortcut)new WshShell().CreateShortcut(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Uncealed-Browser.lnk"));
|
||||
uncealedBrowserShortcut.TargetPath = ShowBox.Text;
|
||||
uncealedBrowserShortcut.TargetPath = PathBox.Text;
|
||||
uncealedBrowserShortcut.Description = "Created By Sheas Cealer";
|
||||
uncealedBrowserShortcut.Save();
|
||||
|
||||
foreach (Process browserProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(ShowBox.Text)))
|
||||
foreach (Process browserProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(PathBox.Text)))
|
||||
{
|
||||
browserProcess.Kill();
|
||||
browserProcess.WaitForExit();
|
||||
}
|
||||
|
||||
new Cmd().ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, CEALING_ARGUMENT);
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
new Command().ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, CEALING_ARGUMENT);
|
||||
}
|
||||
|
||||
private void ConfigOpenButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
ProcessStartInfo processStartInfo = new(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Cealing-Config.yaml")) { UseShellExecute = true };
|
||||
Process.Start(processStartInfo);
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
}
|
||||
|
||||
private void HostMenuButton_MouseEnter(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
IS_HOST_MENU_OPENED = true;
|
||||
|
||||
double hostButtonHeight = HostMenuButton.ActualHeight;
|
||||
AnimateHostButton(new Thickness(0, -hostButtonHeight - 5, 0, hostButtonHeight + 5), new Thickness(0, -hostButtonHeight * 2 - 10, 0, hostButtonHeight * 2 + 10));
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
}
|
||||
private void HostMenuButton_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
try { AnimateHostButton(new Thickness(5, 0, 5, 0), new Thickness(5, 0, 5, 0)); }
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
}
|
||||
private void HostMenuButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
IS_HOST_MENU_OPENED = !IS_HOST_MENU_OPENED;
|
||||
|
||||
if (IS_HOST_MENU_OPENED)
|
||||
{
|
||||
double hostButtonHeight = HostMenuButton.ActualHeight;
|
||||
AnimateHostButton(new Thickness(0, -hostButtonHeight - 5, 0, hostButtonHeight + 5), new Thickness(0, -hostButtonHeight * 2 - 10, 0, hostButtonHeight * 2 + 10));
|
||||
}
|
||||
else
|
||||
AnimateHostButton(new Thickness(5, 0, 5, 0), new Thickness(5, 0, 5, 0));
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
}
|
||||
private void AnimateHostButton(Thickness hostOpenButtonThickness, Thickness hostUpdateButtonThickness)
|
||||
{
|
||||
HostOpenButton.BeginAnimation(MarginProperty, new ThicknessAnimation(hostOpenButtonThickness, TimeSpan.FromSeconds(0.25)));
|
||||
HostUpdateButton.BeginAnimation(MarginProperty, new ThicknessAnimation(hostUpdateButtonThickness, TimeSpan.FromSeconds(0.25)));
|
||||
}
|
||||
|
||||
private void HostOpenButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
private void HostEditButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProcessStartInfo processStartInfo = new(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Cealing-Host.json")) { UseShellExecute = true };
|
||||
Process.Start(processStartInfo);
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
}
|
||||
private async void HostUpdateButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string hostUpdateString = await Http.GetAsync<string>(@"https://gitlab.com/SpaceTimee/Cealing-Host/-/raw/main/Cealing-Host.json", MAIN_CLIENT);
|
||||
const string hostUrl = @"https://gitlab.com/SpaceTimee/Cealing-Host/raw/main/Cealing-Host.json";
|
||||
|
||||
string hostUpdateString = await Http.GetAsync<string>(hostUrl, MAIN_CLIENT);
|
||||
StreamReader hostLocalStreamReader = new(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Cealing-Host.json"));
|
||||
string hostLocalString = hostLocalStreamReader.ReadToEnd();
|
||||
hostLocalStreamReader.Close();
|
||||
|
||||
if (Regex.Replace(hostLocalString, @"\r", string.Empty) == hostUpdateString)
|
||||
MessageBox.Show("太腻害了,你的伪造规则和存储库里的一模一样");
|
||||
else if (MessageBox.Show("你的伪造规则和存储库里的不太一样,需要与存储库同步吗", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
if (HOST_REGEX().Replace(hostLocalString, string.Empty) == hostUpdateString)
|
||||
MessageBox.Show("本地伪造规则和上游一模一样");
|
||||
else
|
||||
{
|
||||
MessageBoxResult overrideResult = MessageBox.Show("本地伪造规则和上游略有不同,需要覆盖本地吗? 否则只为你打开上游规则的网页", "", MessageBoxButton.YesNoCancel);
|
||||
if (overrideResult == MessageBoxResult.Yes)
|
||||
{
|
||||
File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Cealing-Host.json"), hostUpdateString);
|
||||
MessageBox.Show("同步已完成");
|
||||
MessageBox.Show("更新已完成");
|
||||
}
|
||||
else if (overrideResult == MessageBoxResult.No)
|
||||
Process.Start(new ProcessStartInfo(hostUrl) { UseShellExecute = true });
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
}
|
||||
|
||||
private void AboutButton_Click(object sender, RoutedEventArgs e) => new AboutWindow().ShowDialog();
|
||||
|
||||
private void MONITOR_TIMER_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
if (Process.GetProcessesByName("Cealing-Clash").Length == 0)
|
||||
ClashButton.Content = "启动代理";
|
||||
else
|
||||
ClashButton.Content = "停止代理";
|
||||
}
|
||||
|
||||
private void CEALING_HOST_WATCHER_Changed(object sender, FileSystemEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string hostRules = string.Empty, hostResolverRules = string.Empty;
|
||||
int ruleIndex = 0;
|
||||
FileStream hostStream = new(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Cealing-Host.json"), FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
JArray hostJArray = JArray.Parse(new StreamReader(hostStream).ReadToEnd());
|
||||
|
||||
foreach (var hostJToken in hostJArray)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(hostJToken[1]!.ToString()))
|
||||
hostJToken[1] = "c" + ruleIndex;
|
||||
|
||||
hostResolverRules += "MAP " + hostJToken[1]!.ToString() + " " + hostJToken[2]!.ToString() + ",";
|
||||
foreach (var hostName in hostJToken[0]!)
|
||||
hostRules += "MAP " + hostName.ToString() + " " + hostJToken[1] + ",";
|
||||
|
||||
++ruleIndex;
|
||||
}
|
||||
|
||||
CEALING_ARGUMENT = @"/c @start .\""Uncealed-Browser.lnk"" --host-rules=""" + hostRules[0..^1] + @""" --host-resolver-rules=""" + hostResolverRules[0..^1] + @""" --test-type --ignore-certificate-errors";
|
||||
}
|
||||
catch { return; }
|
||||
catch { CEALING_ARGUMENT = string.Empty; }
|
||||
}
|
||||
|
||||
private void MainWin_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||
private void MainWin_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.W)
|
||||
Environment.Exit(0);
|
||||
|
76
app.manifest
76
app.manifest
@ -1,76 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<!-- UAC 清单选项
|
||||
如果想要更改 Windows 用户帐户控制级别,请使用
|
||||
以下节点之一替换 requestedExecutionLevel 节点。
|
||||
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
|
||||
|
||||
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
|
||||
如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此
|
||||
元素。
|
||||
-->
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
|
||||
Windows 版本的列表。取消评论适当的元素,
|
||||
Windows 将自动选择最兼容的环境。 -->
|
||||
|
||||
<!-- Windows Vista -->
|
||||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
|
||||
|
||||
<!-- Windows 7 -->
|
||||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
|
||||
|
||||
<!-- Windows 8 -->
|
||||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
|
||||
|
||||
<!-- Windows 8.1 -->
|
||||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
|
||||
|
||||
<!-- Windows 10 -->
|
||||
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
|
||||
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
|
||||
选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
|
||||
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。
|
||||
|
||||
将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
|
||||
<!--
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
-->
|
||||
|
||||
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
|
||||
<!--
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*" />
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
-->
|
||||
</assembly>
|
Loading…
Reference in New Issue
Block a user