We have script that successfully ran. It`s execute encoded command and show output.
$EncodedCommand = 'JABFAHIAcgBvAHIALgBjAGwAZQBhAHIAKAApAA0ACgAgACAAIAAgACAAIAAgACAAIAAgACAAIABbAHMAdAByAGkAbgBnAF0AIAAkAEUAbgBjAG8AZABlAGQAQQByAGcAdQBtAGUAbgB0AHMAIAA9ACAAJwBQAEEAQgBQAEEARwBJAEEAYQBnAEIAegBBAEMAQQBBAFYAZwBCAGwAQQBIAEkAQQBjAHcAQgBwAEEARwA4AEEAYgBnAEEAOQBBAEMASQBBAE0AUQBBAHUAQQBEAEUAQQBMAGcAQQB3AEEAQwA0AEEATQBRAEEAaQBBAEMAQQBBAGUAQQBCAHQAQQBHAHcAQQBiAGcAQgB6AEEARAAwAEEASQBnAEIAbwBBAEgAUQBBAGQAQQBCAHcAQQBEAG8AQQBMAHcAQQB2AEEASABNAEEAWQB3AEIAbwBBAEcAVQBBAGIAUQBCAGgAQQBIAE0AQQBMAGcAQgB0AEEARwBrAEEAWQB3AEIAeQBBAEcAOABBAGMAdwBCAHYAQQBHAFkAQQBkAEEAQQB1AEEARwBNAEEAYgB3AEIAdABBAEMAOABBAGMAQQBCAHYAQQBIAGMAQQBaAFEAQgB5AEEASABNAEEAYQBBAEIAbABBAEcAdwBBAGIAQQBBAHYAQQBEAEkAQQBNAEEAQQB3AEEARABRAEEATAB3AEEAdwBBAEQAUQBBAEkAZwBBACsAQQBBADAAQQBDAGcAQQBnAEEAQwBBAEEAUABBAEIAUABBAEcASQBBAGEAZwBBAGcAQQBGAEkAQQBaAFEAQgBtAEEARQBrAEEAWgBBAEEAOQBBAEMASQBBAE0AQQBBAGkAQQBEADQAQQBEAFEAQQBLAEEAQwBBAEEASQBBAEEAZwBBAEMAQQBBAFAAQQBCAFUAQQBFADQAQQBJAEEAQgBTAEEARwBVAEEAWgBnAEIASgBBAEcAUQBBAFAAUQBBAGkAQQBEAEEAQQBJAGcAQQArAEEAQQAwAEEAQwBnAEEAZwBBAEMAQQBBAEkAQ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gACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJABVAHMAZQByACAAfAAgAEUAeABwAG8AcgB0AC0AQwBsAGkAWABNAEwAIAAtAFAAYQB0AGgAIAAiAEMAOgBcAFUAcwBlAHIAcwBcAFAAdQBiAGwAaQBjAFwAVABNAFAAXABSAGUAcwB1AGwAdAAuAHgAbQBsACIAIAAtAEYAbwByAGMAZQANAAoAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAdAByAHkAewAgAHMAdABvAHAALQB0AHIAYQBuAHMAYwByAGkAcAB0ACAAfQBjAGEAdABjAGgAewB9AA0ACgAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAjAGUAeABpAHQADQAKACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAjAGUAbgBkAHIAZQBnAGkAbwBuAA0ACgAgACAAIAAgACAAIAAgACAAIAAgACAAIAB9AA0ACgAgACAAIAAgACAAIAAgACAAIAAgACAAIAANAAoAIAAgACAAIAAgACAAIAAgACAAIAAgACAASQBuAHYAbwBrAGUALQBDAG8AbQBtAGEAbgBkACAALQBTAGMAcgBpAHAAdABCAGwAbwBjAGsAIAAkAFMAYwByAGkAcAB0AEIAbABvAGMAawAgAC0AQQByAGcAdQBtAGUAbgB0AEwAaQBzAHQAIAAgACQAQQByAGcAdQBtAGUAbgB0AHMA'
$Arguments = '-Noexit', '-NoLogo', '–NoProfile', '-ExecutionPolicy RemoteSigned', "-EncodedCommand $EncodedCommand"
$ProcessStartInfoParam = [ordered]@{
Arguments = $Arguments -join ' '
CreateNoWindow = $False
FileName = 'powershell'
WindowStyle = 'Normal'
LoadUserProfile = $False
UseShellExecute = $False
}
$ProcessStartInfo = New-Object -TypeName 'System.Diagnostics.ProcessStartInfo' -Property $ProcessStartInfoParam
$Process = New-Object 'System.Diagnostics.Process'
$Process.StartInfo = $ProcessStartInfo
$Process.Start()
For better understanding i`m added scriptblock with decoded command.
$Error.clear()
[Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding( "utf-8" )
[string] $EncodedArguments = 'PABPAGIAagBzACAAVgBlAHIAcwBpAG8AbgA9ACIAMQAuADEALgAwAC4AMQAiACAAeABtAGwAbgBzAD0AIgBoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBtAGkAYwByAG8AcwBvAGYAdAAuAGMAbwBtAC8AcABvAHcAZQByAHMAaABlAGwAbAAvADIAMAAwADQALwAwADQAIgA AA0ACgAgACAAPABPAGIAagAgAFIAZQBmAEkAZAA9ACIAMAAiAD4ADQAKACAAIAAgACAAPABUAE4AIABSAGUAZgBJAGQAPQAiADAAIgA AA0ACgAgACAAIAAgACAAIAA8AFQAPgBTAHkAcwB0AGUAbQAuAE8AYgBqAGUAYwB0AFsAXQA8AC8AVAA AA0ACgAgACAAIAAgACAAIAA8AFQAPgBTAHkAcwB0AGUAbQAuAEEAcgByAGEAeQA8AC8AVAA AA0ACgAgACAAIAAgACAAIAA8AFQAPgBTAHkAcwB0AGUAbQAuAE8AYgBqAGUAYwB0ADwALwBUAD4ADQAKACAAIAAgACAAPAAvAFQATgA AA0ACgAgACAAIAAgADwATABTAFQAPgANAAoAIAAgACAAIAAgACAAPABTAD4AdABlAHMAdAAtAHQAZQBzAHQALQB0AGUAcwB0ADwALwBTAD4ADQAKACAAIAAgACAAIAAgADwATwBiAGoAIABSAGUAZgBJAGQAPQAiADEAIgA AA0ACgAgACAAIAAgACAAIAAgACAAPABEAFQAPgAyADAAMgAyAC0AMAA3AC0AMAA4AFQAMQAxADoAMwAxADoAMwAxAC4AOQA3ADMAOAA2ADYAOQArADAAMwA6ADAAMAA8AC8ARABUAD4ADQAKACAAIAAgACAAIAAgACAAIAA8AE0AUwA AA0ACgAgACAAIAAgACAAIAAgACAAIAAgADwATwBiAGoAIABOAD0AIgBEAGkAcwBwAGwAYQB5AEgAaQBuAHQAIgAgAFIAZQBmAEkAZAA9ACIAMgAiAD4ADQAKACAAIAAgACAAIAAgACAAIAAgACAAIAAgADwAVABOACAAUgBlAGYASQBkAD0AIgAxACIAPgANAAoAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgADwAVAA AE0AaQBjAHIAbwBzAG8AZgB0AC4AUABvAHcAZQByAFMAaABlAGwAbAAuAEMAbwBtAG0AYQBuAGQAcwAuAEQAaQBzAHAAbABhAHkASABpAG4AdABUAHkAcABlADwALwBUAD4ADQAKACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAA8AFQAPgBTAHkAcwB0AGUAbQAuAEUAbgB1AG0APAAvAFQAPgANAAoAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgADwAVAA AFMAeQBzAHQAZQBtAC4AVgBhAGwAdQBlAFQAeQBwAGUAPAAvAFQAPgANAAoAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgADwAVAA AFMAeQBzAHQAZQBtAC4ATwBiAGoAZQBjAHQAPAAvAFQAPgANAAoAIAAgACAAIAAgACAAIAAgACAAIAAgACAAPAAvAFQATgA AA0ACgAgACAAIAAgACAAIAAgACAAIAAgACAAIAA8AFQAbwBTAHQAcgBpAG4AZwA AEQAYQB0AGUAVABpAG0AZQA8AC8AVABvAFMAdAByAGkAbgBnAD4ADQAKACAAIAAgACAAIAAgACAAIAAgACAAIAAgADwASQAzADIAPgAyADwALwBJADMAMgA AA0ACgAgACAAIAAgACAAIAAgACAAIAAgADwALwBPAGIAagA AA0ACgAgACAAIAAgACAAIAAgACAAPAAvAE0AUwA AA0ACgAgACAAIAAgACAAIAA8AC8ATwBiAGoAPgANAAoAIAAgACAAIAAgACAAPABCAD4AdAByAHUAZQA8AC8AQgA AA0ACgAgACAAIAAgADwALwBMAFMAVAA AA0ACgAgACAAPAAvAE8AYgBqAD4ADQAKADwALwBPAGIAagBzAD4A'
$Arguments = [System.Management.Automation.PSSerializer]::Deserialize( [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String( $EncodedArguments )) )
$ScriptBlock = {
#sb1
param( $Param1, $Param2, $Param3 )
#region Outer script addition
Start-Transcript -path "C:\Users\Public\TMP\Transcript.txt" -force
$Global:PSScriptName = "Scriptblock"
$PSCommandPath = "C:\Users\Public\TMP\Scriptblock"
#endregion
get-date
$User = whoami
$Runas = Test-ElevatedRights
write-host "User = $User"
write-host "Runas = $Runas"
write-host "Param1 = $Param1"
write-host "Param2 = $Param2"
write-host "Param3 = $Param3"
#region Outer script addition (return replace)
$User | Export-CliXML -Path "C:\Users\Public\TMP\Result.xml" -Force
try{ stop-transcript }catch{}
exit
#endregion
}
Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments
And arguments.
test-test-test
7 июля 2022 г. 1:08:56
True
Then we want to add credential to start under different account.
$EncodedCommand = 'JABFAHIAcgBvAHIALgBjAGwAZQBhAHIAKAApAA0ACgAgACAAIAAgACAAIAAgACAAIAAgACAAIABbAHMAdAByAGkAbgBnAF0AIAAkAEUAbgBjAG8AZABlAGQAQQByAGcAdQBtAGUAbgB0AHMAIAA9ACAAJwBQAEEAQgBQAEEARwBJAEEAYQBnAEIAegBBAEMAQQBBAFYAZwBCAGwAQQBIAEkAQQBjAHcAQgBwAEEARwA4AEEAYgBnAEEAOQBBAEMASQBBAE0AUQBBAHUAQQBEAEUAQQBMAGcAQQB3AEEAQwA0AEEATQBRAEEAaQBBAEMAQQBBAGUAQQBCAHQAQQBHAHcAQQBiAGcAQgB6AEEARAAwAEEASQBnAEIAbwBBAEgAUQBBAGQAQQBCAHcAQQBEAG8AQQBMAHcAQQB2AEEASABNAEEAWQB3AEIAbwBBAEcAVQBBAGIAUQBCAGgAQQBIAE0AQQBMAGcAQgB0AEEARwBrAEEAWQB3AEIAeQBBAEcAOABBAGMAdwBCAHYAQQBHAFkAQQBkAEEAQQB1AEEARwBNAEEAYgB3AEIAdABBAEMAOABBAGMAQQBCAHYAQQBIAGMAQQBaAFEAQgB5AEEASABNAEEAYQBBA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BTAGMAcgBpAHAAdABCAGwAbwBjAGsAIAAkAFMAYwByAGkAcAB0AEIAbABvAGMAawAgAC0AQQByAGcAdQBtAGUAbgB0AEwAaQBzAHQAIAAgACQAQQByAGcAdQBtAGUAbgB0AHMA'
$Arguments = '-Noexit', '-NoLogo', '–NoProfile', '-ExecutionPolicy RemoteSigned', "-EncodedCommand $EncodedCommand"
$Credential = get-credential 'HOME-PC\Alex'
$DomainAndUserName = $Credential.UserName.Split("\")
$ProcessStartInfoParam = [ordered]@{
Arguments = $Arguments -join ' '
CreateNoWindow = $False
FileName = 'powershell'
WindowStyle = 'Normal'
LoadUserProfile = $False
UseShellExecute = $False
Domain = $DomainAndUserName | Select-Object -first 1
UserName = $DomainAndUserName | Select-Object -last 1
Password = $Credential.Password
}
$ProcessStartInfo = New-Object -TypeName 'System.Diagnostics.ProcessStartInfo' -Property $ProcessStartInfoParam
$Process = New-Object 'System.Diagnostics.Process'
$Process.StartInfo = $ProcessStartInfo
$Process.Start()
We have error Exception calling "Start" with "0" argument(s): "The parameter is incorrect."
My main idea is to make powershell function that will run scriptblock and powershell files with different credentials and with option of runas.
Whats wrong with the new script?
CodePudding user response:
This happend because of strange behavour while proccessing powershell encoded commands. See my question System.Diagnostics.Process run Powershell encoded command strange behaviour.