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

Error using --base64 Option #4

Closed
s6mahahn opened this issue Jan 19, 2022 · 4 comments
Closed

Error using --base64 Option #4

s6mahahn opened this issue Jan 19, 2022 · 4 comments

Comments

@s6mahahn
Copy link

Hey,
When I use --base64 to obfuscate a script the resulting script can not be executed.

The error is:

Get-Command : Die Benennung "Get-Command" wurde nicht als Name eines Cmdlet, einer
Funktion, einer Skriptdatei oder eines ausführbaren Programms erkannt. Überprüfen Sie die
Schreibweise des Namens, oder ob der Pfad korrekt ist (sofern enthalten), und wiederholen
Sie den Vorgang.
In Zeile:1 Zeichen:1

As you can see the highlighted section contains some invalid characters. Any reasons why this happens? Or am I doing something wrong?

@klezVirus
Copy link
Owner

Hi @MaxMax147 , I think this should be related to the encoding used by the script.

Can you try to change line 440:

_content = text.encode().decode(encoding="windows-1252", errors="replace")

with this one:

_content = text.encode().decode(encoding="utf-8", errors="replace")

And tell me if it works like that?

@s6mahahn
Copy link
Author

It still doesn't work, but I think it has something to do with the encoding.

 is the BOM of UTF-8 in Windows-1252. I tried changing the encoding to utf-8 or utf-8-sig, but it made no difference.

@s6mahahn
Copy link
Author

I found out what the problem was. The PowerShell ISE save a skript as utf-8 with BOM for some reason. I just opened the skripts in Notepad++ and saved them with a different encoding.

@klezVirus
Copy link
Owner

klezVirus commented Jan 22, 2022

That's great @MaxMax147! I never work in ISE and just tried it now to confirm this behaviour. Now that I know what is the problem, I can address it in the code itself. Thanks for the help here! ;)

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

2 participants