Created
December 4, 2023 07:48
-
-
Save byronwai/c79ed775d7a7de1e79c29dc45907d041 to your computer and use it in GitHub Desktop.
Base64 to transfer file
This file contains hidden or 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
| # Set the path to the executable file | |
| $executablePath = "C:\path\to\executable.exe" | |
| # Set the output path for the Base64 string | |
| $outputFilePath = "C:\base64\output.txt" | |
| # Read the content of the executable file as bytes | |
| $fileBytes = [System.IO.File]::ReadAllBytes($executablePath) | |
| # Convert the byte array to a Base64 string | |
| $base64String = [System.Convert]::ToBase64String($fileBytes) | |
| # Save the Base64 string to a text file | |
| $base64String | Out-File -FilePath $outputFilePath -Encoding ASCII | |
| # Inform the user about the completion and the output file path | |
| Write-Host "Executable file converted to Base64 and saved at: $outputFilePath" |
This file contains hidden or 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
| # Set the path to the Base64-encoded text file | |
| $base64FilePath = "C:\base64\file.txt" | |
| # Set the output path for the recovered executable file | |
| $outputFilePath = "C:\recovered\executable.exe" | |
| # Read the content of the Base64-encoded text file | |
| $base64Content = Get-Content -Path $base64FilePath -Raw | |
| # Convert the Base64 string back to bytes | |
| $fileBytes = [System.Convert]::FromBase64String($base64Content) | |
| # Write the bytes to the output file | |
| [System.IO.File]::WriteAllBytes($outputFilePath, $fileBytes) | |
| # Inform the user about the recovery completion | |
| Write-Host "Executable file recovered successfully at: $outputFilePath" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment