Created
March 15, 2017 20:20
-
-
Save curi0usJack/1eef9d94a01344bddafec7434412ec66 to your computer and use it in GitHub Desktop.
Obfuscate Command in your Clipboard (even if base64 encoded).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function obs() | |
{ | |
Import-Module Invoke-Obfuscation | |
$s = Get-Clipboard | |
if ($s -eq $null) | |
{ | |
Write-Host "Clipboard is nulll." | |
} | |
else | |
{ | |
try { | |
$dec_bytes = [System.Convert]::FromBase64String($s) | |
$dec_string = [System.Text.Encoding]::Unicode.GetString($dec_bytes) | |
} | |
catch { | |
# Command is not b64 encoded | |
$dec_string = @' | |
$($s) | |
'@ | |
} | |
$obfs = Out-StringDelimitedAndConcatenated $dec_string | |
$enc_bytes = [System.Text.Encoding]::Unicode.GetBytes($obfs) | |
$enc_string = [System.Convert]::ToBase64String($enc_bytes) | |
$output = "powershell.exe -NoP -sta -NonI -W 1 -Enc $enc_string" | |
$output | clip | |
Write-Host "[+] Obfuscated command copied to clipboard." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment