mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 14:07:46 +08:00
use pwfile instead of pw for puttyng
This commit is contained in:
@@ -13,6 +13,9 @@ using mRemoteNG.Properties;
|
||||
using mRemoteNG.Resources.Language;
|
||||
using System.IO;
|
||||
using System.Runtime.Versioning;
|
||||
using System.IO.Pipes;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using System.Linq;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
@@ -57,6 +60,19 @@ namespace mRemoteNG.Connection.Protocol
|
||||
return !PuttyProcess.HasExited;
|
||||
}
|
||||
|
||||
public void CreatePipe(object oData)
|
||||
{
|
||||
string data = (string)oData;
|
||||
string random = data[..8];
|
||||
string password = data[8..];
|
||||
var server = new NamedPipeServerStream($"mRemoteNGSecretPipe{random}");
|
||||
server.WaitForConnection();
|
||||
StreamWriter writer = new(server);
|
||||
writer.Write(password);
|
||||
writer.Flush();
|
||||
server.Dispose();
|
||||
}
|
||||
|
||||
public override bool Connect()
|
||||
{
|
||||
string optionalTemporaryPrivateKeyPath = ""; // path to ppk file instead of password. only temporary (extracted from credential vault).
|
||||
@@ -74,7 +90,7 @@ namespace mRemoteNG.Connection.Protocol
|
||||
}
|
||||
};
|
||||
|
||||
var arguments = new CommandLineArguments {EscapeForShell = false};
|
||||
var arguments = new CommandLineArguments { EscapeForShell = false };
|
||||
|
||||
arguments.Add("-load", InterfaceControl.Info.PuttySession);
|
||||
|
||||
@@ -162,7 +178,13 @@ namespace mRemoteNG.Connection.Protocol
|
||||
|
||||
if (!string.IsNullOrEmpty(password))
|
||||
{
|
||||
arguments.Add("-pw", password);
|
||||
string random = string.Join("", Guid.NewGuid().ToString("n").Take(8).Select(o => o));
|
||||
// write data to pipe
|
||||
var thread = new Thread(new ParameterizedThreadStart(CreatePipe));
|
||||
thread.Start($"{random}{password}");
|
||||
// start putty with piped password
|
||||
arguments.Add("-pwfile", $"\\\\.\\PIPE\\mRemoteNGSecretPipe{random}");
|
||||
//arguments.Add("-pw", password);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user