0

i have this hybris batch/powershell base64 decoder and i want to decode the string in powershell and set the decoded variable to a variable in batch, this is my code

@echo off
set syscall=dGVzdGluZ3hk
powershell.exe $decoded=[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($env:syscall));
1
  • 1
    Please do not vandalize posts on Stack Overflow, including your own. Content is licensed here under CC-BY-SA 4.0. Commented Aug 11, 2021 at 15:28

1 Answer 1

4

Use a for /f statement to capture the output from a command (run for /? in a cmd.exe session for more information):

@echo off
set "syscall=dGVzdGluZ3hk"
for /f "usebackq delims=" %%i in (`powershell.exe -noprofile -c "[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($env:syscall))"`) do set "decoded=%%i"

After executing the above, %decoded% contains testingxd.

Sign up to request clarification or add additional context in comments.

4 Comments

Do you know any big programming language(s)?
@AbrahamZinala, what makes a programming language big?
The more well-known, such as the low-level languages.
@AbrahamZinala I've worked with C and C++ in the past, but it's been many, many years.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.