Ejemplo n.º 1
0
        public EntryPoint(
            EasyHook.RemoteHooking.IContext context,
            String channelName,
            CaptureConfig config)
        {
            // Get reference to IPC to host application
            // Note: any methods called or events triggered against _interface will execute in the host process.
            _interface = EasyHook.RemoteHooking.IpcConnectClient<CaptureInterface>(channelName);

            // We try to ping immediately, if it fails then injection fails
            _interface.Ping();

            #region Allow client event handlers (bi-directional IPC)
            
            // Attempt to create a IpcServerChannel so that any event handlers on the client will function correctly
            System.Collections.IDictionary properties = new System.Collections.Hashtable();
            properties["name"] = channelName;
            properties["portName"] = channelName + Guid.NewGuid().ToString("N"); // random portName so no conflict with existing channels of channelName

            System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider binaryProv = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider();
            binaryProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            System.Runtime.Remoting.Channels.Ipc.IpcServerChannel _clientServerChannel = new System.Runtime.Remoting.Channels.Ipc.IpcServerChannel(properties, binaryProv);
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(_clientServerChannel, false);
            
            #endregion
        }
Ejemplo n.º 2
0
        public EntryPoint(
            EasyHook.RemoteHooking.IContext context,
            String channelName,
            CaptureConfig config)
        {
            // Get reference to IPC to host application
            // Note: any methods called or events triggered against _interface will execute in the host process.
            _interface = EasyHook.RemoteHooking.IpcConnectClient <CaptureInterface>(channelName);

            // We try to ping immediately, if it fails then injection fails
            _interface.Ping();

            #region Allow client event handlers (bi-directional IPC)

            // Attempt to create a IpcServerChannel so that any event handlers on the client will function correctly
            System.Collections.IDictionary properties = new System.Collections.Hashtable();
            properties["name"]     = channelName;
            properties["portName"] = channelName + Guid.NewGuid().ToString("N"); // random portName so no conflict with existing channels of channelName

            System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider binaryProv = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider();
            binaryProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            System.Runtime.Remoting.Channels.Ipc.IpcServerChannel _clientServerChannel = new System.Runtime.Remoting.Channels.Ipc.IpcServerChannel(properties, binaryProv);
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(_clientServerChannel, false);

            #endregion
        }
Ejemplo n.º 3
0
        public RemotingServer(FMSImplementation p, string dataDir)
        {
            plugin = p;

            settingsServer = new SettingStore(dataDir);

            AppDomain.CurrentDomain.AssemblyResolve += ResolveEventHandler;
            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += ResolveEventHandler;

            //Configure .NET Remoting
            if (System.IO.File.Exists(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile))
            {
                RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, false);
            }
            if (System.Runtime.Remoting.Channels.ChannelServices.RegisteredChannels.Count() == 0)
            {
                var clientFormatter = new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();
                var serverFormatter = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider();
                serverFormatter.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
                var props = new System.Collections.Hashtable();
                props["port"] = 8086;
                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(new System.Runtime.Remoting.Channels.Tcp.TcpChannel(props, clientFormatter, serverFormatter), false);

                System.Runtime.Remoting.Lifetime.LifetimeServices.LeaseTime            = TimeSpan.FromMinutes(3);
                System.Runtime.Remoting.Lifetime.LifetimeServices.SponsorshipTimeout   = TimeSpan.FromMinutes(2);
                System.Runtime.Remoting.Lifetime.LifetimeServices.RenewOnCallTime      = TimeSpan.FromMinutes(1);
                System.Runtime.Remoting.Lifetime.LifetimeServices.LeaseManagerPollTime = TimeSpan.FromSeconds(10);
                System.Runtime.Remoting.RemotingConfiguration.CustomErrorsMode         = System.Runtime.Remoting.CustomErrorsModes.Off;
            }

            var jobDb      = plugin.Backend.JobDatabase();
            var logDb      = plugin.Backend.LogDatabase();
            var inspServer = plugin.Backend.InspectionControl();
            var jobControl = plugin.Backend.JobControl();
            var oldJob     = plugin.Backend.OldJobDecrement();

            singletons = new RemoteSingletons();

            singletons.RemoteSingleton(typeof(IJobDatabase),
                                       "JobDB",
                                       jobDb);
            singletons.RemoteSingleton(typeof(ILogDatabase),
                                       "LogDB",
                                       logDb);
            singletons.RemoteSingleton(typeof(IInspectionControl),
                                       "InspectionControl",
                                       inspServer);
            singletons.RemoteSingleton(typeof(IJobControl),
                                       "JobControl",
                                       jobControl);
            singletons.RemoteSingleton(typeof(IOldJobDecrement),
                                       "OldJobDecrement",
                                       oldJob);
            singletons.RemoteSingleton(typeof(IStoreSettings),
                                       "Settings",
                                       settingsServer);
        }
Ejemplo n.º 4
0
        void ServerConfing()
        {
            System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider sfsp = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider();
            sfsp.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            System.Collections.Hashtable props = new System.Collections.Hashtable();
            props["port"] = 9000;
            TcpChannel tcp = new TcpChannel(props, null, sfsp);

            
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(tcp, false);
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(RoomObj), "RoomObj", WellKnownObjectMode.Singleton);

            ReadServerData();
            DatabaseAccess.StartDatabaseAcces();
            hostAct = new HostAction();            
        }
Ejemplo n.º 5
0
        private static void Run(Func <ReactiveClientContext, Task> action)
        {
            var platform = default(IReactivePlatform);

            try
            {
                platform = new TcpReactivePlatform();

                try
                {
                    var clientProvider = new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();
                    var serverProvider = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider {
                        TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full
                    };
                    var props = new System.Collections.Hashtable
                    {
                        { "port", 0 },
                        { "name", System.Guid.NewGuid().ToString() },
                        { "typeFilterLevel", System.Runtime.Serialization.Formatters.TypeFilterLevel.Full }
                    };
                    System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(new System.Runtime.Remoting.Channels.Tcp.TcpChannel(props, clientProvider, serverProvider), ensureSecurity: false);

                    platform.StartAsync(CancellationToken.None).Wait();
                    Console.WriteLine("Running demo with the TCP platform.");
                }
#pragma warning disable CA1031 // Do not catch general exception types. (Demo code.)
                catch
                {
                    try { platform.StopAsync(CancellationToken.None).Wait(); }
                    catch { }

                    platform = new InMemoryReactivePlatform();
                    platform.StartAsync(CancellationToken.None).Wait();
                    Console.WriteLine("Running demo with the in-memory platform.");
                }
#pragma warning restore CA1031

                new ReactivePlatformDeployer(platform, new Deployable.CoreDeployable()).Deploy();

                action(platform.CreateClient().Context).Wait();
            }
            finally
            {
                platform?.Dispose();
            }
        }
Ejemplo n.º 6
0
        private static void Startup()
        {
            //setup IPC channel
            Hashtable props = new Hashtable();

            System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider clientsink = new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();
            System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider serversink = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider();

            serversink.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            props["name"]            = "";
            props["portName"]        = "REMOTING_IPC_CHANNEL_0x" + System.Diagnostics.Process.GetCurrentProcess().Id.ToString("X");
            props["typeFilterLevel"] = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            m_Channel = new System.Runtime.Remoting.Channels.Ipc.IpcChannel(props, clientsink, serversink);

            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(m_Channel, false);
        }
Ejemplo n.º 7
0
        private static void registerChannel(string name, string port)
        {
            System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider serverProv = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider();
            serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider clientProv = new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();
            System.Collections.IDictionary properties = new System.Collections.Hashtable();
            properties["name"]     = name;
            properties["priority"] = "20";
            properties["portName"] = port;
            properties["secure"]   = true;
            properties["tokenImpersonationLevel"] = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            properties["includeVersions"]         = false;
            properties["strictBinding"]           = false;
            System.Security.Principal.SecurityIdentifier sidAdmin = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.InteractiveSid, null);
            System.Security.Principal.NTAccount          nt       = (System.Security.Principal.NTAccount)sidAdmin.Translate(typeof(System.Security.Principal.NTAccount));
            progress("registerChannel: " + port + " with authorized group " + nt);
            properties["authorizedGroup"] = nt.Value;

            System.Runtime.Remoting.Channels.Ipc.IpcChannel ipcCh = new System.Runtime.Remoting.Channels.Ipc.IpcChannel(properties, clientProv, serverProv);
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(ipcCh, true);
        }
Ejemplo n.º 8
0
        private static void registerChannel(string name, string port)
        {
            System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider serverProv = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider();
            serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider clientProv = new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();
            System.Collections.IDictionary properties = new System.Collections.Hashtable();
            properties["name"] = name;
            properties["priority"] = "20";
            properties["portName"] = port;
            properties["secure"] = true;
            properties["tokenImpersonationLevel"] = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            properties["includeVersions"] = false;
            properties["strictBinding"] = false;
            System.Security.Principal.SecurityIdentifier sidAdmin = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.InteractiveSid, null);
            System.Security.Principal.NTAccount nt = (System.Security.Principal.NTAccount) sidAdmin.Translate(typeof (System.Security.Principal.NTAccount));
            progress("registerChannel: " + port + " with authorized group " + nt);
            properties["authorizedGroup"] = nt.Value;

            System.Runtime.Remoting.Channels.Ipc.IpcChannel ipcCh = new System.Runtime.Remoting.Channels.Ipc.IpcChannel(properties, clientProv, serverProv);
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(ipcCh, true);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Richtet einen TCP-Serverkanal ein. Serverkanäle nehmen Anfragen von Clients entgegen.
        /// 
        /// Bei aktivierung der Sicherheit über den Parameter "enableSecurity", wird die Kommunikation 
        /// vom Absender signiert, um die Integrität sicherzustellen und zusätzlich verschlüsselt. 
        /// Über den Parameter "impersonate" kann Impersonierung eingeschaltet werden. Bei eingeschalteter
        /// Impersonierung, wird der Remoteaufruf im Kontext des Client-Benutzers ausgeführt.
        /// </summary>
        /// <param name="tcpPort">TCP-Anschlussnummer</param>
        /// <param name="enableSecurity">Schalter für Sicherheit</param>
        /// <param name="impersonate">Schalter für Impersonierung</param>
        public static void SetupServerChannel(int tcpPort, bool enableSecurity,bool impersonate)
        {
            // Kanalnamen erzeugen
            string channelName = "RainbirdEasyRemotingServer" + Convert.ToString(tcpPort);

            // Kanal suchen
            System.Runtime.Remoting.Channels.IChannel channel = System.Runtime.Remoting.Channels.ChannelServices.GetChannel(channelName);

            // Wenn der Kanal nicht gefunden wurde ...
            if (channel == null)
            {
                // Konfiguration für den TCP-Kanal erstellen
                System.Collections.IDictionary channelSettings = new System.Collections.Hashtable();
                channelSettings["name"] = channelName;
                channelSettings["port"] = tcpPort;
                channelSettings["secure"] = enableSecurity;

                // Wenn Sicherheit aktiviert ist ...
                if (enableSecurity)
                {
                    // Impersonierung entsprechend der Einstellung aktivieren oder deaktivieren
                    channelSettings["tokenImpersonationLevel"] = impersonate ? System.Security.Principal.TokenImpersonationLevel.Impersonation : System.Security.Principal.TokenImpersonationLevel.Identification;

                    // Signatur und Verschlüssung explizit aktivieren
                    channelSettings["protectionLevel"] = System.Net.Security.ProtectionLevel.EncryptAndSign;
                }
                // Binäre Serialisierung von komplexen Objekten aktivieren
                System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider provider = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider();
                provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

                // Neuen TCP-Kanal erzeugen
                channel = new System.Runtime.Remoting.Channels.Tcp.TcpChannel(channelSettings, null, provider);

                // Kanal registrieren
                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, enableSecurity);
            }
        }