private IJobServer GetIJobServer() { // // Register a channel. #region programmatically configured #region using tcp channel //BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); //BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); //serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; //Hashtable props = new Hashtable(); //props["port"] = 0; //First available port //TcpChannel tcpChan = new TcpChannel(props, clientProv, serverProv); //ChannelServices.RegisterChannel(tcpChan, false); #endregion #region using http channel SoapClientFormatterSinkProvider clientProv = new SoapClientFormatterSinkProvider(); SoapServerFormatterSinkProvider serverProv = new SoapServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; Hashtable props = new Hashtable(); props["port"] = 0; //First available port HttpChannel tcpChan = new HttpChannel(props, clientProv, serverProv); ChannelServices.RegisterChannel(tcpChan, false); #endregion #endregion return((IJobServer)Activator.GetObject(typeof(IJobServer), "http://127.0.0.1:1234/JobURI")); }
static void Main(string[] args) { TMParser parser = new TMParser(); if (!parser.Parse(args)) { return; } var serverProv = new SoapServerFormatterSinkProvider { TypeFilterLevel = TypeFilterLevel.Full }; var clientProv = new SoapClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = Int32.Parse(parser["p"]); var channel = new HttpChannel(props, clientProv, serverProv); ChannelServices.RegisterChannel(channel, false); RemotingConfiguration.RegisterWellKnownServiceType (Type.GetType("MyTM.MyTM") // full type name , "TM.soap" // URI , System.Runtime.Remoting.WellKnownObjectMode.Singleton // instancing mode ); while (true) { Thread.Sleep(2000); TwoPhaseCommit.PrintMessage(); } }
public static void Main() { try { // <Snippet2> IClientChannelSinkProvider mySoapProvider = new SoapClientFormatterSinkProvider(); IClientChannelSinkProvider myClientProvider = new MyClientProvider(); // Set the custom provider as the next 'IClientChannelSinkProvider' in the sink chain. mySoapProvider.Next = myClientProvider; // </Snippet2> TcpChannel myTcpChannel = new TcpChannel(null, mySoapProvider, null); ChannelServices.RegisterChannel(myTcpChannel); RemotingConfiguration.RegisterWellKnownClientType(typeof(HelloService), "tcp://localhost:8082/HelloServiceApplication/MyUri"); HelloService myService = new HelloService(); Console.WriteLine(myService.HelloMethod("Welcome to .Net")); } catch (Exception ex) { Console.WriteLine("The following exception is raised at client side :" + ex.Message); } }
public static void Main() { IDictionary prop = new Hashtable(); prop.Add("port", 8082); IServerChannelSinkProvider myServerFormatterProvider = new SoapServerFormatterSinkProvider(); IServerChannelSinkProvider myServerLoggingProvider = new MyServerProcessingLogServerChannelSinkProviderData(); myServerLoggingProvider.Next = myServerFormatterProvider; IClientChannelSinkProvider myClientFormatterProvider = new SoapClientFormatterSinkProvider(); IClientChannelSinkProvider myClientLoggingProvider = new MyServerProcessingLogClientChannelSinkProviderData(); myClientLoggingProvider.Next = myClientFormatterProvider; TcpChannel channel = new TcpChannel(prop, myClientLoggingProvider, myServerLoggingProvider); ChannelServices.RegisterChannel(channel); RemotingConfiguration.ApplicationName = "HelloServiceApplication"; RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyHelloService), "MyUri", WellKnownObjectMode.SingleCall); Console.WriteLine("Press enter to stop this process."); Console.ReadLine(); }
public static void Main() { IClientChannelSinkProvider mySoapClientFormatterProvider = new SoapClientFormatterSinkProvider(); IClientChannelSinkProvider myClientProvider = new MyServerProcessingLogClientChannelSinkProviderData(); mySoapClientFormatterProvider.Next = myClientProvider; TcpChannel channel = new TcpChannel(null, mySoapClientFormatterProvider, null); ChannelServices.RegisterChannel(channel); RemotingConfiguration.RegisterWellKnownClientType(typeof(MyHelloService), "tcp://localhost:8082/HelloServiceApplication/MyUri"); MyHelloService myService = new MyHelloService(); if (myService == null) { Console.WriteLine("Could not locate server."); return; } // Call remote method. Console.WriteLine(); Console.WriteLine("Calling remote object"); Console.WriteLine(myService.HelloMethod("Caveman")); Console.WriteLine(myService.HelloMethod("Spaceman")); Console.WriteLine(myService.HelloMethod("Client Man")); Console.WriteLine("Finished remote object call"); Console.WriteLine(); }
private void RealMain() { var serverProviderTcp = new BinaryServerFormatterSinkProvider(); serverProviderTcp.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; var clientProviderTcp = new BinaryClientFormatterSinkProvider(); var propertiesTcp = new System.Collections.Hashtable(); propertiesTcp["port"] = 9001; var tcpChannel = new TcpChannel(propertiesTcp, clientProviderTcp, serverProviderTcp); ChannelServices.RegisterChannel(tcpChannel, false); var serverProviderHttp = new SoapServerFormatterSinkProvider(); serverProviderHttp.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; var clientProviderHttp = new SoapClientFormatterSinkProvider(); var propertiesHttp = new System.Collections.Hashtable(); propertiesHttp["port"] = 9002; var httpChannel = new HttpChannel(propertiesHttp, clientProviderHttp, serverProviderHttp); ChannelServices.RegisterChannel(httpChannel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyMarshalByRefClass), "GetObject", WellKnownObjectMode.SingleCall); var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "app_server_wait_for_all_request_done_" + Port.ToString()); CreatePidFile(); eventWaitHandle.WaitOne(TimeSpan.FromMinutes(5)); }
static void Main(string[] args) { Console.WriteLine("id machine Ex: http://localhost:12345"); String id = "http://localhost:12345"; SoapServerFormatterSinkProvider serverProv = new SoapServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; SoapClientFormatterSinkProvider clientProv = new SoapClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = 12345; HttpChannel ch = new HttpChannel(props, clientProv, serverProv); ChannelServices.RegisterChannel(ch, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerClass.Server), "RemoteServer.soap", WellKnownObjectMode.Singleton); IManager manager = (IManager)Activator.GetObject(typeof(IManager), "http://localhost:1234/RemoteManager.soap"); manager.Register(id + "/RemoteServer.soap"); Console.WriteLine("Server start"); Console.ReadLine(); manager.UnRegister(id + "/RemoteServer.soap"); }
private IClientChannelSinkProvider CreateDefaultClientProviderChain() { IClientChannelSinkProvider provider = new SoapClientFormatterSinkProvider(); IClientChannelSinkProvider provider2 = provider; provider2.Next = new HttpClientTransportSinkProvider(this._timeout); return(provider); }
} // CreateMessageSink // // end of IChannelSender implementation // private IClientChannelSinkProvider CreateDefaultClientProviderChain() { IClientChannelSinkProvider chain = new SoapClientFormatterSinkProvider(); IClientChannelSinkProvider sink = chain; sink.Next = new HttpClientTransportSinkProvider(_timeout); return(chain); } // CreateDefaultClientProviderChain
static void Main(string[] args) { TMParser parser = new TMParser(); if (!parser.Parse(args)) { return; } SoapServerFormatterSinkProvider serverProv = new SoapServerFormatterSinkProvider(); serverProv.TypeFilterLevel = TypeFilterLevel.Full; SoapClientFormatterSinkProvider clientProv = new SoapClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = Int32.Parse(parser["p"]); HttpChannel channel = new HttpChannel(props, clientProv, serverProv); ChannelServices.RegisterChannel(channel, false); RemotingConfiguration.RegisterWellKnownServiceType (Type.GetType("MyTM.MyTM") // full type name , "TM.soap" // URI , System.Runtime.Remoting.WellKnownObjectMode.Singleton // instancing mode ); // activate the object string[] urls = channel.GetUrlsForUri("TM.soap"); if (1 != urls.Length) { throw new InvalidOperationException(); } MyTM transactionManager = (MyTM)System.Activator.GetObject(typeof(TP.TM), urls[0]); if (null == transactionManager) { throw new InvalidProgramException(); } // Do recovery every 30 seconds to recommit/reabort unacknowledged transactions // as well as doing garbage collection on the outstanding transaction file while (true) { Console.WriteLine("Recovery will run in 30 seconds..."); System.Threading.Thread.Sleep(30000); transactionManager.recovery(); } }
protected override IChannel CreateChannel() { IDictionary prop = new Hashtable(); prop["name"] = ServiceName; prop["port"] = Port; SoapClientFormatterSinkProvider clientProvider = new SoapClientFormatterSinkProvider(); SoapServerFormatterSinkProvider serverProvider = new SoapServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; return(new TcpChannel(prop, clientProvider, serverProvider)); }
static void Main(string[] args) { // Run on localhost, port 1234 String serverAddress = "http://localhost:1234/VulnerableEndpoint.rem"; //String serverAddress = "http://localhost:8080/VulnerableEndpoint.rem"; // to proxy them in Burp - redirecting it to localhost:1234 with "Support invisible proxying" // * The following code could not be used to secure the client application by setting the typeFilterLevel to Low: IDictionary props = new Hashtable(); SoapClientFormatterSinkProvider clientProvider = new SoapClientFormatterSinkProvider(); SoapServerFormatterSinkProvider serverProvider = new SoapServerFormatterSinkProvider() { TypeFilterLevel = TypeFilterLevel.Low // This is where we can exploit it without knowing anything about the application or having an 0day! }; props["name"] = "ClientChannel"; props["portName"] = Guid.NewGuid().ToString(); props["typeFilterLevel"] = "Low"; props["port"] = 0; HttpChannel clientChannel = new HttpChannel(props, clientProvider, serverProvider); // Register the channel. ChannelServices.RegisterChannel(clientChannel, false); RemotingConfiguration.RegisterWellKnownClientType(new WellKnownClientTypeEntry(typeof(RemoteObject1), serverAddress)); // RemoteObject1 obj1 = (RemoteObject1)Activator.GetObject(typeof(RemoteObject1), serverAddress); try { Console.WriteLine("Calling GetCount - received: {0}", obj1.GetCount()); Console.WriteLine("Calling EchoMe - Received: {0}", obj1.EchoMe("This is my text for echo!")); Console.WriteLine("Calling GetCount - received: {0}", obj1.GetCount()); } catch (Exception e) { Console.WriteLine(e.StackTrace); } /* Wait for the user prompt: */ Console.WriteLine("Press ENTER to exit the client."); Console.ReadLine(); Console.WriteLine("The client is exiting."); }
static void Main () { SoapClientFormatterSinkProvider ccsp = new SoapClientFormatterSinkProvider (); HttpClientChannel channel = new HttpClientChannel ((IDictionary) null, ccsp); #if NET_2_0 ChannelServices.RegisterChannel (channel, false); #else ChannelServices.RegisterChannel (channel); #endif IServer server = (IServer) Activator.GetObject (typeof (IServer), "http://127.0.0.1:8080/Server.rem"); ISession session = server.LogOn ("Test"); SessionContext ctx = (SessionContext) CallContext.GetData ("session_ctx"); Assert.AreSame (session, ctx.Session, "#1"); Assert.AreEqual ("Session here", session.GetName (), "#2"); }
public TestResultGrp RunTestSoap() { foreach (IChannel channel in ChannelServices.RegisteredChannels) { ChannelServices.UnregisterChannel(channel); } SoapServerFormatterSinkProvider svr = new SoapServerFormatterSinkProvider(); SoapClientFormatterSinkProvider clnt = new SoapClientFormatterSinkProvider(); HttpChannel httpChannel = new HttpChannel(); TcpChannel tcpChannel = new TcpChannel(null, clnt, svr); ChannelServices.RegisterChannel(httpChannel); ChannelServices.RegisterChannel(tcpChannel); TestResultGrp trg = RunTests(); return(trg); }
public static Peer NewPeer(string port, string uri) { #region CreateServer SoapServerFormatterSinkProvider serverProv = new SoapServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; #endregion #region CreateClient SoapClientFormatterSinkProvider clientProv = new SoapClientFormatterSinkProvider(); #endregion #region CreateChannel IDictionary props = new Hashtable(); props["port"] = port; /* *****Code for add multichannels****** * * * IChannel ch = null; * switch (pc.ConnectionType) * { * case "http": * ch = new HttpChannel(props, clientProv, serverProv); * break; * case "tcp": * ch = new TcpChannel(props, clientProv, serverProv); * break; * } */ IChannel ch = new HttpChannel(props, clientProv, serverProv); ChannelServices.RegisterChannel(ch); #endregion //Registers an object Type on the service end as a well-known type RemotingConfiguration.RegisterWellKnownServiceType( typeof(Peer), "RemotePeer.soap", WellKnownObjectMode.Singleton); //Creates a proxy for a well-known object return((Peer)Activator.GetObject(typeof(Peer), uri)); }
private void ServerStartupRemoting() { SoapClientFormatterSinkProvider clientSinkProvider = new SoapClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["typeFilterLevel"] = "Full"; SoapServerFormatterSinkProvider serverSinkProvider = new SoapServerFormatterSinkProvider(props, null); ClientIpServerSinkProvider clientIpSinkProvider = new ClientIpServerSinkProvider(props, null); serverSinkProvider.Next = clientIpSinkProvider; props["port"] = ServerPort; props["name"] = "ServerChannel"; HttpChannel chan = new HttpChannel(props, clientSinkProvider, serverSinkProvider); string name = chan.ChannelName; ChannelServices.RegisterChannel(chan, false); if (System.IO.File.Exists(configFile)) { RemotingConfiguration.Configure(configFile, false); } else { MessageBox.Show("Missing config file:\r\n" + configFile); } RemotingConfiguration.RegisterWellKnownServiceType( typeof(Allberg.Shooter.WinShooterServer.ClientInterface), "WinShooterServer", WellKnownObjectMode.Singleton); }
private void Init() { if (serviceChannel == null) { //远程抛出错误 RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off; RemotingConfiguration.CustomErrorsEnabled(false); IClientChannelSinkProvider clientProvider; IServerChannelSinkProvider serverProvider; if (channelType == RemotingChannelType.Tcp) { //使用二进制格式化 clientProvider = new BinaryClientFormatterSinkProvider(); //使用二进制格式化 serverProvider = new BinaryServerFormatterSinkProvider(); //设置反序列化级别为Full,支持远程处理在所有情况下支持的所有类型 (serverProvider as BinaryServerFormatterSinkProvider) .TypeFilterLevel = TypeFilterLevel.Full; } else { //使用SOAP格式化 clientProvider = new SoapClientFormatterSinkProvider(); //使用SOAP格式化 serverProvider = new SoapServerFormatterSinkProvider(); //设置反序列化级别为Full,支持远程处理在所有情况下支持的所有类型 (serverProvider as SoapServerFormatterSinkProvider) .TypeFilterLevel = TypeFilterLevel.Full; } string name = AppDomain.CurrentDomain.FriendlyName; foreach (var channel in ChannelServices.RegisteredChannels) { if (channel.ChannelName == name) { ChannelServices.UnregisterChannel(channel); break; } } IDictionary props = new Hashtable(); props["name"] = name; props["port"] = serverPort; //初始化通道并注册 if (channelType == RemotingChannelType.Tcp) { serviceChannel = new TcpChannel(props, clientProvider, serverProvider); } else { serviceChannel = new HttpChannel(props, clientProvider, serverProvider); } try { ChannelServices.RegisterChannel(serviceChannel, false); } catch (RemotingException ex) { //注册信道出错 } } }
/// <summary> /// Erzeugt einen fertig konfigurierten Remoting-Kanal. /// <remarks> /// Wenn der Kanal in der aktuellen Anwendungsdomäne bereits registriert wurde, wird null zurückgegeben. /// </remarks> /// </summary> /// <returns>Remoting Kanal</returns> public IChannel CreateChannel() { // Kanal suchen IChannel channel = ChannelServices.GetChannel(_channelName); // Wenn der Kanal nicht gefunden wurde ... if (channel == null) { // Konfiguration für den HTTP-Kanal erstellen System.Collections.IDictionary channelSettings = new System.Collections.Hashtable(); channelSettings["name"] = _channelName; channelSettings["port"] = 0; // Variable für Clientformatierer IClientFormatterSinkProvider clientFormatter = null; // Wenn binäre Formatierung verwendet werden soll ... if (_useBinaryFormatter) { // Binären Clientformatierer erzeugen clientFormatter = new BinaryClientFormatterSinkProvider(); } else { // SOAP Clientformatierer erzeugen clientFormatter = new SoapClientFormatterSinkProvider(); } // Wenn die Kommunikation verschlüsselt werden soll ... if (_encryption) { // Client-Verschlüsselungs-Kanalsenkenanbieter erzeugen CryptoClientChannelSinkProvider clientEncryption = new CryptoClientChannelSinkProvider(); // Verschlüsselung konfigurieren clientEncryption.Algorithm = _algorithm; clientEncryption.Oaep = _oaep; clientEncryption.MaxAttempts = _maxAttempts; // Verschlüsselungs-Kanalsenkenanbieter hinter den Formatierer hängen clientFormatter.Next = clientEncryption; } // Variable für ersten Server-Senkenanbieter in der Kette IServerChannelSinkProvider firstServerSinkProvider = null; // Variable für Serverformatierer IServerFormatterSinkProvider serverFormatter = null; // Wenn binäre Formatierung verwendet werden soll ... if (_useBinaryFormatter) { // Binären Serverformatierer erzeugen serverFormatter = new BinaryServerFormatterSinkProvider(); // Serialisierung von komplexen Objekten aktivieren ((BinaryServerFormatterSinkProvider)serverFormatter).TypeFilterLevel = TypeFilterLevel.Full; } else { // SOAP Serverformatierer erzeugen serverFormatter = new SoapServerFormatterSinkProvider(); // Serialisierung von komplexen Objekten aktivieren ((SoapServerFormatterSinkProvider)serverFormatter).TypeFilterLevel = TypeFilterLevel.Full; } // Wenn die Kommunikation verschlüsselt werden soll ... if (_encryption) { // Server-Verschlüsselungs-Kanalsenkenanbieter erzeugen CryptoServerChannelSinkProvider serverEncryption = new CryptoServerChannelSinkProvider(); // Verschlüsselung konfigurieren serverEncryption.Algorithm = _algorithm; serverEncryption.Oaep = _oaep; serverEncryption.RequireCryptoClient = true; // Formatierer hinter den Verschlüsselungs-Kanalsenkenanbieter hängen serverEncryption.Next = serverFormatter; // Verschlüsselungs-Kanalsenkenanbieter als ersten Senkenanbieter festlegen firstServerSinkProvider = serverEncryption; } else { // Server-Formatierer als ersten Senkenanbieter festlegen firstServerSinkProvider = serverFormatter; } // Neuen HTTP-Kanal erzeugen channel = new HttpChannel(channelSettings, clientFormatter, firstServerSinkProvider); // Wenn Zyan nicht mit mono ausgeführt wird ... if (!MonoCheck.IsRunningOnMono) { // Sicherstellen, dass vollständige Ausnahmeinformationen übertragen werden if (RemotingConfiguration.CustomErrorsMode != CustomErrorsModes.Off) { RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off; } } // Kanal zurückgeben return(channel); } // Nichts zurückgeben return(null); }