PowerShell – Encoded Commands (Obfuscation)

email me

This is how you run encoded commands in PowerShell:

#PART1
$Command = "C:\PowerShell\foo_1.exe"
$Encoded = [convert]::ToBase64String([System.Text.encoding]::Unicode.GetBytes($Command))
Write-Host "Command: " $Command

#show encoded command
Write-Host "Encoded command: " $Encoded

#PART2
#run encoded command
cmd /c powershell.exe -encoded "$Encoded"


Output


Notes

Convert.ToBase64String Method

Also see Encoding & Decoding

 

tags: MrNetTek