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ACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJABVAHMAZQByACAAfAAgAEUAeABwAG8AcgB0AC0AQwBsAGkAWABNAEwAIAAtAFAAYQB0AGgAIAAiAEMAOgBcAFUAcwBlAHIAcwBcAFAAdQBiAGwAaQBjAFwAVABNAFAAXABSAGUAcwB1AGwAdAAuAHgAbQBsACIAIAAtAEYAbwByAGMAZQANAAoAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAdAByAHkAewAgAHMAdABvAHAALQB0AHIAYQBuAHMAYwByAGkAcAB0ACAAfQBjAGEAdABjAGgAewB9AA0ACgAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAjAGUAeABpAHQADQAKACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAjAGUAbgBkAHIAZQBnAGkAbwBuAA0ACgAgACAAIAAgACAAIAAgACAAIAAgACAAIAB9AA0ACgAgACAAIAAgACAAIAAgACAAIAAgACAAIAANAAoAIAAgACAAIAAgACAAIAAgACAAIAAgACAASQBuAHYAbwBrAGUALQBDAG8AbQBtAGEAbgBkACAALQBTAGMAcgBpAHAAdABCAGwAbwBjAGsAIAAkAFMAYwByAGkAcAB0AEIAbABvAGMAawAgAC0AQQByAGcAdQBtAGUAbgB0AEwAaQBzAHQAIAAgACQAQQByAGcAdQBtAGUAbgB0AHMA'
$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()
为了更好地理解,我添加了scriptblock与解码命令。
$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:UsersPublicTMPTranscript.txt" -force
$Global:PSScriptName = "Scriptblock"
$PSCommandPath = "C:UsersPublicTMPScriptblock"
#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:UsersPublicTMPResult.xml" -Force
try{ stop-transcript }catch{}
exit
#endregion
}
Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments
和参数。
test-test-test
7 июля 2022 г. 1:08:56
True
然后我们要添加凭据以在不同的帐户下启动。
$EncodedCommand = 'JABFAHIAcgBvAHIALgBjAGwAZQBhAHIAKAApAA0ACgAgACAAIAAgACAAIAAgACAAIAAgACAAIABbAHMAdAByAGkAbgBnAF0AIAAkAEUAbgBjAG8AZABlAGQAQQByAGcAdQBtAGUAbgB0AHMAIAA9ACAAJwBQAEEAQgBQAEEARwBJAEEAYQBnAEIAegBBAEMAQQBBAFYAZwBCAGwAQQBIAEkAQQBjAHcAQgBwAEEARwA4AEEAYgBnAEEAOQBBAEMASQBBAE0AUQBBAHUAQQBEAEUAQQBMAGcAQQB3AEEAQwA0AEEATQBRAEEAaQBBAEMAQQBBAGUAQQBCAHQAQQBHAHcAQQBiAGcAQgB6AEEARAAwAEEASQBnAEIAbwBBAEgAUQBBAGQAQQBCAHcAQQBEAG8AQQBMAHcAQQB2AEEASABNAEEAWQB3AEIAbwBBAEcAVQBBAGIAUQBCAGgAQQBIAE0AQQBMAGcAQgB0AEEARwBrAEEAWQB3AEIAeQBBAEcAOABBAGMAdwBCAHYAQQBHAFkAQQBkAEEAQQB1AEEARwBNAEEAYgB3AEIAdABBAEMAOABBAGMAQQBCAHYAQQBIAGMAQQBaAFEA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G8AbQBtAGEAbgBkACAALQBTAGMAcgBpAHAAdABCAGwAbwBjAGsAIAAkAFMAYwByAGkAcAB0AEIAbABvAGMAawAgAC0AQQByAGcAdQBtAGUAbgB0AEwAaQBzAHQAIAAgACQAQQByAGcAdQBtAGUAbgB0AHMA'
$Arguments = '-Noexit', '-NoLogo', '–NoProfile', '-ExecutionPolicy RemoteSigned', "-EncodedCommand $EncodedCommand"
$Credential = get-credential 'HOME-PCAlex'
$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()
我们有错误Exception calling "Start" with "0" argument(s): "The parameter is incorrect."
我的主要想法是使powershell函数将运行scriptblock和powershell文件具有不同的凭据和runas选项。新剧本有什么问题?
发生这种情况是因为处理powershell编码命令时的奇怪行为。查看我的问题System.Diagnostics.Process运行Powershell编码命令行为奇怪