πͺ PowerShell Base64 Encode & Decode
πͺ PowerShell Base64 Encode & Decode
Transfer files without using the network β especially in red-team or penetration testing situations. If you've got terminal access, this method lets you convert a file to Base64, move the string manually (like copy-paste βοΈπ), and decode it on the other side!
β
Step 1: Verify File Integrity with md5sum
π§¬
md5sum
π§¬Before and after transferring the file, generate the MD5 hash to verify it later once transfered
π’ Output:
This is your "file fingerprint" π β it should match after the transfer.
π Step 2: Encode File to Base64 on Linux π§Ύβ‘οΈπ‘
π This gives you a Base64 string of your file β copy it all!
β οΈ Make sure you use
-w 0
so there's no line break!
πͺ Step 3: Decode Base64 in PowerShell π₯οΈ
Paste your Base64 string into this PowerShell command to recreate the file:
πΎ This writes the file back in its original form!
π Step 4: Confirm the File Integrity (again)
Now check the hash on Windows to confirm the file was transferred correctly:
β
If the hash matches 4E301756A07DED0A2DD6953ABF015278
β mission accomplished! π
β οΈ Notes & Limitations π§
πͺ cmd.exe has a max string limit of 8191 characters
πΈοΈ Some web shells can error if strings are too long
π§© For large files, consider other tools (like
certutil
,bitsadmin
, etc.)
This method is perfect for small files like:
SSH keys
Scripts
Tiny DLLs
Let me know if you'd like a PowerShell script version or to automate hash checks! π»β¨
Last updated