klezVirus / chameleon

PowerShell Script Obfuscator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding random lettering in front of a function declaration

AnnaMachovec opened this issue · comments

My simple statement is: python chameleon.py -o OUTPUT.ps1 -v Test1.ps1 .
The only thing in Test1.ps1 is :
-----------------------------------------------start of file
function runmeforfun {
Write-Host "Hey!"
$variablenopurpose = "no purpose"
Write-Host $variablenopurpose
}
#single line comment
runmeforfun

-------------------------------------------------end of file

Unfortunately when I run the statement above I get this in the OUTPUT.ps1 file:

-------------------------------------------------start of file
function runmeforfun {
Write-Host "Hey!"
$obfuscatedrandomletteringnothereforpostingpurposes= "no purpose"
Write-Host $obfuscatedrandomletteringnothereforpostingpurposes
}

runmeforfun
-------------------------------------------------end of file

Notice the comment is completely gone and there is now random lettering in front of the function, making the ps1 file now with errors and will not run.

Upon further investigation it looks like the "zeroing out comments" section seems to be the problem

Let me know if I have done something wrong or if this is an error with the python code!! Thank you!

Alright it was solved with this line
_content = text.encode().decode(encoding="utf-8", errors="replace")

I changed the encoding to utf-8 instead of the windows-1252