Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String Token obfuscation breaks multiline string variable substitution #46

Open
lehoffma opened this issue Feb 4, 2019 · 0 comments
Open

Comments

@lehoffma
Copy link

lehoffma commented Feb 4, 2019

If you apply any of the string obfuscations on a multiline string with a variable substitution, the variable will be treated as a normal part of the string and thus won't be substituted.

Example script:

$script = "hello"

$ps = @"
$script
"@

Write-Output $ps;

After applying the Token\String\2 obfuscation on it:

$script = ("{1}{0}" -f 'o','hell')

$ps = ((('Cd'+'H
'+'
TR'+'Cs'+'cri'+'pt
CdH') -RePLACE ([ChaR]84+[ChaR]82+[ChaR]67),[ChaR]36 -RePLACE 'CdH',[ChaR]34))

Write-Output $ps;

Calling the obfuscated script results in this being printed:

"
$script
"

instead of hello.

As far as I know there is currently no way to obfuscate this script correctly, without just abandoning the script obfuscation entirely. I'm using version 1.8, by the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant