commit e77a5945ce3d23fe5560e6fd8b654c69cf1d828f Author: ProxySU Date: Sun Mar 8 11:15:48 2020 +0800 '提交文件' diff --git a/ProxySU.sln b/ProxySU.sln new file mode 100644 index 0000000..89f5ff9 --- /dev/null +++ b/ProxySU.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.1022 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxySU", "ProxySU\ProxySU.csproj", "{DD5505BC-E7F1-4D03-ABC7-B636E893FC09}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DD5505BC-E7F1-4D03-ABC7-B636E893FC09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DD5505BC-E7F1-4D03-ABC7-B636E893FC09}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DD5505BC-E7F1-4D03-ABC7-B636E893FC09}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DD5505BC-E7F1-4D03-ABC7-B636E893FC09}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A3F3B8D6-7FED-42D9-9994-E913BD32E025} + EndGlobalSection +EndGlobal diff --git a/ProxySU/App.xaml b/ProxySU/App.xaml new file mode 100644 index 0000000..332218e --- /dev/null +++ b/ProxySU/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/ProxySU/App.xaml.cs b/ProxySU/App.xaml.cs new file mode 100644 index 0000000..6ed5114 --- /dev/null +++ b/ProxySU/App.xaml.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Windows; + +namespace ProxySU +{ + /// + /// App.xaml 的交互逻辑 + /// + public partial class App : Application + { + } +} diff --git a/ProxySU/MainWindow.xaml.cs b/ProxySU/MainWindow.xaml.cs new file mode 100644 index 0000000..9dcb60d --- /dev/null +++ b/ProxySU/MainWindow.xaml.cs @@ -0,0 +1,219 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Renci.SshNet; +using System.Text.RegularExpressions; + +namespace ProxySU +{ + /// + /// MainWindow.xaml 的交互逻辑 + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + RadioButtonPasswordLogin.IsChecked = true; + RadioButtonNoProxy.IsChecked = true; + RadioButtonProxyNoLogin.IsChecked = true; + } + + private void Button_Login_Click(object sender, RoutedEventArgs e) + { + //byte[] expectedFingerPrint = new byte[] { + // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, + // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b + // }; + string sshHostName = TextBoxHost.Text.ToString(); + int sshPort = int.Parse(TextBoxPort.Text); + string sshUser = TextBoxUserName.Text.ToString(); + string sshPassword = PasswordBoxHostPassword.Password.ToString(); + string sshPrivateKey = TextBoxCertFilePath.Text.ToString(); + ProxyTypes proxyTypes = new ProxyTypes();//默认为None + //MessageBox.Show(proxyTypes.ToString()); + //proxyTypes = ProxyTypes.Socks5; + if (RadioButtonHttp.IsChecked==true) + { + proxyTypes = ProxyTypes.Http; + } + else if (RadioButtonSocks4.IsChecked==true) + { + proxyTypes = ProxyTypes.Socks4; + } + else if (RadioButtonSocks5.IsChecked==true) + { + proxyTypes = ProxyTypes.Socks5; + } + else + { + proxyTypes = ProxyTypes.None; + } + + //MessageBox.Show(proxyTypes.ToString()); + string sshProxyHost = TextBoxProxyHost.Text.ToString(); + int sshProxyPort = int.Parse(TextBoxProxyPort.Text.ToString()); + string sshProxyUser = TextBoxProxyUserName.Text.ToString(); + string sshProxyPassword = PasswordBoxProxyPassword.Password.ToString(); + + + //var connectionInfo = new PasswordConnectionInfo(sshHostName, sshPort, sshUser, sshPassword); + + var connectionInfo = new ConnectionInfo( + sshHostName, + sshPort, + sshUser, + proxyTypes, + sshProxyHost, + sshProxyPort, + sshProxyUser, + sshProxyPassword, + new PasswordAuthenticationMethod(sshUser, sshPassword), + new PrivateKeyAuthenticationMethod(sshUser, new PrivateKeyFile(sshPrivateKey)) + ); + + using (var client = new SshClient(connectionInfo)) + //using (var client = new SshClient(sshHostName, sshPort, sshUser, sshPassword)) + { + // client.HostKeyReceived += (sender, e) => + // { + // if (expectedFingerPrint.Length == e.FingerPrint.Length) + // { + // for (var i = 0; i < expectedFingerPrint.Length; i++) + // { + // if (expectedFingerPrint[i] != e.FingerPrint[i]) + // { + // e.CanTrust = false; + // break; + // } + // } + // } + // else + // { + // e.CanTrust = false; + // } + // }; + client.Connect(); + client.RunCommand("echo 1111 >> test.json"); + MessageBox.Show(client.ConnectionInfo.ServerVersion.ToString()); + client.Disconnect(); + } + } + + private void Button_canel_Click(object sender, RoutedEventArgs e) + { + Application.Current.Shutdown(); + } + // private static readonly Regex _regex = new Regex("[^0-9]+"); + private void TextBoxPort_PreviewTextInput(object sender, TextCompositionEventArgs e) + { + Regex regex = new Regex("[^0-9]+"); + e.Handled = regex.IsMatch(e.Text); + } + + private void TextBoxPort_PreviewExecuted(object sender, ExecutedRoutedEventArgs e) + { + if (e.Command == ApplicationCommands.Paste) + { + e.Handled = true; + } + } + + //private void RadioButtonHttp_Checked(object sender, RoutedEventArgs e) + //{ + // MessageBox.Show("PrxoyHttp"); + //} + + + private void ButtonOpenFileDialog_Click(object sender, RoutedEventArgs e) + { + var openFileDialog = new Microsoft.Win32.OpenFileDialog() + { + Filter = "Cert Files (*.*)|*.*" + }; + var result = openFileDialog.ShowDialog(); + if (result == true) + { + TextBoxCertFilePath.Text = openFileDialog.FileName; + } + } + + private void RadioButtonNoProxy_Checked(object sender, RoutedEventArgs e) + { + TextBlockProxyHost.IsEnabled = false; + TextBoxProxyHost.IsEnabled = false; + TextBlockProxyPort.IsEnabled = false; + TextBoxProxyPort.IsEnabled = false; + RadioButtonProxyNoLogin.IsEnabled = false; + RadiobuttonProxyYesLogin.IsEnabled = false; + TextBlockProxyUser.IsEnabled = false; + TextBoxProxyUserName.IsEnabled = false; + TextBlockProxyPassword.IsEnabled = false; + PasswordBoxProxyPassword.IsEnabled = false; + } + + private void RadioButtonNoProxy_Unchecked(object sender, RoutedEventArgs e) + { + TextBlockProxyHost.IsEnabled = true; + TextBoxProxyHost.IsEnabled = true; + TextBlockProxyPort.IsEnabled = true; + TextBoxProxyPort.IsEnabled = true; + RadioButtonProxyNoLogin.IsEnabled = true; + RadiobuttonProxyYesLogin.IsEnabled = true; + if (RadioButtonProxyNoLogin.IsChecked == true) + { + TextBlockProxyUser.IsEnabled = false; + TextBlockProxyPassword.IsEnabled = false; + TextBoxProxyUserName.IsEnabled = false; + PasswordBoxProxyPassword.IsEnabled = false; + } + else + { + TextBlockProxyUser.IsEnabled = true; + TextBoxProxyUserName.IsEnabled = true; + TextBlockProxyPassword.IsEnabled = true; + PasswordBoxProxyPassword.IsEnabled = true; + } + } + + private void RadioButtonPasswordLogin_Checked(object sender, RoutedEventArgs e) + { + ButtonOpenFileDialog.IsEnabled = false; + TextBoxCertFilePath.IsEnabled = false; + PasswordBoxHostPassword.IsEnabled = true; + } + + private void RadioButtonCertLogin_Checked(object sender, RoutedEventArgs e) + { + PasswordBoxHostPassword.IsEnabled = false; + ButtonOpenFileDialog.IsEnabled = true; + TextBoxCertFilePath.IsEnabled = true; + } + + private void RadioButtonProxyNoLogin_Checked(object sender, RoutedEventArgs e) + { + TextBlockProxyUser.IsEnabled = false; + TextBlockProxyPassword.IsEnabled = false; + TextBoxProxyUserName.IsEnabled = false; + PasswordBoxProxyPassword.IsEnabled = false; + } + + private void RadiobuttonProxyYesLogin_Checked(object sender, RoutedEventArgs e) + { + TextBlockProxyUser.IsEnabled = true; + TextBlockProxyPassword.IsEnabled = true; + TextBoxProxyUserName.IsEnabled = true; + PasswordBoxProxyPassword.IsEnabled = true; + } + } +} diff --git a/ProxySU/Properties/AssemblyInfo.cs b/ProxySU/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..70f576f --- /dev/null +++ b/ProxySU/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("ProxySU")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ProxySU")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +//若要开始生成可本地化的应用程序,请设置 +//.csproj 文件中的 CultureYouAreCodingWith +//例如,如果您在源文件中使用的是美国英语, +//使用的是美国英语,请将 设置为 en-US。 然后取消 +//对以下 NeutralResourceLanguage 特性的注释。 更新 +//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //主题特定资源词典所处位置 + //(未在页面中找到资源时使用, + //或应用程序资源字典中找到时使用) + ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 + //(未在页面中找到资源时使用, + //、应用程序或任何主题专用资源字典中找到时使用) +)] + + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 +// 方法是按如下所示使用“*”: : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ProxySU/Properties/Resources.Designer.cs b/ProxySU/Properties/Resources.Designer.cs new file mode 100644 index 0000000..50e1154 --- /dev/null +++ b/ProxySU/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本: 4.0.30319.42000 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace ProxySU.Properties +{ + + + /// + /// 强类型资源类,用于查找本地化字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 返回此类使用的缓存 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProxySU.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 覆盖当前线程的 CurrentUICulture 属性 + /// 使用此强类型的资源类的资源查找。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/ProxySU/Properties/Resources.resx b/ProxySU/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/ProxySU/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProxySU/Properties/Settings.Designer.cs b/ProxySU/Properties/Settings.Designer.cs new file mode 100644 index 0000000..654607b --- /dev/null +++ b/ProxySU/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ProxySU.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/ProxySU/Properties/Settings.settings b/ProxySU/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/ProxySU/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ProxySU/ProxySU.csproj b/ProxySU/ProxySU.csproj new file mode 100644 index 0000000..b126303 --- /dev/null +++ b/ProxySU/ProxySU.csproj @@ -0,0 +1,96 @@ + + + + + Debug + AnyCPU + {DD5505BC-E7F1-4D03-ABC7-B636E893FC09} + WinExe + ProxySU + ProxySU + v4.0 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\ssh.net\net40\Renci.SshNet.dll + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + \ No newline at end of file diff --git a/ssh.net/net40/README.md b/ssh.net/net40/README.md new file mode 100644 index 0000000..7bcb27b --- /dev/null +++ b/ssh.net/net40/README.md @@ -0,0 +1 @@ +forked from https://github.com/sshnet/SSH.NET \ No newline at end of file diff --git a/ssh.net/net40/Renci.SshNet.dll b/ssh.net/net40/Renci.SshNet.dll new file mode 100644 index 0000000..4e2d603 Binary files /dev/null and b/ssh.net/net40/Renci.SshNet.dll differ