From c97b84e4a284562cd159b73fba42435d0733bb47 Mon Sep 17 00:00:00 2001 From: Simon Monai <33432894+simonai1254@users.noreply.github.com> Date: Wed, 30 Aug 2023 23:46:42 +0200 Subject: [PATCH] Quote variable for #2195 In order to interpret variable as string and not arbitrary code --- .../Protocol/PowerShell/Connection.Protocol.PowerShell.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mRemoteNG/Connection/Protocol/PowerShell/Connection.Protocol.PowerShell.cs b/mRemoteNG/Connection/Protocol/PowerShell/Connection.Protocol.PowerShell.cs index 7fec7b5d..6864a7ee 100644 --- a/mRemoteNG/Connection/Protocol/PowerShell/Connection.Protocol.PowerShell.cs +++ b/mRemoteNG/Connection/Protocol/PowerShell/Connection.Protocol.PowerShell.cs @@ -42,7 +42,7 @@ namespace mRemoteNG.Connection.Protocol.PowerShell }; _consoleControl.StartProcess(@"C:\Windows\system32\WindowsPowerShell\v1.0\PowerShell.exe", - $@"-NoExit -Command ""$password = ConvertTo-SecureString '{_connectionInfo.Password}' -AsPlainText -Force; $cred = New-Object System.Management.Automation.PSCredential -ArgumentList @('{_connectionInfo.Domain}\{_connectionInfo.Username}', $password); Enter-PSSession -ComputerName {_connectionInfo.Hostname} -Credential $cred"""); + $@"-NoExit -Command ""$password = ConvertTo-SecureString ""'{_connectionInfo.Password}'"" -AsPlainText -Force; $cred = New-Object System.Management.Automation.PSCredential -ArgumentList @('{_connectionInfo.Domain}\{_connectionInfo.Username}', $password); Enter-PSSession -ComputerName {_connectionInfo.Hostname} -Credential $cred"""); while (!_consoleControl.IsHandleCreated) break; _handle = _consoleControl.Handle; @@ -99,4 +99,4 @@ namespace mRemoteNG.Connection.Protocol.PowerShell #endregion } -} \ No newline at end of file +}